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.

107 lines
3.0 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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.Package
{
class InitFormAction : ChemicalWeighingAction, IAction
{
#region 事件定义
/// <summary>
/// 刷新物料信息事件
/// </summary>
public static event EventHandler OnRefresh;
#endregion
private RuntimeParameter _runtime;
private DbMCControl _gridControl = null; //物料列表控件
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须调用
this._runtime = runtime;
#region 事件订阅
if (true)
{
//新增物料后,要刷新物料页面
InsertAction.OnInsert -= Process_Event;
InsertAction.OnInsert += Process_Event;
//修改物料信息后,触发刷新页面事件
ModifyAction.OnModify -= Process_Event;
ModifyAction.OnModify += Process_Event;
//删除物料后,触发刷新页面事件
DeleteAction.OnDelete -= Process_Event;
DeleteAction.OnDelete += Process_Event;
}
#endregion
DbMCControl gridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Hw_Package").FirstOrDefault(); //获取物料数据控件
this._gridControl = gridControl;
//刷新信息
this.requestInfo();
}
/// <summary>
/// 刷新信息
/// </summary>
protected void requestInfo()
{
//获取信息表
DataTable dataTable = PackageHelper.QueryPackage();
lock (String.Empty)
{
if (this._gridControl != null && this._gridControl.BaseControl != null)
{
this._gridControl.BaseControl.BindDataSource = null;
this._gridControl.BaseControl.BindDataSource = dataTable;
DBLog("成功!");
}
else
{
ICSharpCode.Core.LoggingService<InitFormAction>.Warn("刷新信息失败数据控件为Null...");
}
}
#region 触发事件, 刷新信息
if (OnRefresh != null)
{
OnRefresh(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
}
}