SVN r497
SVN-Revision: r497
This commit is contained in:
@@ -91,50 +91,39 @@ namespace Lskj.Control.Model.MenuStrip
|
|||||||
GridRightMenuModel model = cms.Tag as GridRightMenuModel;
|
GridRightMenuModel model = cms.Tag as GridRightMenuModel;
|
||||||
if (model != null)
|
if (model != null)
|
||||||
{
|
{
|
||||||
if (model.PrivilegeOper.Length > 1 && !model.PrivilegeOper.Contains(ERPInfo.Instance.UserName + ","))
|
if (!string.IsNullOrWhiteSpace(model.MenuCond))
|
||||||
{
|
{
|
||||||
if (model.ForbiddenDisplay)
|
try
|
||||||
{
|
{
|
||||||
cms.Visible = false;
|
string cond = string.Empty;
|
||||||
|
if (this._control != null)
|
||||||
|
cond = _control.ReplaceParentControlValue(model.MenuCond);
|
||||||
|
cond = ReplaceHelper.ReplaceRowParam(mSelectRow, model.MenuCond);
|
||||||
|
if (this._gridView != null)
|
||||||
|
{
|
||||||
|
GridCell[] cells = this._gridView.GetSelectedCells();
|
||||||
|
if (cells != null && cells.Length > 0 && cond.Contains("{COLUMN_"))
|
||||||
|
{
|
||||||
|
GridCell cell = cells[0];
|
||||||
|
DataRow focusedRow = this.BaseGridView.GetFocusedDataRow();
|
||||||
|
string colValue = focusedRow == null || !focusedRow.Table.Columns.Contains(cell.Column.Name) ? "" : focusedRow[cell.Column.Name] + "";
|
||||||
|
cond = cond.ReplaceColumnParam(cell.Column.Name, cell.Column.Caption, colValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ControlObj != null)
|
||||||
|
cond = ControlObj.ReplaceParentControlValue(cond);
|
||||||
|
//cms.Enabled = ReplaceHelper.EvalCond(cond);
|
||||||
|
if (model.ForbiddenDisplay)
|
||||||
|
{
|
||||||
|
cms.Visible = ValidateCond(cond, null); ;
|
||||||
|
}
|
||||||
|
cms.Enabled = ValidateCond(cond, null); ;
|
||||||
}
|
}
|
||||||
cms.Enabled = false;
|
catch (Exception ex)
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrWhiteSpace(model.MenuCond))
|
|
||||||
{
|
{
|
||||||
try
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||||
{
|
MessageUtil.Show(ResourceKeys.SetRightMenuCondFault + "\r\n" + Message);
|
||||||
string cond = string.Empty;
|
break;
|
||||||
if (this._control != null)
|
|
||||||
cond = _control.ReplaceParentControlValue(model.MenuCond);
|
|
||||||
cond = ReplaceHelper.ReplaceRowParam(mSelectRow, model.MenuCond);
|
|
||||||
if (this._gridView != null)
|
|
||||||
{
|
|
||||||
GridCell[] cells = this._gridView.GetSelectedCells();
|
|
||||||
if (cells != null && cells.Length > 0 && cond.Contains("{COLUMN_"))
|
|
||||||
{
|
|
||||||
GridCell cell = cells[0];
|
|
||||||
DataRow focusedRow = this.BaseGridView.GetFocusedDataRow();
|
|
||||||
string colValue = focusedRow == null || !focusedRow.Table.Columns.Contains(cell.Column.Name) ? "" : focusedRow[cell.Column.Name] + "";
|
|
||||||
cond = cond.ReplaceColumnParam(cell.Column.Name, cell.Column.Caption, colValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ControlObj != null)
|
|
||||||
cond = ControlObj.ReplaceParentControlValue(cond);
|
|
||||||
//cms.Enabled = ReplaceHelper.EvalCond(cond);
|
|
||||||
if (model.ForbiddenDisplay)
|
|
||||||
{
|
|
||||||
cms.Visible = ValidateCond(cond, null); ;
|
|
||||||
}
|
|
||||||
cms.Enabled = ValidateCond(cond, null); ;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
||||||
MessageUtil.Show(ResourceKeys.SetRightMenuCondFault + "\r\n" + Message);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -157,31 +146,4 @@ namespace Lskj.Control.Model.MenuStrip
|
|||||||
this._gridView.ClearSelection();
|
this._gridView.ClearSelection();
|
||||||
this._gridView.SelectRowHandler(this._oldRowHandler);
|
this._gridView.SelectRowHandler(this._oldRowHandler);
|
||||||
}
|
}
|
||||||
protected override List<string> HandleRightMenuParams(List<string> paramList, DataRow rowData, DataRow[] rowDatas = null, int actionType = 0)
|
protected override List<string> HandleRightMenuParams(List<string> para
|
||||||
{
|
|
||||||
List<string> handleParamList = base.HandleRightMenuParams(paramList, rowData, rowDatas, actionType);
|
|
||||||
|
|
||||||
foreach (string item in handleParamList)
|
|
||||||
{
|
|
||||||
if (item.StartsWith("{"))
|
|
||||||
{
|
|
||||||
string field = item.Replace("{", "").Replace("}", "");
|
|
||||||
if ("COLUMN_NAME".Equals(field))
|
|
||||||
{
|
|
||||||
handleParamList.Add(this._gridView.FocusedColumn.FieldName);
|
|
||||||
}
|
|
||||||
else if ("COLUMN_TITLE".Equals(field))
|
|
||||||
{
|
|
||||||
|
|
||||||
handleParamList.Add(this._gridView.FocusedColumn.GetTextCaption());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
handleParamList.Add(rowData[field] + "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return handleParamList;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -90,88 +90,84 @@ namespace Lskj.Control.Model
|
|||||||
cmsMenu.Items.AddRange(mQQArray.ToArray());
|
cmsMenu.Items.AddRange(mQQArray.ToArray());
|
||||||
cmsMenu.Items.AddRange(mBrowerArray.ToArray());
|
cmsMenu.Items.AddRange(mBrowerArray.ToArray());
|
||||||
|
|
||||||
// 判断右键菜单是否可用
|
Dictionary<ToolStripItem, GridRightMenuModel> cmsModelDic = new Dictionary<ToolStripItem, GridRightMenuModel>();
|
||||||
|
List<string> roleNamesList = new List<string>();
|
||||||
foreach (ToolStripItem cms in cmsMenu.Items)
|
foreach (ToolStripItem cms in cmsMenu.Items)
|
||||||
{
|
{
|
||||||
GridRightMenuModel model = cms.Tag as GridRightMenuModel;
|
GridRightMenuModel model = cms.Tag as GridRightMenuModel;
|
||||||
|
cmsModelDic[cms] = model;
|
||||||
|
roleNamesList.Add(model.PrivilegeOper);
|
||||||
|
}
|
||||||
|
// 判断右键菜单是否可用
|
||||||
|
foreach (ToolStripItem cms in cmsMenu.Items)
|
||||||
|
{
|
||||||
|
GridRightMenuModel model = cmsModelDic.ContainsKey(cms) ? cmsModelDic[cms] : cms.Tag as GridRightMenuModel;
|
||||||
if (model != null)
|
if (model != null)
|
||||||
{
|
{
|
||||||
// !model.PrivilegeOper.Contains(ERPInfo.Instance.UserName + "," 2024-2-23换成下面的判断
|
if (!string.IsNullOrWhiteSpace(model.MenuCond))
|
||||||
if (model.PrivilegeOper.Length > 1 && !model.PrivilegeOper.Split(',').Contains(ERPInfo.Instance.UserName))
|
|
||||||
{
|
{
|
||||||
if (model.ForbiddenDisplay)
|
try
|
||||||
{
|
{
|
||||||
cms.Visible = false;
|
bool condResult = false;
|
||||||
}
|
StringBuilder condBuilder = new StringBuilder();
|
||||||
cms.Enabled = false;
|
StringBuilder sqlCondBuilder = new StringBuilder();
|
||||||
}
|
GridCell[] cells = this._gridView.GetSelectedCells();
|
||||||
else
|
DataRow focusedRow = this.BaseGridView.GetFocusedDataRow();
|
||||||
{
|
foreach (int itemIndex in mSelectRows)
|
||||||
if (!string.IsNullOrWhiteSpace(model.MenuCond))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
bool condResult = false;
|
DataRow selectRow = this._gridView.GetDataRow(itemIndex);
|
||||||
StringBuilder condBuilder = new StringBuilder();
|
string cond = string.Empty;
|
||||||
StringBuilder sqlCondBuilder = new StringBuilder();
|
if (this._control != null)
|
||||||
GridCell[] cells = this._gridView.GetSelectedCells();
|
|
||||||
DataRow focusedRow = this.BaseGridView.GetFocusedDataRow();
|
|
||||||
foreach (int itemIndex in mSelectRows)
|
|
||||||
{
|
{
|
||||||
DataRow selectRow = this._gridView.GetDataRow(itemIndex);
|
cond = _control.ReplaceParentControlValue(model.MenuCond);
|
||||||
string cond = string.Empty;
|
}
|
||||||
if (this._control != null)
|
cond = ReplaceHelper.ReplaceRowParam(selectRow, model.MenuCond);
|
||||||
|
if (this._gridView != null)
|
||||||
|
{
|
||||||
|
if (cells != null && cells.Length > 0 && cond.Contains("{COLUMN_"))
|
||||||
{
|
{
|
||||||
cond = _control.ReplaceParentControlValue(model.MenuCond);
|
GridCell cell = cells[0];
|
||||||
}
|
string colValue = focusedRow == null || !focusedRow.Table.Columns.Contains(cell.Column.Name) ? "" : focusedRow[cell.Column.Name] + "";
|
||||||
cond = ReplaceHelper.ReplaceRowParam(selectRow, model.MenuCond);
|
cond = cond.ReplaceColumnParam(cell.Column.Name, cell.Column.Caption, colValue);
|
||||||
if (this._gridView != null)
|
|
||||||
{
|
|
||||||
if (cells != null && cells.Length > 0 && cond.Contains("{COLUMN_"))
|
|
||||||
{
|
|
||||||
GridCell cell = cells[0];
|
|
||||||
string colValue = focusedRow == null || !focusedRow.Table.Columns.Contains(cell.Column.Name) ? "" : focusedRow[cell.Column.Name] + "";
|
|
||||||
cond = cond.ReplaceColumnParam(cell.Column.Name, cell.Column.Caption, colValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ControlObj != null)
|
|
||||||
{
|
|
||||||
cond = ControlObj.ReplaceParentControlValue(cond);
|
|
||||||
}
|
|
||||||
if (cond.StartsWith("@"))
|
|
||||||
{
|
|
||||||
sqlCondBuilder.Append($"({cond.TrimStart('@')}) = '1' and ");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
condBuilder.Append($"({cond}) and ");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string condStr = "";
|
if (ControlObj != null)
|
||||||
if (model.MenuCond.StartsWith("@"))
|
|
||||||
{
|
{
|
||||||
condStr = $"@if({sqlCondBuilder.ToString().TrimEnd().TrimEnd('d', 'n', 'a')}) begin select '1' end else begin select '0' end";
|
cond = ControlObj.ReplaceParentControlValue(cond);
|
||||||
|
}
|
||||||
|
if (cond.StartsWith("@"))
|
||||||
|
{
|
||||||
|
sqlCondBuilder.Append($"({cond.TrimStart('@')}) = '1' and ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
condStr = condBuilder.ToString().TrimEnd().TrimEnd('d', 'n', 'a');
|
condBuilder.Append($"({cond}) and ");
|
||||||
}
|
}
|
||||||
condResult = ValidateCond(condStr, null);
|
|
||||||
//if (!condResult) break;
|
|
||||||
//cms.Enabled = ReplaceHelper.EvalCond(cond);
|
|
||||||
if (model.ForbiddenDisplay)
|
|
||||||
{
|
|
||||||
cms.Visible = condResult;
|
|
||||||
}
|
|
||||||
cms.Enabled = condResult;
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
string condStr = "";
|
||||||
|
if (model.MenuCond.StartsWith("@"))
|
||||||
{
|
{
|
||||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
condStr = $"@if({sqlCondBuilder.ToString().TrimEnd().TrimEnd('d', 'n', 'a')}) begin select '1' end else begin select '0' end";
|
||||||
MessageUtil.Show(ResourceKeys.SetRightMenuCondFault + "\r\n" + Message);
|
|
||||||
e.Cancel = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
condStr = condBuilder.ToString().TrimEnd().TrimEnd('d', 'n', 'a');
|
||||||
|
}
|
||||||
|
condResult = ValidateCond(condStr, null);
|
||||||
|
//if (!condResult) break;
|
||||||
|
//cms.Enabled = ReplaceHelper.EvalCond(cond);
|
||||||
|
if (model.ForbiddenDisplay)
|
||||||
|
{
|
||||||
|
cms.Visible = condResult;
|
||||||
|
}
|
||||||
|
cms.Enabled = condResult;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||||
|
MessageUtil.Show(ResourceKeys.SetRightMenuCondFault + "\r\n" + Message);
|
||||||
|
e.Cancel = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -227,31 +223,4 @@ namespace Lskj.Control.Model
|
|||||||
this._gridView.SelectRowHandler(this._oldRowHandler);
|
this._gridView.SelectRowHandler(this._oldRowHandler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override List<string> HandleRightMenuParams(List<string> paramList, DataRow rowData, DataRow[] rowDatas = null, int actionType = 0)
|
protected override List<string> HandleRightMenuParams(List<string> para
|
||||||
{
|
|
||||||
List<string> handleParamList = base.HandleRightMenuParams(paramList, rowData, rowDatas, actionType);
|
|
||||||
|
|
||||||
foreach (string item in handleParamList)
|
|
||||||
{
|
|
||||||
if (item.StartsWith("{"))
|
|
||||||
{
|
|
||||||
string field = item.Replace("{", "").Replace("}", "");
|
|
||||||
if ("COLUMN_NAME".Equals(field))
|
|
||||||
{
|
|
||||||
handleParamList.Add(this._gridView.FocusedColumn.FieldName);
|
|
||||||
}
|
|
||||||
else if ("COLUMN_TITLE".Equals(field))
|
|
||||||
{
|
|
||||||
|
|
||||||
handleParamList.Add(this._gridView.FocusedColumn.GetTextCaption());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
handleParamList.Add(rowData[field] + "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return handleParamList;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -123,57 +123,20 @@ namespace Lskj.Control.Model.MenuStrip
|
|||||||
GridRightMenuModel model = cms.Tag as GridRightMenuModel;
|
GridRightMenuModel model = cms.Tag as GridRightMenuModel;
|
||||||
if (model != null)
|
if (model != null)
|
||||||
{
|
{
|
||||||
if (model.PrivilegeOper.Length > 1 && !model.PrivilegeOper.Contains(ERPInfo.Instance.UserName + ","))
|
if (!string.IsNullOrWhiteSpace(model.MenuCond))
|
||||||
{
|
{
|
||||||
if (model.ForbiddenDisplay)
|
try
|
||||||
{
|
{
|
||||||
cms.Visible = false;
|
string cond = string.Empty;
|
||||||
}
|
if (this._control != null)
|
||||||
cms.Enabled = false;
|
cond = _control.ReplaceParentControlValue(model.MenuCond);
|
||||||
}
|
cond = ReplaceHelper.ReplaceRowParam(mSelectRow, model.MenuCond);
|
||||||
else
|
if (this._treeView != null)
|
||||||
{
|
|
||||||
if (!string.IsNullOrWhiteSpace(model.MenuCond))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
string cond = string.Empty;
|
List<TreeListCell> cells = this._treeView.GetSelectedCells();
|
||||||
if (this._control != null)
|
if (cells != null && cells.Count > 0 && cond.Contains("{COLUMN_"))
|
||||||
cond = _control.ReplaceParentControlValue(model.MenuCond);
|
|
||||||
cond = ReplaceHelper.ReplaceRowParam(mSelectRow, model.MenuCond);
|
|
||||||
if (this._treeView != null)
|
|
||||||
{
|
{
|
||||||
List<TreeListCell> cells = this._treeView.GetSelectedCells();
|
TreeListCell cell = cells[0];
|
||||||
if (cells != null && cells.Count > 0 && cond.Contains("{COLUMN_"))
|
DataRow focusedRow = this.BaseGridView.GetFocusedDataRow();
|
||||||
{
|
string colValue = focusedRow == null || !focusedRow.Table.Columns.Contains(cell.Column.Name) ? "" : focusedRow[cell.Column.Name] + "";
|
||||||
TreeListCell cell = cells[0];
|
cond = cond.ReplaceColumnParam(
|
||||||
DataRow focusedRow = this.BaseGridView.GetFocusedDataRow();
|
|
||||||
string colValue = focusedRow == null || !focusedRow.Table.Columns.Contains(cell.Column.Name) ? "" : focusedRow[cell.Column.Name] + "";
|
|
||||||
cond = cond.ReplaceColumnParam(cell.Column.Name, cell.Column.Caption, colValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ControlObj != null)
|
|
||||||
cond = ControlObj.ReplaceParentControlValue(cond);
|
|
||||||
//cms.Enabled = ReplaceHelper.EvalCond(cond);
|
|
||||||
|
|
||||||
if (model.ForbiddenDisplay)
|
|
||||||
{
|
|
||||||
cms.Visible = ValidateCond(cond, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
cms.Enabled = ValidateCond(cond, null); ;
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
||||||
MessageUtil.Show(ResourceKeys.SetRightMenuCondFault + "\r\n" + Message);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user