using System; using System.Linq; using System.Windows.Forms; using Mesnac.Action.Base; namespace Mesnac.Action.ChemicalWeighing.LjMaterial { public class DelAction:ChemicalWeighingAction,IAction { private DbMCControl _clientGridControl = null; //用户列表控件 /// /// 新增物料事件定义 /// public static event EventHandler OnDelMaterial; private RuntimeParameter _runtime; public void Run(RuntimeParameter runtime) { base.RunIni(runtime); //必须调用 this._runtime = runtime; DoWork(); } private void DoWork() { DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "MaterialInfoType").FirstOrDefault(); if (clientGridControl == null) { ICSharpCode.Core.LoggingService.Error("缺少物料信息列表控件..."); return; } this._clientGridControl = clientGridControl; DataGridView clientGridView = this._clientGridControl.BaseControl as DataGridView; //验证是否选中某物料 if (clientGridView.SelectedRows.Count != 1) { string msg1 = "请选择一条要删除的物料!"; //请选择一项要修改的物料! MessageBox.Show(msg1, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); this._runtime.IsReturn = true; return; } int id =(int) clientGridView.SelectedRows[0].Cells[0].Value; var name = clientGridView.SelectedRows[0].Cells[1].Value as string; DialogResult result = MessageBox.Show("确定删除", Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { this._runtime.BaseControl.MCEnabled = false; MaterialInfoTypeHelp.Del(id); if (OnDelMaterial != null) { OnDelMaterial(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty); } } this._runtime.BaseControl.MCEnabled = true; } } }