天大药业
This commit is contained in:
@@ -17,6 +17,7 @@ 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
|
||||
{
|
||||
@@ -28,61 +29,63 @@ namespace MonthlyProductionSchedule
|
||||
base.ButtonClick(e);
|
||||
if (e.Key.EqualsIgnoreCase("FSaveDataButton"))
|
||||
{
|
||||
var reportModel = this.Model as SysReportModel; //简单帐表对应的Model
|
||||
|
||||
try
|
||||
this.View.ShowMessage("生成数据会覆盖当月历史数据,是否继续?", MessageBoxOptions.OKCancel, new Action<MessageBoxResult>(result =>
|
||||
{
|
||||
var year = reportModel.DataObject["DataHoldYear"].Long2Int();
|
||||
var month = reportModel.DataObject["DataHoldMonth"].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));
|
||||
if (result == MessageBoxResult.OK)
|
||||
{
|
||||
var reportModel = this.SysReportModel; //简单帐表对应的Model
|
||||
|
||||
var res = DBUtils.ExecuteStoreProcedure(this.Context, "PROC_SAVE_PLANPLMRPT_DATA", para);
|
||||
//var res = DBUtils.ExecuteStoreProcedure(this.Context, "PROC_PPL_SaveCurrentData", para);
|
||||
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));
|
||||
|
||||
reportModel.DataObject["DataBDStatu"] = 1;
|
||||
var res = DBUtils.ExecuteStoreProcedure(this.Context, "PROC_SAVE_PLANPLMRPT_DATA", para);
|
||||
|
||||
this.View.Refresh();
|
||||
//this.View.InvokeFormOperation(FormOperationEnum.Refresh);
|
||||
reportModel.DataObject["DataBDStatu"] = 1;
|
||||
|
||||
//var btn = this.SysReportView.GetControl("FSaveDataButton");
|
||||
//btn.Enabled = false;
|
||||
|
||||
//确保旧的临时表删除
|
||||
// var deleteTmpSql = $@"
|
||||
//IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[{tableName}]') AND type IN ('U'))
|
||||
// DROP TABLE [dbo].[{tableName}]
|
||||
//GO
|
||||
//";
|
||||
// DBUtils.Execute(this.Context, $"/*dialect*/{deleteTmpSql}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.View.ShowErrMessage(ex.Message);
|
||||
}
|
||||
|
||||
//this.View.ShowMessage("保存数据会覆盖历史数据,是否继续?", MessageBoxOptions.OKCancel, new Action<MessageBoxResult>(result =>
|
||||
//{
|
||||
// if (result == MessageBoxResult.OK)
|
||||
// {
|
||||
|
||||
// }
|
||||
//}));
|
||||
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;
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user