F_PM_2801.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_2801.cs
  5. * 2.功能描述:撤销成型报损
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 周兴 2018/03/30 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Windows.Forms;
  13. using Dongke.IBOSS.PRD.Basics.BaseControls;
  14. using Dongke.IBOSS.PRD.Basics.BaseResources;
  15. using Dongke.IBOSS.PRD.Client.CommonModule;
  16. using Dongke.IBOSS.PRD.Client.Controls;
  17. using Dongke.IBOSS.PRD.WCF.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.Proxys;
  19. namespace Dongke.IBOSS.PRD.Client.PMModule
  20. {
  21. public partial class F_PM_2801 : DKFormBase
  22. {
  23. #region 成员变量
  24. // 当前产品条码
  25. private string _currentbarcode = "";
  26. #endregion
  27. #region 属性
  28. public string CurrentBarCode
  29. {
  30. get
  31. {
  32. return _currentbarcode;
  33. }
  34. set
  35. {
  36. this.txtBarCode.Text = value;
  37. // 获取产品条码信息
  38. GetBarCodeInfo();
  39. _currentbarcode = value;
  40. }
  41. }
  42. #endregion
  43. #region 构造函数
  44. public F_PM_2801()
  45. {
  46. InitializeComponent();
  47. this.btnClose.Text = ButtonText.BTN_CLOSE;
  48. this.btnSave.Text = ButtonText.BTN_SAVE;
  49. this.Text = FormTitles.F_PM_2801;
  50. }
  51. #endregion
  52. #region 事件
  53. /// <summary>
  54. /// 保存按钮事件
  55. /// </summary>
  56. /// <param name="sender"></param>
  57. /// <param name="e"></param>
  58. private void btnSave_Click(object sender, EventArgs e)
  59. {
  60. try
  61. {
  62. if (string.IsNullOrWhiteSpace(this._currentbarcode))
  63. {
  64. MessageBox.Show("产品条码不能为空", this.Text,
  65. MessageBoxButtons.OK, MessageBoxIcon.Information);
  66. this.txtBarCode.Focus();
  67. return;
  68. }
  69. ClientRequestEntity cre = new ClientRequestEntity();
  70. cre.NameSpace = "GroutingScrapProduct";
  71. cre.Name = "ReverseGroutingScrapProduct";
  72. cre.Properties["BarCode"] = this._currentbarcode.Trim();
  73. ServiceResultEntity result = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
  74. {
  75. return PMModuleProxyNew.Service.HandleRequest(cre);
  76. }));
  77. int resultRow = (int)result.Result;
  78. if (resultRow > Constant.INT_IS_ZERO)
  79. {
  80. //成功
  81. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "成型报损", "撤销"),
  82. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  83. this.txtBarCode.Text = "";//成功后,直接下一个
  84. this._currentbarcode = "";
  85. this.btnSave.Visible = false;
  86. this.txtProductionInfo.Text = "";
  87. }
  88. else if (resultRow == -99)
  89. {
  90. MessageBox.Show(string.Format(Messages.W_CMN_C_006, "此产品没有损坯或已被撤销,不能撤销"),
  91. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  92. this.txtBarCode.Focus();
  93. this.txtBarCode.SelectAll();
  94. return;
  95. }
  96. else if (resultRow == -100)
  97. {
  98. MessageBox.Show(string.Format(Messages.W_CMN_C_006, "此产品已经撤销"),
  99. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  100. this.txtBarCode.Focus();
  101. this.txtBarCode.SelectAll();
  102. return;
  103. }
  104. else
  105. {
  106. //失败
  107. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "成型报损", "撤销"),
  108. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  109. }
  110. }
  111. catch (Exception ex)
  112. {
  113. // 对异常进行共通处理
  114. ExceptionManager.HandleEventException(this.ToString(),
  115. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  116. }
  117. }
  118. /// <summary>
  119. /// 回车符事件
  120. /// </summary>
  121. /// <param name="sender"></param>
  122. /// <param name="e"></param>
  123. private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e)
  124. {
  125. try
  126. {
  127. if (this.txtBarCode.ReadOnly)
  128. {
  129. return;
  130. }
  131. if ((int)e.KeyChar == 13) // 按了回车键
  132. {
  133. GetBarCodeInfo();
  134. }
  135. }
  136. catch (Exception ex)
  137. {
  138. // 对异常进行共通处理
  139. ExceptionManager.HandleEventException(this.ToString(),
  140. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  141. }
  142. }
  143. #endregion
  144. #region 私有方法
  145. /// <summary>
  146. /// 获取产品条码信息
  147. /// </summary>
  148. private void GetBarCodeInfo()
  149. {
  150. try
  151. {
  152. this.btnSave.Visible = false;
  153. this.txtProductionInfo.Text = "";
  154. if (this.txtBarCode.Text.Trim() == "")
  155. {
  156. MessageBox.Show("产品条码不能为空", this.Text,
  157. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  158. this.txtBarCode.Focus();
  159. return;
  160. }
  161. this._currentbarcode = this.txtBarCode.Text.Trim();
  162. ClientRequestEntity cre = new ClientRequestEntity();
  163. cre.NameSpace = "GroutingScrapProduct";
  164. cre.Name = "GetGroutingDailyDetail";
  165. cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
  166. ServiceResultEntity result = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
  167. {
  168. return PMModuleProxyNew.Service.HandleRequest(cre);
  169. }));
  170. if (result == null || result.Data == null || result.Data.Tables.Count == 0
  171. || result.Data.Tables[0].Rows.Count == 0)
  172. {
  173. MessageBox.Show("产品条码无效", this.Text,
  174. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  175. this.txtBarCode.SelectAll();
  176. }
  177. else
  178. {
  179. DataRow row = result.Data.Tables[0].Rows[0];
  180. this.txtProductionInfo.Text = "产品编码:" + row["GoodsCode"] + "\r\n\r\n";
  181. this.txtProductionInfo.Text += "成型工号:" + row["GroutingUserCode"] + "\r\n\r\n";
  182. this.txtProductionInfo.Text += "注浆日期:" + Convert.ToDateTime(row["GroutingDate"]).ToString("yyyy-MM-dd") + "\r\n\r\n";
  183. this.txtProductionInfo.Text += "模具编码:" + row["GroutingMouldCode"] + "\r\n\r\n";
  184. this.btnSave.Visible = true;
  185. }
  186. }
  187. catch (Exception ex)
  188. {
  189. throw ex;
  190. }
  191. }
  192. #endregion
  193. }
  194. }