|
|
|
|
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.Technical.PmtRecipe.entity;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.Product.PptPlan.entity;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.Product.PptPlan
|
|
|
|
|
{
|
|
|
|
|
public partial class FrmPlan : Form
|
|
|
|
|
{
|
|
|
|
|
#region 字段定义
|
|
|
|
|
|
|
|
|
|
private ActionType _actionType = ActionType.Add; //操作类型,0-为添加,1-为修改
|
|
|
|
|
private int _planNum; //计划数
|
|
|
|
|
private Base_RecipeInfo _recipe = null; //配方对象
|
|
|
|
|
|
|
|
|
|
private Base_PlanInfo _planInfo = 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, Base_RecipeInfo recipe)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
this._actionType = actionType;
|
|
|
|
|
this._planNum = planNum;
|
|
|
|
|
this._recipe = recipe;
|
|
|
|
|
|
|
|
|
|
this.txtCarNumber.Text = planNum.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public FrmPlan(ActionType actionType,Base_PlanInfo planInfo)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
this._actionType = actionType;
|
|
|
|
|
|
|
|
|
|
this._planInfo = planInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 属性定义
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 物料信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Base_RecipeInfo Recipe
|
|
|
|
|
{
|
|
|
|
|
get { return this._recipe; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Base_PlanInfo PlanInfo
|
|
|
|
|
{
|
|
|
|
|
get { return this._planInfo; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string RecipeVersion
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this.cmbRecipeId.SelectedItem as string;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 计划数
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int PlanNum
|
|
|
|
|
{
|
|
|
|
|
get { return this._planNum; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#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")); //配方名称
|
|
|
|
|
this.label2.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Product_PptPlan_FrmPlan_label2_Text")); //配方版本
|
|
|
|
|
// 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"));
|
|
|
|
|
this.comRunType.SelectedIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化配方列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void InitData()
|
|
|
|
|
{
|
|
|
|
|
List<Base_RecipeInfo> lst = null;
|
|
|
|
|
lst = TechnicalHelper.GetRecipeMaterialListPY();
|
|
|
|
|
this.cmbRecipeMaterial.Items.Clear();
|
|
|
|
|
foreach (Base_RecipeInfo r in lst)
|
|
|
|
|
{
|
|
|
|
|
if(!this.cmbRecipeMaterial.Items.Contains(r.recipeType))
|
|
|
|
|
{
|
|
|
|
|
this.cmbRecipeMaterial.Items.Add(r.recipeType);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this._actionType == ActionType.Modify)
|
|
|
|
|
{
|
|
|
|
|
bool flag = false;
|
|
|
|
|
|
|
|
|
|
this._recipe = RecipeHelper.GetRecipeById(this._planInfo.recipe_Id);
|
|
|
|
|
|
|
|
|
|
if(this._recipe != null)
|
|
|
|
|
{
|
|
|
|
|
flag = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//foreach (Base_RecipeInfo r in this.cmbRecipeMaterial.Items)
|
|
|
|
|
//{
|
|
|
|
|
// if (r.recipeId == this._planInfo.recipe_Id)
|
|
|
|
|
// {
|
|
|
|
|
// this.cmbRecipeMaterial.SelectedItem = r.recipeType;
|
|
|
|
|
// this.cmbRecipeId.SelectedItem = r.recipeName;
|
|
|
|
|
// flag = true;
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//if (!flag)
|
|
|
|
|
//{
|
|
|
|
|
// this.cmbRecipeMaterial.SelectedValue = this._recipe.recipeType;
|
|
|
|
|
// //this.cmbRecipeId.Text = this._recipe.recipeId;
|
|
|
|
|
// this.cmbRecipeId.SelectedValue = this._recipe.recipeName;
|
|
|
|
|
//}
|
|
|
|
|
//this.cmbRecipeMaterial.Enabled = false;
|
|
|
|
|
|
|
|
|
|
//this.cmbRecipeId.SelectedItem = this._recipe.recipeId;
|
|
|
|
|
//this.cmbRecipeId.Enabled = false;
|
|
|
|
|
this.txtGrid.Text = this._planInfo.grid_Amount.ToString();
|
|
|
|
|
//this.txtLine.Text = this._planInfo.line_Amount.ToString();
|
|
|
|
|
this.txtCarNumber.Text = this._planInfo.car_Amount.ToString();
|
|
|
|
|
this.cmbRecipeMaterial.Text = this._recipe.recipeType;
|
|
|
|
|
this.cmbRecipeId.SelectedItem = this._recipe.recipeName;
|
|
|
|
|
this.comRunType.SelectedItem = this._planInfo.run_Type == 0 ? "自动运行" : "手动运行";
|
|
|
|
|
this.txtNumber.Text = this._planInfo.plan_Amount.ToString();
|
|
|
|
|
|
|
|
|
|
//this.txtGrid.Enabled = false;
|
|
|
|
|
//this.txtLine.Enabled = false;
|
|
|
|
|
//this.txtCarNumber.Enabled = false;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化选中的配方版本数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void InitRecipeVersionData()
|
|
|
|
|
{
|
|
|
|
|
if (this.cmbRecipeMaterial.SelectedItem != null)
|
|
|
|
|
{
|
|
|
|
|
string recipe = this.cmbRecipeMaterial.SelectedItem as string;
|
|
|
|
|
List<string> recipeVersionList = TechnicalHelper.GetRecipeListByRecipeType(recipe);
|
|
|
|
|
this.cmbRecipeId.DataSource = recipeVersionList;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 事件处理
|
|
|
|
|
|
|
|
|
|
private void FrmPlan_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.InitUI();
|
|
|
|
|
this.InitData();
|
|
|
|
|
// InitRecipeVersionData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FrmPlan_Activated(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this._actionType == ActionType.Modify)
|
|
|
|
|
{
|
|
|
|
|
this.txtCarNumber.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)
|
|
|
|
|
{
|
|
|
|
|
string recipe = this.cmbRecipeId.SelectedItem as string;
|
|
|
|
|
int planNum = 0;
|
|
|
|
|
if (recipe == null || string.IsNullOrEmpty(recipe))
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
if (String.IsNullOrEmpty(this.cmbRecipeId.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.cmbRecipeId.Focus();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (String.IsNullOrEmpty(this.txtNumber.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.txtNumber.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;
|
|
|
|
|
}
|
|
|
|
|
this._planNum = planNum;
|
|
|
|
|
|
|
|
|
|
Base_RecipeInfo recipeInfo = RecipeHelper.GetRecipeByName(recipe);
|
|
|
|
|
|
|
|
|
|
string runType = this.comRunType.SelectedItem as string;
|
|
|
|
|
|
|
|
|
|
this._planInfo = new Base_PlanInfo()
|
|
|
|
|
{
|
|
|
|
|
uid = this._actionType == ActionType.Modify ? this._planInfo.uid : System.Guid.NewGuid().ToString("N"),
|
|
|
|
|
//plan_Id = this._actionType == ActionType.Modify ? this._planInfo.plan_Id : System.Guid.NewGuid().ToString("N"),
|
|
|
|
|
recipe_Id = recipeInfo.recipeId,
|
|
|
|
|
recipe_Name = recipe,
|
|
|
|
|
plan_Team = "0",
|
|
|
|
|
car_Amount = Convert.ToInt32(this.txtCarNumber.Text),
|
|
|
|
|
grid_Amount = Convert.ToInt32(this.txtGrid.Text),
|
|
|
|
|
line_Amount = 1,
|
|
|
|
|
plan_Amount = Convert.ToInt32(this.txtNumber.Text),
|
|
|
|
|
//plan_beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
|
|
run_Type = runType.Trim().Contains("自动") ? 0 : 1,
|
|
|
|
|
create_By = "admin",
|
|
|
|
|
create_Time = this._actionType == ActionType.Modify ? this._planInfo.create_Time : DateTime.Now
|
|
|
|
|
};
|
|
|
|
|
if (this._actionType == ActionType.Modify)
|
|
|
|
|
{
|
|
|
|
|
_planInfo.plan_Id = this._planInfo.plan_Id;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//查询当天计划最后一条
|
|
|
|
|
string PlanID = PlanHelper.getPlanIDByPlanInfo();
|
|
|
|
|
if (PlanID == "")
|
|
|
|
|
{
|
|
|
|
|
_planInfo.plan_Id = DateTime.Now.ToString("yyMMdd")+"001";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_planInfo.plan_Id = DateTime.Now.ToString("yyMMdd") + (int.Parse(PlanID.Substring(6)) + 1).ToString().PadLeft(3, '0');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.DialogResult = System.Windows.Forms.DialogResult.OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
private void txtCarNumberValidated(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!String.IsNullOrEmpty(this.txtCarNumber.Text))
|
|
|
|
|
{
|
|
|
|
|
int gridNumber = Convert.ToInt32(this.txtGrid.Text);
|
|
|
|
|
|
|
|
|
|
//int lineNumber = Convert.ToInt32(this.txtLine.Text);
|
|
|
|
|
|
|
|
|
|
int carNumber = Convert.ToInt32(this.txtCarNumber.Text);
|
|
|
|
|
|
|
|
|
|
int planNumber = gridNumber * 1 * carNumber;
|
|
|
|
|
|
|
|
|
|
this.txtNumber.Text = planNumber.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|