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;
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(model.MenuCond))
|
||||
catch (Exception ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
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); ;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(ResourceKeys.SetRightMenuCondFault + "\r\n" + Message);
|
||||
break;
|
||||
}
|
||||
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.SelectRowHandler(this._oldRowHandler);
|
||||
}
|
||||
protected override List<string> HandleRightMenuParams(List<string> paramList, DataRow rowData, DataRow[] rowDatas = null, int actionType = 0)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override List<string> HandleRightMenuParams(List<string> para
|
||||
@@ -90,88 +90,84 @@ namespace Lskj.Control.Model
|
||||
cmsMenu.Items.AddRange(mQQArray.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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
// !model.PrivilegeOper.Contains(ERPInfo.Instance.UserName + "," 2024-2-23换成下面的判断
|
||||
if (model.PrivilegeOper.Length > 1 && !model.PrivilegeOper.Split(',').Contains(ERPInfo.Instance.UserName))
|
||||
if (!string.IsNullOrWhiteSpace(model.MenuCond))
|
||||
{
|
||||
if (model.ForbiddenDisplay)
|
||||
try
|
||||
{
|
||||
cms.Visible = false;
|
||||
}
|
||||
cms.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(model.MenuCond))
|
||||
{
|
||||
try
|
||||
bool condResult = false;
|
||||
StringBuilder condBuilder = new StringBuilder();
|
||||
StringBuilder sqlCondBuilder = new StringBuilder();
|
||||
GridCell[] cells = this._gridView.GetSelectedCells();
|
||||
DataRow focusedRow = this.BaseGridView.GetFocusedDataRow();
|
||||
foreach (int itemIndex in mSelectRows)
|
||||
{
|
||||
bool condResult = false;
|
||||
StringBuilder condBuilder = new StringBuilder();
|
||||
StringBuilder sqlCondBuilder = new StringBuilder();
|
||||
GridCell[] cells = this._gridView.GetSelectedCells();
|
||||
DataRow focusedRow = this.BaseGridView.GetFocusedDataRow();
|
||||
foreach (int itemIndex in mSelectRows)
|
||||
DataRow selectRow = this._gridView.GetDataRow(itemIndex);
|
||||
string cond = string.Empty;
|
||||
if (this._control != null)
|
||||
{
|
||||
DataRow selectRow = this._gridView.GetDataRow(itemIndex);
|
||||
string cond = string.Empty;
|
||||
if (this._control != null)
|
||||
cond = _control.ReplaceParentControlValue(model.MenuCond);
|
||||
}
|
||||
cond = ReplaceHelper.ReplaceRowParam(selectRow, model.MenuCond);
|
||||
if (this._gridView != null)
|
||||
{
|
||||
if (cells != null && cells.Length > 0 && cond.Contains("{COLUMN_"))
|
||||
{
|
||||
cond = _control.ReplaceParentControlValue(model.MenuCond);
|
||||
}
|
||||
cond = ReplaceHelper.ReplaceRowParam(selectRow, model.MenuCond);
|
||||
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 ");
|
||||
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);
|
||||
}
|
||||
}
|
||||
string condStr = "";
|
||||
if (model.MenuCond.StartsWith("@"))
|
||||
if (ControlObj != null)
|
||||
{
|
||||
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
|
||||
{
|
||||
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);
|
||||
MessageUtil.Show(ResourceKeys.SetRightMenuCondFault + "\r\n" + Message);
|
||||
e.Cancel = true;
|
||||
break;
|
||||
condStr = $"@if({sqlCondBuilder.ToString().TrimEnd().TrimEnd('d', 'n', 'a')}) begin select '1' end else begin select '0' end";
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
protected override List<string> HandleRightMenuParams(List<string> paramList, DataRow rowData, DataRow[] rowDatas = null, int actionType = 0)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override List<string> HandleRightMenuParams(List<string> para
|
||||
@@ -123,57 +123,20 @@ namespace Lskj.Control.Model.MenuStrip
|
||||
GridRightMenuModel model = cms.Tag as GridRightMenuModel;
|
||||
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;
|
||||
}
|
||||
cms.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(model.MenuCond))
|
||||
{
|
||||
try
|
||||
string cond = string.Empty;
|
||||
if (this._control != null)
|
||||
cond = _control.ReplaceParentControlValue(model.MenuCond);
|
||||
cond = ReplaceHelper.ReplaceRowParam(mSelectRow, model.MenuCond);
|
||||
if (this._treeView != null)
|
||||
{
|
||||
string cond = string.Empty;
|
||||
if (this._control != null)
|
||||
cond = _control.ReplaceParentControlValue(model.MenuCond);
|
||||
cond = ReplaceHelper.ReplaceRowParam(mSelectRow, model.MenuCond);
|
||||
if (this._treeView != null)
|
||||
List<TreeListCell> cells = this._treeView.GetSelectedCells();
|
||||
if (cells != null && cells.Count > 0 && cond.Contains("{COLUMN_"))
|
||||
{
|
||||
List<TreeListCell> cells = this._treeView.GetSelectedCells();
|
||||
if (cells != null && cells.Count > 0 && cond.Contains("{COLUMN_"))
|
||||
{
|
||||
TreeListCell 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
TreeListCell 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(
|
||||
Reference in New Issue
Block a user