using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data; using Mesnac.Action.Base; using Mesnac.Codd.Session; namespace Mesnac.Action.ChemicalWeighing.PumpManage { /// /// 添加泵业务 /// public class InsertAction : ChemicalWeighingAction, IAction { public void Run(RuntimeParameter runtime) { base.RunIni(runtime); //必须调用 ICSharpCode.Core.LoggingService.Debug("投料泵管理-添加..."); FrmInsert frmInsert = new FrmInsert(); DialogResult result = frmInsert.ShowDialog(); if (result == DialogResult.OK) { var hw = frmInsert._hw; string strSql = @"insert into Hw_Pump(Name, BarCode, CreateTime) values (@Name, @BarCode, @CreateTime)"; DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local); dbHelper.ClearParameter(); dbHelper.CommandText = strSql; dbHelper.CommandType = System.Data.CommandType.Text; dbHelper.AddParameter("@Name", hw.Name); dbHelper.AddParameter("@BarCode", hw.BarCode); dbHelper.AddParameter("@CreateTime", DateTime.Now); dbHelper.ExecuteNonQuery(); //刷新DataGridView数据 DbMCControl d = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Hw_Pump").FirstOrDefault(); if (d == null || !(d.BaseControl is DataGridView)) { ICSharpCode.Core.LoggingService.Warn("投料泵-添加-缺少DataGridView控件..."); runtime.IsReturn = false; return; } string sql = "select * from Hw_Pump"; DataTable table = dbHelper.GetDataTableBySql(sql); d.BaseControl.BindDataSource = null; d.BaseControl.BindDataSource = table; } } } }