| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- /*******************************************************************************
- * 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
- {
- /// <summary>
- /// 编辑产品废弃信息窗体
- /// </summary>
- public partial class F_PM_3302 : FormBase
- {
- #region 属性
- /// <summary>
- /// 窗体模式
- /// </summary>
- public Constant.FormMode FormType
- {
- get;
- set;
- }
- #endregion
- #region 构造函数
- /// <summary>
- /// 窗体构造
- /// </summary>
- public F_PM_3302()
- {
- InitializeComponent();
- btnSave.Text = ButtonText.BTN_SAVE;
- btnCancel.Text = ButtonText.BTN_CLOSE;
- }
- #endregion
- #region 事件
- /// <summary>
- /// 窗体加载
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- }
- /// <summary>
- /// 提交操作
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- }
- /// <summary>
- /// 条码回车事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- }
- /// <summary>
- /// 窗体关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnCancel_Click(object sender, EventArgs e)
- {
- Close();
- }
- #endregion
- }
- }
|