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.

375 lines
13 KiB
C#

1 year ago
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using Mesnac.Action.Base;
using System.Text;
using System.Windows.Forms;
using ICSharpCode.Core;
using Mesnac.Action.ChemicalWeighing.Entity;
using Mesnac.Action.ChemicalWeighing.Technical;
using Mesnac.Action.ChemicalWeighing.Technical.PmtRecipe;
using Mesnac.Action.ChemicalWeighing.CylinderManage;
using Mesnac.Action.ChemicalWeighing.PumpManage;
namespace Mesnac.Action.ChemicalWeighing.Product.PptPlan
{
public partial class FrmPlan : Form
{
#region 字段定义
private ActionType _actionType = ActionType.Add; //操作类型0-为添加1-为修改
private int _planNum; //计划数
private SimplePmtRecipe _recipe = null; //配方对象
#endregion
#region 构造方法
public FrmPlan()
{
InitializeComponent();
}
/// <summary>
/// 构造方法
/// </summary>
/// <param name="actionType">操作类型0-为添加1-为修改</param>
public FrmPlan(ActionType actionType)
{
InitializeComponent();
this._actionType = actionType;
}
/// <summary>
/// 构造方法
/// </summary>
/// <param name="actionType">操作类型0-为添加1-为修改</param>
/// <param name="planNum">初始份数</param>
/// <param name="recipe">配方物料</param>
public FrmPlan(ActionType actionType, int planNum, SimplePmtRecipe recipe)
{
InitializeComponent();
this._actionType = actionType;
this._planNum = planNum;
this._recipe = recipe;
this.txtPlanNum.Text = planNum.ToString();
}
#endregion
#region 属性定义
/// <summary>
/// 物料信息
/// </summary>
public SimplePmtRecipe Recipe
{
get { return this._recipe; }
}
public string RecipeVersion
{
get
{
1 year ago
return "1";
1 year ago
}
}
/// <summary>
/// 计划数
/// </summary>
public int PlanNum
{
get { return this._planNum; }
}
/// <summary>
/// 拉缸名称
/// </summary>
//public string CyName
//{
// get
// {
// return this.cmbCylinder.Text;
// }
//}
/// <summary>
/// 拉缸条码
/// </summary>
//public string CyBarCode
//{
// get
// {
// return this.cmbCylinder.SelectedValue as string;
// }
//}
/// <summary>
/// 泵名称
/// </summary>
public string PumpName
{
get
{
return this.cmbPump.Text;
}
}
/// <summary>
/// 泵条码
/// </summary>
public string PumpBarCode
{
get
{
return this.cmbPump.SelectedValue as string;
}
}
/// <summary>
/// 地磅
/// </summary>
public string Weighbridge
{
get
{
return this.cmbWeighbridge.Text as string;
}
}
1 year ago
/// <summary>
/// 生产批次
/// </summary>
public string Batch
{
get
{
return this.txtBatch.Text as string;
}
}
/// <summary>
/// 生产批次
/// </summary>
public string ProductNames
{
get
{
return this.txtProductName.Text as string;
}
}
1 year ago
#endregion
#region 方法定义
/// <summary>
/// 初始化界面文本
/// </summary>
public void InitUI()
{
if (this._actionType == ActionType.Add)
{
this.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Product_PptPlan_FrmPlan_Text_Add")); //添加新计划
}
else if (this._actionType == ActionType.Modify)
{
this.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Product_PptPlan_FrmPlan_Text_Modify")); //修改计划
}
this.label1.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Product_PptPlan_FrmPlan_label1_Text")); //配方名称
1 year ago
//this.label2.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Product_PptPlan_FrmPlan_label2_Text")); //配方版本
1 year ago
this.label3.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Product_PptPlan_FrmPlan_label3_Text")); //份 数
this.btnOk.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Dialog_btnOK"));
this.btnCancel.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Dialog_btnCancel"));
}
/// <summary>
/// 初始化配方列表
/// </summary>
public void InitData()
{
List<SimplePmtRecipe> lst = null;
lst = TechnicalHelper.GetRecipeMaterialListPY();
this.cmbRecipeMaterial.Items.Clear();
this.cmbRecipeMaterial.DataSource = lst;
this.cmbRecipeMaterial.DisplayMember = "Recipe_Name";
this.cmbRecipeMaterial.ValueMember = "ID";
//foreach (SimplePmtRecipe r in lst)
//{
// this.cmbRecipeMaterial.Items.Add(r);
//}
#region 新增绑定拉缸
//拉缸
List<Hw_Cylinder> cyList = CylinderHelper.GetCylinderTList();
//this.cmbCylinder.Items.Clear();
//this.cmbCylinder.DataSource = cyList;
//this.cmbCylinder.DisplayMember = "Name";
//this.cmbCylinder.ValueMember = "BarCode";
//泵
List<Hw_Pump> pumpList = PumpHelper.GetHwPumpTList();
this.cmbPump.Items.Clear();
this.cmbPump.DataSource = pumpList;
this.cmbPump.DisplayMember = "Name";
this.cmbPump.ValueMember = "BarCode";
#endregion
if (this._actionType == ActionType.Modify)
{
bool flag = false;
foreach (SimplePmtRecipe r in this.cmbRecipeMaterial.Items)
{
if (r.MaterialGUID == this._recipe.MaterialGUID)
{
this.cmbRecipeMaterial.SelectedItem = r;
flag = true;
break;
}
}
if (!flag)
{
this.cmbRecipeMaterial.Text = this._recipe.Content;
}
this.cmbRecipeMaterial.Enabled = false;
1 year ago
//this.cmbRecipeVersion.SelectedItem = this._recipe.Version;
//this.cmbRecipeVersion.Enabled = false;
1 year ago
}
}
/// <summary>
/// 初始化选中的配方版本数据
/// </summary>
public void InitRecipeVersionData()
{
1 year ago
//if (this.cmbRecipeMaterial.SelectedItem != null)
//{
// SimplePmtRecipe recipe = this.cmbRecipeMaterial.SelectedItem as SimplePmtRecipe;
// List<string> recipeVersionList = TechnicalHelper.GetRecipeVersionList(recipe.Recipe_Name);
// this.cmbRecipeVersion.DataSource = recipeVersionList;
//}
1 year ago
}
#endregion
#region 事件处理
private void FrmPlan_Load(object sender, EventArgs e)
{
this.InitUI();
this.InitData();
}
private void FrmPlan_Activated(object sender, EventArgs e)
{
if (this._actionType == ActionType.Modify)
{
this.txtPlanNum.Focus();
}
else
{
this.cmbRecipeMaterial.Focus();
}
}
/// <summary>
/// 自动完成实现
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void cmbRecipeMaterial_TextUpdate(object sender, EventArgs e)
{
this.InitData();
//设置光标位置,否则光标位置始终保持在第一列,造成输入关键词的倒序排列
this.cmbRecipeMaterial.SelectionStart = this.cmbRecipeMaterial.Text.Length;
//保持鼠标指针原来状态,有时候鼠标指针会被下拉框覆盖,所以要进行一次设置。
Cursor = Cursors.Default;
//自动弹出下拉框
this.cmbRecipeMaterial.DroppedDown = true;
}
/// <summary>
/// 配方名称更改
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void cmbRecipeMaterial_SelectedIndexChanged(object sender, EventArgs e)
{
this.InitRecipeVersionData();
}
private void btnOk_Click(object sender, EventArgs e)
{
SimplePmtRecipe recipe = this.cmbRecipeMaterial.SelectedItem as SimplePmtRecipe;
recipe.ID= this.cmbRecipeMaterial.SelectedValue as string;
int planNum = 0;
if (recipe == null || string.IsNullOrEmpty(recipe.ID))
{
string msg1 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Product_PptPlan_FrmPlan_msg1")); //请选择配方名称!
MessageBox.Show(msg1, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
this.cmbRecipeMaterial.Focus();
return;
}
1 year ago
//if (String.IsNullOrEmpty(this.cmbRecipeVersion.SelectedItem as string))
//{
// string msg1_1 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Product_PptPlan_FrmPlan_msg1_1")); //请选择配方版本!
// MessageBox.Show(msg1_1, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
// this.cmbRecipeVersion.Focus();
// return;
//}
1 year ago
if (String.IsNullOrEmpty(this.txtPlanNum.Text))
{
string msg2 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Product_PptPlan_FrmPlan_msg2")); //请输入份数!
MessageBox.Show(msg2, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (!int.TryParse(this.txtPlanNum.Text, out planNum))
{
string msg3 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Product_PptPlan_FrmPlan_msg3")); //份数只能为整型数字!
MessageBox.Show(msg3, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (planNum <= 0)
{
string msg4 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Product_PptPlan_FrmPlan_msg4")); //份数必须大于0!
MessageBox.Show(msg4, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
//if (String.IsNullOrEmpty(this.cmbCylinder.Text as string))
//{
// string msg1_1 = "请选择拉缸!";
// MessageBox.Show(msg1_1, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
// this.cmbCylinder.Focus();
// return;
//}
if (String.IsNullOrEmpty(this.cmbPump.Text as string))
{
string msg1_1 = "请选择泵!";
MessageBox.Show(msg1_1, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
1 year ago
this.cmbPump.Focus();
1 year ago
return;
}
if (String.IsNullOrEmpty(this.cmbWeighbridge.Text as string))
{
string msg1_1 = "请选择地磅!";
MessageBox.Show(msg1_1, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
this.cmbWeighbridge.Focus();
return;
}
this._recipe = recipe;
this._planNum = planNum;
this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
#endregion
#region 取消
private void btnCancel_Click(object sender, EventArgs e)
{
this.Dispose();
}
#endregion
}
}