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.SmallMaterial.Parameter
{
class ModifyMaterialAction : ChemicalWeighingAction, IAction
{
#region 字段定义
private RuntimeParameter _runtime;
private DbMCControl _clientGridControl = null; //用户列表控件
#endregion
#region 事件定义
///
/// 修改用户信息事件定义
///
public static event EventHandler OnModifyMaterial;
#endregion
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须要调用
this._runtime = runtime;
#region 获取界面控件
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Pmt_material").FirstOrDefault();
if (clientGridControl == null)
{
ICSharpCode.Core.LoggingService.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_MaterialManage_ModifyMaterialAction_msg1")); //请选择一项要修改的物料!
MessageBox.Show(msg1, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
this._runtime.IsReturn = true;
return;
}
//封装选中行对应的物料对象
Pmt_material material = new Pmt_material
{
ID = clientGridView.SelectedRows[0].Cells["ID"].Value as string,
Material_name = clientGridView.SelectedRows[0].Cells["Material_name"].Value as string,
Material_code = clientGridView.SelectedRows[0].Cells["Material_code"].Value as string
};
#region 执行修改物料信息
//Parameter frmMaterial = new Parameter(ActionType.Modify, material);
//DialogResult result = frmMaterial.ShowDialog();
//if (result == DialogResult.OK)
//{
// Pmt_material newMaterial = frmMaterial.Material;
// newMaterial.ID = material.ID; //在此设定物料对象的ID
// frmMaterial.Dispose();
// string msg2 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_MaterialManage_ModifyMaterialAction_msg2")); //确认修改{0}物料信息?
// msg2 = String.Format(msg2, material.Material_name);
// if (MessageBox.Show(msg2, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
// {
// //更新数据库中的物料信息
// MaterialHelper.updateMaterial(newMaterial);
// #region 触发刷新物料列表事件
// if (OnModifyMaterial != null)
// {
// OnModifyMaterial(runtime, System.EventArgs.Empty);
// }
// #endregion
// }
//}
//else
//{
// frmMaterial.Dispose();
//}
#endregion
}
}
}