using ICSharpCode.Core; using Mesnac.Action.Base; using Mesnac.Action.ChemicalWeighing.Product.PptPlan.entity; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Mesnac.Action.ChemicalWeighing.Product.PptPlan { public class ModifyPlanInfoAction : ChemicalWeighingAction, IAction { private RuntimeParameter _runtime; private DbMCControl _clientGridControl = null; //网格计划控件 private string selectedPlanId = null;//选中计划号 private string selectedPlanState = null; /// /// 修改计划数事件定义 /// public static event EventHandler OnModifyPlanInfo; public void Run(RuntimeParameter runtime) { base.RunIni(runtime); //必须要调用的 this._runtime = runtime; ICSharpCode.Core.LoggingService.Debug("生产计划-修改计划信息..."); try { //获取界面控件 DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Base_PlanInfo").FirstOrDefault(); if (clientGridControl == null) { ICSharpCode.Core.LoggingService.Error("{生产计划-修改计划信息} 缺少计划列表网格控件..."); return; } this._runtime = runtime; this._clientGridControl = clientGridControl; DataGridView clientGridView = this._clientGridControl.BaseControl as DataGridView; if (clientGridView.SelectedRows.Count != 1) { string msg1_1 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Product_PptPlan_ModifyPlanNumAction_msg1_1")); //请选择一条要修改计划数的计划! MessageBox.Show(msg1_1, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); this._runtime.IsReturn = true; return; } //获取选中的计划号 this.selectedPlanId = clientGridView.SelectedRows[0].Cells["plan_Id"].Value as string; this.selectedPlanState = clientGridView.SelectedRows[0].Cells["plan_state"].Value as string; //判断选中计划状态是否合法 //if (selectedPlanState == "0") //{ // string msg7 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Product_PptPlan_ModifyPlanNumAction_msg1_2")); //当前计划已终止,不能执行此操作! // MessageBox.Show(msg7, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); // return; //} //if (selectedPlanState == "1") //{ // string msg7 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Product_PptPlan_ModifyPlanNumAction_msg1_3")); //当前计划已完成,不能执行此操作! // MessageBox.Show(msg7, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); // return; //} //根据计划号获取计划信息 Base_PlanInfo planInfo = PlanHelper.getPlanInfoByPlanId(selectedPlanId); if (planInfo == null) { ICSharpCode.Core.LoggingService.Warn("生产管理-修改计划数-获取当前计划数据失败..."); return; } FrmPlan frmModifyPlanNum = new FrmPlan(Entity.ActionType.Modify, planInfo); //FrmModifyPlanNum frmModifyPlanNum = new FrmModifyPlanNum(); DialogResult result = frmModifyPlanNum.ShowDialog(); if (result == DialogResult.OK) { Base_PlanInfo basePlanInfo = frmModifyPlanNum.PlanInfo; frmModifyPlanNum.Dispose(); string msg14 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Product_PptPlan_ModifyPlanNumAction_msg1_6")); msg14 = String.Format(msg14, basePlanInfo.plan_Id); if (MessageBox.Show(msg14, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { #region 4.3 记录操作日志 string logContent = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Product_PptPlan_ModifyPlanNumAction_logContent")); //base.DBLog(logContent); #endregion //修改数据库 PlanHelper.UpdateBasePlanInfo(basePlanInfo); #region 4.5 触发刷新计划事件 if (OnModifyPlanInfo != null) { OnModifyPlanInfo(runtime, System.EventArgs.Empty); } #endregion } } else { frmModifyPlanNum.Dispose(); } } catch (Exception ex) { } } } }