SVN-Revision: r435
This commit is contained in:
tdx
2025-04-02 09:31:39 +00:00
parent 2b092cb23f
commit c06b8bf9fd
2 changed files with 29 additions and 42 deletions
+28 -42
View File
@@ -4,8 +4,10 @@ using DevExpress.XtraEditors.Controls;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.BandedGrid;
using DevExpress.XtraGrid.Views.BandedGrid.ViewInfo;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using DevExpress.XtraTab;
using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Columns;
@@ -56,6 +58,8 @@ namespace Lskj.ProductiSched
InitControlEvents();
SetControlData();
}
/// <summary>
/// 获取数据
/// </summary>
@@ -184,6 +188,7 @@ namespace Lskj.ProductiSched
bandGcTop.SetEditColumns(DataModel.TopGridColumns, GridCustomColumnStruct.BaseMainGridView + DataModel.TopModuleModel.FormKey);
bandGcTop.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(DataModel.TopModuleModel.ModeCode), DataModel.TopSysModel);
bandGcTop.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(DataModel.TopModuleModel.ModeCode));
bandGcTop.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(DataModel.TopModuleModel.ModeCode));
treebandGcTop.Visible = false;
}
if (TreeMultiHeader)
@@ -235,12 +240,15 @@ namespace Lskj.ProductiSched
gcRight.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(DataModel.RightModuleModel.ModeCode));
}
}
/// <summary>
/// 绑定控件事件
/// </summary>
public void InitControlEvents()
{
splitLeftControl.SplitterPositionChanged += OnBandedViewColumnWidthChanged;
splitLeftControl.SplitterPositionChanged += OnSplitContainerPositionChanged;
splitMainControl.SplitterPositionChanged += OnSplitContainerPositionChanged;
DataModel.TopSearchObj.OnDataSourceBindCallBack += OnDataSourceBindCallBack;
DataModel.TopSearchObj.OnSearchBeforeCallBack += OnSearchBeforeCallBack; ;
@@ -1237,7 +1245,7 @@ namespace Lskj.ProductiSched
{
if (bandedGridControlEx == bandGcTop)
{
bandedGridControlEx.BandedView.OptionsView.ShowFooter = true;
bandedGridControlEx.BandedView.OptionsView.ShowFooter = false;
}
foreach (GridBand gridBand in bandedGridControlEx.BandedView.Bands)
{
@@ -1331,7 +1339,7 @@ namespace Lskj.ProductiSched
{
if (bandedGridControlEx == treebandGcTop)
{
bandedGridControlEx.TreeListObj.OptionsView.ShowSummaryFooter = true;
bandedGridControlEx.TreeListObj.OptionsView.ShowSummaryFooter = false;
}
foreach (TreeListBand fixedBand in bandedGridControlEx.TreeListObj.Bands)
@@ -1557,9 +1565,8 @@ namespace Lskj.ProductiSched
// 设置周列表头:例如 "03-01至03-07"
weekBand.Caption = $"{weekStart:MM-dd}至{weekEnd:MM-dd}";
weekColumn.FieldName = weekStart.ToString("yyyy-MM-dd");
// 设置列的内容为“第几周”
weekColumn.Caption = $"第{GetWeekOfYear(weekStart)}周";
// 使用修改后的方法设置 Caption
weekColumn.Caption = $"{weekEnd.Month}月第{GetWeekOfMonth(weekEnd)}周";
// 设置列的宽度
weekColumn.Width = 140;
// 设置该列的Tag为周的开始日期(便于后续操作)
@@ -1628,7 +1635,8 @@ namespace Lskj.ProductiSched
weekBand.Caption = $"{weekStart:MM-dd}至{weekEnd:MM-dd}";
weekColumn.FieldName = weekStart.ToString("yyyy-MM-dd");
weekColumn.Caption = $"第{GetWeekOfYear(weekStart)}周";
// 使用修改后的方法设置 Caption
weekColumn.Caption = $"{weekEnd.Month}月第{GetWeekOfMonth(weekEnd)}周";
weekColumn.Width = 140;
// 新优化方式(使用字典存储)
DataModel.columnDateMapping[weekColumn] = weekStart;
@@ -1674,15 +1682,23 @@ namespace Lskj.ProductiSched
/// <summary>
/// 计算某个日期属于这一年的第几周
/// 计算某个日期在该月的第几周
/// </summary>
/// <param name="date">日期</param>
/// <returns>周数</returns>
private int GetWeekOfYear(DateTime date)
/// <returns>该月的周数</returns>
private int GetWeekOfMonth(DateTime date)
{
var cultureInfo = new CultureInfo("zh-CN");
var calendar = cultureInfo.Calendar;
return calendar.GetWeekOfYear(date, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
// 月份的第一天
DateTime firstDayOfMonth = new DateTime(date.Year, date.Month, 1);
// 月份第一天是一年中的第几周
int firstWeekOfYear = calendar.GetWeekOfYear(firstDayOfMonth, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
// 当前日期是一年中的第几周
int currentWeekOfYear = calendar.GetWeekOfYear(date, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
// 计算结果为当前周减去当月第一周,再加1(第一周为第1周)
return currentWeekOfYear - firstWeekOfYear + 1;
}
@@ -2351,34 +2367,4 @@ namespace Lskj.ProductiSched
// 对每个动态日期列,从 dtPlan 中查找 billdocument_id 在 keyValues 内,
// 且 ShowDay 等于当前列名的记录,将 amount 累加后再乘以系数
foreach (string dateCol in dateColumns)
{
decimal sumAmount = planRows
.Where(pr => keyValues.Contains(pr.BillId) && pr.ShowDay == dateCol)
.Sum(pr => pr.Amount);
// 乘以系数得到实际值
newRow[dateCol] = sumAmount * coefficient;
}
dtC.Rows.Add(newRow);
}
return dtC;
}
catch (Exception)
{
return default;
}
}
/// <summary>
/// 纠正输入异常
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnInvalidValueException(object sender, InvalidValueExceptionEventArgs e)
{
if (e.Value.Equals(""))
{
e.ExceptionMode = ExceptionMode.Ignore;
}
}
}
}
foreach (stri
@@ -41,6 +41,7 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files (x86)\DevExpress 15.2\Components\Bin\Framework\DevExpress.XtraEditors.v15.2.dll</HintPath>
</Reference>
<Reference Include="DevExpress.XtraPrinting.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.XtraGrid.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.XtraTreeList.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<Reference Include="Lskj.Core, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">