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(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; var para = new List(); 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 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()); var res = DBUtils.ExecuteStoreProcedure(this.Context, "PROC_SAVE_PLANPLMRPT_DATA", para); reportModel.DataObject["DataBDStatu"] = 1; this.View.Refresh(); } catch (Exception ex) { 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; //} } }