using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Mesnac.Action.Base; namespace Mesnac.Action.Feeding.Technology { public partial class FrmRecipeSaveAs : Form { #region 定义字段 private string _materCode = String.Empty; private string _materName = String.Empty; #endregion public FrmRecipeSaveAs() { InitializeComponent(); } #region 重载构造方法 public FrmRecipeSaveAs(string materCode, string materName) { this._materCode = materCode; this._materName = materName; InitializeComponent(); this.InitUI(); this.InitData(); } #endregion #region 初始化界面 /// /// 初始化界面元素 /// public void InitUI() { this.Text = LanguageService.Instance.Read(278); //配方另存为... this.lblMaterCode.Text = LanguageService.Instance.Read(279); //配方编码 this.lblMaterName.Text = LanguageService.Instance.Read(280); //配方名称 this.btnOK.Text = LanguageService.Instance.Read(18); //确定 this.btnCancel.Text = LanguageService.Instance.Read(19); //取消 } #endregion #region 初始化数据 /// /// 初始化数据 /// public void InitData() { this.txtMaterCode.Text = this._materCode; this.txtMaterName.Text = this._materName; } #endregion #region 定义属性 /// /// 配方编码 /// public string MaterCode { get { return this.txtMaterCode.Text; } } /// /// 配方名称 /// public string MaterName { get { return this.txtMaterName.Text; } } #endregion private void btnOK_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(this.MaterCode)) { //请输入配方编码! MessageBox.Show(LanguageService.Instance.Read(281), LanguageService.Instance.Read(1), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (String.IsNullOrEmpty(this.MaterName)) { //请输入配方名称! MessageBox.Show(LanguageService.Instance.Read(282), LanguageService.Instance.Read(1), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (PlanCommon.IsExistsRecipeMaterCode(this.MaterCode.Trim())) { //【配方编码】已存在,请输入一个不存在的配方编码! MessageBox.Show(LanguageService.Instance.Read(283), LanguageService.Instance.Read(1), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (PlanCommon.IsExistsRecipeMaterName(this.MaterName.Trim())) { //【配方名称】已存在,请输入一个不存在的配方编码! MessageBox.Show(LanguageService.Instance.Read(284), LanguageService.Instance.Read(1), 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; } } }