diff --git a/插件库/Lskj.ProductSched/FrmProductSched.cs b/插件库/Lskj.ProductSched/FrmProductSched.cs
index 982ed54..f439948 100644
--- a/插件库/Lskj.ProductSched/FrmProductSched.cs
+++ b/插件库/Lskj.ProductSched/FrmProductSched.cs
@@ -30,6 +30,7 @@ namespace Lskj.ProductiSched
{
public partial class FrmProductSched : UserControl
{
+
public ProductDataModel DataModel;
public FrmProductSched()
{
@@ -183,8 +184,38 @@ namespace Lskj.ProductiSched
bandGcTop.BandedView.CustomDrawFooterCell += OnCustomDrawFooterCell;
bandGcTop.BandedView.CustomDrawColumnHeader += OnCustomDrawColumnHeader;
bandGcBottom.BandedView.CustomDrawColumnHeader += OnCustomDrawColumnHeader;
+ bandGcTop.BandedView.ShowingEditor += OnshowingEditor;
btnSave.Click += OnBtnSaveClick;
}
+ ///
+ /// 判断单元格是否可以编辑
+ ///
+ ///
+ ///
+ private void OnshowingEditor(object sender, CancelEventArgs e)
+ {
+ BandedGridView view = sender as BandedGridView;
+ if (view == null) return;
+
+ string billDocumentId = view.GetRowCellValue(view.FocusedRowHandle, DataModel.TopModuleModel.ParmaryKey) +"";
+ if (view.FocusedColumn.Tag is DateTime dateTimeTag)
+ {
+ string columnName = dateTimeTag.ToString("yyyy-MM-dd");
+ // 检查该行的 billdocument_id 是否在字典中
+ if (DataModel.nonEditableCells.ContainsKey(billDocumentId))
+ {
+ HashSet showDays = DataModel.nonEditableCells[billDocumentId];
+
+ // 如果列名(日期)在 showday_list 里,则禁用编辑
+ if (showDays.Contains(columnName))
+ {
+ e.Cancel = true; // 取消编辑,单元格变灰
+ }
+ }
+
+ }
+ }
+
///
/// 保存按钮点击时
///
@@ -692,6 +723,28 @@ namespace Lskj.ProductiSched
}
OnBandedViewRowCellClick(bandGcTop.BandedView, null);
}
+ string query = @"
+ SELECT
+ billdocument_id,
+ STUFF((SELECT ',' + CAST(showday AS VARCHAR(MAX))
+ FROM mps_dayplantab AS sub WITH(NOLOCK)
+ WHERE sub.billdocument_id = main.billdocument_id
+ AND sub.update_tig = 1
+ FOR XML PATH('')), 1, 1, '') AS showday_list
+ FROM mps_dayplantab AS main WITH(NOLOCK)
+ GROUP BY billdocument_id;";
+ DataTable dt = BaseImpl.GetDataTableResult(query);
+ foreach (DataRow row in dt.Rows)
+ {
+ string billDocumentId = row["billdocument_id"]+"";
+ string showDayList = row["showday_list"].ToString();
+
+ if (!string.IsNullOrEmpty(showDayList))
+ {
+ HashSet daysSet = new HashSet(showDayList.Split(','));
+ DataModel.nonEditableCells[billDocumentId] = daysSet;
+ }
+ }
}
///
/// 获取数据源缓存
@@ -951,7 +1004,7 @@ namespace Lskj.ProductiSched
{
// 原有的日处理逻辑(保持原代码不变)
DateTime endDate = currentDate.AddMonths(3).AddDays(-1);
-
+
// 处理每天的列(现有逻辑)
for (int i = 0; i < 93; i++)
{
@@ -985,7 +1038,7 @@ namespace Lskj.ProductiSched
if (dateForColumn.Date < DateTime.Now.Date)
{
gridColumn.OptionsColumn.AllowEdit = false;
- }
+ }
else
{
gridColumn.OptionsColumn.AllowEdit = true;
@@ -1074,7 +1127,6 @@ namespace Lskj.ProductiSched
if (dayValue >= startDate && dayValue <= endDate && dataMain.Columns.Contains(colName))
{
decimal.TryParse(dayRow["amount"] + "", out decimal amountValue);
- dataMap[key][colName] = amountValue;
// 如果日期已存在,则累加金额;否则直接赋值
if (dataMap[key].ContainsKey(colName))
@@ -1226,8 +1278,6 @@ namespace Lskj.ProductiSched
if (dayValue >= startDate && dayValue <= endDate && focusedRow.Table.Columns.Contains(colName))
{
decimal.TryParse(dayRow["amount"] + "", out decimal amountValue);
- dataMap[key][colName] = amountValue;
-
// 如果日期已存在,则累加金额;否则直接赋值
if (dataMap[key].ContainsKey(colName))
{
@@ -1446,4 +1496,28 @@ namespace Lskj.ProductiSched
decimal coefficient = kvp.Value.Coefficient;
List keyValues = kvp.Value.KeyValues;
-
\ No newline at end of file
+ DataRow newRow = dtC.NewRow();
+ newRow["产地"] = origin;
+ newRow["总产能"] = totalCapacity;
+
+ // 对每个动态日期列,从 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;
+ }
+ }
+ }
+}
diff --git a/插件库/Lskj.ProductSched/ProductDataModel.cs b/插件库/Lskj.ProductSched/ProductDataModel.cs
index 2ffa334..06614ad 100644
--- a/插件库/Lskj.ProductSched/ProductDataModel.cs
+++ b/插件库/Lskj.ProductSched/ProductDataModel.cs
@@ -1,4 +1,11 @@
-using Lskj.Control.Model;
-using Lskj.Model;
-using System;
-using System.Collections.Generic;
\ No newline at end of file
+using Lskj.Control.Model;
+using Lskj.Model;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Text;
+
+namespace Lskj.ProductiSched
+{
+ public class P
\ No newline at end of file