using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.Entity;
using Mesnac.Action.ChemicalWeighing.Entity.Barrel;
using Mesnac.Action.ChemicalWeighing.Entity.Package;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesnac.Action.ChemicalWeighing.Package
{
public class InsertAction : ChemicalWeighingAction, IAction
{
#region 事件定义
///
/// 新增物料事件定义
///
public static event EventHandler OnInsert;
#endregion
private RuntimeParameter _runtime;
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime);
this._runtime = runtime;
this.DoWork();
}
///
/// 新增桶信息
///
private void DoWork()
{
this._runtime.BaseControl.MCEnabled = false;
//创建新增用户窗体
FrmPackage frmInsert = new FrmPackage();
frmInsert.ShowDialog(this._runtime.BaseControl.MCRoot as Control);
//点击确定按钮后DialogResult属性为OK
if (frmInsert.DialogResult == DialogResult.OK)
{
//获取用户对象
Hw_Package bar = frmInsert._package;
PackageHelper.AddPackage(bar);
#region 触发事件
if (OnInsert != null)
{
OnInsert(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty);
}
#endregion
}
frmInsert.Dispose();
this._runtime.BaseControl.MCEnabled = true;
}
}
}