/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_PM_3302.cs * 2.功能描述:新建/编辑产品废弃信息窗体 * 编辑履历: * 作者 日期 版本 修改内容 * 付斌 2020/11/06 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.WCF.DataModels; using Dongke.IBOSS.PRD.WCF.Proxys; namespace Dongke.IBOSS.PRD.Client.PMModule { /// /// 编辑产品废弃信息窗体 /// public partial class F_PM_3302 : FormBase { #region 属性 /// /// 窗体模式 /// public Constant.FormMode FormType { get; set; } #endregion #region 构造函数 /// /// 窗体构造 /// public F_PM_3302() { InitializeComponent(); btnSave.Text = ButtonText.BTN_SAVE; btnCancel.Text = ButtonText.BTN_CLOSE; } #endregion #region 事件 /// /// 窗体加载 /// /// /// private void F_PM_3302_Load(object sender, EventArgs e) { try { dgvBarcode.AutoGenerateColumns = false; if (FormType == Constant.FormMode.Add) { // 调出原因 DataSet dsRreason = (DataSet)DoAsync(new BaseAsyncMethod(() => { return SystemModuleProxy.Service.GetDictionaryData(0, "TPC009"); })); cmbRreason.DisplayMember = "DictionaryValue"; cmbRreason.ValueMember = "DictionaryID"; cmbRreason.DataSource = dsRreason.Tables[0]; } else if (FormType == Constant.FormMode.Edit) { Text = "工厂调出撤销"; cmbRreason.Enabled = false; } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, Text, ex); } } /// /// 提交操作 /// /// /// private void btnSave_Click(object sender, EventArgs e) { try { txtRemarks.Focus();//把光标移开,由于删除工号后,值未变 DataTable dtBarcode = dgvBarcode.DataSource as DataTable; dtBarcode?.AcceptChanges(); if (dtBarcode == null || dtBarcode.Rows.Count == 0) { MessageBox.Show("没有选择任何条码", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); txtBarCode.Focus(); return; } if (FormType == Constant.FormMode.Add) { if (cmbRreason.Text == string.Empty) { MessageBox.Show("调出类型必须填写!", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); return; } // 异步处理 ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "F_PM_3302"; cre.Name = "SaveAllocateOut"; cre.Properties["rreason"] = cmbRreason.Text.Trim(); cre.Properties["remarks"] = txtRemarks.Text.Trim(); cre.Data = new DataSet(); cre.Data.Tables.Add(dtBarcode.Copy()); ServiceResultEntity sre = (ServiceResultEntity)DoAsync( () => { return PMModuleProxyNew.Service.HandleRequest(cre); }); if (sre.OtherStatus > 0) { MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "工厂调出", "保存"), Text, MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; } else if (sre.OtherStatus < 0 && !string.IsNullOrEmpty(sre.Message)) { MessageBox.Show(string.Format(Messages.MSG_CMN_W007, sre.Message), Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "工厂调出", "保存"), Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else if (FormType == Constant.FormMode.Edit) { // 异步处理 ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "F_PM_3302"; cre.Name = "CancelAllocateOut"; cre.Data = new DataSet(); cre.Data.Tables.Add(dtBarcode.Copy()); ServiceResultEntity sre = (ServiceResultEntity)DoAsync( () => { return PMModuleProxyNew.Service.HandleRequest(cre); }); if (sre.OtherStatus > 0) { MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "工厂调出撤销", "保存"), Text, MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; } else if (sre.OtherStatus < 0 && !string.IsNullOrEmpty(sre.Message)) { MessageBox.Show(string.Format(Messages.MSG_CMN_W007, sre.Message), Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "工厂调出撤销", "保存"), Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, Text, ex); } } /// /// 条码回车事件 /// /// /// private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e) { try { if ((int)e.KeyChar == 13) // 按了回车键 { string barcode = txtBarCode.Text.Trim(); if (!string.IsNullOrEmpty(barcode)) { DataTable dtBarcode = dgvBarcode.DataSource as DataTable; if (dtBarcode != null) { DataRow[] rows = dtBarcode.Select("Barcode = '" + barcode + "'"); if (rows.Length > 0) { MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "当前编码在列表中已存在"), Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } // 异步处理 ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "F_PM_3302"; cre.Name = "CheckAllocateOut"; cre.Data = new DataSet(); cre.Properties["Barcode"] = barcode; cre.Properties["OutFlag"] = FormType == Constant.FormMode.Add ? 1 : 0; ServiceResultEntity sre = (ServiceResultEntity)DoAsync( () => { return PMModuleProxyNew.Service.HandleRequest(cre); }); if (sre.OtherStatus < 0 && !string.IsNullOrEmpty(sre.Message)) { MessageBox.Show(string.Format(Messages.MSG_CMN_W007, sre.Message), Text, MessageBoxButtons.OK, MessageBoxIcon.Information); txtBarCode.Clear(); return; } if (sre.Data != null && sre.Data.Tables[0].Rows.Count > 0) { if (dtBarcode == null) { dgvBarcode.DataSource = sre.Data.Tables[0]; } else { DataRow row = dtBarcode.NewRow(); row.ItemArray = sre.Data.Tables[0].Rows[0].ItemArray; dtBarcode.Rows.Add(row); } } txtBarCode.Clear(); } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, Text, ex); } } /// /// 窗体关闭 /// /// /// private void btnCancel_Click(object sender, EventArgs e) { Close(); } #endregion } }