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/CheckRecipeTree.cs

102 lines
3.9 KiB
C#

using Mesnac.Action.Base;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesnac.Action.ChemicalWeighing.Technical.PmtRecipe
{
public class CheckRecipeTree : ChemicalWeighingAction, IAction
{
private RuntimeParameter _runtime;
private DbMCControl _recipeTreeGridControl = null;
private DbMCControl _materialGridControl = null;
private DbMCControl _recipeInfoGridControl = null;
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须要调用的
this._runtime = runtime;
#region 获取界面recipe控件
List<DbMCControl> recipeControlList = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Base_RecipeInfo");
DbMCControl recipeTreeGridControl = recipeControlList.Where(x => x.BaseControl is TreeView).FirstOrDefault();
if (recipeTreeGridControl == null || !(recipeTreeGridControl.BaseControl is TreeView))
{
ICSharpCode.Core.LoggingService<RefreshAction>.Error("{配方管理—删除配方}缺少配方管理控件...");
return;
}
DbMCControl recipeInfoGridControl = recipeControlList.Where(x => x.BaseControl is DataGridView).FirstOrDefault();
if (recipeInfoGridControl == null || !(recipeInfoGridControl.BaseControl is DataGridView))
{
ICSharpCode.Core.LoggingService<RefreshAction>.Error("{配方管理—删除配方}缺少配方管理控件...");
return;
}
this._recipeTreeGridControl = recipeTreeGridControl;
this._recipeInfoGridControl = recipeInfoGridControl;
#endregion
this.DoWork();
}
protected void DoWork()
{
//判断是否选择了一条配方并显示物料信息
TreeView recipeGridView = this._recipeTreeGridControl.BaseControl as TreeView;
if (recipeGridView.SelectedNode != null)
{
//获取界面配方关联物料的物料信息控件
DbMCControl materialGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Base_RecipeMaterial").FirstOrDefault();
if (materialGridControl == null || !(materialGridControl.BaseControl is DataGridView))
{
ICSharpCode.Core.LoggingService<RefreshAction>.Error("{配方管理—选择配方}缺少配方物料显示控件...");
return;
}
this._materialGridControl = materialGridControl;
string recipeId = recipeGridView.SelectedNode.Name;
//刷新配方信息
DataTable recipeInfoTable = RecipeHelper.GetBaseRecipeInfo(recipeId);
lock (String.Empty)
{
//本地计划
if (this._recipeInfoGridControl != null && recipeInfoTable != null)
{
this._recipeInfoGridControl.BaseControl.BindDataSource = null;
this._recipeInfoGridControl.BaseControl.BindDataSource = recipeInfoTable;
}
}
//刷新物料信息
DataTable table = RecipeHelper.GetRecipeMaterialInfo(recipeId);
lock (String.Empty)
{
//本地计划
if (this._materialGridControl != null && table != null)
{
this._materialGridControl.BaseControl.BindDataSource = null;
this._materialGridControl.BaseControl.BindDataSource = table;
}
}
}
else
{
return;
}
}
}
}