F_PM_0503.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_0503.cs
  5. * 2.功能描述:撤销装车
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈冰 2014/10/23 1.00 设计窗体布局
  9. *******************************************************************************/
  10. using System;
  11. using System.Windows.Forms;
  12. using Dongke.IBOSS.PRD.Basics.BaseControls;
  13. using Dongke.IBOSS.PRD.Basics.BaseResources;
  14. using Dongke.IBOSS.PRD.Client.CommonModule;
  15. using Dongke.IBOSS.PRD.WCF.DataModels;
  16. using Dongke.IBOSS.PRD.WCF.Proxys;
  17. using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
  18. namespace Dongke.IBOSS.PRD.Client.PMModule
  19. {
  20. /// <summary>
  21. /// 撤销装车
  22. /// </summary>
  23. public partial class F_PM_0503 : FormBase
  24. {
  25. #region
  26. //当前工序
  27. int _procedureID = 0;
  28. //保存标记
  29. bool _SaveOKFlag = false;
  30. #endregion
  31. #region 构造
  32. public F_PM_0503(int procedureID)
  33. {
  34. this._procedureID = procedureID;
  35. InitializeComponent();
  36. this.SetFromTitleInfo();
  37. this.btnSave.Enabled = false;
  38. this.txtBarcode.Focus();
  39. }
  40. public F_PM_0503(int procedureID,string barcode)
  41. {
  42. this._procedureID = procedureID;
  43. InitializeComponent();
  44. this.SetFromTitleInfo();
  45. this.txtBarcode.Text = barcode;
  46. this.btnSave.Enabled = false;
  47. this.txtBarcode.SelectionStart = barcode.Length;
  48. }
  49. #endregion
  50. #region 事件
  51. /// <summary>
  52. /// 条码焦点离开事件
  53. /// </summary>
  54. /// <param name="sender"></param>
  55. /// <param name="e"></param>
  56. private void txtBarcode_Leave(object sender, System.EventArgs e)
  57. {
  58. }
  59. /// <summary>
  60. /// 保存
  61. /// </summary>
  62. /// <param name="sender"></param>
  63. /// <param name="e"></param>
  64. private void btnSave_Click(object sender, EventArgs e)
  65. {
  66. try
  67. {
  68. if (string.IsNullOrEmpty(this.txtBarcode.Text.Trim()))
  69. {
  70. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "条码", "条码"),
  71. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  72. return;
  73. }
  74. string err = (string)DoAsync(new BaseAsyncMethod(() =>
  75. {
  76. return PMModuleProxy.Service.AddCancelLoadCar(this._procedureID, this.txtBarcode.Text.Trim());
  77. }));
  78. if (string.IsNullOrEmpty(err))
  79. {
  80. this._SaveOKFlag = true;
  81. // 提示信息
  82. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, this.Text, "保存"),
  83. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  84. // 清空文本框
  85. this.CleanTextBox();
  86. }
  87. else
  88. {
  89. MessageBox.Show(err,
  90. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  91. return;
  92. }
  93. }
  94. catch (Exception ex)
  95. {
  96. // 对异常进行共通处理
  97. ExceptionManager.HandleEventException(this.ToString(),
  98. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  99. }
  100. }
  101. /// <summary>
  102. /// 关闭
  103. /// </summary>
  104. /// <param name="sender"></param>
  105. /// <param name="e"></param>
  106. private void btnCancel_Click(object sender, EventArgs e)
  107. {
  108. this.Close();
  109. }
  110. /// <summary>
  111. /// 关闭窗体
  112. /// </summary>
  113. /// <param name="sender"></param>
  114. /// <param name="e"></param>
  115. private void F_PM_0503_FormClosing(object sender, FormClosingEventArgs e)
  116. {
  117. if (this._SaveOKFlag)
  118. {
  119. this.DialogResult = DialogResult.OK;
  120. }
  121. }
  122. /// <summary>
  123. /// 条码回车事件
  124. /// </summary>
  125. /// <param name="sender"></param>
  126. /// <param name="e"></param>
  127. private void txtBarcode_KeyPress(object sender, KeyPressEventArgs e)
  128. {
  129. try
  130. {
  131. // 按了回车键
  132. if ((int)e.KeyChar == Constant.SYSTEM_KEYBOARD_ENTER_VALUE)
  133. {
  134. this.CheckBarcode();
  135. }
  136. }
  137. catch (Exception ex)
  138. {
  139. // 对异常进行共通处理
  140. ExceptionManager.HandleEventException(this.ToString(),
  141. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  142. }
  143. }
  144. #endregion
  145. #region 私有方法
  146. /// <summary>
  147. /// 清空文本框
  148. /// </summary>
  149. private void CleanTextBox()
  150. {
  151. this.txtBarcode.Text = string.Empty;
  152. this.txtGoodsCode.Text = string.Empty;
  153. this.txtGoodsName.Text = string.Empty;
  154. this.txtKilnCarNo.Text = string.Empty;
  155. this.txtBarcodeStatus.Text = string.Empty;
  156. }
  157. /// <summary>
  158. /// 设置窗体按钮的文本信息
  159. /// </summary>
  160. private void SetFromTitleInfo()
  161. {
  162. this.Text = FormTitles.F_PM_0503;
  163. this.btnSave.Text = ButtonText.BTN_SAVE;
  164. this.btnCancel.Text = ButtonText.BTN_CANCEL;
  165. }
  166. /// <summary>
  167. /// 检验条码是否可以下车
  168. /// </summary>
  169. private void CheckBarcode()
  170. {
  171. try
  172. {
  173. if (!string.IsNullOrEmpty(this.txtBarcode.Text.Trim()))
  174. {
  175. CheckCancelLoadCar checkCancelLoadCar = (CheckCancelLoadCar)DoAsync(new BaseAsyncMethod(() =>
  176. {
  177. return PMModuleProxy.Service.CheckCancelLoadCar(this._procedureID, this.txtBarcode.Text.Trim());
  178. }));
  179. if (!string.IsNullOrEmpty(checkCancelLoadCar.ErrMsg))
  180. {
  181. this.txtBarcodeStatus.Text = checkCancelLoadCar.ErrMsg;
  182. this.txtGoodsCode.Text = "";
  183. this.txtGoodsName.Text = "";
  184. this.txtKilnCarNo.Text = "";
  185. this.btnSave.Enabled = false;
  186. //this.btnCancel.Focus();
  187. }
  188. else
  189. {
  190. this.txtBarcodeStatus.Text = checkCancelLoadCar.ErrMsg;
  191. this.btnSave.Enabled = true;
  192. this.txtGoodsCode.Text = checkCancelLoadCar.GoodsCode;
  193. this.txtGoodsName.Text = checkCancelLoadCar.GoodsName;
  194. this.txtKilnCarNo.Text = checkCancelLoadCar.KilnCarCode;
  195. }
  196. }
  197. }
  198. catch (Exception ex)
  199. {
  200. throw ex;
  201. }
  202. }
  203. #endregion
  204. }
  205. }