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.
153 lines
5.2 KiB
C#
153 lines
5.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using System.Data;
|
|
using ICSharpCode.Core;
|
|
using Mesnac.Controls.Base;
|
|
using Mesnac.Action.Base;
|
|
using Mesnac.Codd.Session;
|
|
using Mesnac.Action.ChemicalWeighing.Entity;
|
|
using Mesnac.Action.ChemicalWeighing.Technical.PmtRecipe.entity;
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.Technical.PmtRecipe
|
|
{
|
|
/// <summary>
|
|
/// 生产管理-修改计划数业务
|
|
/// </summary>
|
|
public class SelectRecipe : ChemicalWeighingAction, IAction
|
|
{
|
|
#region 字段定义
|
|
|
|
private RuntimeParameter _runtime;
|
|
private DbMCControl _recipeGridControl = null;
|
|
private DbMCControl _cratParamGridControl = null;
|
|
private Pmt_recipe pmt_Recipe = null;
|
|
private List<Pmt_weigh> pmt_Weighs = null;
|
|
|
|
#endregion
|
|
|
|
#region 业务入口
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
{
|
|
base.RunIni(runtime); //必须要调用的
|
|
this._runtime = runtime;
|
|
|
|
#region 获取界面recipe控件
|
|
|
|
DbMCControl recipeGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Base_RecipeMaterial").FirstOrDefault();
|
|
if (recipeGridControl == null || !(recipeGridControl.BaseControl is DataGridView))
|
|
{
|
|
ICSharpCode.Core.LoggingService<RefreshAction>.Error("{配方管理—删除配方}缺少配方管理控件...");
|
|
return;
|
|
}
|
|
this._recipeGridControl = recipeGridControl;
|
|
|
|
#endregion
|
|
|
|
this.DoWork();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 方法定义
|
|
|
|
protected void DoWork()
|
|
{
|
|
|
|
#region 1 判断是否选择了一条配方并显示物料信息
|
|
|
|
DataGridView recipeGridView = this._recipeGridControl.BaseControl as DataGridView;
|
|
if (recipeGridView.SelectedRows.Count == 1)
|
|
{
|
|
|
|
#region 变量定义
|
|
|
|
string selectRecipeName = null;
|
|
|
|
#endregion
|
|
|
|
#region 2.1 获取界面weigh控件
|
|
|
|
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._cratParamGridControl = cratParamGridControl;
|
|
DataGridView weighGridView = this._cratParamGridControl.BaseControl as DataGridView;
|
|
|
|
#endregion
|
|
|
|
string recipeId = recipeGridView.SelectedRows[0].Cells["recipe_Id"].Value as string;
|
|
string materialId = recipeGridView.SelectedRows[0].Cells["material_Id"].Value as string;
|
|
|
|
//DataTable table = DataListShow();
|
|
DataTable table = RecipeHelper.GerCratParamByRecipeAndMaterial(recipeId.Trim(), materialId.Trim());
|
|
lock (String.Empty)
|
|
{
|
|
//本地计划
|
|
if (this._cratParamGridControl != null && table != null)
|
|
{
|
|
this._cratParamGridControl.BaseControl.BindDataSource = null;
|
|
this._cratParamGridControl.BaseControl.BindDataSource = table;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
#region DataTable数据整理显示
|
|
|
|
private DataTable DataListShow()
|
|
{
|
|
DataTable dataTable = null;
|
|
|
|
if (pmt_Weighs != null && pmt_Weighs.Count > 0)
|
|
{
|
|
dataTable = new DataTable();
|
|
|
|
DataColumn materialName = new DataColumn("Material_Name", Type.GetType("System.String"));
|
|
DataColumn setWeight = new DataColumn("Set_Weight", Type.GetType("System.String"));
|
|
DataColumn setError = new DataColumn("Set_Error", Type.GetType("System.String"));
|
|
dataTable.Columns.Add(materialName);
|
|
dataTable.Columns.Add(setWeight);
|
|
dataTable.Columns.Add(setError);
|
|
for (int i = 0; i < pmt_Weighs.Count; i++)
|
|
{
|
|
DataRow dataRow = dataTable.NewRow();
|
|
|
|
Base_MaterialInfo pmt_Material = Product.PptPlan.PlanHelper.GetPmt_material(pmt_Weighs[i].Material_ID);
|
|
if (pmt_Material != null&& pmt_Material.materialName != null)
|
|
{
|
|
dataRow["Material_Name"] = pmt_Material.materialName;
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
dataRow["Set_Weight"] = pmt_Weighs[i].Set_Weight.ToString();
|
|
dataRow["Set_Error"] = pmt_Weighs[i].Set_Error.ToString();
|
|
dataTable.Rows.Add(dataRow);
|
|
}
|
|
}
|
|
|
|
return dataTable;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|