feat: 更新控件及相关业务功能
This commit is contained in:
@@ -182,7 +182,10 @@ namespace Lskj.Control.Model
|
||||
/// 判断两个值是否相同。
|
||||
/// 优先按日期、数字进行值比较,最后再按普通字符串比较。
|
||||
/// </summary>
|
||||
private static bool IsSameValue(string oldValue, string newValue)
|
||||
/// <param name="oldValue">原始值</param>
|
||||
/// <param name="newValue">当前值</param>
|
||||
/// <returns>两个值在统一格式后是否相同</returns>
|
||||
public static bool IsSameValue(string oldValue, string newValue)
|
||||
{
|
||||
oldValue = NormalizeValue(oldValue);
|
||||
newValue = NormalizeValue(newValue);
|
||||
|
||||
@@ -22,6 +22,7 @@ using System.IO;
|
||||
using System.Data.SqlClient;
|
||||
using Lskj.Business;
|
||||
using DevExpress.XtraGrid.Views.Grid;
|
||||
using Lskj.Core;
|
||||
|
||||
namespace Lskj.Control.Model
|
||||
{
|
||||
@@ -38,6 +39,12 @@ namespace Lskj.Control.Model
|
||||
/// </summary>
|
||||
private MyControl _controlObj;
|
||||
public bool issuccess = true;
|
||||
|
||||
/// <summary>
|
||||
/// 最初账套版本
|
||||
/// </summary>
|
||||
public DataRow AccountItem;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [apply before].
|
||||
/// </summary>
|
||||
@@ -73,13 +80,12 @@ namespace Lskj.Control.Model
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||
public bool Apply(DataRow rowItem)
|
||||
{
|
||||
bool resultValue = false;
|
||||
if (rowItem == null || this._controlObj == null) return resultValue;
|
||||
GridRightMenuModel model = new GridRightMenuModel(rowItem);
|
||||
|
||||
try
|
||||
{
|
||||
bool resultValue = false;
|
||||
if (rowItem == null || this._controlObj == null) return resultValue;
|
||||
|
||||
GridRightMenuModel model = new GridRightMenuModel(rowItem);
|
||||
|
||||
//if (!string.IsNullOrWhiteSpace(model.MenuCond))
|
||||
//{
|
||||
// try
|
||||
@@ -103,6 +109,18 @@ namespace Lskj.Control.Model
|
||||
// }
|
||||
//}
|
||||
|
||||
if (!string.IsNullOrEmpty(model.UnionZTid))
|
||||
{
|
||||
string UnionZTid = ReplaceHelper.ReplaceRowParam(BaseGridView.GetFocusedDataRow(), model.UnionZTid);
|
||||
string condition = string.Format("where ShowName ='{0}'", ERPInfo.Instance.AccountBook);
|
||||
DataTable dt = MainImpl.GetLedgerList(condition);
|
||||
DataRow RT = BaseImpl.GetDataRowResult($"select * from p_sydbGroupTab where ID={UnionZTid}");
|
||||
|
||||
AccountItem = dt.Rows[0];
|
||||
AccountItem["IP"] = DBConfig.Instance.ServerName;
|
||||
ToDBatching(RT, AccountItem);
|
||||
}
|
||||
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(model.BeforeMsg))
|
||||
{
|
||||
@@ -186,6 +204,10 @@ namespace Lskj.Control.Model
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(Message, ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!string.IsNullOrEmpty(model.UnionZTid)) ToDBatching(AccountItem, AccountItem);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
@@ -507,5 +529,29 @@ namespace Lskj.Control.Model
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 启动账套数据源刷新
|
||||
/// </summary>
|
||||
protected void ToDBatching(DataRow RT, DataRow firstrow)
|
||||
{
|
||||
string serverIP = RT["IP"] + "";
|
||||
string dbName = RT["DBName"] + "";
|
||||
string dataBook = RT["ShowName"] + "";
|
||||
bool isInternal = RT.Table.Columns.Contains("IsInternalNetwork") && !string.IsNullOrEmpty(RT["IsInternalNetwork"] + "") ? "1".Equals(RT["IsInternalNetwork"] + "") : false;
|
||||
DBConfig.Instance.DataBook = dataBook;
|
||||
DBConfig.Instance.ServerName = serverIP;
|
||||
DBConfig.Instance.DataBase = dbName;
|
||||
DBConfig.Instance.IsInternalNetwork = isInternal;
|
||||
if (!DBConfig.Instance.CreateConnection())
|
||||
{
|
||||
ToDBatching(firstrow, firstrow);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,6 +501,23 @@ namespace Lskj.Control.Model
|
||||
/// </summary>
|
||||
public const int LabSearchReturnIdExtended = 174;
|
||||
|
||||
///// <summary>
|
||||
///// 快速搜索框返回id(字典模式)
|
||||
///// </summary>
|
||||
//public const int DictionarySearchBoxToId = 181;
|
||||
///// <summary>
|
||||
///// 快速搜索框返回text(字典模式)
|
||||
///// </summary>
|
||||
//public const int DictionarySearchBoxToText = 182;
|
||||
///// <summary>
|
||||
///// 快速搜索框返回id 带参数(字典模式)
|
||||
///// </summary>
|
||||
//public const int DictionarySearchBoxToIdParam = 183;
|
||||
///// <summary>
|
||||
///// 快速搜索框返回text 带参数(字典模式)
|
||||
///// </summary>
|
||||
//public const int DictionarySearchBoxToTextParam = 184;
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:是否为Value类型</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
|
||||
@@ -307,6 +307,11 @@ namespace Lskj.Control.Model
|
||||
/// </summary>
|
||||
public bool AddHideBottomPanel;
|
||||
|
||||
/// <summary>
|
||||
/// 禁用条件
|
||||
/// </summary>
|
||||
public string VisibleCond;
|
||||
|
||||
/// <summary>
|
||||
/// 主模块编号
|
||||
/// </summary>
|
||||
@@ -379,6 +384,7 @@ namespace Lskj.Control.Model
|
||||
this.IgnoreAssociatedFields = item.Table.Columns.Contains("IgnoreAssociatedFields") ? "1".Equals(item["IgnoreAssociatedFields"] + "") : false;
|
||||
this.Library = item.Table.Columns.Contains("Library") ? item["Library"] + "" : "";
|
||||
this.AddHideBottomPanel = item.Table.Columns.Contains("AddHideBottomPanel") ? "1".Equals(item["AddHideBottomPanel"] + "") : false;
|
||||
this.VisibleCond = item.Table.Columns.Contains("VisibleCond") ? item["VisibleCond"] + "" : "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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("@"))
|
||||
{
|
||||
//替换[],替换的是多选行中的数据
|
||||
|
||||
@@ -265,6 +265,12 @@ namespace Lskj.Control.Model
|
||||
///特殊左侧表
|
||||
/// </summary>
|
||||
public GridControlEx SpecialLeftTable;
|
||||
/// <summary>
|
||||
///修改前的数据源
|
||||
/// </summary>
|
||||
public DataRow beforeData;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 控件Panel对象
|
||||
/// </summary>
|
||||
@@ -3048,6 +3054,8 @@ namespace Lskj.Control.Model
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
// 修改记录
|
||||
foreach (ControlModel model in this.ControlModels)
|
||||
{
|
||||
@@ -3064,6 +3072,16 @@ namespace Lskj.Control.Model
|
||||
if (userControl != null)
|
||||
{
|
||||
string fieldValue = this.GetControlValue(model);
|
||||
|
||||
if (beforeData != null &&
|
||||
beforeData.Table != null &&
|
||||
beforeData.Table.Columns.Contains(model.FieldName) &&
|
||||
AuditChangeLog.IsSameValue(beforeData[model.FieldName] + "", fieldValue))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (fieldValue == "****") continue;
|
||||
if (model.FieldType == 7)
|
||||
{
|
||||
@@ -4373,6 +4391,8 @@ namespace Lskj.Control.Model
|
||||
model.FieldType = 161;
|
||||
model.IsRadio = true;
|
||||
}
|
||||
|
||||
|
||||
return model;
|
||||
}
|
||||
/// <summary>
|
||||
@@ -4727,7 +4747,11 @@ namespace Lskj.Control.Model
|
||||
multiAutoEdit.ValueField = model.ValueMember;
|
||||
multiAutoEdit.TextField = model.TextMember;
|
||||
multiAutoEdit.ControlObj = this;
|
||||
multiAutoEdit.CurrentOperColumnKey= Model.ModuleCode + "_" + model.FieldName;
|
||||
if (Model != null)
|
||||
{
|
||||
multiAutoEdit.CurrentOperColumnKey = Model.ModuleCode + "_" + model.FieldName;
|
||||
}
|
||||
|
||||
//multiAutoEdit.SetDataSource(dataSource);
|
||||
multiAutoEdit.TextBoxProhibition = model.TextBoxProhibition;
|
||||
multiAutoEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
||||
|
||||
Reference in New Issue
Block a user