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.
103 lines
3.6 KiB
C#
103 lines
3.6 KiB
C#
using ICSharpCode.Core;
|
|
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
|
|
{
|
|
class ModifyAction : ChemicalWeighingAction, IAction
|
|
{
|
|
#region 字段定义
|
|
|
|
private RuntimeParameter _runtime;
|
|
private DbMCControl _clientGridControl = null; //控件
|
|
|
|
#endregion
|
|
|
|
#region 事件定义
|
|
|
|
/// <summary>
|
|
/// 修改用户信息事件定义
|
|
/// </summary>
|
|
public static event EventHandler OnModify;
|
|
|
|
#endregion
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
{
|
|
base.RunIni(runtime); //必须要调用
|
|
this._runtime = runtime;
|
|
|
|
#region 获取界面控件
|
|
|
|
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Hw_Package").FirstOrDefault();
|
|
if (clientGridControl == null)
|
|
{
|
|
ICSharpCode.Core.LoggingService<ModifyAction>.Error("缺少料桶信息列表控件...");
|
|
return;
|
|
}
|
|
this._runtime = runtime;
|
|
this._clientGridControl = clientGridControl;
|
|
DataGridView clientGridView = this._clientGridControl.BaseControl as DataGridView;
|
|
|
|
#endregion
|
|
|
|
//验证是否选中某料桶
|
|
if (clientGridView.SelectedRows.Count != 1)
|
|
{
|
|
string msg1 = "请选择一项要修改的料桶!";
|
|
MessageBox.Show(msg1, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
this._runtime.IsReturn = true;
|
|
return;
|
|
}
|
|
//封装选中行对应的物料对象
|
|
Hw_Package package = new Hw_Package
|
|
{
|
|
ID = (int)clientGridView.SelectedRows[0].Cells["ID"].Value,
|
|
Name = clientGridView.SelectedRows[0].Cells["Name"].Value as string,
|
|
BarCode = clientGridView.SelectedRows[0].Cells["BarCode"].Value as string,
|
|
MaterialID = clientGridView.SelectedRows[0].Cells["MaterialID"].Value as string,
|
|
MaterialName = clientGridView.SelectedRows[0].Cells["MaterialName"].Value as string,
|
|
IsEnable = clientGridView.SelectedRows[0].Cells["IsEnable"].Value as string
|
|
};
|
|
|
|
#region 执行修改桶信息
|
|
FrmPackage frmPackage = new FrmPackage(ActionType.Modify, package);
|
|
DialogResult result = frmPackage.ShowDialog();
|
|
if (result == DialogResult.OK)
|
|
{
|
|
string msg2 = "确认修改{0}信息";
|
|
msg2 = String.Format(msg2, package.Name);
|
|
if (MessageBox.Show(msg2, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
{
|
|
//更新数据库中的物料信息
|
|
PackageHelper.UpdatePackage(frmPackage._package);
|
|
|
|
#region 触发刷新物料列表事件
|
|
|
|
if (OnModify != null)
|
|
{
|
|
OnModify(runtime, System.EventArgs.Empty);
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
frmPackage.Dispose();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|