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.

104 lines
3.6 KiB
C#

using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesnac.Action.ChemicalWeighing.Warehouse
{
public class ModifyWarehouseAction : ChemicalWeighingAction, IAction
{
#region 字段定义
private RuntimeParameter _runtime;
private DbMCControl _clientGridControl = null;
#endregion
#region 事件定义
/// <summary>
/// 修改计划数事件定义
/// </summary>
public static event EventHandler OnModifyWarehouse;
#endregion
#region 业务入口
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须要调用的
this._runtime = runtime;
ICSharpCode.Core.LoggingService<ModifyAction>.Debug("投料管理-修改釜条码");
try
{
#region 1 获取界面控件
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "[Hw_Warehouse").FirstOrDefault();
if (clientGridControl == null || !(clientGridControl.BaseControl is DataGridView))
{
ICSharpCode.Core.LoggingService<RefreshAction>.Error("{投料管理—编辑釜条码}缺少投料管理控件...");
return;
}
this._clientGridControl = clientGridControl;
this._runtime = runtime;
DataGridView clientGridView = this._clientGridControl.BaseControl as DataGridView;
#endregion
#region 2 判断是否选择了要修改的物料
if (clientGridView.SelectedRows.Count != 1)
{
MessageBox.Show("请选择一条要修改的釜信息", Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
this._runtime.IsReturn = true;
return;
}
#endregion
int selectId = (int)clientGridView.SelectedRows[0].Cells["ID"].Value;
string name =clientGridView.SelectedRows[0].Cells["Name"].Value as string;
string barCode = clientGridView.SelectedRows[0].Cells["BarCode"].Value as string;
UpdateWareHouse frm = new UpdateWareHouse(ActionType.Modify, selectId, name, barCode);
frm.ShowDialog(this._runtime.BaseControl.MCRoot as Control);
if (frm.DialogResult == DialogResult.OK)
{
var ware = frm._wh;
WarehouseHelper.UpdateWareHouse(ware);
#region 触发事件
if (OnModifyWarehouse != null)
{
OnModifyWarehouse(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty);
}
#endregion
frm.Dispose();
MessageBox.Show("修改釜信息成功!");
}
else
{
frm.Dispose();
}
}
catch (Exception ex)
{
ICSharpCode.Core.LoggingService<ModifyAction>.Error("修改釜信息失败:" + ex.Message, ex);
MessageBox.Show(ex.Message, Mesnac.Basic.LanguageHelper.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
#endregion
}
}