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.

164 lines
5.8 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.Entity.material;
namespace Mesnac.Action.ChemicalWeighing.Technical.XlRecipe
{
/// <summary>
/// 配方管理-选择数业务
/// </summary>
public class SelectRecipe : ChemicalWeighingAction, IAction
{
#region 字段定义
private RuntimeParameter _runtime;
private DbMCControl _recipeGridControl = null;
private DbMCControl _weighGridControl = null;
private xl_recipe pmt_Recipe = null;
private List<xl_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, "xl_recipe").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;
string selectRecipeID = null;
#endregion
#region 2.1 获取界面weigh控件
DbMCControl weighGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "xl_weigh").FirstOrDefault();
if (weighGridControl == null || !(weighGridControl.BaseControl is DataGridView))
{
ICSharpCode.Core.LoggingService<RefreshAction>.Error("{配方管理—选择配方}缺少配方物料显示控件...");
return;
}
this._weighGridControl = weighGridControl;
DataGridView weighGridView = this._weighGridControl.BaseControl as DataGridView;
#endregion
#region 获取配方的物料信息List
selectRecipeID = recipeGridView.SelectedRows[0].Cells["ID"].Value as string;
//selectRecipeName = recipeGridView.SelectedRows[0].Cells["Recipe_Name"].Value as string;
//pmt_Recipe = RecipeHelper.GetRecipeByName(selectRecipeID);
//pmt_Weighs = Product.XlPlan.PlanHelper.Getxl_weighList(pmt_Recipe.ID);
#endregion
DataTable table = DataListShow(selectRecipeID);
lock (String.Empty)
{
//本地计划
if (this._weighGridControl != null && table != null)
{
this._weighGridControl.BaseControl.BindDataSource = null;
this._weighGridControl.BaseControl.BindDataSource = table;
}
else
{
this._weighGridControl.BaseControl.BindDataSource = null;
}
}
}
else
{
return;
}
#endregion
}
#region DataTable数据整理显示
private DataTable DataListShow(string selectRecipeID)
{
//DataTable dataTable = null;
//if (pmt_Weighs != null && pmt_Weighs.Count > 0)
//{
return Product.XlPlan.PlanHelper.GetXl_material(selectRecipeID);
//DataColumn materialName = new DataColumn("Material_Name", Type.GetType("System.String"));
//DataColumn Station = new DataColumn("Station", 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(Station);
//dataTable.Columns.Add(setWeight);
//dataTable.Columns.Add(setError);
//for (int i = 0; i < pmt_Weighs.Count; i++)
//{
// DataRow dataRow = dataTable.NewRow();
// xl_material pmt_Material = Product.XlPlan.PlanHelper.GetXl_material(pmt_Weighs[i].Material_ID);
// if (pmt_Material != null&& pmt_Material.Material_name != null)
// {
// dataRow["Material_Name"] = pmt_Material.Material_name;
// }
// else
// {
// continue;
// }
// dataRow["Station"] = pmt_Weighs[i].Station;
// 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
}
}