/*******************************************************************************
* Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_PM_0503.cs
* 2.功能描述:撤销装车
* 编辑履历:
* 作者 日期 版本 修改内容
* 陈冰 2014/10/23 1.00 设计窗体布局
*******************************************************************************/
using System;
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.WCF.DataModels;
using Dongke.IBOSS.PRD.WCF.Proxys;
using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
namespace Dongke.IBOSS.PRD.Client.PMModule
{
///
/// 撤销装车
///
public partial class F_PM_0503 : FormBase
{
#region
//当前工序
int _procedureID = 0;
//保存标记
bool _SaveOKFlag = false;
#endregion
#region 构造
public F_PM_0503(int procedureID)
{
this._procedureID = procedureID;
InitializeComponent();
this.SetFromTitleInfo();
this.btnSave.Enabled = false;
this.txtBarcode.Focus();
}
public F_PM_0503(int procedureID,string barcode)
{
this._procedureID = procedureID;
InitializeComponent();
this.SetFromTitleInfo();
this.txtBarcode.Text = barcode;
this.btnSave.Enabled = false;
this.txtBarcode.SelectionStart = barcode.Length;
}
#endregion
#region 事件
///
/// 条码焦点离开事件
///
///
///
private void txtBarcode_Leave(object sender, System.EventArgs e)
{
}
///
/// 保存
///
///
///
private void btnSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(this.txtBarcode.Text.Trim()))
{
MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "条码", "条码"),
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
string err = (string)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.AddCancelLoadCar(this._procedureID, this.txtBarcode.Text.Trim());
}));
if (string.IsNullOrEmpty(err))
{
this._SaveOKFlag = true;
// 提示信息
MessageBox.Show(string.Format(Messages.MSG_CMN_I001, this.Text, "保存"),
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
// 清空文本框
this.CleanTextBox();
}
else
{
MessageBox.Show(err,
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 关闭
///
///
///
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 关闭窗体
///
///
///
private void F_PM_0503_FormClosing(object sender, FormClosingEventArgs e)
{
if (this._SaveOKFlag)
{
this.DialogResult = DialogResult.OK;
}
}
///
/// 条码回车事件
///
///
///
private void txtBarcode_KeyPress(object sender, KeyPressEventArgs e)
{
try
{
// 按了回车键
if ((int)e.KeyChar == Constant.SYSTEM_KEYBOARD_ENTER_VALUE)
{
this.CheckBarcode();
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
#endregion
#region 私有方法
///
/// 清空文本框
///
private void CleanTextBox()
{
this.txtBarcode.Text = string.Empty;
this.txtGoodsCode.Text = string.Empty;
this.txtGoodsName.Text = string.Empty;
this.txtKilnCarNo.Text = string.Empty;
this.txtBarcodeStatus.Text = string.Empty;
}
///
/// 设置窗体按钮的文本信息
///
private void SetFromTitleInfo()
{
this.Text = FormTitles.F_PM_0503;
this.btnSave.Text = ButtonText.BTN_SAVE;
this.btnCancel.Text = ButtonText.BTN_CANCEL;
}
///
/// 检验条码是否可以下车
///
private void CheckBarcode()
{
try
{
if (!string.IsNullOrEmpty(this.txtBarcode.Text.Trim()))
{
CheckCancelLoadCar checkCancelLoadCar = (CheckCancelLoadCar)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.CheckCancelLoadCar(this._procedureID, this.txtBarcode.Text.Trim());
}));
if (!string.IsNullOrEmpty(checkCancelLoadCar.ErrMsg))
{
this.txtBarcodeStatus.Text = checkCancelLoadCar.ErrMsg;
this.txtGoodsCode.Text = "";
this.txtGoodsName.Text = "";
this.txtKilnCarNo.Text = "";
this.btnSave.Enabled = false;
//this.btnCancel.Focus();
}
else
{
this.txtBarcodeStatus.Text = checkCancelLoadCar.ErrMsg;
this.btnSave.Enabled = true;
this.txtGoodsCode.Text = checkCancelLoadCar.GoodsCode;
this.txtGoodsName.Text = checkCancelLoadCar.GoodsName;
this.txtKilnCarNo.Text = checkCancelLoadCar.KilnCarCode;
}
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}