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.
189 lines
6.4 KiB
C#
189 lines
6.4 KiB
C#
using ICSharpCode.Core;
|
|
using Mesnac.Action.ChemicalWeighing.Technical.PmtRecipe.entity;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.Technical.PmtRecipe
|
|
{
|
|
public partial class SetCratParamForm : Form
|
|
{
|
|
|
|
private string recipeId = null;
|
|
|
|
private string materialId = null;
|
|
|
|
private List<Base_CratParamInfo> pmt_Materials = null;
|
|
|
|
private List<Base_RecipeCratParam> base_CratParams = null;
|
|
|
|
public SetCratParamForm()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public SetCratParamForm(string recipeId,string materialId)
|
|
{
|
|
InitializeComponent();
|
|
this.recipeId = recipeId;
|
|
this.materialId = materialId;
|
|
|
|
this.base_CratParams = new List<Base_RecipeCratParam>();
|
|
}
|
|
|
|
private void Form_Load(object sender, EventArgs e)
|
|
{
|
|
this.InitCombox();
|
|
this.InitUi();
|
|
this.InitData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 工艺参数下拉框初始化
|
|
/// </summary>
|
|
public void InitCombox()
|
|
{
|
|
//获取工艺参数
|
|
pmt_Materials = Product.PptPlan.PlanHelper.GetAllBaseCratParamInfo();
|
|
}
|
|
|
|
public void InitUi()
|
|
{
|
|
this.btnOk.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Dialog_btnOK"));
|
|
this.btnCancel.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Dialog_btnCancel"));
|
|
}
|
|
|
|
public void InitData()
|
|
{
|
|
//根据配方编号、物料编号获取工艺参数
|
|
DataTable dataTable = RecipeHelper.GetCratParamByRecipeAndMaterial(recipeId,materialId);
|
|
//先添加好空行
|
|
if (dataTable != null && dataTable.Rows.Count > 0)
|
|
{
|
|
for (int i = 0; i < dataTable.Rows.Count; i++)
|
|
{
|
|
this.DGVMaterialSet.Rows.Add();
|
|
//再将数据填入
|
|
for (int j = 0; j < this.DGVMaterialSet.ColumnCount; j++)
|
|
{
|
|
if (j == 0)
|
|
{
|
|
this.DGVMaterialSet.Rows[i].Cells[j].Value = dataTable.Rows[i][0].ToString();
|
|
}
|
|
else if (j == 1)
|
|
{
|
|
this.DGVMaterialSet.Rows[i].Cells[j].Value = dataTable.Rows[i][2].ToString();
|
|
}
|
|
else if (j == 2)
|
|
{
|
|
this.DGVMaterialSet.Rows[i].Cells[j].Value = dataTable.Rows[i][5].ToString();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.DGVMaterialSet.Rows.Add();
|
|
}
|
|
}
|
|
|
|
|
|
private void DGVMaterialSet_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
|
|
{
|
|
this.DGVMaterialSet.Rows.Add();
|
|
}
|
|
|
|
private void DGVMaterialSet_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
|
|
{
|
|
this.DGVMaterialSet.Refresh();
|
|
int newRowNum = this.DGVMaterialSet.RowCount;
|
|
if (pmt_Materials != null && pmt_Materials.Count > 0)
|
|
{
|
|
this.DGVMaterialSet.Rows[newRowNum - 1].Cells[0].Value = newRowNum;
|
|
foreach (Base_CratParamInfo pmt_Material in pmt_Materials)
|
|
{
|
|
(this.DGVMaterialSet.Rows[newRowNum - 1].Cells[1] as DataGridViewComboEditBoxCell).Items.Add(pmt_Material.paramName);
|
|
}
|
|
}
|
|
this.DGVMaterialSet.Rows[newRowNum - 1].HeaderCell.Value = "+";
|
|
this.DGVMaterialSet.CurrentCell = this.DGVMaterialSet[1, newRowNum - 1];
|
|
}
|
|
|
|
private void btnOk_Click(object sender, EventArgs e)
|
|
{
|
|
this.GetCratParamList();
|
|
|
|
this.SaveCratParam();
|
|
|
|
this.DialogResult = System.Windows.Forms.DialogResult.OK;
|
|
}
|
|
|
|
//获取工艺参数信息
|
|
public void GetCratParamList()
|
|
{
|
|
base_CratParams.Clear();
|
|
for (int i = 0; i < DGVMaterialSet.Rows.Count; i++)
|
|
{
|
|
Base_RecipeCratParam base_CratParam = new Base_RecipeCratParam();
|
|
base_CratParam.recipeId = this.recipeId;
|
|
base_CratParam.materialId = this.materialId;
|
|
for (int j = 1; j < DGVMaterialSet.ColumnCount; j++)
|
|
{
|
|
if (j == 1)
|
|
{
|
|
//根据物料名称获取物料ID
|
|
string materialNameStr = DGVMaterialSet.Rows[i].Cells[j].Value.ToString();
|
|
base_CratParam.paramName = materialNameStr;
|
|
//if (pmt_Materials.Exists(x => x.materialName == materialNameStr))
|
|
//{
|
|
// baseRepiceMaterial.materialId = GetMaterialID(materialNameStr);
|
|
//}
|
|
}
|
|
else if (j == 2)
|
|
{
|
|
base_CratParam.paramValue = DGVMaterialSet.Rows[i].Cells[j].Value.ToString();
|
|
}
|
|
}
|
|
base_CratParams.Add(base_CratParam);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存工艺参数
|
|
/// </summary>
|
|
public void SaveCratParam()
|
|
{
|
|
|
|
if (base_CratParams != null && base_CratParams.Count > 0)
|
|
{
|
|
RecipeHelper.DeleteCratParam(this.recipeId, this.materialId);
|
|
foreach (Base_RecipeCratParam cratParam in base_CratParams)
|
|
{
|
|
cratParam.editUser = "admin";
|
|
RecipeHelper.InsertCratParam(cratParam);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
private void toolStripMenuItemAdd_Click(object sender, EventArgs e)
|
|
{
|
|
this.DGVMaterialSet.Rows.Add();
|
|
}
|
|
|
|
private void toolStripMenuItemDel_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.DGVMaterialSet.CurrentCell != null)
|
|
{
|
|
this.DGVMaterialSet.Rows.RemoveAt(this.DGVMaterialSet.CurrentRow.Index);
|
|
}
|
|
}
|
|
}
|
|
}
|