using System; using System.Linq; using System.Windows.Forms; using ICSharpCode.Core; using Mesnac.Action.Base; using Mesnac.Action.ChemicalWeighing.Entity; using StringParser = DevExpress.Utils.Text.StringParser; namespace Mesnac.Action.ChemicalWeighing.LjMaterial { public class UpdateAction:ChemicalWeighingAction,IAction { private DbMCControl _clientGridControl = null; //用户列表控件 /// /// 新增物料事件定义 /// public static event EventHandler OnUpdateMaterial; 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; this._runtime.BaseControl.MCEnabled = false; FrmMaterial frmInsertMaterial = new FrmMaterial(ActionType.Modify,new MaterialInfoType() { Id = id, MaterialName = name }); frmInsertMaterial.ShowDialog(this._runtime.BaseControl.MCRoot as Control); if (frmInsertMaterial.DialogResult == DialogResult.OK) { if (OnUpdateMaterial != null) { OnUpdateMaterial(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty); } frmInsertMaterial.Dispose(); } this._runtime.BaseControl.MCEnabled = true; } } }