F_PM_0201.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_0201.cs
  5. * 2.功能描述:变更条码
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 庄天威 2014/09/23 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Reflection;
  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. /// <summary>
  22. /// 变更条码
  23. /// </summary>
  24. public partial class F_PM_0201 : DKFormBase
  25. {
  26. #region 构造函数
  27. /// <summary>
  28. /// 变更条码
  29. /// </summary>
  30. public F_PM_0201()
  31. {
  32. this.InitializeComponent();
  33. this.Text = FormTitles.F_PM_0201;
  34. this.btnSave.Text = ButtonText.BTN_SAVE;
  35. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  36. this.btnClose.Text = ButtonText.BTN_CLOSE;
  37. }
  38. #endregion
  39. #region 属性
  40. /// <summary>
  41. /// 原条码
  42. /// </summary>
  43. public string BarCode
  44. {
  45. get
  46. {
  47. return this.txtBarCode.Text;
  48. }
  49. set
  50. {
  51. this.txtBarCode.Text = value;
  52. }
  53. }
  54. /// <summary>
  55. /// 新条码
  56. /// </summary>
  57. public string NewBarCode
  58. {
  59. get
  60. {
  61. return this.txtNewBarCode.Text;
  62. }
  63. set
  64. {
  65. this.txtNewBarCode.Text = value;
  66. }
  67. }
  68. /// <summary>
  69. /// 产品编码
  70. /// </summary>
  71. public string GoodsCode
  72. {
  73. get
  74. {
  75. return this.txtGoodsCode.Text;
  76. }
  77. set
  78. {
  79. this.txtGoodsCode.Text = value;
  80. }
  81. }
  82. #endregion 属性
  83. #region 事件
  84. /// <summary>
  85. /// 画面加载事件
  86. /// </summary>
  87. /// <param name="sender"></param>
  88. /// <param name="e"></param>
  89. private void F_PM_0201_Load(object sender, EventArgs e)
  90. {
  91. if (!string.IsNullOrWhiteSpace(this.txtBarCode.Text))
  92. {
  93. this.txtNewBarCode.Focus();
  94. }
  95. }
  96. /// <summary>
  97. /// 替换条码
  98. /// </summary>
  99. private void btnSave_Click(object sender, EventArgs e)
  100. {
  101. string barCode = this.txtBarCode.Text.Trim();
  102. string newBarCode = this.txtNewBarCode.Text.Trim();
  103. string groutingusercode = this.txtGroutingUserCode.Text.Trim();
  104. string goodscode = this.txtGoodsCode.Text.Trim();
  105. try
  106. {
  107. if (string.IsNullOrWhiteSpace(groutingusercode))
  108. {
  109. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_003, this.lblGroutingUserCode.Text);
  110. this.txtGroutingUserCode.Focus();
  111. return;
  112. }
  113. if (string.IsNullOrWhiteSpace(goodscode))
  114. {
  115. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_003, this.lblBarCode.Text);
  116. this.txtGoodsCode.Focus();
  117. return;
  118. }
  119. if (string.IsNullOrWhiteSpace(barCode))
  120. {
  121. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_003, this.lblBarCode.Text);
  122. this.txtBarCode.Focus();
  123. return;
  124. }
  125. if (string.IsNullOrWhiteSpace(newBarCode))
  126. {
  127. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_003, this.lblNewBarCode.Text);
  128. this.txtNewBarCode.Focus();
  129. return;
  130. }
  131. if (newBarCode.Length != 11)
  132. {
  133. MessageBox.Show($"{this.lblNewBarCode.Text}不是11位" , this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  134. this.txtNewBarCode.Focus();
  135. return;
  136. }
  137. if (newBarCode == barCode)
  138. {
  139. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_004, this.lblNewBarCode.Text, this.lblBarCode.Text);
  140. this.txtNewBarCode.Focus();
  141. return;
  142. }
  143. ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
  144. {
  145. return PMModuleProxyNew.Service.SetFPM0201Data(barCode, newBarCode, this.txtRemarks.Text, this.txtGroutingUserCode.Text,goodscode);
  146. }
  147. );
  148. if (sre.Status == Constant.ServiceResultStatus.Success)
  149. {
  150. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  151. this.DialogResult = DialogResult.OK;
  152. //this.Close();
  153. return;
  154. }
  155. if (sre.Status == Constant.ServiceResultStatus.Other)
  156. {
  157. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, sre.Message);
  158. }
  159. }
  160. catch (Exception ex)
  161. {
  162. // 对异常进行共通处理
  163. ExceptionManager.HandleEventException(this.ToString(),
  164. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  165. }
  166. }
  167. /// <summary>
  168. /// 查询原条码
  169. /// </summary>
  170. /// <param name="sender"></param>
  171. /// <param name="e"></param>
  172. private void btnSearch_Click(object sender, EventArgs e)
  173. {
  174. try
  175. {
  176. F_PM_0202 frmPM0202 = F_PM_0202.Instance;
  177. frmPM0202.BarCode = this.txtBarCode.Text;
  178. frmPM0202.GroutingUserCode = this.txtGroutingUserCode.Text;
  179. frmPM0202.GoodsCodeText = this.txtGoodsCode.Text;
  180. DialogResult dialogResult = frmPM0202.ShowDialog();
  181. // 查询窗体返回值给控件赋值
  182. if (dialogResult == DialogResult.OK)
  183. {
  184. this.txtBarCode.Text = frmPM0202.BarCode;
  185. this.txtGoodsCode.Text = frmPM0202.GoodsCodeText;
  186. if (!string.IsNullOrWhiteSpace(this.txtBarCode.Text))
  187. {
  188. this.txtNewBarCode.Focus();
  189. }
  190. }
  191. }
  192. catch (Exception ex)
  193. {
  194. // 对异常进行共通处理
  195. ExceptionManager.HandleEventException(this.ToString(),
  196. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  197. }
  198. }
  199. /// <summary>
  200. /// 输入原条码后,新条码获得焦点
  201. /// </summary>
  202. /// <param name="sender"></param>
  203. /// <param name="e"></param>
  204. private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e)
  205. {
  206. if (e.KeyChar == Constant.SYSTEM_KEYBOARD_ENTER_VALUE)
  207. {
  208. this.txtNewBarCode.Focus();
  209. }
  210. }
  211. #endregion
  212. }
  213. }