using Mesnac.Action.Base; using Mesnac.Action.ChemicalWeighing.LjPlanning; using System.Windows.Forms; using System; using System.Linq; using Mesnac.Action.ChemicalWeighing.LjMaterial; namespace Mesnac.Action.ChemicalWeighing.LjRecipeData { public class DelAction : ChemicalWeighingAction, IAction { public static event EventHandler OnDel; private DbMCControl _materialGridControl = null; //物料列表控件 private RuntimeParameter _runtime; public void Run(RuntimeParameter runtime) { base.RunIni(runtime); //必须调用 this._runtime = runtime; DbMCControl materialGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Lj_Formula").FirstOrDefault(); //获取物料数据控件 this._materialGridControl = materialGridControl; FileControl(); } private void FileControl() { DataGridView clientGridView = this._materialGridControl.BaseControl as DataGridView; //验证是否选中某物料 if (clientGridView.SelectedRows.Count != 1) { MessageBox.Show("请选择要修改的数据", Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); this._runtime.IsReturn = true; return; } var dataGridViewRow = clientGridView.SelectedRows[0]; var id = Convert.ToInt32(dataGridViewRow.Cells["Id"].Value); string sql = " update Lj_Formula set IsEnable=0 where id=" + id; DBHelp.ExecuteNonQuery(sql); this._runtime.BaseControl.MCEnabled = false; if (OnDel != null) { OnDel(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty); } this._runtime.BaseControl.MCEnabled = true; } } }