|
|
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 Mesnac.Action.Feeding.Technology;
|
|
|
|
|
|
namespace Mesnac.Action.Feeding.ProducingPlan
|
|
|
{
|
|
|
public partial class FrmPlan : Form
|
|
|
{
|
|
|
private int _actionType = 0; //操作类型,0-为添加,1-为修改
|
|
|
//private string _recipeMaterialName = String.Empty; //组合物料名称
|
|
|
private SimplePmtRecipe _recipe = null; //物料对象
|
|
|
|
|
|
#region 构造方法
|
|
|
|
|
|
public FrmPlan()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 构造方法
|
|
|
/// </summary>
|
|
|
/// <param name="actionType">操作类型,0-为添加,1-为修改</param>
|
|
|
public FrmPlan(int actionType)
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
this._actionType = actionType;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 构造方法
|
|
|
/// </summary>
|
|
|
/// <param name="actionType">操作类型,0-为添加,1-为修改</param>
|
|
|
/// <param name="planNum">初始份数</param>
|
|
|
//public FrmPlan(int actionType, int planNum, string recipeMaterialName)
|
|
|
//{
|
|
|
// InitializeComponent();
|
|
|
// this._actionType = actionType;
|
|
|
// this.txtPlanNum.Text = planNum.ToString();
|
|
|
// this._recipeMaterialName = recipeMaterialName;
|
|
|
//}
|
|
|
/// <summary>
|
|
|
/// 构造方法
|
|
|
/// </summary>
|
|
|
/// <param name="actionType">操作类型,0-为添加,1-为修改</param>
|
|
|
/// <param name="planNum">初始份数</param>
|
|
|
/// <param name="recipe">配方物料</param>
|
|
|
public FrmPlan(int actionType, int planNum, SimplePmtRecipe recipe)
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
this._actionType = actionType;
|
|
|
this.txtPlanNum.Text = planNum.ToString();
|
|
|
this._recipe = recipe;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 初始化工作
|
|
|
|
|
|
#region 初始化界面文本
|
|
|
/// <summary>
|
|
|
/// 初始化界面文本
|
|
|
/// </summary>
|
|
|
public void InitUI()
|
|
|
{
|
|
|
if (this._actionType == 0)
|
|
|
{
|
|
|
//添加
|
|
|
this.Text = LanguageService.Instance.Read(115);
|
|
|
this.btnOk.Text = LanguageService.Instance.Read(117);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//修改
|
|
|
this.Text = LanguageService.Instance.Read(116);
|
|
|
this.btnOk.Text = LanguageService.Instance.Read(118);
|
|
|
}
|
|
|
this.btnSelect.Text = LanguageService.Instance.Read(159); //筛选
|
|
|
this.btnCancel.Text = LanguageService.Instance.Read(119);
|
|
|
this.label1.Text = LanguageService.Instance.Read(120);
|
|
|
this.label2.Text = LanguageService.Instance.Read(121);
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 初始化配方列表
|
|
|
|
|
|
public void InitData()
|
|
|
{
|
|
|
List<SimplePmtRecipe> lst = null;
|
|
|
//判断是网络版还是单机版
|
|
|
DatabaseAction action = new DatabaseAction();
|
|
|
if (action.NetType == BaseAction.NetTypes.Net)
|
|
|
{
|
|
|
//网络版
|
|
|
lst = PlanCommon.GetNetRecipeMaterialList(action.CurrEquipCode, 1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//单机版
|
|
|
lst = PlanCommon.GetLocalRecipeMaterialList(action.CurrEquipCode, 1);
|
|
|
}
|
|
|
foreach (SimplePmtRecipe r in lst)
|
|
|
{
|
|
|
this.cmbRecipeMaterial.Items.Add(r);
|
|
|
}
|
|
|
this.cmbRecipeMaterial.SelectedIndex = 0; //默认定位到第一项
|
|
|
if (this._actionType == 1)
|
|
|
{
|
|
|
bool flag = false;
|
|
|
foreach (SimplePmtRecipe r in this.cmbRecipeMaterial.Items)
|
|
|
{
|
|
|
if (r.ObjID == this._recipe.ObjID)
|
|
|
{
|
|
|
this.cmbRecipeMaterial.SelectedItem = r;
|
|
|
flag = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (!flag)
|
|
|
{
|
|
|
this.cmbRecipeMaterial.Text = this._recipe.Content;
|
|
|
}
|
|
|
this.cmbRecipeMaterial.Enabled = false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
private void FrmPlan_Load(object sender, EventArgs e)
|
|
|
{
|
|
|
this.InitUI();
|
|
|
this.InitData();
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
private void btnOk_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
SimplePmtRecipe recipe = this.cmbRecipeMaterial.SelectedItem as SimplePmtRecipe;
|
|
|
int planNum = 0;
|
|
|
if (recipe == null || string.IsNullOrEmpty(recipe.ObjID))
|
|
|
{
|
|
|
MessageBox.Show(LanguageService.Instance.Read(123), LanguageService.Instance.Read(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
return;
|
|
|
}
|
|
|
if (String.IsNullOrEmpty(this.txtPlanNum.Text))
|
|
|
{
|
|
|
MessageBox.Show(LanguageService.Instance.Read(124), LanguageService.Instance.Read(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
return;
|
|
|
}
|
|
|
if (!int.TryParse(this.txtPlanNum.Text, out planNum))
|
|
|
{
|
|
|
MessageBox.Show(LanguageService.Instance.Read(125), LanguageService.Instance.Read(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
return;
|
|
|
}
|
|
|
if (planNum <= 0)
|
|
|
{
|
|
|
MessageBox.Show(LanguageService.Instance.Read(126), LanguageService.Instance.Read(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
return;
|
|
|
}
|
|
|
this._recipe = recipe;
|
|
|
this._planNum = planNum;
|
|
|
|
|
|
this.DialogResult = System.Windows.Forms.DialogResult.OK;
|
|
|
}
|
|
|
|
|
|
#region 属性定义
|
|
|
|
|
|
//private SimplePmtRecipe _recipe;
|
|
|
private int _planNum;
|
|
|
/// <summary>
|
|
|
/// 物料信息
|
|
|
/// </summary>
|
|
|
public SimplePmtRecipe Recipe
|
|
|
{
|
|
|
get { return this._recipe; }
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 份数
|
|
|
/// </summary>
|
|
|
public int PlanNum
|
|
|
{
|
|
|
get { return this._planNum; }
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
private void btnSelect_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
SimplePmtRecipe selectedRecipe = null;
|
|
|
FrmRecipeFinder recipeFinder = new FrmRecipeFinder(0);
|
|
|
recipeFinder.ShowDialog(this);
|
|
|
if (recipeFinder.DialogResult == System.Windows.Forms.DialogResult.OK)
|
|
|
{
|
|
|
selectedRecipe = recipeFinder.SelectedRecipe;
|
|
|
}
|
|
|
recipeFinder.Dispose();
|
|
|
if (selectedRecipe != null)
|
|
|
{
|
|
|
foreach (SimplePmtRecipe r in this.cmbRecipeMaterial.Items)
|
|
|
{
|
|
|
if (r.ObjID == selectedRecipe.ObjID)
|
|
|
{
|
|
|
this.cmbRecipeMaterial.SelectedItem = r;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|