/*******************************************************************************
* Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_PM_0201.cs
* 2.功能描述:变更条码
* 编辑履历:
* 作者 日期 版本 修改内容
* 庄天威 2014/09/23 1.00 新建
*******************************************************************************/
using System;
using System.Reflection;
using System.Windows.Forms;
using Dongke.IBOSS.PRD.Basics.BaseControls;
using Dongke.IBOSS.PRD.Basics.BaseResources;
using Dongke.IBOSS.PRD.Client.CommonModule;
using Dongke.IBOSS.PRD.Client.Controls;
using Dongke.IBOSS.PRD.WCF.DataModels;
using Dongke.IBOSS.PRD.WCF.Proxys;
namespace Dongke.IBOSS.PRD.Client.PMModule
{
///
/// 变更条码
///
public partial class F_PM_0201 : DKFormBase
{
#region 构造函数
///
/// 变更条码
///
public F_PM_0201()
{
this.InitializeComponent();
this.Text = FormTitles.F_PM_0201;
this.btnSave.Text = ButtonText.BTN_SAVE;
this.btnSearch.Text = ButtonText.BTN_SEARCH;
this.btnClose.Text = ButtonText.BTN_CLOSE;
}
#endregion
#region 属性
///
/// 原条码
///
public string BarCode
{
get
{
return this.txtBarCode.Text;
}
set
{
this.txtBarCode.Text = value;
}
}
///
/// 新条码
///
public string NewBarCode
{
get
{
return this.txtNewBarCode.Text;
}
set
{
this.txtNewBarCode.Text = value;
}
}
///
/// 产品编码
///
public string GoodsCode
{
get
{
return this.txtGoodsCode.Text;
}
set
{
this.txtGoodsCode.Text = value;
}
}
#endregion 属性
#region 事件
///
/// 画面加载事件
///
///
///
private void F_PM_0201_Load(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(this.txtBarCode.Text))
{
this.txtNewBarCode.Focus();
}
}
///
/// 替换条码
///
private void btnSave_Click(object sender, EventArgs e)
{
string barCode = this.txtBarCode.Text.Trim();
string newBarCode = this.txtNewBarCode.Text.Trim();
string groutingusercode = this.txtGroutingUserCode.Text.Trim();
string goodscode = this.txtGoodsCode.Text.Trim();
try
{
if (string.IsNullOrWhiteSpace(groutingusercode))
{
DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_003, this.lblGroutingUserCode.Text);
this.txtGroutingUserCode.Focus();
return;
}
if (string.IsNullOrWhiteSpace(goodscode))
{
DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_003, this.lblBarCode.Text);
this.txtGoodsCode.Focus();
return;
}
if (string.IsNullOrWhiteSpace(barCode))
{
DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_003, this.lblBarCode.Text);
this.txtBarCode.Focus();
return;
}
if (string.IsNullOrWhiteSpace(newBarCode))
{
DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_003, this.lblNewBarCode.Text);
this.txtNewBarCode.Focus();
return;
}
if (newBarCode == barCode)
{
DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_004, this.lblNewBarCode.Text, this.lblBarCode.Text);
this.txtNewBarCode.Focus();
return;
}
ServiceResultEntity sre = this.DoAsync(() =>
{
return PMModuleProxyNew.Service.SetFPM0201Data(barCode, newBarCode, this.txtRemarks.Text, this.txtGroutingUserCode.Text,goodscode);
}
);
if (sre.Status == Constant.ServiceResultStatus.Success)
{
DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
this.DialogResult = DialogResult.OK;
//this.Close();
return;
}
if (sre.Status == Constant.ServiceResultStatus.Other)
{
DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, sre.Message);
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 查询原条码
///
///
///
private void btnSearch_Click(object sender, EventArgs e)
{
try
{
F_PM_0202 frmPM0202 = F_PM_0202.Instance;
frmPM0202.BarCode = this.txtBarCode.Text;
frmPM0202.GroutingUserCode = this.txtGroutingUserCode.Text;
frmPM0202.GoodsCodeText = this.txtGoodsCode.Text;
DialogResult dialogResult = frmPM0202.ShowDialog();
// 查询窗体返回值给控件赋值
if (dialogResult == DialogResult.OK)
{
this.txtBarCode.Text = frmPM0202.BarCode;
this.txtGoodsCode.Text = frmPM0202.GoodsCodeText;
if (!string.IsNullOrWhiteSpace(this.txtBarCode.Text))
{
this.txtNewBarCode.Focus();
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 输入原条码后,新条码获得焦点
///
///
///
private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == Constant.SYSTEM_KEYBOARD_ENTER_VALUE)
{
this.txtNewBarCode.Focus();
}
}
#endregion
}
}