merge: 合并初始化缓存与资源释放优化

This commit is contained in:
2026-08-15 11:39:58 +08:00
27 changed files with 474 additions and 110 deletions
@@ -1612,7 +1612,6 @@ namespace Lskj.Control
{
Popup.LabelObj.Text = "正在筛选数据,请稍后...";
Popup.BottomPanelObj.Visible = true;
Popup.GridControlObj.DataSourceTable().Clear();
}
_queryWorker.Queue(new PopupQueryRequest
+6 -2
View File
@@ -654,13 +654,14 @@ namespace Lskj.Control
if (parametersArray.Length > i)
{
string commandParameter = parametersArray[i];
//string field = commandParameter.Replace("@", "").Replace("{", "").Replace("}", "");
string field = commandParameter.Replace("@", "").Replace("{", "").Replace("}", "");
//string value = focusedRow.Table.Columns.Contains(field) ? focusedRow[field] + "" : commandParameter.Replace("@", "");
//value = SearchObj.ReplaceControlValue(value);
//value = TopControlObj.ReplaceControlValue(value);
//value = ReplaceControlValue(value, MainControlPanel);
//value = value.Replace("@", "").Replace("{", "").Replace("}", "");
//sqlParameter.Value = value;
sqlParameter.Value = field;
}
}
SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4);
@@ -670,16 +671,19 @@ namespace Lskj.Control
if (!(returnValue.Value + "").Equals("1"))
{
SqlParameter outSqlParameter = sqlParameters.Cast<SqlParameter>().Where(n => n.Direction == ParameterDirection.Output).FirstOrDefault();
string msg = "导入后执行sql失败";
if (outSqlParameter != null)
{
string outMessage = outSqlParameter.Value + "";
if (!string.IsNullOrEmpty(outMessage))
{
MessageUtil.Show("导入后执行sql失败:" + outSqlParameter.Value + "");
msg="导入后执行sql失败:" + outSqlParameter.Value + "";
}
}
MessageUtil.Show(msg);
string deleteSql = string.Format("delete from {0} where {1}='1'", this._tableName, this._importFlag);
SqlHelper.ExecuteNonQuery(deleteSql);
return false;
}
}
else
+4 -1
View File
@@ -1157,7 +1157,10 @@ namespace Lskj.Control
if (groupDataTable.Columns.Count > 0)
{
DataTable orderTable = groupDataTable.Clone();
groupDataTable.Select().OrderBy(n => n[groupDataTable.Columns[0]]).CopyToDataTable(orderTable, LoadOption.PreserveChanges);
// DataTable中的数据库空值是DBNull,不能直接和String等实际类型比较。
// 仅将DBNull作为null参与排序,非空数据仍按字段原始类型排序。
DataColumn orderColumn = groupDataTable.Columns[0];
groupDataTable.Select().OrderBy(n => n.IsNull(orderColumn) ? null : n[orderColumn]).CopyToDataTable(orderTable, LoadOption.PreserveChanges);
InitShowDataGridColumns(orderTable);
try
{
+16 -1
View File
@@ -94,6 +94,11 @@ namespace Lskj.Control
/// 父容器表格
/// </summary>
public GridControlEx ParentGridEx;
/// <summary>
/// 父容器表格条件
/// </summary>
public MyControl SearchObj;
/// <summary>
/// 源表格
@@ -391,6 +396,7 @@ namespace Lskj.Control
//提交到数据库
try
{
WaitForm.ShowForm();
string sql = "select * from " + _tableName + " where 1<>1";
//SqlDataAdapter dat = BaseImpl.GetAdapterResult(sql);
//SqlCommandBuilder scb = new SqlCommandBuilder(dat);
@@ -678,6 +684,10 @@ namespace Lskj.Control
string errorMsg = string.Format("{0}\r\n第{1}行,第{2}列\r\n列名:{3}", mesage, rowNum, colNum, colName);
XtraMessageBox.Show("数据提交错误:\n" + errorMsg + "\r\n", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
WaitForm.HideForm();
}
}
/// <summary>
/// 数字转换时间格式
@@ -954,7 +964,12 @@ namespace Lskj.Control
DataRow SelectTheLine = this.ParentGridEx.GetViewFocusedDataRow();
fieldValue = ReplaceHelper.ReplaceRowParam(SelectTheLine, fieldValue);
}
fieldValue= BaseImpl.GetDefaultValue(fieldValue);
if (this.SearchObj != null)
{
fieldValue = this.SearchObj.ReplaceParentControlValue(fieldValue);
}
fieldValue = BaseImpl.GetDefaultValue(fieldValue);
if (!string.IsNullOrEmpty(fieldValue))
{
rowItem[col.FieldName] = fieldValue;
+9
View File
@@ -73,6 +73,10 @@ namespace Lskj.Control
/// </summary>
private bool isFirstVisableCol = true;
/// <summary>
/// 表格自定义字体
/// </summary>
private System.Drawing.Text.PrivateFontCollection customFont = new System.Drawing.Text.PrivateFontCollection();
/// <summary>
/// The _grid enum object
/// </summary>
private HeaderSiftEnum _columnEnumObj;
@@ -677,6 +681,11 @@ namespace Lskj.Control
_mainGridToolTipController.Dispose();
_mainGridToolTipController = null;
}
if (customFont != null)
{
customFont.Dispose();
customFont = null;
}
}
private void PrepareForColumnRebuild()
+21 -7
View File
@@ -26,6 +26,7 @@ namespace Lskj.Control.Model
/// </summary>
public class GridDragTree : IDisposable
{
private bool _disposed;
/// <summary>
/// 拖动位置
/// </summary>
@@ -38,7 +39,6 @@ namespace Lskj.Control.Model
/// 拖动目标源
/// </summary>
private TreeView _treeView;
private bool _disposed;
public bool CanDragParentNode = false;
/// <summary>
/// 表格数据拖动完成
@@ -60,25 +60,40 @@ namespace Lskj.Control.Model
this._treeView.AllowDrop = true;
this._treeView.DragOver += new DragEventHandler(treeView_DragOver);
this._treeView.DragDrop += new DragEventHandler(treeView_DragDrop);
if (this._gridView.GridControl != null)
{
this._gridView.GridControl.Disposed += OnOwnerDisposed;
}
this._treeView.Disposed += OnOwnerDisposed;
}
private void OnOwnerDisposed(object sender, EventArgs e)
{
Dispose();
}
/// <summary>
/// 模块关闭时解除源表格和目标树的拖拽事件。
/// </summary>
public void Dispose()
{
if (_disposed)
{
return;
}
if (_disposed) return;
_disposed = true;
if (_gridView != null)
{
_gridView.MouseDown -= gridView_MouseDown;
_gridView.MouseMove -= gridView_MouseMove;
if (_gridView.GridControl != null)
{
_gridView.GridControl.Disposed -= OnOwnerDisposed;
}
}
if (_treeView != null)
{
_treeView.DragOver -= treeView_DragOver;
_treeView.DragDrop -= treeView_DragDrop;
_treeView.Disposed -= OnOwnerDisposed;
}
OnDragComplete = null;
@@ -86,7 +101,6 @@ namespace Lskj.Control.Model
_gridView = null;
_treeView = null;
}
/// <summary>
/// <para>说明:获取表格选中行数据</para>
+1 -1
View File
@@ -958,7 +958,7 @@ namespace Lskj.Control.Model
{
try
{
if (!BaseImpl.HasExistsColumn(ResourceKeys.SettingTableName, ""))
if (!BaseImpl.HasExistsColumn(ResourceKeys.SettingTableName, "IfFixColumn"))
{
BaseImpl.ExecSqlValue("alter table " + ResourceKeys.SettingTableName + " add IfFixColumn bit");
}
@@ -114,6 +114,7 @@ namespace Lskj.Control.Model.MenuStrip
{
conditionRows = new DataRow[] { new DataTable().NewRow() };
}
if (conditionRows.Length == 0) continue;
foreach (DataRow selectRow in conditionRows)
{
@@ -137,6 +137,7 @@ namespace Lskj.Control.Model
{
conditionRows = new DataRow[] { new DataTable().NewRow() };
}
if (conditionRows.Length == 0) continue;
foreach (DataRow selectRow in conditionRows)
{
@@ -147,6 +147,7 @@ namespace Lskj.Control.Model.MenuStrip
{
conditionRows = new DataRow[] { new DataTable().NewRow() };
}
if (conditionRows.Length == 0) continue;
foreach (DataRow selectRow in conditionRows)
{
+33 -11
View File
@@ -143,6 +143,10 @@ namespace Lskj.Control.Model
public DataRow CurrentData;
public ModuleModel SystemModel;
/// <summary>
/// 外部已查询的MRP操作按钮数据;为空时保持原查询逻辑。
/// </summary>
public DataTable MrpClickMenus;
/// <summary>
/// 下拉框、搜索框控件对象
/// </summary>
public List<ControlModel> mControlList = new List<ControlModel>();
@@ -909,10 +913,13 @@ namespace Lskj.Control.Model
return controlModel;
}));
}
Task<DataTable> rightDtGridRightMenusTask = cachesDic.AddTask(this, "RightDtGridRightMenus", new Task<DataTable>(() =>
if (MrpClickMenus == null)
{
return BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);
}));
Task<DataTable> rightDtGridRightMenusTask = cachesDic.AddTask(this, "RightDtGridRightMenus", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);
}));
}
return true;
}));
}
@@ -1056,7 +1063,17 @@ namespace Lskj.Control.Model
}
if (dynamicModel != null && !string.IsNullOrEmpty(dynamicModel.ModuleCode))
{
if (!dataCaches.GetValue(parent, "SysModel", out ModuleModel moduleModel))
ModuleModel moduleModel = null;
if (SystemModel != null && string.Equals(SystemModel.ModeCode, dynamicModel.ModuleCode, StringComparison.OrdinalIgnoreCase))
{
moduleModel = SystemModel;
}
if (moduleModel == null && dataCaches.GetValue(parent, "SysModel", out ModuleModel cacheModuleModel) &&
cacheModuleModel != null && string.Equals(cacheModuleModel.ModeCode, dynamicModel.ModuleCode, StringComparison.OrdinalIgnoreCase))
{
moduleModel = cacheModuleModel;
}
if (moduleModel == null)
{
moduleModel = new ModuleModel(MainImpl.GetSystemdllTab(dynamicModel.ModuleCode));
}
@@ -1074,13 +1091,14 @@ namespace Lskj.Control.Model
btnCondSearch.Click += new EventHandler(OnBtnCondSearchClick);
}
}
DataTable rightDt = null;
if (dynamicModel != null)
DataTable rightDt = MrpClickMenus;
if (rightDt == null && dynamicModel != null)
{
if (!dataCaches.GetValue(this, "RightDtGridRightMenus", out rightDt))
{
rightDt = BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);
}
MrpClickMenus = rightDt;
}
if (rightDt != null && rightDt.Rows.Count > 0)
{
@@ -1238,13 +1256,14 @@ namespace Lskj.Control.Model
_popupMenu.Name = "pm_search";
CreateSearchScheme();
}
DataTable rightDt = null;
if (dynamicModel != null)
DataTable rightDt = MrpClickMenus;
if (rightDt == null && dynamicModel != null)
{
if (!dynamicModel.DataCaches.GetValue(this, "RightDtGridRightMenus", out rightDt))
{
rightDt = BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);
}
MrpClickMenus = rightDt;
}
if (rightDt != null && rightDt.Rows.Count > 0)
{
@@ -1313,10 +1332,13 @@ namespace Lskj.Control.Model
return controlModel;
}));
}
Task<DataTable> rightDtGridRightMenusTask = cachesDic.AddTask(this, "RightDtGridRightMenus", new Task<DataTable>(() =>
if (MrpClickMenus == null)
{
return BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);
}));
Task<DataTable> rightDtGridRightMenusTask = cachesDic.AddTask(this, "RightDtGridRightMenus", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);
}));
}
return true;
}));
}
+43 -8
View File
@@ -64,6 +64,8 @@ namespace Lskj.Control
private MyControl _leftGridSearchObj;
private GridDragTree _gridDragTree;
private bool mModuleResourcesReleased;
private GridDragGrid _gridDragGrid;
private BandedGridDragGrid _bandedGridDragGrid;
public bool IsExcel { get { return Model is DynamicExcelModel; } }
/// <summary>
@@ -152,6 +154,7 @@ namespace Lskj.Control
public ModuleEx()
{
InitializeComponent();
this.Disposed += OnModuleExDisposed;
}
public void ReleaseResourcesForDispose()
@@ -207,6 +210,22 @@ namespace Lskj.Control
dragTree.Dispose();
}
GridDragGrid dragGrid = _gridDragGrid;
_gridDragGrid = null;
if (dragGrid != null)
{
dragGrid.OnDragComplete -= OnDragGridCompleted;
dragGrid.Dispose();
}
BandedGridDragGrid bandedDragGrid = _bandedGridDragGrid;
_bandedGridDragGrid = null;
if (bandedDragGrid != null)
{
bandedDragGrid.OnDragComplete -= OnDragBandedGridCompleted;
bandedDragGrid.Dispose();
}
try
{
if (treeLeft != null)
@@ -379,9 +398,14 @@ namespace Lskj.Control
if (Model.HasOperPrivilege() && model.IsBaseModule)
{
// 有权限则允许拖拽
this._gridDragTree = new GridDragTree(this.ModuleGridObj.GridControlObj.GridView, this.treeLeft.TreeView);
this._gridDragTree.CanDragParentNode = true;
this._gridDragTree.OnDragComplete += new GridDragTreeCompleteEventHandler(OnDragTreeCompleted);
if (_gridDragTree != null)
{
_gridDragTree.OnDragComplete -= OnDragTreeCompleted;
_gridDragTree.Dispose();
}
_gridDragTree = new GridDragTree(this.ModuleGridObj.GridControlObj.GridView, this.treeLeft.TreeView);
_gridDragTree.CanDragParentNode = true;
_gridDragTree.OnDragComplete += new GridDragTreeCompleteEventHandler(OnDragTreeCompleted);
}
if (this.SysModel.TreeDoubleClick)
{
@@ -428,10 +452,11 @@ namespace Lskj.Control
if (Model.HasOperPrivilege() && model.IsBaseModule && !this.SysModel.IsTreeTable)
{
// 有权限则允许拖拽
GridDragGrid dragGrid = new GridDragGrid(this.ModuleGridObj.GridControlObj.GridView, this.gridLeft.GridView);
dragGrid.OnDragComplete += new GridFragGridCompleteEventHandler(OnDragGridCompleted);
_gridDragGrid?.Dispose();
_gridDragGrid = new GridDragGrid(this.ModuleGridObj.GridControlObj.GridView, this.gridLeft.GridView);
_gridDragGrid.OnDragComplete += new GridFragGridCompleteEventHandler(OnDragGridCompleted);
//配置了拖拽条件后,在点击时判断条件
dragGrid.DragConditions = this.SysModel.DragConditions;
_gridDragGrid.DragConditions = this.SysModel.DragConditions;
}
break;
@@ -504,8 +529,9 @@ namespace Lskj.Control
if (Model.HasOperPrivilege() && model.IsBaseModule && !this.SysModel.IsTreeTable && this.ModuleGridObj.GridControlObj.GridView is BandedGridView&&(this.SysModel.MenuType==2 || this.SysModel.MenuType==5))
{
// 有权限则允许拖拽
BandedGridDragGrid BandedDragGrid = new BandedGridDragGrid(this.ModuleGridObj.GridControlObj.GridView as BandedGridView, this.gridLeft.GridView);
BandedDragGrid.OnDragComplete += new BandedGridFragGridCompleteEventHandler(OnDragBandedGridCompleted);
_bandedGridDragGrid?.Dispose();
_bandedGridDragGrid = new BandedGridDragGrid(this.ModuleGridObj.GridControlObj.GridView as BandedGridView, this.gridLeft.GridView);
_bandedGridDragGrid.OnDragComplete += new BandedGridFragGridCompleteEventHandler(OnDragBandedGridCompleted);
}
}
@@ -2122,6 +2148,15 @@ namespace Lskj.Control
}
}
/// <summary>
/// 控件销毁后释放拖拽辅助对象;关闭被取消时不会触发,不影响模块继续使用。
/// </summary>
private void OnModuleExDisposed(object sender, EventArgs e)
{
this.Disposed -= OnModuleExDisposed;
ReleaseResourcesForDispose();
}
/// <summary>
/// 初始化页签
@@ -295,6 +295,12 @@ namespace Lskj.Control
cachesDic.AddTask(ModuleGridObj, "DynamicModel", dynamicModelTask);
cachesDic.AddTask(ModuleGridObj, "SysModel", sysModelTask);
this.ModuleGridObj.GetDataCaches(cachesDic);
// 下方模块都使用当前主表的主键,共享主表已经创建的查询任务,避免每个明细重复查询。
Task<string> parentPrimaryKeyTask = cachesDic.GetTask<string>(ModuleGridObj, "BasePrimaryKey");
if (parentPrimaryKeyTask != null)
{
cachesDic.AddTask(tcButtom, "ParentPrimaryKey", parentPrimaryKeyTask);
}
}
return true;
}));
+60 -32
View File
@@ -77,6 +77,10 @@ namespace Lskj.Control
/// </summary>
private bool _visibleMrpSearchPanel;
/// <summary>
/// 外部已查询的MRP操作按钮数据,供搜索区域复用。
/// </summary>
public DataTable MrpClickMenus;
/// <summary>
/// 底部操作按钮是否显示简短模式,默认为简短模式
/// </summary>
private bool _operShortMode = true;
@@ -529,7 +533,17 @@ namespace Lskj.Control
searchObj.GetSearchDataCaches(Model.DataCaches);
}
}
if (this.MrpClickMenus == null && Model.DataCaches != null)
{
Model.DataCaches.GetValue(
this,
"UnionBaseGridRightMenus",
out this.MrpClickMenus);
}
this.SearchObj = searchObj;
// 搜索区域复用当前模块配置,MyControl 内部会校验模块号,不一致时仍按原逻辑查询。
this.SearchObj.SystemModel = this.SysModel;
this.SearchObj.MrpClickMenus = this.MrpClickMenus;
if (this._leftGridField != null)
{
@@ -551,13 +565,6 @@ namespace Lskj.Control
if (fixedQuery)
{
//固定条件不显示,隐藏上方。(只显示表格)
if (SystemInfo.Instance.HideFixedConditions)
{
this.pl_top.Visible = false;
return;
}
this.pl_top_fix_search.Visible = true;
// 加载固定查询条件
@@ -570,7 +577,12 @@ namespace Lskj.Control
{
table = Business.Impl.LanguageTranslation.TranslationTableColumn(table, "fieldText");
}
//固定条件不显示,隐藏上方。(只显示表格)
if (SystemInfo.Instance.HideFixedConditions)
{
this.pl_top.Visible = false;
table = new DataTable();
}
// DataTable
this.cbField.DisplayMember = "fieldText";
@@ -3480,6 +3492,12 @@ namespace Lskj.Control
// 刷新数据
if (ImportResults)
{
if (!string.IsNullOrWhiteSpace(this.SysModel.afterimportSql))
{
string sql = this.SearchObj.ReplaceControlValue(this.SysModel.afterimportSql);
string newResult = SqlHelper.ExecuteScalar(sql) + "";
}
if (ImportReturnName.Count > 0)
{
this.SearchObj.SearchGrid();
@@ -3488,11 +3506,7 @@ namespace Lskj.Control
{
this.SearchObj.SearchLastGrid();
}
if (!string.IsNullOrWhiteSpace(this.SysModel.afterimportSql))
{
string sql = this.SearchObj.ReplaceControlValue(this.SysModel.afterimportSql);
string newResult = SqlHelper.ExecuteScalar(sql) + "";
}
}
//GridColumnCollection gridColumns = this.gcMain.GridView.Columns;
@@ -3527,11 +3541,20 @@ namespace Lskj.Control
FrmImport import = new FrmImport(this.SysModel.MenuTable, this.Model.ModuleCode, _parmaryKey, this.gcMain, this.SysModel.PrefixKey, leftField, leftValue, this.Model.FormText, this.SysModel.ConcatenatedPrefix);
import.ParentGridEx = this.ParentGridEx;
import.SearchObj = this.SearchObj;
import.ImportReturnName = ImportReturnName;
import.ImportReturnValue = ImportReturnValue;
DialogResult result = import.ShowDialog();
if (result == DialogResult.OK)
{
if (!string.IsNullOrWhiteSpace(this.SysModel.afterimportSql))
{
string sql = this.SearchObj.ReplaceControlValue(this.SysModel.afterimportSql);
string newResult = SqlHelper.ExecuteScalar(sql) + "";
//if (!string.IsNullOrEmpty(newResult)) MessageUtil.Show(newResult);
}
// 刷新数据
if (ImportReturnName.Count > 0)
{
@@ -3542,14 +3565,6 @@ namespace Lskj.Control
this.SearchObj.SearchLastGrid();
}
if (!string.IsNullOrWhiteSpace(this.SysModel.afterimportSql))
{
string sql = this.SearchObj.ReplaceControlValue(this.SysModel.afterimportSql);
string newResult = SqlHelper.ExecuteScalar(sql) + "";
//if (!string.IsNullOrEmpty(newResult)) MessageUtil.Show(newResult);
}
}
}
@@ -3688,6 +3703,16 @@ namespace Lskj.Control
{
InitializeComponent();
this.OperShortMode = true;
this.Disposed += OnModuleGridExDisposed;
}
/// <summary>
/// 清理公共事件和全局右键引用,避免模块关闭后仍保留当前表格。
/// </summary>
private void OnModuleGridExDisposed(object sender, EventArgs e)
{
this.Disposed -= OnModuleGridExDisposed;
ReleaseResourcesForDispose();
}
internal void ReleaseResourcesForDispose()
@@ -3707,6 +3732,10 @@ namespace Lskj.Control
searchObj.OnSearchBeforeCallBack -= OnSearchBeforeCallBack;
searchObj.OnSearchAfterCallBack -= OnSearchAfterCallBack;
searchObj.OnDataSourceBindCallBack -= OnMainSearchDataSourceBindCallBack;
if (ReferenceEquals(StaticControl.RightMenuMyControl, searchObj))
{
StaticControl.RightMenuMyControl = null;
}
searchObj.Dispose();
}
@@ -3714,6 +3743,10 @@ namespace Lskj.Control
{
if (gcMain != null)
{
if (ReferenceEquals(StaticControl.RightMenuGridView, gcMain.GridView))
{
StaticControl.RightMenuGridView = null;
}
if (gcMain.GridView != null)
{
gcMain.GridView.FocusedRowObjectChanged -= OnGridViewFocusedRowObjectChanged;
@@ -3895,13 +3928,10 @@ namespace Lskj.Control
}
if (this.SearchObj != null)
{
this.SearchObj.SystemModel = sysModel;
}
//if (this.SearchObj != null)
//{
// this.SearchObj.SystemModel = sysModel;
//}
//禁用条件
if (this.SysModel.ForbiddenCondition)
@@ -4068,10 +4098,8 @@ namespace Lskj.Control
{
return BaseModuleImpl.GetSchemesList(dynamicModel.ModuleId);//获取高级查询条件模版
}));
Task<ModuleModel> searchSysModelTask = cachesDic.AddTask(pl_top_search, "SysModel", new Task<ModuleModel>(() =>
{
return new ModuleModel(MainImpl.GetSystemdllTab(dynamicModel.ModuleCode));
}));
// 搜索区域与当前模块共享同一个模块配置任务,避免再次查询模块信息。
cachesDic.AddTask(pl_top_search, "SysModel", sysModelTask);
//Task<DataTable> searchBaseGridRightMenusTask = cachesDic.AddTask(pl_top_search, "BaseGridRightMenus", new Task<DataTable>(() =>
//{
// return BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);
+1 -1
View File
@@ -2743,7 +2743,7 @@ namespace Lskj.Control
BaseUserControl baseControl = this.ControlObj.FindControl(PrimaryKey);
if (baseControl != null)
{
this.ControlObj.CopyControlValue();
this.ControlObj.CopyControlValue(this.SysModel.CancelCopyAssociation);
baseControl.EditText = BaseImpl.GetDefaultValue(baseControl.Model.Default, ParentKey);
lteSpeciesNo.TextEdit.EditValue = this.ParentKey;
@@ -466,7 +466,8 @@ namespace Lskj.Control.MultiModelLookUp
}
}
}
SetCustomColumns();
//SetCustomColumns();
}
#endregion
#region
@@ -481,7 +482,7 @@ namespace Lskj.Control.MultiModelLookUp
/// </summary>
private void SetCustomColumns()
{
if (string.IsNullOrEmpty(this.CurrentOperColumnKey) || !BaseImpl.HasExistsTable(ResourceKeys.SettingTableName)) return;
if (string.IsNullOrEmpty(this.CurrentOperColumnKey)) return;
DataTable customTable = this.gcMain.GridView.GetCustomColumnByDatabase(this.CurrentOperColumnKey);
if (customTable != null && customTable.Rows.Count > 0)
+48 -15
View File
@@ -211,17 +211,17 @@ namespace Lskj.Control
g.SetGridViewDataSource(table);
break;
/* ③ Tag 是面板/其它容器,递归找内部网格 ------------------------ */
/* ③ 图表控件:需先于通用容器判断,避免绑定到图表内部隐藏网格 -- */
case ChartControlEx chartEx:
chartEx.CreateChart(table);
break;
/* ④ Tag 是面板/其它容器,递归找内部网格 ------------------------ */
case System.Windows.Forms.Control container when FindGridControlEx(container) is GridControlEx g2:
g2.LastSearchSql = lastSql ?? g2.LastSearchSql;
g2.SetGridViewDataSource(table);
break;
/* ④ 图表控件 ---------------------------------------------------- */
case ChartControlEx chartEx:
chartEx.CreateChart(table);
break;
/* ⑤ 其它控件无需绑定 ------------------------------------------- */
default:
break;
@@ -501,6 +501,14 @@ namespace Lskj.Control
Dictionary<object, Hashtable> dataCaches = Model?.DataCaches;
// 普通 ModuleGridEx 明细使用同一个父模块主键,避免同步加载时每个明细重复查询。
bool hasModuleGridDetail = Model != null && gridDetail.Any(model => IsModuleGridDetail(model, gridDetail, isGridmerge));
string parentPrimaryKey = null;
if (hasModuleGridDetail && !dataCaches.GetValue(this, "ParentPrimaryKey", out parentPrimaryKey))
{
parentPrimaryKey = BaseImpl.GetBasePrimaryKey(Model.ModuleCode);
}
this.DetaiName = string.Empty;
foreach (GridDetailModel model in gridDetail)
@@ -520,7 +528,7 @@ namespace Lskj.Control
page.SizeChanged += OnPageSizeChanged;
// 2️⃣ 先生成“左侧”父明细控件
System.Windows.Forms.Control leftCtrl = CreateDetailControl(page, model, dataCaches);
System.Windows.Forms.Control leftCtrl = CreateDetailControl(page, model, dataCaches, true, null, hasModuleGridDetail, parentPrimaryKey);
int position = int.TryParse(IniHelper.Read($"base_TabPageMain_{model.Id}"), out int value) ? value : 0; // 0 是转换失败时的默认值
if (hasRight && isGridmerge)
{
@@ -559,7 +567,7 @@ namespace Lskj.Control
foreach (var child in rightChildren.OrderBy(c => c.Orderid))
{
XtraTabPage childPage = new XtraTabPage { Text = child.DetailName };
System.Windows.Forms.Control childCtrl = CreateDetailControl(childPage, child, dataCaches, true, leftControl);
System.Windows.Forms.Control childCtrl = CreateDetailControl(childPage, child, dataCaches, true, leftControl, hasModuleGridDetail, parentPrimaryKey);
childPage.Controls.Add(childCtrl);
rightTab.TabPages.Add(childPage);
_rightSideTabPages.Add(childPage);
@@ -605,6 +613,21 @@ namespace Lskj.Control
}
}
/// <summary>
/// 判断明细配置是否会创建普通 ModuleGridEx 控件。
/// </summary>
private static bool IsModuleGridDetail(GridDetailModel model, List<GridDetailModel> gridDetail, bool isGridmerge)
{
if (model == null || model.IsChart || model.IsExcel || model.IsWebView || model.IsWebView2 || model.IsWebView3 ||
model.IsSched || (model.IsAddPanel && isGridmerge) || model.IsDetailView)
{
return false;
}
int sameDetailCount = gridDetail.Count(item => item.DetailName.Equals(model.DetailName));
return !(model.IsReadOnly && sameDetailCount == 1) && !(sameDetailCount > 1 && isGridmerge);
}
@@ -989,6 +1012,7 @@ namespace Lskj.Control
this.isMrpDetail = true;
gridEx.VisibleMrpSearchPanel = true;
}
gridEx.MrpClickMenus = rightDt;
gridEx.VisibleOperPanel = !model.IsReadOnly;
gridEx.InitializeControl(model.SystemModel, dyncModel);
gridEx.GridControlObj.Tag = model;
@@ -1106,7 +1130,7 @@ namespace Lskj.Control
/// <param name="dataCaches"></param>
/// <param name="isGridmerge"></param>
/// <returns></returns>
private System.Windows.Forms.Control CreateDetailControl(System.Windows.Forms.Control parentControl, GridDetailModel model, Dictionary<object, Hashtable> dataCaches, bool isGridmerge = true, GridControlEx leftGridControlEx =null)
private System.Windows.Forms.Control CreateDetailControl(System.Windows.Forms.Control parentControl, GridDetailModel model, Dictionary<object, Hashtable> dataCaches, bool isGridmerge = true, GridControlEx leftGridControlEx = null, bool hasParentPrimaryKey = false, string parentPrimaryKey = null)
{
GridDetailModel[] isMeage = _gridDetail.Cast<GridDetailModel>().Where(x => x.DetailName.Equals(model.DetailName)).ToArray();
@@ -1441,8 +1465,11 @@ namespace Lskj.Control
if (Model != null)
{
if (!dataCaches.GetValue(gridEx, "ParentPrimaryKey", out string primaryKey))
string primaryKey = parentPrimaryKey;
if (!hasParentPrimaryKey && !dataCaches.GetValue(gridEx, "ParentPrimaryKey", out primaryKey))
{
primaryKey = BaseImpl.GetBasePrimaryKey(Model.ModuleCode);
}
model.SystemModel.ParmaryKey = primaryKey;
}
@@ -1465,6 +1492,7 @@ namespace Lskj.Control
isMrpDetail = true;
gridEx.VisibleMrpSearchPanel = true;
}
gridEx.MrpClickMenus = rightDt;
gridEx.VisibleOperPanel = !model.IsReadOnly;
if (model.HideBottomPanel|| model.Library.Equals("Lskj.Report.dll", StringComparison.OrdinalIgnoreCase))
@@ -1600,6 +1628,15 @@ namespace Lskj.Control
Task<List<GridDetailModel>> detailsTask = cachesDic.GetTask<List<GridDetailModel>>(this, "Details");
DynamicModel dynamicModel = dynamicModelTask.Result;
List<GridDetailModel> details = detailsTask.Result;
// 所有子模块使用同一个父模块主键。优先复用外部主表的查询任务,其他入口只补查一次。
Task<string> parentPrimaryKeyTask = cachesDic.GetTask<string>(this, "ParentPrimaryKey");
if (parentPrimaryKeyTask == null)
{
parentPrimaryKeyTask = cachesDic.AddTask(this, "ParentPrimaryKey", new Task<string>(() =>
{
return BaseImpl.GetBasePrimaryKey(dynamicModel.ModuleCode);
}));
}
string DetaiName = string.Empty;
PageControlsDic.Clear();
foreach (GridDetailModel model in details)
@@ -1778,11 +1815,7 @@ namespace Lskj.Control
}));
if (dynamicModel != null)
{
Task<string> basePrimaryKeyTask = cachesDic.AddTask(gridEx, "ParentPrimaryKey", new Task<string>(() =>
{
string basePrimaryKey = BaseImpl.GetBasePrimaryKey(dynamicModel.ModuleCode);
return basePrimaryKey;
}));
cachesDic.AddTask(gridEx, "ParentPrimaryKey", parentPrimaryKeyTask);
}
Task<DataTable> baseGridRightMenusTask = cachesDic.AddTask(gridEx, "UnionBaseGridRightMenus", new Task<DataTable>(() =>
{
+2 -2
View File
@@ -418,7 +418,7 @@ namespace Lskj.Control
if (model.IsStrickOut) fontStyle = fontStyle | FontStyle.Strikeout;
if (model.IsUnderLine) fontStyle = fontStyle | FontStyle.Underline;
e.Appearance.Font = new Font(e.Appearance.Font, fontStyle);
e.Appearance.FontStyleDelta = fontStyle;
}
}
catch (Exception)
@@ -471,7 +471,7 @@ namespace Lskj.Control
if (model.IsStrickOut) fontStyle = fontStyle | FontStyle.Strikeout;
if (model.IsUnderLine) fontStyle = fontStyle | FontStyle.Underline;
e.Appearance.Font = new Font(e.Appearance.Font, fontStyle);
e.Appearance.FontStyleDelta = fontStyle;
}
}
catch (Exception)