feat: 更新控件及相关业务功能
This commit is contained in:
@@ -36,54 +36,62 @@ namespace Lskj.Control.Model.MenuStrip
|
||||
}
|
||||
protected override void MenuStripOpening(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
int[] mSelectRows = this._gridView.GetSelectedRows();
|
||||
if (mSelectRows == null || mSelectRows.Length == 0) return;
|
||||
int[] mSelectRows = this._gridView.GetSelectedRows() ?? new int[0];
|
||||
|
||||
DataRow mSelectRow = this._gridView.GetDataRow(mSelectRows[0]);
|
||||
DataRow[] dataRows = new DataRow[mSelectRows.Length];
|
||||
for (int i = 0; i < mSelectRows.Length; i++)
|
||||
{
|
||||
dataRows[i] = this._gridView.GetDataRow(mSelectRows[i]);
|
||||
}
|
||||
|
||||
ContextMenuStrip cmsMenu = (ContextMenuStrip)sender;
|
||||
cmsMenu.Items.Clear();
|
||||
cmsMenu.Items.AddRange(this.RightMenuItems.ToArray());
|
||||
|
||||
// 创建QQ、浏览器右键菜单
|
||||
List<ToolStripMenuItem> mQQArray = new List<ToolStripMenuItem>();
|
||||
List<ToolStripMenuItem> mBrowerArray = new List<ToolStripMenuItem>();
|
||||
|
||||
foreach (GridColumn column in this._gridView.Columns)
|
||||
if (mSelectRows.Length > 0)
|
||||
{
|
||||
if (!mSelectRow.Table.Columns.Contains(column.Name))
|
||||
continue;
|
||||
string rowValue = mSelectRow[column.Name] + "";
|
||||
if (!string.IsNullOrWhiteSpace(rowValue))
|
||||
DataRow mSelectRow = this._gridView.GetDataRow(mSelectRows[0]);
|
||||
|
||||
// 创建QQ、浏览器右键菜单
|
||||
List<ToolStripMenuItem> mQQArray = new List<ToolStripMenuItem>();
|
||||
List<ToolStripMenuItem> mBrowerArray = new List<ToolStripMenuItem>();
|
||||
|
||||
foreach (GridColumn column in this._gridView.Columns)
|
||||
{
|
||||
GridColumnModel model = column.Tag as GridColumnModel;
|
||||
if (model == null) continue;
|
||||
|
||||
if (model.FieldType == ControlType.LabQQ)
|
||||
if (!mSelectRow.Table.Columns.Contains(column.Name))
|
||||
continue;
|
||||
string rowValue = mSelectRow[column.Name] + "";
|
||||
if (!string.IsNullOrWhiteSpace(rowValue))
|
||||
{
|
||||
ToolStripMenuItem item = new ToolStripMenuItem("(" + column.Caption + ")" + rowValue, Resources.qq);
|
||||
item.Tag = mSelectRow[column.Name] + "";
|
||||
item.Click += new EventHandler(QQItemClick);
|
||||
mQQArray.Add(item);
|
||||
}
|
||||
GridColumnModel model = column.Tag as GridColumnModel;
|
||||
if (model == null) continue;
|
||||
|
||||
if (model.FieldType == ControlType.LabWWW ||
|
||||
rowValue.StartsWith("www.") ||
|
||||
rowValue.StartsWith("http://") ||
|
||||
rowValue.StartsWith("https://") ||
|
||||
rowValue.StartsWith("ftp://") ||
|
||||
rowValue.StartsWith("file://"))
|
||||
{
|
||||
ToolStripMenuItem item = new ToolStripMenuItem("(" + column.Caption + ")" + rowValue, Resources.qq);
|
||||
item.Tag = mSelectRow[column.Name] + "";
|
||||
item.Click += new EventHandler(BrowerItemClick);
|
||||
mBrowerArray.Add(item);
|
||||
if (model.FieldType == ControlType.LabQQ)
|
||||
{
|
||||
ToolStripMenuItem item = new ToolStripMenuItem("(" + column.Caption + ")" + rowValue, Resources.qq);
|
||||
item.Tag = mSelectRow[column.Name] + "";
|
||||
item.Click += new EventHandler(QQItemClick);
|
||||
mQQArray.Add(item);
|
||||
}
|
||||
|
||||
if (model.FieldType == ControlType.LabWWW ||
|
||||
rowValue.StartsWith("www.") ||
|
||||
rowValue.StartsWith("http://") ||
|
||||
rowValue.StartsWith("https://") ||
|
||||
rowValue.StartsWith("ftp://") ||
|
||||
rowValue.StartsWith("file://"))
|
||||
{
|
||||
ToolStripMenuItem item = new ToolStripMenuItem("(" + column.Caption + ")" + rowValue, Resources.qq);
|
||||
item.Tag = mSelectRow[column.Name] + "";
|
||||
item.Click += new EventHandler(BrowerItemClick);
|
||||
mBrowerArray.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cmsMenu.Items.AddRange(mQQArray.ToArray());
|
||||
cmsMenu.Items.AddRange(mBrowerArray.ToArray());
|
||||
cmsMenu.Items.AddRange(mQQArray.ToArray());
|
||||
cmsMenu.Items.AddRange(mBrowerArray.ToArray());
|
||||
}
|
||||
|
||||
// 判断右键菜单是否可用
|
||||
foreach (ToolStripItem cms in cmsMenu.Items)
|
||||
@@ -95,34 +103,83 @@ namespace Lskj.Control.Model.MenuStrip
|
||||
{
|
||||
try
|
||||
{
|
||||
string cond = string.Empty;
|
||||
if (this._control != null)
|
||||
cond = _control.ReplaceParentControlValue(model.MenuCond);
|
||||
cond = ReplaceHelper.ReplaceRowParam(mSelectRow, model.MenuCond);
|
||||
if (this._gridView != null)
|
||||
bool condResult = false;
|
||||
StringBuilder condBuilder = new StringBuilder();
|
||||
StringBuilder sqlCondBuilder = new StringBuilder();
|
||||
GridCell[] cells = this._gridView.GetSelectedCells();
|
||||
DataRow focusedRow = this.BaseGridView.GetFocusedDataRow();
|
||||
|
||||
DataRow[] conditionRows = dataRows;
|
||||
if (model.AllowNullExec && conditionRows.Length == 0)
|
||||
{
|
||||
GridCell[] cells = this._gridView.GetSelectedCells();
|
||||
if (cells != null && cells.Length > 0 && cond.Contains("{COLUMN_"))
|
||||
conditionRows = new DataRow[] { new DataTable().NewRow() };
|
||||
}
|
||||
|
||||
foreach (DataRow selectRow in conditionRows)
|
||||
{
|
||||
string cond = ReplaceHelper.ReplaceUserInfo(model.MenuCond);
|
||||
cond = RaiseBeforeHandleParamsCallback(model.ParamList, conditionRows, model.MenuCond, selectRow, cond);
|
||||
if (this._control != null)
|
||||
{
|
||||
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);
|
||||
cond = _control.ReplaceParentControlValue(cond);
|
||||
}
|
||||
//cond = ReplaceHelper.ReplaceRowParam(selectRow, cond);
|
||||
cond = ReplaceHelper.ReplaceRowParamEmptyWrapQuote(selectRow, cond);
|
||||
if (model.Mergeexec && cond.StartsWith("@"))
|
||||
{
|
||||
//替换[],替换的是多选行中的数据
|
||||
cond = ReplaceHelper.ReplaceRowParam(conditionRows, cond.Replace("[", "{").Replace("]", "}"), "", "");
|
||||
}
|
||||
|
||||
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 ");
|
||||
}
|
||||
}
|
||||
if (ControlObj != null)
|
||||
cond = ControlObj.ReplaceParentControlValue(cond);
|
||||
string condStr = model.MenuCond;
|
||||
if (!string.IsNullOrWhiteSpace(sqlCondBuilder.ToString()) || !string.IsNullOrWhiteSpace(condBuilder.ToString()))
|
||||
{
|
||||
if (model.MenuCond.StartsWith("@"))
|
||||
{
|
||||
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);
|
||||
//cms.Enabled = ReplaceHelper.EvalCond(cond);
|
||||
if (model.ForbiddenDisplay)
|
||||
{
|
||||
cms.Visible = ValidateCond(cond, null); ;
|
||||
cms.Visible = condResult;
|
||||
}
|
||||
cms.Enabled = ValidateCond(cond, null); ;
|
||||
cms.Enabled = condResult;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(ResourceKeys.SetRightMenuCondFault + "\r\n" + Message);
|
||||
e.Cancel = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace Lskj.Control.Model
|
||||
/// 最初账套版本
|
||||
/// </summary>
|
||||
public DataRow AccountItem;
|
||||
|
||||
public DataTable MenuTable;
|
||||
public DynamicModel Model;
|
||||
public MyControl ControlObj;
|
||||
@@ -267,7 +268,7 @@ namespace Lskj.Control.Model
|
||||
public bool ValidateCond(string cond, DataRow dataRow)
|
||||
{
|
||||
bool result = false;
|
||||
cond = ReplaceHelper.ReplaceRowParam(dataRow, cond);
|
||||
cond = ReplaceHelper.ReplaceRowParamEmptyWrapQuote(dataRow, cond);
|
||||
if (cond.StartsWith("@") || cond.StartsWith("!"))
|
||||
{
|
||||
result = "1".Equals(BaseImpl.GetDefaultValue(cond));
|
||||
|
||||
@@ -147,8 +147,8 @@ namespace Lskj.Control.Model
|
||||
{
|
||||
cond = _control.ReplaceParentControlValue(cond);
|
||||
}
|
||||
cond = ReplaceHelper.ReplaceRowParam(selectRow, cond);
|
||||
|
||||
//cond = ReplaceHelper.ReplaceRowParam(selectRow, cond);
|
||||
cond = ReplaceHelper.ReplaceRowParamEmptyWrapQuote(selectRow, cond);
|
||||
if (model.Mergeexec&& cond.StartsWith("@"))
|
||||
{
|
||||
//替换[],替换的是多选行中的数据
|
||||
|
||||
@@ -156,8 +156,8 @@ namespace Lskj.Control.Model.MenuStrip
|
||||
cond = RaiseBeforeHandleParamsCallback(model.ParamList, conditionRows, model.MenuCond, selectRow, cond);
|
||||
if (this._control != null)
|
||||
cond = _control.ReplaceParentControlValue(cond);
|
||||
cond = ReplaceHelper.ReplaceRowParam(selectRow, cond);
|
||||
|
||||
//cond = ReplaceHelper.ReplaceRowParam(selectRow, cond);
|
||||
cond = ReplaceHelper.ReplaceRowParamEmptyWrapQuote(selectRow, cond);
|
||||
if (model.Mergeexec && cond.StartsWith("@"))
|
||||
{
|
||||
//替换[],替换的是多选行中的数据
|
||||
|
||||
Reference in New Issue
Block a user