Files
GateDge2023_ljy/04.天大药业(珠海)有限公司/MonthlyProductionSchedule/BarItemClickEventPlugIn.cs

95 lines
4.2 KiB
C#
Raw Normal View History

2023-12-17 11:37:43 +08:00
using Kingdee.BOS.App.Data;
using Kingdee.BOS;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
2023-12-15 09:08:09 +08:00
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.List.PlugIn;
using Kingdee.BOS.Core.Report.PlugIn;
2023-12-17 11:37:43 +08:00
using Kingdee.BOS.Model.Report;
using Kingdee.BOS.Orm.DataEntity;
2023-12-15 09:08:09 +08:00
using Kingdee.BOS.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
2023-12-17 11:37:43 +08:00
using System.Data;
2023-12-15 09:08:09 +08:00
using System.Linq;
2023-12-17 11:37:43 +08:00
using System.Runtime.InteropServices.ComTypes;
using System.Security.Cryptography;
2023-12-29 08:46:01 +08:00
using Kingdee.BOS.Core.Report;
using System.Threading.Tasks;
2024-01-02 10:44:59 +08:00
using Kingdee.BOS.Core.Metadata.Util;
2023-12-15 09:08:09 +08:00
namespace MonthlyProductionSchedule
{
[Description("生产计划表-点击事件"), HotUpdate]
public class BarItemClickEventPlugIn : AbstractSysReportPlugIn
{
public override void ButtonClick(ButtonClickEventArgs e)
{
2023-12-29 08:46:01 +08:00
base.ButtonClick(e);
2023-12-15 09:08:09 +08:00
if (e.Key.EqualsIgnoreCase("FSaveDataButton"))
{
2024-01-08 10:58:24 +08:00
this.View.ShowMessage("生成数据会覆盖该月历史数据,是否继续?", MessageBoxOptions.OKCancel, new Action<MessageBoxResult>(result =>
2023-12-17 11:37:43 +08:00
{
2024-01-02 10:44:59 +08:00
if (result == MessageBoxResult.OK)
{
var reportModel = this.SysReportModel; //简单帐表对应的Model
2023-12-17 11:37:43 +08:00
2024-01-02 10:44:59 +08:00
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;
2024-01-08 10:58:24 +08:00
2024-01-02 10:44:59 +08:00
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));
2024-01-08 10:58:24 +08:00
//var scheduleId = "65967bf69b80ca";//天大正式
//scheduleId = "658e1974b04f4f"//天大测试
//scheduleId = "657BF589F52174";//本地
var sql = $@" EXEC PROC_SAVE_PLANPLMRPT_BEFORE_CHECK '{startDate}' ,'{endDate}' ,{year} ,{month} ";
var dataSet = DBUtils.ExecuteDynamicObject(this.Context, $"/*dialect*/{sql}");
if (dataSet.IsEmpty())
throw new Exception("检测结果未知,请联系管理员!");
if (dataSet[0]["code"].Long2Int() == -1)
throw new Exception(dataSet[0]["msg"].ToString());
2023-12-29 08:46:01 +08:00
2024-01-02 10:44:59 +08:00
var res = DBUtils.ExecuteStoreProcedure(this.Context, "PROC_SAVE_PLANPLMRPT_DATA", para);
2023-12-29 08:46:01 +08:00
2024-01-02 10:44:59 +08:00
reportModel.DataObject["DataBDStatu"] = 1;
2023-12-29 08:46:01 +08:00
2024-01-02 10:44:59 +08:00
this.View.Refresh();
}
catch (Exception ex)
{
2024-01-08 10:58:24 +08:00
this.View.ShowErrMessage(ex.Message);
2024-01-02 10:44:59 +08:00
}
}
}));
2023-12-15 09:08:09 +08:00
return;
}
}
2023-12-29 08:46:01 +08:00
2024-01-02 10:44:59 +08:00
//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;
//}
2023-12-15 09:08:09 +08:00
}
}