using System.Linq; using System.Windows.Forms; using Mesnac.Action.Base; namespace Mesnac.Action.ChemicalWeighing.LjMixFormula { public class SelectRecipe:ChemicalWeighingAction, IAction { private DbMCControl _recipeGridControl; private RuntimeParameter _runtime; public void Run(RuntimeParameter runtime) { base.RunIni(runtime); //必须要调用的 this._runtime = runtime; DbMCControl recipeGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "lj_mix").FirstOrDefault(); this._recipeGridControl = recipeGridControl; DoWork(); } protected void DoWork() { #region 1 判断是否选择了一条配方并显示物料信息 DataGridView recipeGridView = this._recipeGridControl.BaseControl as DataGridView; if (recipeGridView.SelectedRows.Count == 1) { string id = recipeGridView.SelectedRows[0].Cells["Id"].Value as string; DbMCControl recipeGridControlDetail = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "lj_mix_detail").FirstOrDefault(); var metageDetailById = MixDb.GetDetailByMId(id); // recipeGrid.AutoGenerateColumns = false; recipeGridControlDetail.BaseControl.BindDataSource = null; recipeGridControlDetail.BaseControl.BindDataSource = metageDetailById; } #endregion } } }