/*******************************************************************************
* Copyright(c) 2017 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_PM_2403.cs
* 2.功能描述:撤销产成品交接
* 编辑履历:
* 作者 日期 版本 修改内容
* 王鑫 2017/02/10 1.00 新建
*******************************************************************************/
using System;
using System.Data;
using System.Reflection;
using System.Text;
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_2404 : DKFormBase
{
#region 成员变量
private string _currentbarcode = "";//当前产品条码
#endregion
#region 构造函数
public F_PM_2404()
{
InitializeComponent();
this.btnClose.Text = ButtonText.BTN_CLOSE;
this.btnSave.Text = ButtonText.BTN_SAVE;
this.Text = FormTitles.F_PM_2404;
}
#endregion
#region 事件
///
/// 保存按钮事件
///
///
///
private void btnSave_Click(object sender, EventArgs e)
{
try
{
if (this._currentbarcode.Trim() == "")
{
MessageBox.Show("产品条码不能为空", this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Information);
this.txtBarCode.Focus();
return;
}
if (this.cmbLogo.SelectedValue.ToString() == "-1")
{
MessageBox.Show("请选择生产订单",
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.cmbLogo.Focus();
return;
}
int orderid = Convert.ToInt32(this.cmbLogo.SelectedValue);
ServiceResultEntity returnValue = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.SaveChangeFinishedHandoverByBarcode(this._currentbarcode.Trim(), orderid);
}));
if (Convert.ToInt32(returnValue.Result) < 0)
{
MessageBox.Show(returnValue.Message, this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.txtBarCode.Focus();
this.txtBarCode.SelectAll();
return;
}
else if (Convert.ToInt32(returnValue.Result) > 0)
{
MessageBox.Show("变更单号成功", this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Information);
this.txtBarCode.Text = "";//成功后,直接下一个
this._currentbarcode = "";
this.btnSave.Visible = false;
this.txtProductionInfo.Text = "";
this.txtBarCode.Focus();
this.txtOrderNo.Text = "";
this.cmbLogo.SelectedValue = -1;
return;
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 回车符事件
///
///
///
private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e)
{
try
{
if (this.txtBarCode.ReadOnly)
{
return;
}
if ((int)e.KeyChar == 13) // 按了回车键
{
this.btnSave.Visible = false;
this.txtProductionInfo.Text = "";
if (this.txtBarCode.Text.Trim() == "")
{
MessageBox.Show("产品条码不能为空", this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.txtBarCode.Focus();
return;
}
//this._currentbarcode = this.txtBarCode.Text.Trim();
// 由产品条码获取注浆信息
ServiceResultEntity entity = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.CancelFinishedHandoverBarcode(this.txtBarCode.Text.Trim());
}));
if (Convert.ToInt32(entity.Result) > 0)
{
this._currentbarcode = entity.Data.Tables[0].Rows[0]["BarCode"].ToString();
this.txtProductionInfo.Text = "生产订单:" + entity.Data.Tables[0].Rows[0]["OrderNo"] + "\r\n\r\n";
this.txtProductionInfo.Text += "产品条码:" + this._currentbarcode + "\r\n\r\n";
this.txtProductionInfo.Text += "包装条码:" + entity.Data.Tables[0].Rows[0]["FinishedBarCode"] + "\r\n\r\n";
this.txtProductionInfo.Text += "产品编码:" + entity.Data.Tables[0].Rows[0]["GoodsCode"] + "\r\n\r\n";
this.txtProductionInfo.Text += "产品商标:" + entity.Data.Tables[0].Rows[0]["LogoName"] + "\r\n\r\n";
this.txtProductionInfo.Text += "成型工号:" + entity.Data.Tables[0].Rows[0]["GroutingUserCode"] + "\r\n\r\n";
this.txtProductionInfo.Text += "模具编号:" + entity.Data.Tables[0].Rows[0]["GroutingMouldCode"] + "\r\n\r\n";
this.txtProductionInfo.Text += "注浆日期:" + Convert.ToDateTime(entity.Data.Tables[0].Rows[0]["GroutingDate"]).ToString("yyyy-MM-dd") + "\r\n\r\n";
this.txtProductionInfo.Text += "交坯日期:" + Convert.ToDateTime(entity.Data.Tables[0].Rows[0]["DeliverTime"]).ToString("yyyy-MM-dd hh:mm:ss") + "\r\n\r\n";
this.cmbLogo.SelectedValue = entity.Data.Tables[0].Rows[0]["FHOrderID"];
this.btnSave.Visible = true;
}
else
{
MessageBox.Show(entity.Message, this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.txtBarCode.SelectAll();
return;
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 窗体加载数据
///
///
///
private void F_PM_2404_Load(object sender, EventArgs e)
{
// 加载订单数据源
DataSet dsResultLogo = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetOrderList(new OrderEntity());
}));
if (dsResultLogo != null && dsResultLogo.Tables[0].Rows.Count > 0)
{
DataView dv = dsResultLogo.Tables[0].DefaultView;
dv.RowFilter = "ValueFlag=1";
DataTable dtNew = dv.ToTable();
DataRow dr = dtNew.NewRow();
dr["OrderID"] = -1;
dr["OrderNo"] = string.Empty;
dtNew.Rows.InsertAt(dr, 0);
this.cmbLogo.DataSource = dtNew;
this.cmbLogo.ValueMember = "OrderID";
this.cmbLogo.DisplayMember = "OrderNo";
}
}
private void txtOrderNo_KeyPress(object sender, KeyPressEventArgs e)
{
try
{
if (this.txtOrderNo.ReadOnly)
{
return;
}
if ((int)e.KeyChar == 13) // 按了回车键
{
DataTable dt = this.cmbLogo.DataSource as DataTable;
if (dt != null && dt.Rows.Count > 0)
{
DataRow[] dr = dt.Select("OrderNo='" + this.txtOrderNo.Text.Trim() + "'");
if (dr.Length > 0)
{
this.cmbLogo.SelectedValue = Convert.ToInt32(dr[0]["OrderID"]);
}
else
{
this.cmbLogo.SelectedIndex = 0;
}
this.txtOrderNo.Text = string.Empty;
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
#endregion
}
}