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/Technical/PmtRecipe/InitFormAction.cs

141 lines
4.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data;
using Mesnac.Action.Base;
using Mesnac.Codd.Session;
using System.Reflection;
using Mesnac.Controls.Base;
namespace Mesnac.Action.ChemicalWeighing.Technical.PmtRecipe
{
/// <summary>
/// 当班计划窗体初始化业务
/// </summary>
public class InitFormAction : ChemicalWeighingAction,IAction
{
#region 字段定义
public static bool IsFirstRun = true; //是否首次运行
private RuntimeParameter _runtime;
private DbMCControl _materialGridControl = null; //物料信息控件
private DbMCControl _cratParamControl = null; //物料控件
#endregion
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime);
#region 首次执行,进行事件订阅
if (IsFirstRun)
{
IsFirstRun = false;
ICSharpCode.Core.LoggingService<InitFormAction>.Debug("配方管理-窗体初始化业务...");
}
#endregion
#region 初始化
#region 获取界面控件
string source = string.Empty;
//获取配方树控件
List<DbMCControl> recipeControlList = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Base_RecipeInfo");
DbMCControl treeDbMCControl = recipeControlList.Where(x => x.BaseControl is TreeView).FirstOrDefault();
if (treeDbMCControl == null)
{
ICSharpCode.Core.LoggingService<InitFormAction>.Error("{配方管理-窗体加载} 缺少配方树网格控件...");
return;
}
DbMCControl recipeInfoDbMCControl = recipeControlList.Where(x => x.BaseControl is DataGridView).FirstOrDefault();
if(recipeInfoDbMCControl == null)
{
ICSharpCode.Core.LoggingService<InitFormAction>.Error("{配方管理-窗体加载} 缺少配方信息网格控件...");
return;
}
//获取物料列表
DbMCControl materialGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Base_RecipeMaterial").FirstOrDefault();
if (materialGridControl == null)
{
ICSharpCode.Core.LoggingService<InitFormAction>.Error("{配方管理-窗体加载} 缺少物料列表网格控件...");
return;
}
//获取工艺参数列表
DbMCControl cratParamGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Base_CratParam").FirstOrDefault();
if (cratParamGridControl == null || !(cratParamGridControl.BaseControl is DataGridView))
{
ICSharpCode.Core.LoggingService<RefreshAction>.Error("{配方管理—选择配方}缺少配方物料显示控件...");
return;
}
this._runtime = runtime;
this._materialGridControl = materialGridControl;
this._cratParamControl = cratParamGridControl;
#endregion
#region 初始化操作
TreeView treeView = (treeDbMCControl.BaseControl as TreeView);
DataGridView materialGrid = (materialGridControl.BaseControl as DataGridView);
DataGridView cratParamGridView = (cratParamGridControl.BaseControl as DataGridView);
this.InitGridViewEvent(materialGrid);
this.InitGridViewEvent(cratParamGridView);
#endregion
#endregion
}
#region 方法定义
#region 网格事件处理方法
/// <summary>
/// 初始化网格样式
/// </summary>
/// <param name="dgv">DataGridView网格控件对象</param>
private void InitGridViewEvent(DataGridView dgv)
{
if (dgv != null)
{
RecipeHelper.SetDataGridViewStyle(dgv); //设置网格样式
//双击时取消选择行(取消高亮显示)
dgv.CellDoubleClick += delegate(object sender, DataGridViewCellEventArgs e)
{
if (dgv.Rows != null && dgv.Rows.Count > 0)
{
foreach (DataGridViewRow row in dgv.Rows)
{
row.Selected = false;
}
}
};
}
}
#endregion
#endregion
}
}