using ICSharpCode.Core; using Mesnac.Action.Base; using Mesnac.Action.ChemicalWeighing.Entity; using Mesnac.Action.ChemicalWeighing.Entity.Barrel; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Mesnac.Action.ChemicalWeighing.Barrel { class SplitBindAction : ChemicalWeighingAction, IAction { #region 字段定义 private RuntimeParameter _runtime; private DbMCControl _clientGridControl = null; //控件 #endregion #region 事件定义 /// /// 修改用户信息事件定义 /// public static event EventHandler OnModifySplit; #endregion public void Run(RuntimeParameter runtime) { base.RunIni(runtime); //必须要调用 this._runtime = runtime; #region 获取界面控件 DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Hw_Barrel").FirstOrDefault(); if (clientGridControl == null) { ICSharpCode.Core.LoggingService.Error("缺少料桶信息列表控件..."); return; } this._runtime = runtime; this._clientGridControl = clientGridControl; DataGridView clientGridView = this._clientGridControl.BaseControl as DataGridView; #endregion //验证是否选中某料桶 if (clientGridView.SelectedRows.Count != 1) { string msg1 = "请选择一项要修改的料桶!"; MessageBox.Show(msg1, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); this._runtime.IsReturn = true; return; } //封装选中行对应的物料对象 Hw_Barrel barrel = new Hw_Barrel { ID = (int)clientGridView.SelectedRows[0].Cells["ID"].Value, BarrelID = Guid.NewGuid().ToString(), BarrelName = clientGridView.SelectedRows[0].Cells["BarrelName"].Value as string, BarCode = clientGridView.SelectedRows[0].Cells["BarCode"].Value as string, IsEnable = clientGridView.SelectedRows[0].Cells["IsEnable"].Value as string }; int ID = (int)clientGridView.SelectedRows[0].Cells["ID"].Value; string name = clientGridView.SelectedRows[0].Cells["BarrelName"].Value as string; string msg2 = "确认解绑{0}关联的配方信息?"; msg2 = String.Format(msg2, name); if (MessageBox.Show(msg2, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //更新数据库中的物料信息 BarrelHelper.SplitMaterial(ID); #region 触发刷新物料列表事件 if (OnModifySplit != null) { OnModifySplit(runtime, System.EventArgs.Empty); } #endregion } #region 执行修改桶信息 // FrmBarrel frmBarrel = new FrmBarrel(ActionType.Modify, barrel); // DialogResult result = frmBarrel.ShowDialog(); // if (result == DialogResult.OK) // { // string msg2 = "确认修改{0}信息"; // msg2 = String.Format(msg2, barrel.BarrelName); // if (MessageBox.Show(msg2, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) // { // //更新数据库中的物料信息 // BarrelHelper.UpdateMaterial(frmBarrel.bar); // #region 触发刷新物料列表事件 // if (OnModify != null) // { // OnModify(runtime, System.EventArgs.Empty); // } // #endregion // } // } // else // { // frmBarrel.Dispose(); // } } #endregion } }