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.

108 lines
3.3 KiB
C#

1 year ago
using Mesnac.Action.Base;
using Mesnac.Controls.Default;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mesnac.Action.ChemicalWeighing.Solvent.Material
{
class InitMaterialFormAction : ChemicalWeighingAction, IAction
{
#region 事件定义
/// <summary>
/// 刷新物料信息事件
/// </summary>
public static event EventHandler OnRefreshMaterial;
#endregion
private RuntimeParameter _runtime;
private DbMCControl _materialGridControl = null; //物料列表控件
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须调用
this._runtime = runtime;
#region 事件订阅
if (true)
{
//新增物料后,要刷新物料页面
InsertMaterialAction.OnInsertMaterial -= Process_Event;
InsertMaterialAction.OnInsertMaterial += Process_Event;
//修改物料信息后,触发刷新页面事件
ModifyMaterialAction.OnModifyMaterial -= Process_Event;
ModifyMaterialAction.OnModifyMaterial += Process_Event;
//删除物料后,触发刷新页面事件
DeleteMaterialAction.OnDeleteMaterial -= Process_Event;
DeleteMaterialAction.OnDeleteMaterial += Process_Event;
}
#endregion
DbMCControl materialGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "xl_material").FirstOrDefault(); //获取物料数据控件
this._materialGridControl = materialGridControl;
//刷新物料信息
this.requestMaterialInfo();
}
/// <summary>
/// 刷新物料信息
/// </summary>
protected void requestMaterialInfo()
{
//获取物料信息表
DataTable materialTable = MaterialHelper.getMaterial();
lock (String.Empty)
{
if (this._materialGridControl != null && this._materialGridControl.BaseControl != null)
{
this._materialGridControl.BaseControl.BindDataSource = null;
this._materialGridControl.BaseControl.BindDataSource = materialTable;
DBLog("成功!");
}
else
{
ICSharpCode.Core.LoggingService<InitMaterialFormAction>.Warn("刷新物料信息失败物料数据控件为Null...");
}
}
#region 触发事件, 刷新物料信息
if (OnRefreshMaterial != null)
{
OnRefreshMaterial(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty);
}
#endregion
}
#region 事件处理方法
private void Process_Event(object sender, EventArgs e)
{
if (sender is RuntimeParameter)
{
this.Run(sender as RuntimeParameter);
}
else
{
this.Run(this._runtime);
}
}
#endregion
}
}