F_SAP_HEGII_0111.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. using Dongke.IBOSS.PRD.Basics.BaseControls;
  2. using Dongke.IBOSS.PRD.Basics.BaseResources;
  3. using Dongke.IBOSS.PRD.Client.CommonModule;
  4. using Dongke.IBOSS.PRD.Client.Controls;
  5. using Dongke.IBOSS.PRD.WCF.DataModels;
  6. using Dongke.IBOSS.PRD.WCF.Proxys;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.ComponentModel;
  10. using System.Data;
  11. using System.Drawing;
  12. using System.Linq;
  13. using System.Reflection;
  14. using System.Text;
  15. using System.Windows.Forms;
  16. namespace Dongke.IBOSS.PRD.Client.SAPDataModule.Hegii
  17. {
  18. public partial class F_SAP_HEGII_0111 : DKDockPanelBase
  19. {
  20. #region 成员变量
  21. private int _scrapid;
  22. #endregion
  23. #region 构造函数
  24. public F_SAP_HEGII_0111()
  25. {
  26. InitializeComponent();
  27. }
  28. public F_SAP_HEGII_0111(int scrapid)
  29. {
  30. InitializeComponent();
  31. if (scrapid == 0)
  32. {
  33. this.Text = "新建 ";
  34. }
  35. else
  36. {
  37. _scrapid = scrapid;
  38. this.Text = "编辑 ";
  39. }
  40. }
  41. #endregion
  42. #region 事件
  43. /// <summary>
  44. /// 加载页面
  45. /// </summary>
  46. /// <param name="sender"></param>
  47. /// <param name="e"></param>
  48. private void F_SAP_HEGII_0111_Load(object sender, EventArgs e)
  49. {
  50. try
  51. {
  52. //编辑加载数据
  53. if (_scrapid > 0)
  54. {
  55. ClientRequestEntity cre = new ClientRequestEntity();
  56. cre.NameSpace = "Hegii";
  57. cre.Name = "GetIDNRKScrap";
  58. cre.Properties["scrapid"] = _scrapid;
  59. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  60. {
  61. return SAPDataModuleProxy.Service.DoRequest(cre);
  62. });
  63. if (sre.Status == Constant.ServiceResultStatus.Success)
  64. {
  65. DataTable dt = sre.Data.Tables[0];
  66. if (dt != null && dt.Rows.Count > 0)
  67. {
  68. this.scbIdnrk.Text = dt.Rows[0]["idnrk"].ToString();
  69. this.txtIdnrkName.Text = dt.Rows[0]["idnrkname"].ToString();
  70. this.txtIdnrkOnlyCode.Text = dt.Rows[0]["idnrkonlycode"].ToString();
  71. this.txtMenge.Text = dt.Rows[0]["menge"].ToString();
  72. this.txtMeins.Text = dt.Rows[0]["meins"].ToString();
  73. this.txtCharg.Text = dt.Rows[0]["charg"].ToString();
  74. this.txtLgort.Text = dt.Rows[0]["lgort"].ToString();
  75. this.txtBarcode.Text = dt.Rows[0]["barcode"].ToString();
  76. this.txtMatnr.Text = dt.Rows[0]["matnr"].ToString();
  77. }
  78. }
  79. }
  80. }
  81. catch (Exception ex)
  82. {
  83. // 对异常进行共通处理
  84. ExceptionManager.HandleEventException(this.ToString(),
  85. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  86. }
  87. }
  88. /// <summary>
  89. /// 关闭
  90. /// </summary>
  91. /// <param name="sender"></param>
  92. /// <param name="e"></param>
  93. private void btnClose_Click(object sender, EventArgs e)
  94. {
  95. this.Close();
  96. }
  97. /// <summary>
  98. /// 保存
  99. /// </summary>
  100. /// <param name="sender"></param>
  101. /// <param name="e"></param>
  102. private void btnSave_Click(object sender, EventArgs e)
  103. {
  104. try
  105. {
  106. if (!CheckInputValidity())
  107. {
  108. return;
  109. }
  110. string IDNRK = this.scbIdnrk.Text.Trim();//组件编码
  111. string IDNRKNAME = this.txtIdnrkName.Text.Trim();//组件名称
  112. string MEINS = this.txtMeins.Text.Trim();//单位
  113. decimal MENGE = Convert.ToDecimal(this.txtMenge.Text.Trim());//数量
  114. string IDNRKONLYCODE = this.txtIdnrkOnlyCode.Text.Trim();//唯一编码
  115. string CHARG = this.txtCharg.Text.Trim();//批次
  116. string LGORT = this.txtLgort.Text.Trim();//库存地点
  117. string BARCODE = this.txtBarcode.Text.Trim();//产品条码
  118. string MATNR = this.txtMatnr.Text.Trim();//物料编码
  119. // 调用服务器端获取数据集
  120. ClientRequestEntity cre = new ClientRequestEntity();
  121. cre.NameSpace = "Hegii";
  122. if (_scrapid > 0)
  123. {
  124. cre.Name = "UpdateIDNRKScrap";
  125. cre.Properties["scrapid"] = _scrapid;
  126. }
  127. else
  128. {
  129. cre.Name = "AddIDNRKScrap";
  130. }
  131. cre.Properties["IDNRK"] = IDNRK;
  132. cre.Properties["IDNRKNAME"] = IDNRKNAME;
  133. cre.Properties["MEINS"] = MEINS;
  134. cre.Properties["MENGE"] = MENGE;
  135. cre.Properties["IDNRKONLYCODE"] = IDNRKONLYCODE;
  136. cre.Properties["CHARG"] = CHARG;
  137. cre.Properties["LGORT"] = LGORT;
  138. cre.Properties["BARCODE"] = BARCODE;
  139. cre.Properties["MATNR"] = MATNR;
  140. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  141. {
  142. return SAPDataModuleProxy.Service.DoRequest(cre);
  143. });
  144. if (sre.Status == Constant.ServiceResultStatus.Success)
  145. {
  146. if (sre.OtherStatus > 0)
  147. {
  148. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "组件报损", "保存"),
  149. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  150. this.DialogResult = DialogResult.OK;
  151. }
  152. else
  153. {
  154. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, sre.Message);
  155. return;
  156. }
  157. }
  158. }
  159. catch (Exception ex)
  160. {
  161. // 对异常进行共通处理
  162. ExceptionManager.HandleEventException(this.ToString(),
  163. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  164. }
  165. }
  166. /// <summary>
  167. /// 编码改变事件
  168. /// </summary>
  169. /// <param name="sender"></param>
  170. /// <param name="e"></param>
  171. private void scbIdnrk_TextValueChanged(object sender, WinForm.Controls.ScbSearchBox.TextChangeEventArgs e)
  172. {
  173. try
  174. {
  175. if (!string.IsNullOrEmpty(scbIdnrk.Text.Trim()))
  176. {
  177. ClientRequestEntity cre = new ClientRequestEntity();
  178. cre.NameSpace = "Hegii";
  179. cre.Name = "GetIdnrkCode";
  180. cre.Properties["IDNRK"] = this.scbIdnrk.Text.Trim();
  181. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  182. {
  183. return SAPDataModuleProxy.Service.DoRequest(cre);
  184. });
  185. if (sre.Status == Constant.ServiceResultStatus.Success)
  186. {
  187. this.txtIdnrkName.Text = sre.Data.Tables[0].Rows[0]["IDNRKNAME"].ToString();
  188. this.txtMeins.Text = sre.Data.Tables[0].Rows[0]["MEINS"].ToString();
  189. }
  190. }
  191. }
  192. catch (Exception ex)
  193. {
  194. // 对异常进行共通处理
  195. ExceptionManager.HandleEventException(this.ToString(),
  196. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  197. }
  198. }
  199. #endregion
  200. #region 私有方法
  201. /// <summary>
  202. /// 报存数据校验
  203. /// </summary>
  204. /// <returns></returns>
  205. private bool CheckInputValidity()
  206. {
  207. if (string.IsNullOrEmpty(this.scbIdnrk.Text.Trim()))
  208. {
  209. return false;
  210. }
  211. if (string.IsNullOrEmpty(this.txtMenge.Text.Trim()))
  212. {
  213. this.txtMenge.Focus();
  214. return false;
  215. }
  216. if (string.IsNullOrEmpty(this.txtLgort.Text.Trim()))
  217. {
  218. this.txtLgort.IsMustInput = true;
  219. this.txtLgort.Focus();
  220. return false;
  221. }
  222. this.txtLgort.IsMustInput = false;
  223. return true;
  224. }
  225. #endregion
  226. private void txtMenge_KeyPress_1(object sender, KeyPressEventArgs e)
  227. {
  228. //如果输入的不是退格和数字,则屏蔽输入
  229. if (!(e.KeyChar == 8 || (e.KeyChar >= 48 && e.KeyChar <= 57)))
  230. {
  231. e.Handled = true;
  232. }
  233. }
  234. }
  235. }