/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_PM_2801.cs * 2.功能描述:撤销成型报损 * 编辑履历: * 作者 日期 版本 修改内容 * 周兴 2018/03/30 1.00 新建 *******************************************************************************/ using System; using System.Data; 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_2801 : DKFormBase { #region 成员变量 // 当前产品条码 private string _currentbarcode = ""; #endregion #region 属性 public string CurrentBarCode { get { return _currentbarcode; } set { this.txtBarCode.Text = value; // 获取产品条码信息 GetBarCodeInfo(); _currentbarcode = value; } } #endregion #region 构造函数 public F_PM_2801() { InitializeComponent(); this.btnClose.Text = ButtonText.BTN_CLOSE; this.btnSave.Text = ButtonText.BTN_SAVE; this.Text = FormTitles.F_PM_2801; } #endregion #region 事件 /// /// 保存按钮事件 /// /// /// private void btnSave_Click(object sender, EventArgs e) { try { if (string.IsNullOrWhiteSpace(this._currentbarcode)) { MessageBox.Show("产品条码不能为空", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); this.txtBarCode.Focus(); return; } ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "GroutingScrapProduct"; cre.Name = "ReverseGroutingScrapProduct"; cre.Properties["BarCode"] = this._currentbarcode.Trim(); ServiceResultEntity result = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() => { return PMModuleProxyNew.Service.HandleRequest(cre); })); int resultRow = (int)result.Result; if (resultRow > Constant.INT_IS_ZERO) { //成功 MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "成型报损", "撤销"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); this.txtBarCode.Text = "";//成功后,直接下一个 this._currentbarcode = ""; this.btnSave.Visible = false; this.txtProductionInfo.Text = ""; } else if (resultRow == -99) { MessageBox.Show(string.Format(Messages.W_CMN_C_006, "此产品没有损坯或已被撤销,不能撤销"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.txtBarCode.Focus(); this.txtBarCode.SelectAll(); return; } else if (resultRow == -100) { MessageBox.Show(string.Format(Messages.W_CMN_C_006, "此产品已经撤销"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.txtBarCode.Focus(); this.txtBarCode.SelectAll(); return; } else { //失败 MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "成型报损", "撤销"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } 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) // 按了回车键 { GetBarCodeInfo(); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } #endregion #region 私有方法 /// /// 获取产品条码信息 /// private void GetBarCodeInfo() { try { 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(); ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "GroutingScrapProduct"; cre.Name = "GetGroutingDailyDetail"; cre.Properties["BarCode"] = this.txtBarCode.Text.Trim(); ServiceResultEntity result = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() => { return PMModuleProxyNew.Service.HandleRequest(cre); })); if (result == null || result.Data == null || result.Data.Tables.Count == 0 || result.Data.Tables[0].Rows.Count == 0) { MessageBox.Show("产品条码无效", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.txtBarCode.SelectAll(); } else { DataRow row = result.Data.Tables[0].Rows[0]; this.txtProductionInfo.Text = "产品编码:" + row["GoodsCode"] + "\r\n\r\n"; this.txtProductionInfo.Text += "成型工号:" + row["GroutingUserCode"] + "\r\n\r\n"; this.txtProductionInfo.Text += "注浆日期:" + Convert.ToDateTime(row["GroutingDate"]).ToString("yyyy-MM-dd") + "\r\n\r\n"; this.txtProductionInfo.Text += "模具编码:" + row["GroutingMouldCode"] + "\r\n\r\n"; this.btnSave.Visible = true; } } catch (Exception ex) { throw ex; } } #endregion } }