F_PM_3302.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_3302.cs
  5. * 2.功能描述:新建/编辑产品废弃信息窗体
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 付斌 2020/11/06 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.WCF.DataModels;
  17. using Dongke.IBOSS.PRD.WCF.Proxys;
  18. namespace Dongke.IBOSS.PRD.Client.PMModule
  19. {
  20. /// <summary>
  21. /// 编辑产品废弃信息窗体
  22. /// </summary>
  23. public partial class F_PM_3302 : FormBase
  24. {
  25. #region 属性
  26. /// <summary>
  27. /// 窗体模式
  28. /// </summary>
  29. public Constant.FormMode FormType
  30. {
  31. get;
  32. set;
  33. }
  34. #endregion
  35. #region 构造函数
  36. /// <summary>
  37. /// 窗体构造
  38. /// </summary>
  39. public F_PM_3302()
  40. {
  41. InitializeComponent();
  42. btnSave.Text = ButtonText.BTN_SAVE;
  43. btnCancel.Text = ButtonText.BTN_CLOSE;
  44. }
  45. #endregion
  46. #region 事件
  47. /// <summary>
  48. /// 窗体加载
  49. /// </summary>
  50. /// <param name="sender"></param>
  51. /// <param name="e"></param>
  52. private void F_PM_3302_Load(object sender, EventArgs e)
  53. {
  54. try
  55. {
  56. dgvBarcode.AutoGenerateColumns = false;
  57. if (FormType == Constant.FormMode.Add)
  58. {
  59. // 调出原因
  60. DataSet dsRreason = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  61. {
  62. return SystemModuleProxy.Service.GetDictionaryData(0, "TPC009");
  63. }));
  64. cmbRreason.DisplayMember = "DictionaryValue";
  65. cmbRreason.ValueMember = "DictionaryID";
  66. cmbRreason.DataSource = dsRreason.Tables[0];
  67. }
  68. else if (FormType == Constant.FormMode.Edit)
  69. {
  70. Text = "工厂调出撤销";
  71. cmbRreason.Enabled = false;
  72. }
  73. }
  74. catch (Exception ex)
  75. {
  76. // 对异常进行共通处理
  77. ExceptionManager.HandleEventException(ToString(),
  78. System.Reflection.MethodBase.GetCurrentMethod().Name, Text, ex);
  79. }
  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. txtRemarks.Focus();//把光标移开,由于删除工号后,值未变
  91. DataTable dtBarcode = dgvBarcode.DataSource as DataTable;
  92. dtBarcode?.AcceptChanges();
  93. if (dtBarcode == null || dtBarcode.Rows.Count == 0)
  94. {
  95. MessageBox.Show("没有选择任何条码",
  96. Text,
  97. MessageBoxButtons.OK,
  98. MessageBoxIcon.Warning,
  99. MessageBoxDefaultButton.Button1);
  100. txtBarCode.Focus();
  101. return;
  102. }
  103. if (FormType == Constant.FormMode.Add)
  104. {
  105. if (cmbRreason.Text == string.Empty)
  106. {
  107. MessageBox.Show("调出类型必须填写!",
  108. Text,
  109. MessageBoxButtons.OK,
  110. MessageBoxIcon.Warning,
  111. MessageBoxDefaultButton.Button1);
  112. return;
  113. }
  114. // 异步处理
  115. ClientRequestEntity cre = new ClientRequestEntity();
  116. cre.NameSpace = "F_PM_3302";
  117. cre.Name = "SaveAllocateOut";
  118. cre.Properties["rreason"] = cmbRreason.Text.Trim();
  119. cre.Properties["remarks"] = txtRemarks.Text.Trim();
  120. cre.Data = new DataSet();
  121. cre.Data.Tables.Add(dtBarcode.Copy());
  122. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(
  123. () => { return PMModuleProxyNew.Service.HandleRequest(cre); });
  124. if (sre.OtherStatus > 0)
  125. {
  126. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "工厂调出", "保存"),
  127. Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  128. DialogResult = DialogResult.OK;
  129. }
  130. else if (sre.OtherStatus < 0 && !string.IsNullOrEmpty(sre.Message))
  131. {
  132. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, sre.Message),
  133. Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  134. }
  135. else
  136. {
  137. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "工厂调出", "保存"),
  138. Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  139. }
  140. }
  141. else if (FormType == Constant.FormMode.Edit)
  142. {
  143. // 异步处理
  144. ClientRequestEntity cre = new ClientRequestEntity();
  145. cre.NameSpace = "F_PM_3302";
  146. cre.Name = "CancelAllocateOut";
  147. cre.Data = new DataSet();
  148. cre.Data.Tables.Add(dtBarcode.Copy());
  149. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(
  150. () => { return PMModuleProxyNew.Service.HandleRequest(cre); });
  151. if (sre.OtherStatus > 0)
  152. {
  153. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "工厂调出撤销", "保存"),
  154. Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  155. DialogResult = DialogResult.OK;
  156. }
  157. else if (sre.OtherStatus < 0 && !string.IsNullOrEmpty(sre.Message))
  158. {
  159. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, sre.Message),
  160. Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  161. }
  162. else
  163. {
  164. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "工厂调出撤销", "保存"),
  165. Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  166. }
  167. }
  168. }
  169. catch (Exception ex)
  170. {
  171. // 对异常进行共通处理
  172. ExceptionManager.HandleEventException(ToString(),
  173. System.Reflection.MethodBase.GetCurrentMethod().Name, Text, ex);
  174. }
  175. }
  176. /// <summary>
  177. /// 条码回车事件
  178. /// </summary>
  179. /// <param name="sender"></param>
  180. /// <param name="e"></param>
  181. private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e)
  182. {
  183. try
  184. {
  185. if ((int)e.KeyChar == 13) // 按了回车键
  186. {
  187. string barcode = txtBarCode.Text.Trim();
  188. if (!string.IsNullOrEmpty(barcode))
  189. {
  190. DataTable dtBarcode = dgvBarcode.DataSource as DataTable;
  191. if (dtBarcode != null)
  192. {
  193. DataRow[] rows = dtBarcode.Select("Barcode = '" + barcode + "'");
  194. if (rows.Length > 0)
  195. {
  196. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "当前编码在列表中已存在"),
  197. Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  198. return;
  199. }
  200. }
  201. // 异步处理
  202. ClientRequestEntity cre = new ClientRequestEntity();
  203. cre.NameSpace = "F_PM_3302";
  204. cre.Name = "CheckAllocateOut";
  205. cre.Data = new DataSet();
  206. cre.Properties["Barcode"] = barcode;
  207. cre.Properties["OutFlag"] = FormType == Constant.FormMode.Add ? 1 : 0;
  208. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(
  209. () => { return PMModuleProxyNew.Service.HandleRequest(cre); });
  210. if (sre.OtherStatus < 0 && !string.IsNullOrEmpty(sre.Message))
  211. {
  212. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, sre.Message),
  213. Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  214. txtBarCode.Clear();
  215. return;
  216. }
  217. if (sre.Data != null && sre.Data.Tables[0].Rows.Count > 0)
  218. {
  219. if (dtBarcode == null)
  220. {
  221. dgvBarcode.DataSource = sre.Data.Tables[0];
  222. }
  223. else
  224. {
  225. DataRow row = dtBarcode.NewRow();
  226. row.ItemArray = sre.Data.Tables[0].Rows[0].ItemArray;
  227. dtBarcode.Rows.Add(row);
  228. }
  229. }
  230. txtBarCode.Clear();
  231. }
  232. }
  233. }
  234. catch (Exception ex)
  235. {
  236. // 对异常进行共通处理
  237. ExceptionManager.HandleEventException(ToString(),
  238. System.Reflection.MethodBase.GetCurrentMethod().Name, Text, ex);
  239. }
  240. }
  241. /// <summary>
  242. /// 窗体关闭
  243. /// </summary>
  244. /// <param name="sender"></param>
  245. /// <param name="e"></param>
  246. private void btnCancel_Click(object sender, EventArgs e)
  247. {
  248. Close();
  249. }
  250. #endregion
  251. }
  252. }