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.
lj_plc/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjMaterial/UpdateAction.cs

80 lines
2.8 KiB
C#

1 year ago
using System;
using System.Linq;
using System.Windows.Forms;
using ICSharpCode.Core;
using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.Entity;
using StringParser = DevExpress.Utils.Text.StringParser;
namespace Mesnac.Action.ChemicalWeighing.LjMaterial
{
public class UpdateAction:ChemicalWeighingAction,IAction
{
private DbMCControl _clientGridControl = null; //用户列表控件
/// <summary>
/// 新增物料事件定义
/// </summary>
public static event EventHandler OnUpdateMaterial;
private RuntimeParameter _runtime;
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须调用
this._runtime = runtime;
DoWork();
}
private void DoWork()
{
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "MaterialInfoType").FirstOrDefault();
if (clientGridControl == null)
{
ICSharpCode.Core.LoggingService<UpdateAction>.Error("缺少物料信息列表控件...");
return;
}
this._clientGridControl = clientGridControl;
DataGridView clientGridView = this._clientGridControl.BaseControl as DataGridView;
//验证是否选中某物料
if (clientGridView.SelectedRows.Count != 1)
{
string msg1 = "请选择一项要修改的物料!"; //请选择一项要修改的物料!
MessageBox.Show(msg1, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
this._runtime.IsReturn = true;
return;
}
int id =(int) clientGridView.SelectedRows[0].Cells[0].Value;
var name = clientGridView.SelectedRows[0].Cells[1].Value as string;
this._runtime.BaseControl.MCEnabled = false;
FrmMaterial frmInsertMaterial = new FrmMaterial(ActionType.Modify,new MaterialInfoType()
{
Id = id,
1 year ago
MaterialName = name
1 year ago
});
frmInsertMaterial.ShowDialog(this._runtime.BaseControl.MCRoot as Control);
if (frmInsertMaterial.DialogResult == DialogResult.OK)
{
if (OnUpdateMaterial != null)
{
OnUpdateMaterial(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty);
}
frmInsertMaterial.Dispose();
1 year ago
1 year ago
}
1 year ago
this._runtime.BaseControl.MCEnabled = true;
1 year ago
}
}
}