using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data; using ICSharpCode.Core; using Mesnac.Controls.Base; using Mesnac.Action.Base; using Mesnac.Codd.Session; using Mesnac.Action.ChemicalWeighing.Entity; using System.Configuration; namespace Mesnac.Action.ChemicalWeighing.Product.PptPlan { /// /// 添加计划业务 /// public class InsertAction : ChemicalWeighingAction, IAction { #region 事件定义 /// /// 添加计划事件定义 /// public static event EventHandler OnInsertPlan; #endregion #region 字段定义 private RuntimeParameter _runtime; //private DbMCControl _planDateControl = null; //计划日期 //private DbMCControl _pptShiftControl = null; //班次 private DbMCControl _clientGridControl = null; //网格计划控件 #endregion #region IAction接口实现 public void Run(RuntimeParameter runtime) { base.RunIni(runtime); this._runtime = runtime; ICSharpCode.Core.LoggingService.Debug("当班计划—添加计划业务..."); DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "RT_plan").FirstOrDefault(); //获取本机台计划网格控件 this._clientGridControl = clientGridControl; DateTime planDate = DateTime.Now; //int shiftID = Product.ProductHelper.shiftIDAtuoRefresh(); //if (shiftID == 0) //{ // string msg1 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Product_PptPlan_InsertAction_msg1")); //自动刷新班次号未生效! // MessageBox.Show(msg1, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); // this._runtime.IsReturn = true; // return; //} this.DoWork(planDate, 0); } #endregion #region 方法定义 /// /// 添加计划 /// protected void DoWork(DateTime planDate, int shiftID) { this._runtime.BaseControl.MCEnabled = false; try { FrmPlan frmPlan = new FrmPlan(0); frmPlan.ShowDialog(this._runtime.BaseControl.MCRoot as Control); if (frmPlan.DialogResult == DialogResult.OK) { SimplePmtRecipe recipe = frmPlan.Recipe; int planNum = frmPlan.PlanNum; //在本地数据库中添加计划 string equipCode = string.Empty; if (String.IsNullOrEmpty(equipCode)) { equipCode = ConfigurationManager.AppSettings["EquipCode"]; } string planID = PlanHelper.AddPlan(equipCode, planDate, shiftID,recipe.ID, planNum, "", "", frmPlan.PumpName, frmPlan.PumpBarCode, frmPlan.Weighbridge, frmPlan.Batch, frmPlan.ProductNames); #region 触发事件 if (OnInsertPlan != null) { OnInsertPlan(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty); } #endregion #region 记录日志 string logContent = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Product_PptPlan_InsertAction_logContent_10")); //计划编号:{0},添加完毕! logContent = String.Format(logContent, planID); #endregion } frmPlan.Dispose(); } catch (Exception ex) { ICSharpCode.Core.LoggingService.Error("添加计划异常:" + ex.Message, ex); #region 记录操作日志 base.DBLog(ex.Message); #endregion MessageBox.Show(ex.Message, Mesnac.Basic.LanguageHelper.WarnCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); } this._runtime.BaseControl.MCEnabled = true; } #endregion } }