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

97 lines
3.7 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 System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesnac.Action.ChemicalWeighing.Technical.PmtRecipe
{
/// <summary>
/// 工艺参数设置
/// </summary>
public class SetCratParam : ChemicalWeighingAction, IAction
{
private RuntimeParameter _runtime;
private DbMCControl _recipeGridControl = null;
private DbMCControl _materialGridControl = null;
private string selectRecipeId = null;
/// <summary>
/// 设置参数事件定义
/// </summary>
public static event EventHandler OnSetCratParam;
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须要调用的
this._runtime = runtime;
ICSharpCode.Core.LoggingService<ModifyRecipeAction>.Debug("配方管理-设置工艺参数...");
List<DbMCControl> recipeControlList = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Base_RecipeInfo");
DbMCControl clientGridControl = recipeControlList.Where(x => x.BaseControl is TreeView).FirstOrDefault();
if (clientGridControl == null || !(clientGridControl.BaseControl is TreeView))
{
ICSharpCode.Core.LoggingService<RefreshAction>.Error("{配方管理—删除配方}缺少配方树控件...");
return;
}
this._recipeGridControl = clientGridControl;
DbMCControl materialControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Base_RecipeMaterial").FirstOrDefault();
if(materialControl == null || !(materialControl.BaseControl is DataGridView))
{
ICSharpCode.Core.LoggingService<RefreshAction>.Error("{配方管理—删除配方}缺少配方关联物料信息控件...");
return;
}
this._materialGridControl = materialControl;
//判断是否选择了要修改的配方 及 关联的物料信息
TreeView recipeGridView = this._recipeGridControl.BaseControl as TreeView;
DataGridView materialGridView = this._materialGridControl.BaseControl as DataGridView;
if (recipeGridView.SelectedNode == null || materialGridView.SelectedRows.Count != 1)
{
MessageBox.Show("请选择一条要修改的配方", Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
this._runtime.IsReturn = true;
return;
}
//判断该配方是否可进行修改如果配方正在RT_Plan表中查不允许修改
selectRecipeId = recipeGridView.SelectedNode.Name as string;
//获取物料编号
string materialId = materialGridView.SelectedRows[0].Cells["material_Id"].Value as string;
//执行设置参数
SetCratParamForm setCratParamForm = new SetCratParamForm(selectRecipeId, materialId);
setCratParamForm.ShowDialog(this._runtime.BaseControl.MCRoot as Control);
if (setCratParamForm.DialogResult == DialogResult.OK)
{
#region 触发事件
if (OnSetCratParam != null)
{
OnSetCratParam(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty);
}
#endregion
setCratParamForm.Dispose();
MessageBox.Show("配方参数修改成功!");
}
else
{
setCratParamForm.Dispose();
}
}
}
}