SVN r375
SVN-Revision: r375
This commit is contained in:
@@ -30,6 +30,7 @@ namespace Lskj.ProductiSched
|
|||||||
{
|
{
|
||||||
public partial class FrmProductSched : UserControl
|
public partial class FrmProductSched : UserControl
|
||||||
{
|
{
|
||||||
|
|
||||||
public ProductDataModel DataModel;
|
public ProductDataModel DataModel;
|
||||||
public FrmProductSched()
|
public FrmProductSched()
|
||||||
{
|
{
|
||||||
@@ -183,8 +184,38 @@ namespace Lskj.ProductiSched
|
|||||||
bandGcTop.BandedView.CustomDrawFooterCell += OnCustomDrawFooterCell;
|
bandGcTop.BandedView.CustomDrawFooterCell += OnCustomDrawFooterCell;
|
||||||
bandGcTop.BandedView.CustomDrawColumnHeader += OnCustomDrawColumnHeader;
|
bandGcTop.BandedView.CustomDrawColumnHeader += OnCustomDrawColumnHeader;
|
||||||
bandGcBottom.BandedView.CustomDrawColumnHeader += OnCustomDrawColumnHeader;
|
bandGcBottom.BandedView.CustomDrawColumnHeader += OnCustomDrawColumnHeader;
|
||||||
|
bandGcTop.BandedView.ShowingEditor += OnshowingEditor;
|
||||||
btnSave.Click += OnBtnSaveClick;
|
btnSave.Click += OnBtnSaveClick;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 判断单元格是否可以编辑
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
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<string> showDays = DataModel.nonEditableCells[billDocumentId];
|
||||||
|
|
||||||
|
// 如果列名(日期)在 showday_list 里,则禁用编辑
|
||||||
|
if (showDays.Contains(columnName))
|
||||||
|
{
|
||||||
|
e.Cancel = true; // 取消编辑,单元格变灰
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 保存按钮点击时
|
/// 保存按钮点击时
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -692,6 +723,28 @@ namespace Lskj.ProductiSched
|
|||||||
}
|
}
|
||||||
OnBandedViewRowCellClick(bandGcTop.BandedView, null);
|
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<string> daysSet = new HashSet<string>(showDayList.Split(','));
|
||||||
|
DataModel.nonEditableCells[billDocumentId] = daysSet;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取数据源缓存
|
/// 获取数据源缓存
|
||||||
@@ -1074,7 +1127,6 @@ namespace Lskj.ProductiSched
|
|||||||
if (dayValue >= startDate && dayValue <= endDate && dataMain.Columns.Contains(colName))
|
if (dayValue >= startDate && dayValue <= endDate && dataMain.Columns.Contains(colName))
|
||||||
{
|
{
|
||||||
decimal.TryParse(dayRow["amount"] + "", out decimal amountValue);
|
decimal.TryParse(dayRow["amount"] + "", out decimal amountValue);
|
||||||
dataMap[key][colName] = amountValue;
|
|
||||||
|
|
||||||
// 如果日期已存在,则累加金额;否则直接赋值
|
// 如果日期已存在,则累加金额;否则直接赋值
|
||||||
if (dataMap[key].ContainsKey(colName))
|
if (dataMap[key].ContainsKey(colName))
|
||||||
@@ -1226,8 +1278,6 @@ namespace Lskj.ProductiSched
|
|||||||
if (dayValue >= startDate && dayValue <= endDate && focusedRow.Table.Columns.Contains(colName))
|
if (dayValue >= startDate && dayValue <= endDate && focusedRow.Table.Columns.Contains(colName))
|
||||||
{
|
{
|
||||||
decimal.TryParse(dayRow["amount"] + "", out decimal amountValue);
|
decimal.TryParse(dayRow["amount"] + "", out decimal amountValue);
|
||||||
dataMap[key][colName] = amountValue;
|
|
||||||
|
|
||||||
// 如果日期已存在,则累加金额;否则直接赋值
|
// 如果日期已存在,则累加金额;否则直接赋值
|
||||||
if (dataMap[key].ContainsKey(colName))
|
if (dataMap[key].ContainsKey(colName))
|
||||||
{
|
{
|
||||||
@@ -1446,4 +1496,28 @@ namespace Lskj.ProductiSched
|
|||||||
decimal coefficient = kvp.Value.Coefficient;
|
decimal coefficient = kvp.Value.Coefficient;
|
||||||
List<string> keyValues = kvp.Value.KeyValues;
|
List<string> keyValues = kvp.Value.KeyValues;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,3 +2,10 @@
|
|||||||
using Lskj.Model;
|
using Lskj.Model;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Lskj.ProductiSched
|
||||||
|
{
|
||||||
|
public class P
|
||||||
Reference in New Issue
Block a user