F_MST_0503.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_MST_0503.cs
  5. * 2.功能描述:配置或撤销产品工序配置
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2017/07/11 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Windows.Forms;
  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. using Dongke.WinForm.Controls;
  19. namespace Dongke.IBOSS.PRD.Client.SystemModule
  20. {
  21. /// <summary>
  22. /// 配置或撤销产品工序配置
  23. /// </summary>
  24. public partial class F_MST_0503 : FormBase
  25. {
  26. #region 成员变量
  27. // 1:配置到工序;2:从工序撤销
  28. private int _formStatus;
  29. #endregion
  30. #region 构造函数
  31. /// <summary>
  32. /// 配置或撤销产品工序配置
  33. /// </summary>
  34. /// <param name="formStatus">1:配置到工序;2:从工序撤销</param>
  35. /// <param name="goods">产品列表</param>
  36. public F_MST_0503(int formStatus, DataTable goods)
  37. {
  38. InitializeComponent();
  39. this.dgvGoods.AutoGenerateColumns = false;
  40. if (goods.Columns.Contains("Sel"))
  41. {
  42. goods.Columns.Remove("Sel");
  43. }
  44. goods.Columns.Add("Sel", typeof(int));
  45. this.dgvGoods.DataSource = goods;
  46. this._formStatus = formStatus;
  47. this.Text = (_formStatus == 1 ? "配置" : "撤销") + "产品工序";
  48. }
  49. #endregion
  50. #region 事件
  51. /// <summary>
  52. /// 关闭
  53. /// </summary>
  54. /// <param name="sender"></param>
  55. /// <param name="e"></param>
  56. private void tsbtnClose_Click(object sender, System.EventArgs e)
  57. {
  58. this.Close();
  59. }
  60. /// <summary>
  61. /// 自适应列宽
  62. /// </summary>
  63. /// <param name="sender"></param>
  64. /// <param name="e"></param>
  65. private void tsbtnAdaptive_Click(object sender, System.EventArgs e)
  66. {
  67. this.dgvGoods.AutoResizeColumns();
  68. }
  69. /// <summary>
  70. /// 画面加载
  71. /// </summary>
  72. /// <param name="sender"></param>
  73. /// <param name="e"></param>
  74. private void F_MST_0503_Load(object sender, System.EventArgs e)
  75. {
  76. try
  77. {
  78. foreach (DataGridViewColumn item in this.dgvGoods.Columns)
  79. {
  80. if ("Sel" != item.Name)
  81. {
  82. item.ReadOnly = true;
  83. }
  84. }
  85. this.dgvGoods.IsSetInputColumnsColor = true;
  86. }
  87. catch (Exception ex)
  88. {
  89. // 对异常进行共通处理
  90. ExceptionManager.HandleEventException(this.ToString(),
  91. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  92. }
  93. }
  94. /// <summary>
  95. /// 全选
  96. /// </summary>
  97. /// <param name="sender"></param>
  98. /// <param name="e"></param>
  99. private void tsbtnAllCheck_Click(object sender, System.EventArgs e)
  100. {
  101. try
  102. {
  103. this.dgvGoods.CommitEdit(DataGridViewDataErrorContexts.Commit);
  104. foreach (DataGridViewRow item in dgvGoods.Rows)
  105. {
  106. DataRowView row = item.DataBoundItem as DataRowView;
  107. if (row != null)
  108. {
  109. row["Sel"] = 1;
  110. row.EndEdit();
  111. }
  112. }
  113. }
  114. catch (Exception ex)
  115. {
  116. // 对异常进行共通处理
  117. ExceptionManager.HandleEventException(this.ToString(),
  118. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  119. }
  120. }
  121. /// <summary>
  122. /// 反选
  123. /// </summary>
  124. /// <param name="sender"></param>
  125. /// <param name="e"></param>
  126. private void tsbtnUnCheck_Click(object sender, System.EventArgs e)
  127. {
  128. try
  129. {
  130. this.dgvGoods.CommitEdit(DataGridViewDataErrorContexts.Commit);
  131. foreach (DataGridViewRow item in dgvGoods.Rows)
  132. {
  133. DataRowView row = item.DataBoundItem as DataRowView;
  134. if (row != null)
  135. {
  136. int c = int.Parse(row["Sel"].ToString());
  137. row["Sel"] = (c == 1 ? 0 : 1);
  138. row.EndEdit();
  139. }
  140. }
  141. }
  142. catch (Exception ex)
  143. {
  144. // 对异常进行共通处理
  145. ExceptionManager.HandleEventException(this.ToString(),
  146. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  147. }
  148. }
  149. /// <summary>
  150. /// 全不选
  151. /// </summary>
  152. /// <param name="sender"></param>
  153. /// <param name="e"></param>
  154. private void tsbtnNoCheck_Click(object sender, System.EventArgs e)
  155. {
  156. try
  157. {
  158. this.dgvGoods.CommitEdit(DataGridViewDataErrorContexts.Commit);
  159. foreach (DataGridViewRow item in dgvGoods.Rows)
  160. {
  161. DataRowView row = item.DataBoundItem as DataRowView;
  162. if (row != null)
  163. {
  164. row["Sel"] = 0;
  165. row.EndEdit();
  166. }
  167. }
  168. }
  169. catch (Exception ex)
  170. {
  171. // 对异常进行共通处理
  172. ExceptionManager.HandleEventException(this.ToString(),
  173. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  174. }
  175. }
  176. /// <summary>
  177. /// 保存
  178. /// </summary>
  179. /// <param name="sender"></param>
  180. /// <param name="e"></param>
  181. private void tsbtnSave_Click(object sender, EventArgs e)
  182. {
  183. try
  184. {
  185. this.dgvGoods.CommitEdit(DataGridViewDataErrorContexts.Commit);
  186. this.dgvGoods.EndEdit();
  187. DataTable goods = this.dgvGoods.DataSource as DataTable;
  188. List<string> goodsIDList = new List<string>();
  189. foreach (DataRow item in goods.Rows)
  190. {
  191. item.EndEdit();
  192. if ("1" == item["Sel"].ToString())
  193. {
  194. goodsIDList.Add(item["GoodsID"].ToString());
  195. }
  196. }
  197. if (goodsIDList.Count == 0)
  198. {
  199. MessageBox.Show("没有选择任何产品", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  200. return;
  201. }
  202. if (dkproductionLineSearchBox.ProductionLineID== null ||
  203. string.IsNullOrWhiteSpace(this.dkProcedureSearchBox.ProcedureIDS))
  204. {
  205. DialogResult dr = MessageBox.Show("确定设置全部生产线或工序?", this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  206. if (dr != DialogResult.OK)
  207. {
  208. return;
  209. }
  210. }
  211. ClientRequestEntity cre = new ClientRequestEntity();
  212. cre.NameSpace = "MST05";
  213. cre.Name = "SetGoodsToProcedure";
  214. cre.Properties["Type"] = _formStatus;
  215. cre.Properties["GoodsIDs"] = string.Join(",", goodsIDList);
  216. cre.Properties["ProductionLineID"] = this.dkproductionLineSearchBox.ProductionLineID;
  217. cre.Properties["ProcedureIDs"] = this.dkProcedureSearchBox.ProcedureIDS;
  218. ServiceResultEntity sre = CommonModuleProxy.Service.DoRequest(cre);
  219. if (sre.Status == Basics.BaseResources.Constant.ServiceResultStatus.Success)
  220. {
  221. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "产品工序", (_formStatus == 1 ? "配置" : "撤销")),
  222. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  223. }
  224. else
  225. {
  226. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "产品工序", (_formStatus == 1 ? "配置" : "撤销")),
  227. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  228. }
  229. }
  230. catch (Exception ex)
  231. {
  232. // 对异常进行共通处理
  233. ExceptionManager.HandleEventException(this.ToString(),
  234. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  235. }
  236. }
  237. #endregion
  238. #region 私有方法
  239. #endregion
  240. }
  241. }