F_PM_2106.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_2106.cs
  5. * 2.功能描述:损坯撤销
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2015/06/13 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Reflection;
  13. using System.Text;
  14. using System.Windows.Forms;
  15. using Dongke.IBOSS.PRD.Basics.BaseControls;
  16. using Dongke.IBOSS.PRD.Basics.BaseResources;
  17. using Dongke.IBOSS.PRD.Client.CommonModule;
  18. using Dongke.IBOSS.PRD.Client.Controls;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. namespace Dongke.IBOSS.PRD.Client.PMModule
  22. {
  23. public partial class F_PM_2106 : DKFormBase
  24. {
  25. #region 成员变量
  26. private string _currentbarcode = "";//当前产品条码
  27. #endregion
  28. #region 构造函数
  29. public F_PM_2106()
  30. {
  31. InitializeComponent();
  32. this.btnClose.Text = ButtonText.BTN_CLOSE;
  33. this.btnSave.Text = ButtonText.BTN_SAVE;
  34. this.Text = FormTitles.F_PM_2106;
  35. }
  36. #endregion
  37. #region 事件
  38. /// <summary>
  39. /// 保存按钮事件
  40. /// </summary>
  41. /// <param name="sender"></param>
  42. /// <param name="e"></param>
  43. private void btnSave_Click(object sender, EventArgs e)
  44. {
  45. //try
  46. //{
  47. // if (this.txtBarCode.Text.Trim() == "")
  48. // {
  49. // MessageBox.Show("产品条码不能为空", this.Text,
  50. // MessageBoxButtons.OK, MessageBoxIcon.Information);
  51. // this.txtBarCode.Focus();
  52. // return;
  53. // }
  54. // int returnValue = (int)DoAsync(new BaseAsyncMethod(() =>
  55. // {
  56. // return PMModuleProxy.Service.AddChancelFinishedproduct(this.txtBarCode.Text.Trim());
  57. // }));
  58. // if (returnValue == -1)
  59. // {
  60. // MessageBox.Show("此产品没有损坯,不能撤销", this.Text,
  61. // MessageBoxButtons.OK, MessageBoxIcon.Information);
  62. // this.txtBarCode.SelectAll();
  63. // return;
  64. // }
  65. // else if (returnValue == 0)
  66. // {
  67. // MessageBox.Show("损坯撤销失败", this.Text,
  68. // MessageBoxButtons.OK, MessageBoxIcon.Information);
  69. // this.txtBarCode.SelectAll();
  70. // return;
  71. // }
  72. // else if (returnValue > 0)
  73. // {
  74. // MessageBox.Show("损坯撤销成功", this.Text,
  75. // MessageBoxButtons.OK, MessageBoxIcon.Information);
  76. // this.txtBarCode.Text = "";//成功后,直接下一个
  77. // return;
  78. // }
  79. //}
  80. //catch (Exception ex)
  81. //{
  82. // // 对异常进行共通处理
  83. // ExceptionManager.HandleEventException(this.ToString(),
  84. // System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  85. //}
  86. try
  87. {
  88. if (this._currentbarcode.Trim() == "")
  89. {
  90. MessageBox.Show("产品条码不能为空", this.Text,
  91. MessageBoxButtons.OK, MessageBoxIcon.Information);
  92. this.txtBarCode.Focus();
  93. return;
  94. }
  95. ServiceResultEntity returnValue = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
  96. {
  97. return PMModuleProxy.Service.AddCancelScrapProduction(this._currentbarcode.Trim());
  98. }));
  99. if (Convert.ToInt32(returnValue.Result) == -1)
  100. {
  101. MessageBox.Show("此产品没有损坯,不能撤销", this.Text,
  102. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  103. this.txtBarCode.Focus();
  104. this.txtBarCode.SelectAll();
  105. return;
  106. }
  107. else if (Convert.ToInt32(returnValue.Result) == 0)
  108. {
  109. MessageBox.Show("损坯撤销失败", this.Text,
  110. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  111. this.txtBarCode.Focus();
  112. this.txtBarCode.SelectAll();
  113. return;
  114. }
  115. else if (Convert.ToInt32(returnValue.Result) == -200)
  116. {
  117. MessageBox.Show(returnValue.Message, this.Text,
  118. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  119. this.txtBarCode.Focus();
  120. this.txtBarCode.SelectAll();
  121. return;
  122. }
  123. else if (Convert.ToInt32(returnValue.Result) > 0)
  124. {
  125. MessageBox.Show("损坯撤销成功", this.Text,
  126. MessageBoxButtons.OK, MessageBoxIcon.Information);
  127. this.txtBarCode.Text = "";//成功后,直接下一个
  128. this._currentbarcode = "";
  129. this.btnSave.Visible = false;
  130. this.txtProductionInfo.Text = "";
  131. return;
  132. }
  133. }
  134. catch (Exception ex)
  135. {
  136. // 对异常进行共通处理
  137. ExceptionManager.HandleEventException(this.ToString(),
  138. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  139. }
  140. }
  141. /// <summary>
  142. /// 回车符事件
  143. /// </summary>
  144. /// <param name="sender"></param>
  145. /// <param name="e"></param>
  146. private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e)
  147. {
  148. //try
  149. //{
  150. // if (this.txtBarCode.ReadOnly)
  151. // {
  152. // return;
  153. // }
  154. // if ((int)e.KeyChar == 13) // 按了回车键
  155. // {
  156. // if (this.txtBarCode.Text.Trim() == "")
  157. // {
  158. // MessageBox.Show("产品条码不能为空", this.Text,
  159. // MessageBoxButtons.OK, MessageBoxIcon.Information);
  160. // this.txtBarCode.Focus();
  161. // return;
  162. // }
  163. // int returnValue = (int)DoAsync(new BaseAsyncMethod(() =>
  164. // {
  165. // return PMModuleProxy.Service.AddCancelScrapProduction(this.txtBarCode.Text.Trim());
  166. // }));
  167. // if (returnValue == -1)
  168. // {
  169. // MessageBox.Show("此产品没有损坯,不能撤销", this.Text,
  170. // MessageBoxButtons.OK, MessageBoxIcon.Information);
  171. // this.txtBarCode.SelectAll();
  172. // return;
  173. // }
  174. // else if (returnValue == 0)
  175. // {
  176. // MessageBox.Show("损坯撤销失败", this.Text,
  177. // MessageBoxButtons.OK, MessageBoxIcon.Information);
  178. // this.txtBarCode.SelectAll();
  179. // return;
  180. // }
  181. // else if (returnValue > 0)
  182. // {
  183. // MessageBox.Show("损坯撤销成功", this.Text,
  184. // MessageBoxButtons.OK, MessageBoxIcon.Information);
  185. // this.txtBarCode.Text = "";//成功后,直接下一个
  186. // return;
  187. // }
  188. // }
  189. //}
  190. //catch (Exception ex)
  191. //{
  192. // // 对异常进行共通处理
  193. // ExceptionManager.HandleEventException(this.ToString(),
  194. // System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  195. //}
  196. try
  197. {
  198. if (this.txtBarCode.ReadOnly)
  199. {
  200. return;
  201. }
  202. if ((int)e.KeyChar == 13) // 按了回车键
  203. {
  204. this.btnSave.Visible = false;
  205. this.txtProductionInfo.Text = "";
  206. if (this.txtBarCode.Text.Trim() == "")
  207. {
  208. MessageBox.Show("产品条码不能为空", this.Text,
  209. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  210. this.txtBarCode.Focus();
  211. return;
  212. }
  213. this._currentbarcode = this.txtBarCode.Text.Trim();
  214. // 由产品条码获取注浆信息
  215. DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  216. {
  217. return PMModuleProxy.Service.GetGroutingInfoBybarcode(this.txtBarCode.Text.Trim());
  218. }));
  219. if (dsGroutingProduct != null && dsGroutingProduct.Tables[0].Rows.Count > 0)
  220. {
  221. this.txtProductionInfo.Text = "产品编码:" + dsGroutingProduct.Tables[0].Rows[0]["GoodsCode"] + "\r\n\r\n";
  222. this.txtProductionInfo.Text += "成型工号:" + dsGroutingProduct.Tables[0].Rows[0]["UserCode"] + "\r\n\r\n";
  223. this.txtProductionInfo.Text += "注浆日期:" + Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]).ToString("yyyy-MM-dd") + "\r\n\r\n";
  224. this.txtProductionInfo.Text += "模具编码:" + dsGroutingProduct.Tables[0].Rows[0]["GroutingMouldCode"] + "\r\n\r\n";
  225. this.btnSave.Visible = true;
  226. }
  227. else
  228. {
  229. MessageBox.Show("产品条码无效", this.Text,
  230. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  231. this.txtBarCode.SelectAll();
  232. return;
  233. }
  234. }
  235. }
  236. catch (Exception ex)
  237. {
  238. // 对异常进行共通处理
  239. ExceptionManager.HandleEventException(this.ToString(),
  240. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  241. }
  242. }
  243. #endregion
  244. }
  245. }