using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ICSharpCode.Core;
using Mesnac.Action.Base;

namespace Mesnac.Action.ChemicalWeighing.Product.PptPlan
{
    public partial class FrmModifyPlanNum : Form
    {
        #region 字段定义

        private int _oldPlanNum = 0;        //保存原计划数

        #endregion

        #region 构造方法

        public FrmModifyPlanNum()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="oldPlanNum">原始计划数</param>
        public FrmModifyPlanNum(int oldPlanNum)
        {
            InitializeComponent();
            this._oldPlanNum = oldPlanNum;
        }

        #endregion

        #region 属性定义

        /// <summary>
        /// 设定车次
        /// </summary>
        public int NewPlanNum
        {
            get { return Convert.ToInt32(this.txtNewPlanNum.Text); }
        }

        #endregion

        #region 初始化界面文本

        /// <summary>
        /// 初始化界面文本
        /// </summary>
        public void InitUIMethod()
        {
            this.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Product_PptPlan_FrmModifyPlanNum_Text"));      //修改计划数
            this.label1.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Product_PptPlan_FrmModifyPlanNum_label1_Text"));        //当前配方设定次数为:
            this.label2.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Product_PptPlan_FrmModifyPlanNum_label2_Text"));        //请重新输入设定车次:
            this.btnOK.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Dialog_btnOK"));
            this.btnCancel.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Dialog_btnCancel"));
            //this.lblCurrentPlanNum.Text = BasePlcHelper.Instance.RecipeSetNumber.LastValue.ToInt().ToString();
            this.lblCurrentPlanNum.Text = this._oldPlanNum.ToString();
        }

        #endregion

        #region 事件处理

        private void FrmModifyPlanNum_Load(object sender, EventArgs e)
        {
            this.InitUIMethod();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(this.txtNewPlanNum.Text))
            {
                string msg1 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_Feeding_Product_PptPlan_FrmModifyPlanNum_msg1"));        //设定车次不能为空,请输入!
                MessageBox.Show(msg1, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (!Mesnac.Basic.DataProcessor.IsNumeric(this.txtNewPlanNum.Text))
            {
                string msg2 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_Feeding_Product_PptPlan_FrmModifyPlanNum_msg2"));        //设定车次必须为数字,请重新输入!
                MessageBox.Show(msg2, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
        }

        #endregion
    }
}