You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
127 lines
4.2 KiB
C#
127 lines
4.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using System.Data;
|
|
using ICSharpCode.Core;
|
|
using Mesnac.Controls.Base;
|
|
using Mesnac.Action.Base;
|
|
using Mesnac.Codd.Session;
|
|
using Mesnac.Action.ChemicalWeighing.Entity;
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.Warehouse
|
|
{
|
|
/// <summary>
|
|
/// 添加物料业务
|
|
/// </summary>
|
|
public class InsertAction : ChemicalWeighingAction, IAction
|
|
{
|
|
#region 事件定义
|
|
|
|
/// <summary>
|
|
/// 添加物料事件定义
|
|
/// </summary>
|
|
public static event EventHandler OnInsert;
|
|
|
|
#endregion
|
|
|
|
#region 字段定义
|
|
|
|
private RuntimeParameter _runtime;
|
|
private DbMCControl _clientGridControl = null;
|
|
|
|
#endregion
|
|
|
|
#region IAction接口实现
|
|
public void Run(RuntimeParameter runtime)
|
|
{
|
|
base.RunIni(runtime);
|
|
this._runtime = runtime;
|
|
|
|
ICSharpCode.Core.LoggingService<InsertAction>.Debug("投料管理—添加物料业务...");
|
|
|
|
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Hw_Warehouse").FirstOrDefault();
|
|
if (clientGridControl == null || !(clientGridControl.BaseControl is DataGridView))
|
|
{
|
|
ICSharpCode.Core.LoggingService<InsertAction>.Error("{投料管理—添加物料}缺少物料控件...");
|
|
return;
|
|
}
|
|
this._clientGridControl = clientGridControl;
|
|
this.DoWork();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 方法定义
|
|
|
|
/// <summary>
|
|
/// 添加配方
|
|
/// </summary>
|
|
protected void DoWork()
|
|
{
|
|
this._runtime.BaseControl.MCEnabled = false;
|
|
try
|
|
{
|
|
DbMCControl gridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Hw_Warehouse").FirstOrDefault();
|
|
if (gridControl == null || !(gridControl.BaseControl is DataGridView))
|
|
{
|
|
ICSharpCode.Core.LoggingService<InsertAction>.Error("{反应釜管理—添加物料}缺少物料控件...");
|
|
return;
|
|
}
|
|
DataGridView subridView = gridControl.BaseControl as DataGridView;
|
|
if (subridView.SelectedRows.Count == 1)
|
|
{
|
|
int selectId = (int)subridView.SelectedRows[0].Cells["ID"].Value;
|
|
|
|
FrmNewMaterial frmNewMaterial = new FrmNewMaterial(ActionType.Add, selectId);
|
|
frmNewMaterial.ShowDialog(this._runtime.BaseControl.MCRoot as Control);
|
|
if (frmNewMaterial.DialogResult == DialogResult.OK)
|
|
{
|
|
var ware = frmNewMaterial._sub;
|
|
|
|
bool result = WarehouseHelper.InsertWareHouseSub(ware);
|
|
if (result)
|
|
{
|
|
frmNewMaterial.Dispose();
|
|
MessageBox.Show("新物料添加成功!");
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("保存失败!");
|
|
}
|
|
#region 触发事件
|
|
|
|
if (OnInsert != null)
|
|
{
|
|
OnInsert(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty);
|
|
}
|
|
#endregion
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
frmNewMaterial.Dispose();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSharpCode.Core.LoggingService<InsertAction>.Error("添加新物料异常:" + ex.Message, ex);
|
|
|
|
#region 记录操作日志
|
|
|
|
base.DBLog(ex.Message);
|
|
|
|
#endregion
|
|
|
|
MessageBox.Show(ex.Message, Mesnac.Basic.LanguageHelper.WarnCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
}
|
|
this._runtime.BaseControl.MCEnabled = true;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|