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
4.3 KiB
C#

1 year ago
using ICSharpCode.Core;
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.BinManage
{
class ModifyBinAction : ChemicalWeighingAction, IAction
{
#region 字段定义
private RuntimeParameter _runtime;
private DbMCControl _clientGridControl = null; //料仓列表控件
#endregion
#region 事件定义
/// <summary>
/// 修改料仓信息事件定义
/// </summary>
public static event EventHandler OnModifyBin;
#endregion
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须要调用
this._runtime = runtime;
#region 获取界面控件
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Pmt_Bin").FirstOrDefault();
if (clientGridControl == null)
{
ICSharpCode.Core.LoggingService<ModifyBinAction>.Error("缺少料仓信息列表控件...");
return;
}
this._runtime = runtime;
this._clientGridControl = clientGridControl;
DataGridView clientGridView = this._clientGridControl.BaseControl as DataGridView;
#endregion
//验证是否选中某用户
if (clientGridView.SelectedRows.Count != 1)
{
string msg1 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_BinManage_ModifyBinAction_msg1")); //请选择一项要修改的料仓信息!
MessageBox.Show(msg1, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
this._runtime.IsReturn = true;
return;
}
//封装选中行对应的用户对象
Pmt_Bin bin = new Pmt_Bin
{
Bin_Serial = Convert.ToInt32(clientGridView.SelectedRows[0].Cells["Bin_Serial"].Value),
Bin_Code = clientGridView.SelectedRows[0].Cells["Bin_Code"].Value as string,
Material_ID = clientGridView.SelectedRows[0].Cells["Material_ID"].Value as string,
Bin_Name = clientGridView.SelectedRows[0].Cells["Bin_Name"].Value as string,
Station_Weight_Medium = Convert.ToInt32(clientGridView.SelectedRows[0].Cells["Station_Weight_Medium"].Value),
Station_Weight_Low = Convert.ToInt32(clientGridView.SelectedRows[0].Cells["Station_Weight_Low"].Value),
Station_Weight_Advance = Convert.ToInt32(clientGridView.SelectedRows[0].Cells["Station_Weight_Advance"].Value),
Station_Speed_Hight = Convert.ToInt32(clientGridView.SelectedRows[0].Cells["Station_Speed_Hight"].Value),
Station_Speed_Medium = Convert.ToInt32(clientGridView.SelectedRows[0].Cells["Station_Speed_Medium"].Value),
Station_Speed_Low = Convert.ToInt32(clientGridView.SelectedRows[0].Cells["Station_Speed_Low"].Value)
};
FrmBin frmBin = new FrmBin(ActionType.Modify, bin);
DialogResult result = frmBin.ShowDialog();
if (result == DialogResult.OK)
{
Pmt_Bin newBin = frmBin.Bin;
frmBin.Dispose();
string msg2 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_BinManage_ModifyBinAction_msg2")); //确认修改{0}号料仓的物料信息?
msg2 = String.Format(msg2, bin.Bin_Serial.ToString());
if (MessageBox.Show(msg2, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
//更新数据库中的用户信息
BinHelper.updateBin(newBin);
#region 触发刷新料仓列表事件
if (OnModifyBin != null)
{
OnModifyBin(runtime, System.EventArgs.Empty);
}
#endregion
}
}
else
{
frmBin.Dispose();
}
}
}
}