|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 添加泵业务
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class InsertAction : ChemicalWeighingAction, IAction
|
|
|
|
|
{
|
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
|
|
|
{
|
|
|
|
|
base.RunIni(runtime); //必须调用
|
|
|
|
|
ICSharpCode.Core.LoggingService<InsertAction>.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<InsertAction>.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;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|