F_PC_1004.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /*******************************************************************************
  2. * Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PC_1004.cs
  5. * 2.功能描述:模具操作
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2017/12/12 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Reflection;
  14. using System.Windows.Forms;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.Client.Controls;
  18. using Dongke.IBOSS.PRD.Client.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. namespace Dongke.IBOSS.PRD.Client.PCModule
  22. {
  23. /// <summary>
  24. /// 模具操作
  25. /// </summary>
  26. public partial class F_PC_1004 : DKFormBase
  27. {
  28. #region 成员变量
  29. private string _mouldIDs = null;
  30. private Constant.MouldOperationType _mouldOperationType;
  31. #endregion
  32. #region 构造函数
  33. /// <summary>
  34. ///
  35. /// </summary>
  36. public F_PC_1004(string mouldIDs, Constant.MouldOperationType mouldOperationType)
  37. {
  38. InitializeComponent();
  39. this.dgvMould.AutoGenerateColumns = false;
  40. _mouldIDs = mouldIDs;
  41. _mouldOperationType = mouldOperationType;
  42. }
  43. #endregion
  44. #region 控件事件
  45. /// <summary>
  46. /// 画面加载
  47. /// </summary>
  48. /// <param name="sender"></param>
  49. /// <param name="e"></param>
  50. private void F_PC_1001_Load(object sender, System.EventArgs e)
  51. {
  52. try
  53. {
  54. bool hasLoad = false;
  55. ClientRequestEntity cre = new ClientRequestEntity();
  56. cre.NameSpace = "FPC1001";
  57. cre.Name = "GetFPC1001QueryData";
  58. cre.Properties["MouldIDs"] = _mouldIDs;
  59. switch (_mouldOperationType)
  60. {
  61. case Constant.MouldOperationType.ChangeGoodsCode:
  62. this.Text = "变更型号-【在库、在产、待产】模具";
  63. this.dkGoodsCode.Visible = true;
  64. cre.Properties["MouldStatus"] = (int)Constant.MouldStatus.Inv + "," + (int)Constant.MouldStatus.OnLine + "," + (int)Constant.MouldStatus.Out;
  65. break;
  66. case Constant.MouldOperationType.InvToOut:
  67. this.Text = "模具领用-【在库】模具";
  68. cre.Properties["MouldStatus"] = (int)Constant.MouldStatus.Inv;
  69. break;
  70. case Constant.MouldOperationType.OutToInv:
  71. this.Text = "模具回收-【待产】模具";
  72. cre.Properties["MouldStatus"] = (int)Constant.MouldStatus.Out;
  73. break;
  74. case Constant.MouldOperationType.InvToScrap:
  75. this.Text = "模具报损-【在库、待产】模具";
  76. cre.Properties["MouldStatus"] = (int)Constant.MouldStatus.Inv + "," + (int)Constant.MouldStatus.Out;
  77. this.lblScrapReason.Visible = true;
  78. this.lblScrapResponsibility.Visible = true;
  79. this.ftcScrapReason.Visible = true;
  80. this.txtScrapResponsibility.Visible = true;
  81. hasLoad = true;
  82. break;
  83. case Constant.MouldOperationType.ScrapToInv:
  84. this.Text = "报损撤销-【报废】模具";
  85. cre.Properties["MouldStatus"] = (int)Constant.MouldStatus.Scrap;
  86. break;
  87. default:
  88. return;
  89. }
  90. ServiceResultEntity sre = PCModuleProxyNew.Service.HandleRequest(cre);
  91. this.dgvMould.DataSource = sre.Data.Tables[0];
  92. if (hasLoad)
  93. {
  94. ClientRequestEntity creLoad = new ClientRequestEntity();
  95. creLoad.NameSpace = "FPC1004";
  96. creLoad.Name = "GetFPC1004LoadData";
  97. creLoad.Properties["MouldOperationType"] = (int)_mouldOperationType;
  98. ServiceResultEntity sreLoad = PCModuleProxyNew.Service.HandleRequest(creLoad);
  99. this.ftcScrapReason.ValueMember = "dictionaryid";
  100. this.ftcScrapReason.DisplayMember = "dictionaryvalue";
  101. this.ftcScrapReason.DataSource = sreLoad.Data.Tables[0];
  102. }
  103. //this.dgvMould.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect;
  104. }
  105. catch (Exception ex)
  106. {
  107. // 对异常进行共通处理
  108. ExceptionManager.HandleEventException(this.ToString(),
  109. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  110. }
  111. }
  112. /// <summary>
  113. /// 查询
  114. /// </summary>
  115. /// <param name="sender"></param>
  116. /// <param name="e"></param>
  117. private void tsbtnSave_Click(object sender, EventArgs e)
  118. {
  119. try
  120. {
  121. if (!this.CheckInput())
  122. {
  123. return;
  124. }
  125. ClientRequestEntity cre = new ClientRequestEntity();
  126. cre.NameSpace = "FPC1004";
  127. cre.Name = "SetFPC1004Data";
  128. cre.Properties["MouldOperationType"] = (int)_mouldOperationType;
  129. if (this.dkGoodsCode.Visible)
  130. {
  131. cre.Properties["GoodsID"] = this.dkGoodsCode.GoodsID;
  132. cre.Properties["GoodsCode"] = this.dkGoodsCode.GoodsCode;
  133. }
  134. if (this.ftcScrapReason.Visible)
  135. {
  136. cre.Properties["ScrapReason"] = this.ftcScrapReason.SelectedValue;
  137. cre.Properties["ScrapResponsibility"] = this.txtScrapResponsibility.Text;
  138. }
  139. cre.Properties["Remarks"] = this.txtRemarks.Text;
  140. List<string> ids = new List<string>();
  141. foreach (DataRow item in (this.dgvMould.DataSource as DataTable).Rows)
  142. {
  143. ids.Add(item["MouldID"].ToString());
  144. }
  145. cre.Properties["MouldIDs"] = string.Join(",", ids);
  146. ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
  147. {
  148. return PCModuleProxyNew.Service.HandleRequest(cre);
  149. });
  150. if (sre != null)
  151. {
  152. if (sre.Status == Constant.ServiceResultStatus.Success)
  153. {
  154. // 提示信息
  155. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, this.Text, "保存"),
  156. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  157. this.DialogResult = DialogResult.OK;
  158. this.Close();
  159. }
  160. else if (!string.IsNullOrWhiteSpace(sre.Message))
  161. {
  162. MessageBox.Show(sre.Message,
  163. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  164. }
  165. }
  166. else
  167. {
  168. // 提示信息
  169. MessageBox.Show("保存失败",
  170. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  171. }
  172. }
  173. catch (Exception ex)
  174. {
  175. // 对异常进行共通处理
  176. ExceptionManager.HandleEventException(this.ToString(),
  177. 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 dgvMould_Sorted(object sender, EventArgs e)
  186. {
  187. this.dgvMould.IsSetInputColumnsColor = true;
  188. }
  189. /// <summary>
  190. /// 自适应列宽
  191. /// </summary>
  192. /// <param name="sender"></param>
  193. /// <param name="e"></param>
  194. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  195. {
  196. this.dgvMould.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  197. }
  198. /// <summary>
  199. /// 关闭画面
  200. /// </summary>
  201. /// <param name="sender"></param>
  202. /// <param name="e"></param>
  203. private void tsbtnClose_Click(object sender, EventArgs e)
  204. {
  205. this.Close();
  206. }
  207. #endregion
  208. #region 私有方法
  209. /// <summary>
  210. /// 保存前画面数据验证
  211. /// </summary>
  212. /// <returns></returns>
  213. private bool CheckInput()
  214. {
  215. if ((this.dgvMould.DataSource as DataTable).Rows.Count == 0)
  216. {
  217. MessageBox.Show("没有选择任何模具",
  218. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  219. MessageBoxDefaultButton.Button1);
  220. this.txtRemarks.Focus();
  221. return false;
  222. }
  223. if (this.dkGoodsCode.Visible && this.dkGoodsCode.GoodsID == null)
  224. {
  225. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "产品型号"),
  226. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  227. MessageBoxDefaultButton.Button1);
  228. this.dkGoodsCode.Focus();
  229. return false;
  230. }
  231. if (this.ftcScrapReason.Visible && this.ftcScrapReason.SelectedValue == null)
  232. {
  233. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "报废原因"),
  234. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  235. MessageBoxDefaultButton.Button1);
  236. this.ftcScrapReason.Focus();
  237. return false;
  238. }
  239. return true;
  240. }
  241. #endregion
  242. }
  243. }