F_MST_0504.cs 10 KB

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