SVN-Revision: r298
This commit is contained in:
tdx
2025-03-06 08:38:00 +00:00
parent 9c912165e2
commit 6e9f2db7d4
5 changed files with 534 additions and 88 deletions
+1 -4
View File
@@ -32,11 +32,8 @@ namespace Lskj.ProductSched
/// <param name="e"></param>
private void OnFrmMainLoad(object sender, EventArgs e)
{
frmProductSched.GetControlData(Model);
frmProductSched.InitControlView();
frmProductSched.SetControlData();
frmProductSched.OnLoad(Model);
}
/// <summary>
/// 获取数据源缓存
/// </summary>
+72 -63
View File
@@ -32,26 +32,26 @@ namespace Lskj.ProductiSched
this.pl_main = new DevExpress.XtraEditors.PanelControl();
this.splitMainControl = new DevExpress.XtraEditors.SplitContainerControl();
this.splitLeftControl = new DevExpress.XtraEditors.SplitContainerControl();
this.gcBottom = new Lskj.Control.GridControlEx();
this.panelControl1 = new DevExpress.XtraEditors.PanelControl();
this.bandGcTop = new Lskj.Control.BandedGridControlEx();
this.bandGcBottom = new Lskj.Control.BandedGridControlEx();
this.pl_mainSearch = new DevExpress.XtraEditors.PanelControl();
this.pl_flowRightBtn = new System.Windows.Forms.FlowLayoutPanel();
this.pl_search = new DevExpress.XtraEditors.PanelControl();
this.pl_btn = new DevExpress.XtraEditors.PanelControl();
this.flowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel();
this.btnColse = new DevExpress.XtraEditors.SimpleButton();
this.btnSave = new DevExpress.XtraEditors.SimpleButton();
this.gcRight = new Lskj.Control.GridControlEx();
this.pl_left = new DevExpress.XtraEditors.PanelControl();
this.bandGcTop = new Lskj.Control.BandedGridControlEx();
((System.ComponentModel.ISupportInitialize)(this.pl_main)).BeginInit();
this.pl_main.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitMainControl)).BeginInit();
this.splitMainControl.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitLeftControl)).BeginInit();
this.splitLeftControl.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.panelControl1)).BeginInit();
this.panelControl1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pl_mainSearch)).BeginInit();
this.pl_mainSearch.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pl_search)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pl_btn)).BeginInit();
this.pl_btn.SuspendLayout();
this.flowLayoutPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pl_left)).BeginInit();
this.SuspendLayout();
//
@@ -93,82 +93,102 @@ namespace Lskj.ProductiSched
this.splitLeftControl.Name = "splitLeftControl";
this.splitLeftControl.Panel1.Controls.Add(this.bandGcTop);
this.splitLeftControl.Panel1.Text = "Panel1";
this.splitLeftControl.Panel2.Controls.Add(this.gcBottom);
this.splitLeftControl.Panel2.Controls.Add(this.panelControl1);
this.splitLeftControl.Panel2.Controls.Add(this.bandGcBottom);
this.splitLeftControl.Panel2.Controls.Add(this.pl_mainSearch);
this.splitLeftControl.Panel2.Text = "Panel2";
this.splitLeftControl.Size = new System.Drawing.Size(997, 679);
this.splitLeftControl.SplitterPosition = 353;
this.splitLeftControl.TabIndex = 7;
this.splitLeftControl.Text = "splitContainerControl2";
//
// gcBottom
// bandGcTop
//
this.gcBottom.AdapterObj = null;
this.gcBottom.Dock = System.Windows.Forms.DockStyle.Fill;
this.gcBottom.Location = new System.Drawing.Point(0, 38);
this.gcBottom.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.gcBottom.Name = "gcBottom";
this.gcBottom.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum;
this.gcBottom.Size = new System.Drawing.Size(997, 283);
this.gcBottom.TabIndex = 12;
this.bandGcTop.AdapterObj = null;
this.bandGcTop.Dock = System.Windows.Forms.DockStyle.Fill;
this.bandGcTop.Location = new System.Drawing.Point(0, 0);
this.bandGcTop.Margin = new System.Windows.Forms.Padding(4);
this.bandGcTop.Name = "bandGcTop";
this.bandGcTop.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum;
this.bandGcTop.Size = new System.Drawing.Size(997, 353);
this.bandGcTop.TabIndex = 0;
//
// panelControl1
// bandGcBottom
//
this.panelControl1.Appearance.BackColor = System.Drawing.Color.Transparent;
this.panelControl1.Appearance.Options.UseBackColor = true;
this.panelControl1.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
this.panelControl1.Controls.Add(this.pl_search);
this.panelControl1.Controls.Add(this.pl_btn);
this.panelControl1.Dock = System.Windows.Forms.DockStyle.Top;
this.panelControl1.Location = new System.Drawing.Point(0, 0);
this.panelControl1.LookAndFeel.UseDefaultLookAndFeel = false;
this.panelControl1.Name = "panelControl1";
this.panelControl1.Size = new System.Drawing.Size(997, 38);
this.panelControl1.TabIndex = 11;
this.bandGcBottom.AdapterObj = null;
this.bandGcBottom.Dock = System.Windows.Forms.DockStyle.Fill;
this.bandGcBottom.Location = new System.Drawing.Point(0, 33);
this.bandGcBottom.Margin = new System.Windows.Forms.Padding(4);
this.bandGcBottom.Name = "bandGcBottom";
this.bandGcBottom.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum;
this.bandGcBottom.Size = new System.Drawing.Size(997, 288);
this.bandGcBottom.TabIndex = 12;
//
// pl_mainSearch
//
this.pl_mainSearch.Appearance.BackColor = System.Drawing.Color.Transparent;
this.pl_mainSearch.Appearance.Options.UseBackColor = true;
this.pl_mainSearch.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
this.pl_mainSearch.Controls.Add(this.pl_flowRightBtn);
this.pl_mainSearch.Controls.Add(this.pl_search);
this.pl_mainSearch.Controls.Add(this.flowLayoutPanel);
this.pl_mainSearch.Dock = System.Windows.Forms.DockStyle.Top;
this.pl_mainSearch.Location = new System.Drawing.Point(0, 0);
this.pl_mainSearch.LookAndFeel.UseDefaultLookAndFeel = false;
this.pl_mainSearch.Name = "pl_mainSearch";
this.pl_mainSearch.Size = new System.Drawing.Size(997, 33);
this.pl_mainSearch.TabIndex = 11;
//
// pl_flowRightBtn
//
this.pl_flowRightBtn.Dock = System.Windows.Forms.DockStyle.Left;
this.pl_flowRightBtn.Location = new System.Drawing.Point(221, 0);
this.pl_flowRightBtn.Name = "pl_flowRightBtn";
this.pl_flowRightBtn.Size = new System.Drawing.Size(340, 33);
this.pl_flowRightBtn.TabIndex = 15;
this.pl_flowRightBtn.WrapContents = false;
//
// pl_search
//
this.pl_search.Appearance.BackColor = System.Drawing.Color.Transparent;
this.pl_search.Appearance.Options.UseBackColor = true;
this.pl_search.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
this.pl_search.Dock = System.Windows.Forms.DockStyle.Fill;
this.pl_search.Dock = System.Windows.Forms.DockStyle.Left;
this.pl_search.Location = new System.Drawing.Point(0, 0);
this.pl_search.LookAndFeel.UseDefaultLookAndFeel = false;
this.pl_search.Name = "pl_search";
this.pl_search.Size = new System.Drawing.Size(867, 38);
this.pl_search.TabIndex = 12;
this.pl_search.Size = new System.Drawing.Size(221, 33);
this.pl_search.TabIndex = 14;
//
// pl_btn
// flowLayoutPanel
//
this.pl_btn.Appearance.BackColor = System.Drawing.Color.Transparent;
this.pl_btn.Appearance.Options.UseBackColor = true;
this.pl_btn.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
this.pl_btn.Controls.Add(this.btnColse);
this.pl_btn.Controls.Add(this.btnSave);
this.pl_btn.Dock = System.Windows.Forms.DockStyle.Right;
this.pl_btn.Location = new System.Drawing.Point(867, 0);
this.pl_btn.Name = "pl_btn";
this.pl_btn.Size = new System.Drawing.Size(130, 38);
this.pl_btn.TabIndex = 8;
this.flowLayoutPanel.Controls.Add(this.btnColse);
this.flowLayoutPanel.Controls.Add(this.btnSave);
this.flowLayoutPanel.Dock = System.Windows.Forms.DockStyle.Right;
this.flowLayoutPanel.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
this.flowLayoutPanel.Location = new System.Drawing.Point(859, 0);
this.flowLayoutPanel.Name = "flowLayoutPanel";
this.flowLayoutPanel.Size = new System.Drawing.Size(138, 33);
this.flowLayoutPanel.TabIndex = 13;
this.flowLayoutPanel.WrapContents = false;
//
// btnColse
//
this.btnColse.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnColse.Appearance.Options.UseFont = true;
this.btnColse.Location = new System.Drawing.Point(62, 7);
this.btnColse.Location = new System.Drawing.Point(81, 3);
this.btnColse.Name = "btnColse";
this.btnColse.Size = new System.Drawing.Size(54, 24);
this.btnColse.TabIndex = 44;
this.btnColse.TabIndex = 48;
this.btnColse.Text = "关闭";
//
// btnSave
//
this.btnSave.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnSave.Appearance.Options.UseFont = true;
this.btnSave.Location = new System.Drawing.Point(6, 7);
this.btnSave.Location = new System.Drawing.Point(25, 3);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(50, 24);
this.btnSave.TabIndex = 43;
this.btnSave.TabIndex = 47;
this.btnSave.Text = "保存";
//
// gcRight
@@ -194,17 +214,6 @@ namespace Lskj.ProductiSched
this.pl_left.Size = new System.Drawing.Size(315, 38);
this.pl_left.TabIndex = 10;
//
// bandGcTop
//
this.bandGcTop.AdapterObj = null;
this.bandGcTop.Dock = System.Windows.Forms.DockStyle.Fill;
this.bandGcTop.Location = new System.Drawing.Point(0, 0);
this.bandGcTop.Margin = new System.Windows.Forms.Padding(4);
this.bandGcTop.Name = "bandGcTop";
this.bandGcTop.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum;
this.bandGcTop.Size = new System.Drawing.Size(997, 353);
this.bandGcTop.TabIndex = 0;
//
// FrmProductSched
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@@ -218,7 +227,7 @@ namespace Lskj.ProductiSched
this.splitMainControl.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitLeftControl)).EndInit();
this.splitLeftControl.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.panelControl1)).EndInit();
this.panelControl1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pl_mainSearch)).EndInit();
this.pl_mainSearch.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pl_search)).EndInit();
((System.Compo
this.flowLayoutPanel.ResumeLayou
+440 -13
View File
@@ -1,4 +1,10 @@
using Lskj.Business.Impl;
using DevExpress.Data;
using DevExpress.Utils;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.BandedGrid;
using Lskj.Business.Impl;
using Lskj.Control;
using Lskj.Control.Model;
using Lskj.Model;
using Lskj.ProductSched;
@@ -24,6 +30,17 @@ namespace Lskj.ProductiSched
InitializeComponent();
}
/// <summary>
/// 界面加载时
/// </summary>
public void OnLoad(DynamicProductSchedModel mainModel)
{
GetControlData(mainModel);
InitSpiltLocation();
InitControlView();
InitControlEvents();
SetControlData();
}
/// <summary>
/// 获取数据
/// </summary>
public void GetControlData(DynamicProductSchedModel mainModel)
@@ -33,24 +50,36 @@ namespace Lskj.ProductiSched
DataRow topSysRow = MainImpl.GetSystemdllTab(DataModel.TopSysModel.ModuleCode);
DataModel.TopModuleModel = new ModuleModel(topSysRow);
DataModel.TopGridColumns = BaseModuleImpl.GetBaseGridColumns(DataModel.TopSysModel.ModuleCode);
DataModel.TopRightMenus = BaseModuleImpl.GetBaseGridRightMenus(DataModel.TopModuleModel.FormKey);
DataModel.TopRowColors = BaseModuleImpl.GetBaseGridRowColors(DataModel.TopModuleModel.FormKey);
DataModel.TopSearchTab = BaseModuleImpl.GetCustomQueryFields(DataModel.TopModuleModel.CondKey);
DataModel.TopSchemesTable = BaseModuleImpl.GetSchemesList(DataModel.TopSysModel.ModuleId);
DataModel.TopSearchObj = new MyControl(DataModel.TopModuleModel.MenuSql, bandGcTop);
DataModel.TopSearchObj.Model = DataModel.TopSysModel;
DataTable detailsTab = BaseModuleImpl.GetBaseDetailPages(DataModel.TopSysModel.ModuleCode);
if (detailsTab != null)
{
if (detailsTab.Rows.Count > 0)
{
string moduleCode = detailsTab.Rows[0]["unionModule"] + "";
DataModel.BottomDetailModel = new GridDetailModel(detailsTab.Rows[0], null, GridCustomColumnStruct.BaseDetailGridView);
DataModel.BottomSysModel = new DynamicModel(new string[] { DataModel.TopSysModel.FormText, DataModel.TopSysModel.UserId, DataModel.TopSysModel.UserName, DataModel.TopSysModel.Privilege, moduleCode });
DataRow sysRow = MainImpl.GetSystemdllTab(DataModel.BottomSysModel.ModuleCode);
DataModel.BottomModuleModel = new ModuleModel(sysRow);
DataModel.BottomGridColumns = BaseModuleImpl.GetBaseDetailPages(DataModel.BottomSysModel.ModuleCode);
DataModel.BottomGridColumns = BaseModuleImpl.GetBaseGridColumns(DataModel.BottomSysModel.ModuleCode);
DataModel.BottomRightMenus = BaseModuleImpl.GetBaseGridRightMenus(DataModel.TopModuleModel.FormKey);
DataModel.BottomRowColors = BaseModuleImpl.GetBaseGridRowColors(DataModel.TopModuleModel.FormKey);
}
if (detailsTab.Rows.Count > 1)
{
string moduleCode = detailsTab.Rows[1]["unionModule"] + "";
DataModel.RightDetailModel = new GridDetailModel(detailsTab.Rows[1], null, GridCustomColumnStruct.BaseDetailGridView);
DataModel.RightSysModel = new DynamicModel(new string[] { DataModel.TopSysModel.FormText, DataModel.TopSysModel.UserId, DataModel.TopSysModel.UserName, DataModel.TopSysModel.Privilege, moduleCode });
DataRow sysRow = MainImpl.GetSystemdllTab(DataModel.RightSysModel.ModuleCode);
DataModel.RightModuleModel = new ModuleModel(sysRow);
DataModel.RightGridColumns = BaseModuleImpl.GetBaseDetailPages(DataModel.RightSysModel.ModuleCode);
DataModel.RightGridColumns = BaseModuleImpl.GetBaseGridColumns(DataModel.RightSysModel.ModuleCode);
DataModel.RightRightMenus = BaseModuleImpl.GetBaseGridRightMenus(DataModel.TopModuleModel.FormKey);
DataModel.RightRowColors = BaseModuleImpl.GetBaseGridRowColors(DataModel.TopModuleModel.FormKey);
}
}
}
@@ -66,21 +95,197 @@ namespace Lskj.ProductiSched
/// </summary>
public void InitControlView()
{
//搜索控件
bool fixedQuery = DataModel.TopSearchTab == null || DataModel.TopSearchTab.Rows.Count == 0;
if (!fixedQuery)
{
this.pl_mainSearch.Height = DataModel.TopSearchObj.InitSearchControl(DataModel.TopSearchTab, this.pl_search, true, DataModel.TopSchemesTable, DataModel.TopSysModel);
this.pl_search.Width = DataModel.TopSearchObj.ParentPanel.Controls.Cast<System.Windows.Forms.Control>().Max(n => n.Location.X + n.Width) + 5;
}
//上方表格
bandGcTop.Model = DataModel.TopSysModel;
bandGcTop.SetReadOnlyColumns(DataModel.TopGridColumns, GridCustomColumnStruct.BaseMainGridView + DataModel.TopModuleModel.FormKey);
bandGcTop.SetEditColumns(DataModel.TopGridColumns, GridCustomColumnStruct.BaseMainGridView + DataModel.TopModuleModel.FormKey);
bandGcTop.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(DataModel.TopModuleModel.FormKey), DataModel.TopSysModel);
bandGcTop.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(DataModel.TopModuleModel.FormKey));
AddDataColumns(bandGcTop, true);
//下方表格
gcBottom.Model = DataModel.BottomSysModel;
gcBottom.SetReadOnlyColumns(DataModel.RightGridColumns, GridCustomColumnStruct.BaseMainGridView + DataModel.BottomModuleModel.FormKey);
gcBottom.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(DataModel.BottomModuleModel.FormKey), DataModel.BottomSysModel);
gcBottom.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(DataModel.BottomModuleModel.FormKey));
if (!string.IsNullOrEmpty(DataModel.BottomSysModel.ModuleCode))
{
bandGcBottom.Model = DataModel.BottomSysModel;
bandGcBottom.SetEditColumns(DataModel.BottomGridColumns, GridCustomColumnStruct.BaseMainGridView + DataModel.BottomModuleModel.FormKey);
bandGcBottom.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(DataModel.BottomModuleModel.FormKey), DataModel.BottomSysModel);
bandGcBottom.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(DataModel.BottomModuleModel.FormKey));
AddDataColumns(bandGcBottom);
foreach (GridBand gridBand in bandGcBottom.BandedView.Bands)
{
gridBand.OptionsBand.AllowSize = false;
foreach (BandedGridColumn bandedGridColumn in gridBand.Columns)
{
bandedGridColumn.OptionsColumn.AllowSize = false;
}
}
OnBandedViewColumnWidthChanged(bandGcTop.BandedView, null);
}
//右侧表格
gcRight.Model = DataModel.RightSysModel;
gcRight.SetReadOnlyColumns(DataModel.RightGridColumns, GridCustomColumnStruct.BaseMainGridView + DataModel.RightModuleModel.FormKey);
gcRight.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(DataModel.RightModuleModel.FormKey), DataModel.RightSysModel);
gcRight.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(DataModel.RightModuleModel.FormKey));
if (!string.IsNullOrEmpty(DataModel.RightSysModel.ModuleCode))
{
gcRight.Model = DataModel.RightSysModel;
gcRight.SetEditColumns(DataModel.RightGridColumns, GridCustomColumnStruct.BaseMainGridView + DataModel.RightModuleModel.FormKey);
gcRight.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(DataModel.RightModuleModel.FormKey), DataModel.RightSysModel);
gcRight.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(DataModel.RightModuleModel.FormKey));
}
}
/// <summary>
/// 绑定控件事件
/// </summary>
public void InitControlEvents()
{
splitLeftControl.SplitterPositionChanged += OnSplitContainerPositionChanged;
splitMainControl.SplitterPositionChanged += OnSplitContainerPositionChanged;
DataModel.TopSearchObj.OnDataSourceBindCallBack += OnDataSourceBindCallBack;
DataModel.TopSearchObj.OnSearchAfterCallBack += OnSearchAfterCallBack;
bandGcTop.BandedView.BandWidthChanged += OnBandedViewColumnWidthChanged;
bandGcTop.BandedView.ColumnWidthChanged += OnBandedViewColumnWidthChanged;
bandGcTop.BandedView.LeftCoordChanged += OnBandedViewLeftCoordChanged;
bandGcBottom.BandedView.LeftCoordChanged += OnBandedViewLeftCoordChanged;
bandGcTop.BandedView.FocusedRowObjectChanged += OnBandedTopFocusedRowObjectChanged;
}
/// <summary>
/// 选中行改变时
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnBandedTopFocusedRowObjectChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventArgs e)
{
GridDetailModel model = DataModel.RightDetailModel;
DataRow rowItem = bandGcTop.BandedView.GetFocusedDataRow();
string searchSql = this.GetSearchSql(model, rowItem, false);
gcRight.SetGridViewDataSource(BaseImpl.GetDataTableResult(searchSql));
}
/// <summary>
/// 获取查询sql
/// </summary>
/// <param name="model"></param>
/// <param name="rowItem"></param>
/// <param name="isLeft"></param>
/// <returns></returns>
private string GetSearchSql(GridDetailModel model, DataRow rowItem, bool isLeft = false)
{
string fieldName = !string.IsNullOrEmpty(model.UnionParentField) && rowItem.Table.Columns.Contains(model.UnionParentField) ? model.UnionParentField : DataModel.TopModuleModel.ParmaryKey;
string sqlValue = model.IsReadOnly || model.IsChart ? model.DetailSql : DataModel.RightModuleModel.MenuSql;
sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, sqlValue);
DataRow row = bandGcTop.GetViewFocusedDataRow();
if (row != null && isLeft)
{
//先替换左侧选中行,在替换主表
sqlValue = ReplaceHelper.ReplaceRowParam(row, sqlValue);
}
if (ReplaceHelper.IsSelect(sqlValue) && !string.IsNullOrEmpty(model.UnionValue))
{
string Conditions = string.Empty;
//是左侧选中行,并且没有替换字段,则使用主表选中行
Conditions = isLeft ? rowItem.Table.Columns.Contains(fieldName) ? rowItem[fieldName] + "" : row[fieldName] + "" : rowItem[fieldName] + "";
sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue) + string.Format(" and {0}='{1}'", model.UnionValue, Conditions);
}
if (!string.IsNullOrEmpty(model.UnionCond))
{
string UnionCond = ReplaceHelper.ReplaceRowParam(rowItem, model.UnionCond);
sqlValue += UnionCond;
}
return sqlValue;
}
/// <summary>
/// 宽度改变时
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnBandedViewColumnWidthChanged(object sender, EventArgs e)
{
if (sender == bandGcTop.BandedView)
{
int allWidth = 0;
foreach (GridBand gridBand in bandGcTop.BandedView.Bands)
{
if (gridBand.Columns.Count == 1 && gridBand.Columns[0].Name.Contains("DDay_"))
{
break;
}
else
{
allWidth += gridBand.Width;
}
}
List<BandedGridColumn> bandedColumnList = new List<BandedGridColumn>();
foreach (GridBand gridBand in bandGcBottom.BandedView.Bands)
{
if (gridBand.Columns.Count == 1 && gridBand.Columns[0].Name.Contains("DDay_"))
{
break;
}
else
{
bandedColumnList.AddRange(gridBand.Columns.Cast<BandedGridColumn>());
}
}
int perWidth = allWidth / bandedColumnList.Count;
foreach (BandedGridColumn bandedGridColumn in bandedColumnList)
{
bandedGridColumn.Width = perWidth;
}
}
}
/// <summary>
/// 水平滚动条改变时
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnBandedViewLeftCoordChanged(object sender, EventArgs e)
{
if (sender == bandGcTop.BandedView)
{
bandGcBottom.BandedView.LeftCoord = bandGcTop.BandedView.LeftCoord;
}
else if (sender == bandGcBottom.BandedView)
{
bandGcTop.BandedView.LeftCoord = bandGcBottom.BandedView.LeftCoord;
}
}
/// <summary>
/// 搜索条件绑定完成后
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnDataSourceBindCallBack(object sender, EventArgs e)
{
BaseUserControl baseUserControl = DataModel.TopSearchObj.ParentPanel.Controls.Cast<BaseUserControl>().Where(n => n is LabelDateEdit).FirstOrDefault();
if (baseUserControl != null)
{
LabelDateEdit labelDateEdit = baseUserControl as LabelDateEdit;
DateTime dateTime = labelDateEdit.TextEdit.DateTime;
UpdateDynamicColumns(bandGcTop, dateTime);
UpdateDynamicColumns(bandGcBottom, dateTime);
}
}
/// <summary>
/// 搜索后事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnSearchAfterCallBack(object sender, EventArgs e)
{
BaseUserControl baseUserControl = DataModel.TopSearchObj.ParentPanel.Controls.Cast<BaseUserControl>().Where(n => n is LabelDateEdit).FirstOrDefault();
if (baseUserControl != null)
{
LabelDateEdit labelDateEdit = baseUserControl as LabelDateEdit;
DateTime dateTime = labelDateEdit.TextEdit.DateTime;
UpdateDynamicColumns(bandGcTop, dateTime);
UpdateDynamicColumns(bandGcBottom, dateTime);
DataTable dataMain = bandGcTop.GridControl.DataSourceTable();
string sqlValue = DataModel.RightModuleModel.MenuSql;
sqlValue = $"{ReplaceHelper.ReplaceWhereCond(sqlValue)} and day >= '{dateTime.ToString("yyyy-MM-dd")}'";
DataTable dataDayPlan = BaseImpl.GetDataTableResult(sqlValue);
MergeMainDataWithDayPlan(dataMain, dataDayPlan, dateTime);
}
}
/// <summary>
/// 获取数据源缓存
@@ -101,4 +306,226 @@ namespace Lskj.ProductiSched
if (sysModel != null && dynamicModel != null)
{
Task<DataRow> menuConfigTabTask = cachesDic.AddTask(this, "MenuConfigTab", new Task<DataRow>(() =>
{
return BaseImpl.GetMenuConfigTab(dynamicModel.ModuleId); //获取菜单其他配置
}));
if (dynamicModel is DynamicExcelModel)//isExcel
{
Task<string> basePrimaryKeyTask = cachesDic.AddTask(this, "BasePrimaryKey", new Task<string>(() =>
{
return BaseImpl.GetBasePrimaryKey(dynamicModel.ModuleCode);
}));
Task<DataTable> gridColumnsTask = cachesDic.AddTask(this, "GridColumns", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridColumns(dynamicModel.ModuleCode);
}));
}
else
{
//构建主表数据
}
}
return true;
}));
}
/// <summary>
/// 添加虚拟日期列
/// </summary>
private void AddDataColumns(BandedGridControlEx bandedGridControlEx, bool canSum = false)
{
foreach (GridBand gridBand in bandedGridControlEx.BandedView.Bands)
{
gridBand.Fixed = FixedStyle.Left;
}
for (int i = 0; i < 93; i++)
{
GridBand gridBand = new GridBand();
gridBand.Name = $"Day_{i}";
gridBand.Caption = "";
gridBand.OptionsBand.AllowMove = false;
gridBand.OptionsBand.AllowSize = false;
gridBand.AppearanceHeader.Options.UseFont = true;
gridBand.AppearanceHeader.Font = new Font("宋体", 9, FontStyle.Bold);
gridBand.AppearanceHeader.Options.UseTextOptions = true;
gridBand.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
bandedGridControlEx.BandedView.Bands.AddRange(new GridBand[] { gridBand });
BandedGridColumn gridColumn = new BandedGridColumn();
gridColumn.AppearanceCell.Options.UseTextOptions = true;
gridColumn.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center;
gridColumn.OptionsColumn.AllowMove = false;
gridColumn.OptionsColumn.AllowSize = false;
gridColumn.FieldName = $"DDay_{i}";
gridColumn.Width = 70;
gridColumn.DisplayFormat.FormatType = FormatType.Numeric;
gridColumn.DisplayFormat.FormatString = "{0:#,##0.####}";
gridColumn.Visible = false;
gridBand.Columns.Add(gridColumn);
if (canSum)
{
gridColumn.Summary.AddRange(new GridSummaryItem[] { new GridColumnSummaryItem(SummaryItemType.Sum, gridColumn.FieldName, "{0:#,##0.####}") });
bandGcTop.BandedView.GroupSummary.Add(new GridGroupSummaryItem(SummaryItemType.Sum, gridColumn.FieldName, gridColumn, "{0:#,##0.####}"));
bandGcTop.BandedView.OptionsView.GroupFooterShowMode = DevExpress.XtraGrid.Views.Grid.GroupFooterShowMode.VisibleAlways;
}
}
if (canSum)
{
bandedGridControlEx.BandedView.OptionsView.ShowFooter = true;
}
}
/// <summary>
/// 根据日期修改列状态
/// </summary>
/// <param name="currentDate"></param>
private void UpdateDynamicColumns(BandedGridControlEx bandedGridControlEx, DateTime currentDate)
{
// 定义三个月的结束日期:起始日期加3个月减1天
DateTime endDate = currentDate.AddMonths(3).AddDays(-1);
bandedGridControlEx.BandedView.BeginUpdate();
try
{
for (int i = 0; i < 93; i++)
{
// 以构建列时的命名规则 "Day_{i}" 查找对应的 GridBand
string bandTitle = $"Day_{i}";
GridBand gridBand = bandedGridControlEx.BandedView.Bands.Cast<GridBand>().FirstOrDefault(x => x.Name == bandTitle);
if (gridBand == null)
{
continue;
}
// 假定每个 GridBand 下只有一个子列
BandedGridColumn gridColumn = gridBand.Columns.Count > 0 ? gridBand.Columns[0] : null;
if (gridColumn == null)
{
continue;
}
// 当前列对应的日期 = 起始日期加 i 天
DateTime dateForColumn = currentDate.AddDays(i);
if (dateForColumn <= endDate)
{
gridBand.Visible = true;
gridColumn.Visible = true;
// 父列标题:上行为日期(MM-dd),下行为中文星期(完整格式)
string bandCaption = dateForColumn.ToString("MM-dd");
gridBand.Caption = bandCaption;
// 子列标题只显示中文星期数字,例如:如果是周三,则显示“3”对应的“三”
gridColumn.Caption = GetChineseWeekDayNumber(dateForColumn);
gridColumn.FieldName = bandCaption;
}
else
{
gridBand.Visible = false;
gridColumn.Visible = false;
}
}
}
finally
{
bandedGridControlEx.BandedView.EndUpdate();
}
}
/// <summary>
/// 构建带日期的数据源
/// </summary>
/// <param name="dataMain"></param>
/// <param name="dataDayPlan"></param>
/// <param name="startDate"></param>
/// <returns></returns>
private DataTable MergeMainDataWithDayPlan(DataTable dataMain, DataTable dataDayPlan, DateTime startDate)
{
DateTime endDate = startDate.AddMonths(3).AddDays(-1); // 计算结束日期
// **1. 预索引 dataDayPlan 数据(billdocument_id -> 该 key 相关的所有行)**
Dictionary<string, List<DataRow>> dayPlanMap = new Dictionary<string, List<DataRow>>();
foreach (DataRow row in dataDayPlan.Rows)
{
string billId = row["billdocument_id"].ToString();
if (!dayPlanMap.ContainsKey(billId))
{
dayPlanMap[billId] = new List<DataRow>();
}
dayPlanMap[billId].Add(row);
}
// **2. 预构建主数据的列**
for (DateTime dt = startDate; dt <= endDate; dt = dt.AddDays(1))
{
string colName = dt.ToString("MM-dd");
if (!dataMain.Columns.Contains(colName))
{
dataMain.Columns.Add(colName, typeof(decimal)); // 确保列存在
}
}
// **3. 预构建数据填充映射表**
Dictionary<string, Dictionary<string, decimal>> dataMap = new Dictionary<string, Dictionary<string, decimal>>();
foreach (DataRow row in dataMain.Rows)
{
string key = row["keyvalue"].ToString();
if (!dataMap.ContainsKey(key))
{
dataMap[key] = new Dictionary<string, decimal>();
}
// **查找 key 关联的时间数据**
if (dayPlanMap.ContainsKey(key))
{
foreach (DataRow dayRow in dayPlanMap[key])
{
if (dayRow["day"] != DBNull.Value)
{
DateTime dayValue = Convert.ToDateTime(dayRow["day"]);
string colName = dayValue.ToString("MM-dd");
if (dayValue >= startDate && dayValue <= endDate && dataMain.Columns.Contains(colName))
{
dataMap[key][colName] = Convert.ToDecimal(dayRow["amount"]);
}
}
}
}
}
// **4. 一次性填充 DataTable(避免逐行赋值带来的性能问题)**
foreach (DataRow row in dataMain.Rows)
{
string key = row["keyvalue"].ToString();
if (dataMap.ContainsKey(key))
{
foreach (var col in dataMap[key])
{
row[col.Key] = col.Value;
}
}
}
return dataMain;
}
/// <summary>
/// 日期对照
/// </summary>
/// <param name="date"></param>
/// <returns></returns>
private string GetChineseWeekDayNumber(DateTime date)
{
switch (date.DayOfWeek)
{
case DayOfWeek.Monday: return "一";
case DayOfWeek.Tuesday: return "二";
case DayOfWeek.Wednesday: return "三";
case DayOfWeek.Thursday: return "四";
case DayOfWeek.Friday: return "五";
case DayOfWeek.Saturday: return "六";
case DayOfWeek.Sunday: return "日";
default: return "";
}
}
/// <summary>
/// 初始化位置
/// </summary>
private void InitSpiltLocation()
{
try
{
string splitLeftWidth = IniHelper.Read(string.Format("ProductSched_SplitLeft_{0}", DataModel.TopSysModel.ModuleCode));
if (!string.IsNullOrEmpty(splitLeftWidth))
{
splitLeftControl.SplitterPosition = Convert.ToInt32(splitLeftWidth);
}
string splitMainWidth = IniHelper.Read(string.Format("ProductSched_SplitMain_{0}", DataModel.TopSysModel.ModuleCode));
if (!string.IsNullOrEmpty(splitMainWidth))
{
splitMainControl.SplitterPosition = Convert.To
@@ -41,9 +41,14 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files (x86)\DevExpress 15.2\Components\Bin\Framework\DevExpress.XtraEditors.v15.2.dll</HintPath>
</Reference>
<Reference Include="DevExpress.XtraGrid.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="Lskj.Core, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Debug\Lskj.Core.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.1.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\引用DLL\Newtonsoft.Json.dll</HintPath>
<HintPath>..\..\引用DLL\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -57,12 +62,16 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FrmMain.cs" />
<Compile Include="FrmMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmMain.Designer.cs">
<DependentUpon>FrmMain.cs</DependentUpon>
</Compile>
<Compile Include="DllBaseClass.cs" />
<Compile Include="FrmProductSched.cs" />
<Compile Include="FrmProductSched.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="FrmProductSched.Designer.cs">
<DependentUpon>FrmProductSched.cs</DependentUpon>
</Compile>
@@ -95,23 +104,27 @@
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Lskj.Business\Lskj.Business.csproj">
<ProjectReference Include="..\Lskj.Business\Lskj.Business.csproj">
<Project>{7eafccc2-a18f-49e9-85c6-a984966cfd01}</Project>
<Name>Lskj.Business</Name>
</ProjectReference>
<ProjectReference Include="..\..\Lskj.Control\Lskj.Control.csproj">
<ProjectReference Include="..\Lskj.Control\Lskj.Control.csproj">
<Project>{447cdc40-659f-4cca-9ed6-8e818b4cf8bf}</Project>
<Name>Lskj.Control</Name>
</ProjectReference>
<ProjectReference Include="..\..\Lskj.Data\Lskj.Data.csproj">
<ProjectReference Include="..\Lskj.Data\Lskj.Data.csproj">
<Project>{308b9b18-9be2-495c-9c64-eed81d567813}</Project>
<Name>Lskj.Data</Name>
</ProjectReference>
<ProjectReference Include="..\..\Lskj.Model\Lskj.Model.csproj">
<ProjectReference Include="..\Lskj.Model\Lskj.Model.csproj">
<Project>{52bc40e0-c0c6-4f78-996b-cae028d209ca}</Project>
<Name>Lskj.Model</Name>
</ProjectReference>
<ProjectReference Include="..\..\Lskj.Util\Lskj.Util.csproj">
<ProjectReference Include="..\Lskj.ProductDynamic\Lskj.ProductDynamic.csproj">
<Project>{DB8D4194-816A-4EA3-86C2-90BA02134CF9}</Project>
<Name>Lskj.ProductDynamic</Name>
</ProjectReference>
<ProjectReference Include="..\Lskj.Util\Lskj.Util.csproj">
<Project>{a51bf642-6543-4de3-8948-83f558b72bd4}</Project>
<Name>Lskj.Util</Name>
</ProjectReference>
Binary file not shown.