F_PC_1003.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*******************************************************************************
  2. * Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PC_1003.cs
  5. * 2.功能描述:替换条码
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2017/12/12 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Reflection;
  13. using System.Windows.Forms;
  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.PCModule
  20. {
  21. /// <summary>
  22. /// 替换条码
  23. /// </summary>
  24. public partial class F_PC_1003 : DKFormBase
  25. {
  26. #region 成员变量
  27. /// <summary>
  28. /// 模具ID
  29. /// </summary>
  30. private int _mouldID = 0;
  31. #endregion
  32. #region 构造函数
  33. /// <summary>
  34. /// 构造函数
  35. /// </summary>
  36. public F_PC_1003(int mouldID)
  37. {
  38. InitializeComponent();
  39. this._mouldID = mouldID;
  40. }
  41. #endregion
  42. #region 事件处理
  43. /// <summary>
  44. /// 画面加载
  45. /// </summary>
  46. /// <param name="sender"></param>
  47. /// <param name="e"></param>
  48. private void F_PC_1002_Load(object sender, System.EventArgs e)
  49. {
  50. try
  51. {
  52. ClientRequestEntity cre = new ClientRequestEntity();
  53. cre.NameSpace = "PC_Mould";
  54. cre.Name = "GetMouldData";
  55. cre.Properties["MouldID"] = this._mouldID;
  56. ServiceResultEntity sre = PCModuleProxyNew.Service.HandleRequest(cre);
  57. if (sre == null)
  58. {
  59. this.Close();
  60. return;
  61. }
  62. DataRow item = sre.Data.Tables["InfoData"].Rows[0];
  63. this.txtBarcode.Text = item["MouldBarcode"].ToString();
  64. }
  65. catch (Exception ex)
  66. {
  67. // 对异常进行共通处理
  68. ExceptionManager.HandleEventException(this.ToString(),
  69. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  70. }
  71. }
  72. /// <summary>
  73. /// 关闭画面
  74. /// </summary>
  75. /// <param name="sender"></param>
  76. /// <param name="e"></param>
  77. private void btnCancel_Click(object sender, System.EventArgs e)
  78. {
  79. this.Close();
  80. }
  81. /// <summary>
  82. /// 保存
  83. /// </summary>
  84. /// <param name="sender"></param>
  85. /// <param name="e"></param>
  86. private void btnSave_Click(object sender, EventArgs e)
  87. {
  88. try
  89. {
  90. if (!this.CheckInput())
  91. {
  92. return;
  93. }
  94. ClientRequestEntity cre = new ClientRequestEntity();
  95. cre.NameSpace = "FPC1003";
  96. cre.Name = "SetFPC1003Data";
  97. cre.Properties["MouldID"] = this._mouldID;
  98. cre.Properties["MouldBarcode"] = this.txtBarcode.Text.Trim();
  99. cre.Properties["NewMouldBarcode"] = this.txtNewBarcode.Text.Trim();
  100. cre.Properties["Remarks"] = this.txtRemarks.Text;
  101. ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
  102. {
  103. return PCModuleProxyNew.Service.HandleRequest(cre);
  104. });
  105. if (sre != null)
  106. {
  107. if (sre.Status == Constant.ServiceResultStatus.Success)
  108. {
  109. // 提示信息
  110. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, this.Text, "保存"),
  111. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  112. this.DialogResult = DialogResult.OK;
  113. this.Close();
  114. }
  115. else if (!string.IsNullOrWhiteSpace(sre.Message))
  116. {
  117. MessageBox.Show(sre.Message,
  118. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  119. }
  120. }
  121. else
  122. {
  123. // 提示信息
  124. MessageBox.Show("保存失败",
  125. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  126. }
  127. }
  128. catch (Exception ex)
  129. {
  130. // 对异常进行共通处理
  131. ExceptionManager.HandleEventException(this.ToString(),
  132. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  133. }
  134. }
  135. #endregion
  136. #region 私有方法
  137. /// <summary>
  138. /// 保存前画面数据验证
  139. /// </summary>
  140. /// <returns></returns>
  141. private bool CheckInput()
  142. {
  143. if (string.IsNullOrEmpty(this.txtBarcode.Text.Trim()))
  144. {
  145. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "原模具条码"),
  146. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  147. MessageBoxDefaultButton.Button1);
  148. this.txtBarcode.Focus();
  149. return false;
  150. }
  151. if (string.IsNullOrEmpty(this.txtNewBarcode.Text.Trim()))
  152. {
  153. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "新模具条码"),
  154. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  155. MessageBoxDefaultButton.Button1);
  156. this.txtNewBarcode.Focus();
  157. return false;
  158. }
  159. if (this.txtNewBarcode.Text.Trim() == this.txtBarcode.Text.Trim())
  160. {
  161. MessageBox.Show("替换前后模具条码不能一致",
  162. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  163. MessageBoxDefaultButton.Button1);
  164. this.txtNewBarcode.Focus();
  165. return false;
  166. }
  167. return true;
  168. }
  169. #endregion
  170. }
  171. }