Files
GateDge2023_ljy/MonthlyProductionSchedule/BarItemClickEventPlugIn.cs
2024-01-02 10:44:59 +08:00

92 lines
4.0 KiB
C#

using Kingdee.BOS.App.Data;
using Kingdee.BOS;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.List.PlugIn;
using Kingdee.BOS.Core.Report.PlugIn;
using Kingdee.BOS.Model.Report;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;
using System.Security.Cryptography;
using Kingdee.BOS.Core.Report;
using System.Threading.Tasks;
using Kingdee.BOS.Core.Metadata.Util;
namespace MonthlyProductionSchedule
{
[Description("生产计划表-点击事件"), HotUpdate]
public class BarItemClickEventPlugIn : AbstractSysReportPlugIn
{
public override void ButtonClick(ButtonClickEventArgs e)
{
base.ButtonClick(e);
if (e.Key.EqualsIgnoreCase("FSaveDataButton"))
{
this.View.ShowMessage("生成数据会覆盖当月历史数据,是否继续?", MessageBoxOptions.OKCancel, new Action<MessageBoxResult>(result =>
{
if (result == MessageBoxResult.OK)
{
var reportModel = this.SysReportModel; //简单帐表对应的Model
try
{
var rptTitles = reportModel.ReportTitles.ToList();
var year = rptTitles.FirstOrDefault(x => x.TitleKey == "FDataHoldYear").TitleValue.Long2Int();
var month = rptTitles.FirstOrDefault(x => x.TitleKey == "FDataHoldMonth").TitleValue.Long2Int();
var date = new DateTime(year, month, 1);
var startDate = date.ToString("yyyy-MM-dd");
var endDate = date.AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd");
var tableName = this.SysReportView.Model.DataSource.TableName;
//para.Add(new SqlParam("@tableName", KDDbType.String, tableName));
//para.Add(new SqlParam("@FRECORDDATE", KDDbType.DateTime, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
var para = new List<SqlParam>();
para.Add(new SqlParam("@STARTDATE", KDDbType.Date, startDate));
para.Add(new SqlParam("@ENDDATE", KDDbType.Date, endDate));
para.Add(new SqlParam("@YEAR", KDDbType.Int64, year));
para.Add(new SqlParam("@MONTH", KDDbType.Int64, month));
para.Add(new SqlParam("@DAY", KDDbType.Int64, 20));
para.Add(new SqlParam("@LCID", KDDbType.Int64, this.Context.UserLocale.LCID));
var res = DBUtils.ExecuteStoreProcedure(this.Context, "PROC_SAVE_PLANPLMRPT_DATA", para);
reportModel.DataObject["DataBDStatu"] = 1;
this.View.Refresh();
}
catch (Exception ex)
{
if (ex.Message.Contains("不能将值 NULL 插入列"))
{
this.View.ShowErrMessage("库存记录信息未记录!");
}
else
{
this.View.ShowErrMessage(ex.Message);
}
}
}
}));
return;
}
}
//public override void AfterBindData(EventArgs e)
//{
// base.AfterBindData(e);
// var dataStatus = this.SysReportModel.ReportTitles.FirstOrDefault(x => x.TitleKey == "FDataBDStatu").TitleValue.Long2Int();
// this.SysReportView.GetControl("FSaveDataButton").Enabled = dataStatus != 1;
//}
}
}