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; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Reflection; using System.Text; using System.Windows.Forms; namespace Dongke.IBOSS.PRD.Client.SAPDataModule.Hegii { public partial class F_SAP_HEGII_0111 : DKDockPanelBase { #region 成员变量 private int _scrapid; #endregion #region 构造函数 public F_SAP_HEGII_0111() { InitializeComponent(); } public F_SAP_HEGII_0111(int scrapid) { InitializeComponent(); if (scrapid == 0) { this.Text = "新建 "; } else { _scrapid = scrapid; this.Text = "编辑 "; } } #endregion #region 事件 /// /// 加载页面 /// /// /// private void F_SAP_HEGII_0111_Load(object sender, EventArgs e) { try { //编辑加载数据 if (_scrapid > 0) { ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "Hegii"; cre.Name = "GetIDNRKScrap"; cre.Properties["scrapid"] = _scrapid; ServiceResultEntity sre = DoAsync(() => { return SAPDataModuleProxy.Service.DoRequest(cre); }); if (sre.Status == Constant.ServiceResultStatus.Success) { DataTable dt = sre.Data.Tables[0]; if (dt != null && dt.Rows.Count > 0) { this.scbIdnrk.Text = dt.Rows[0]["idnrk"].ToString(); this.txtIdnrkName.Text = dt.Rows[0]["idnrkname"].ToString(); this.txtIdnrkOnlyCode.Text = dt.Rows[0]["idnrkonlycode"].ToString(); this.txtMenge.Text = dt.Rows[0]["menge"].ToString(); this.txtMeins.Text = dt.Rows[0]["meins"].ToString(); this.txtCharg.Text = dt.Rows[0]["charg"].ToString(); this.txtLgort.Text = dt.Rows[0]["lgort"].ToString(); this.txtBarcode.Text = dt.Rows[0]["barcode"].ToString(); this.txtMatnr.Text = dt.Rows[0]["matnr"].ToString(); } } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 关闭 /// /// /// private void btnClose_Click(object sender, EventArgs e) { this.Close(); } /// /// 保存 /// /// /// private void btnSave_Click(object sender, EventArgs e) { try { if (!CheckInputValidity()) { return; } string IDNRK = this.scbIdnrk.Text.Trim();//组件编码 string IDNRKNAME = this.txtIdnrkName.Text.Trim();//组件名称 string MEINS = this.txtMeins.Text.Trim();//单位 decimal MENGE = Convert.ToDecimal(this.txtMenge.Text.Trim());//数量 string IDNRKONLYCODE = this.txtIdnrkOnlyCode.Text.Trim();//唯一编码 string CHARG = this.txtCharg.Text.Trim();//批次 string LGORT = this.txtLgort.Text.Trim();//库存地点 string BARCODE = this.txtBarcode.Text.Trim();//产品条码 string MATNR = this.txtMatnr.Text.Trim();//物料编码 // 调用服务器端获取数据集 ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "Hegii"; if (_scrapid > 0) { cre.Name = "UpdateIDNRKScrap"; cre.Properties["scrapid"] = _scrapid; } else { cre.Name = "AddIDNRKScrap"; } cre.Properties["IDNRK"] = IDNRK; cre.Properties["IDNRKNAME"] = IDNRKNAME; cre.Properties["MEINS"] = MEINS; cre.Properties["MENGE"] = MENGE; cre.Properties["IDNRKONLYCODE"] = IDNRKONLYCODE; cre.Properties["CHARG"] = CHARG; cre.Properties["LGORT"] = LGORT; cre.Properties["BARCODE"] = BARCODE; cre.Properties["MATNR"] = MATNR; ServiceResultEntity sre = DoAsync(() => { return SAPDataModuleProxy.Service.DoRequest(cre); }); if (sre.Status == Constant.ServiceResultStatus.Success) { if (sre.OtherStatus > 0) { MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "组件报损", "保存"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; } else { DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, sre.Message); return; } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 编码改变事件 /// /// /// private void scbIdnrk_TextValueChanged(object sender, WinForm.Controls.ScbSearchBox.TextChangeEventArgs e) { try { if (!string.IsNullOrEmpty(scbIdnrk.Text.Trim())) { ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "Hegii"; cre.Name = "GetIdnrkCode"; cre.Properties["IDNRK"] = this.scbIdnrk.Text.Trim(); ServiceResultEntity sre = DoAsync(() => { return SAPDataModuleProxy.Service.DoRequest(cre); }); if (sre.Status == Constant.ServiceResultStatus.Success) { this.txtIdnrkName.Text = sre.Data.Tables[0].Rows[0]["IDNRKNAME"].ToString(); this.txtMeins.Text = sre.Data.Tables[0].Rows[0]["MEINS"].ToString(); } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), MethodBase.GetCurrentMethod().Name, this.Text, ex); } } #endregion #region 私有方法 /// /// 报存数据校验 /// /// private bool CheckInputValidity() { if (string.IsNullOrEmpty(this.scbIdnrk.Text.Trim())) { return false; } if (string.IsNullOrEmpty(this.txtMenge.Text.Trim())) { this.txtMenge.Focus(); return false; } if (string.IsNullOrEmpty(this.txtLgort.Text.Trim())) { this.txtLgort.IsMustInput = true; this.txtLgort.Focus(); return false; } this.txtLgort.IsMustInput = false; return true; } #endregion private void txtMenge_KeyPress_1(object sender, KeyPressEventArgs e) { //如果输入的不是退格和数字,则屏蔽输入 if (!(e.KeyChar == 8 || (e.KeyChar >= 48 && e.KeyChar <= 57))) { e.Handled = true; } } } }