F_PC_1004.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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. case Constant.MouldOperationType.MouldPlan:
  88. this.Text = "生产报工";
  89. this.lblMouldPlan.Visible = true;
  90. this.ftcMouldPlan.Visible = true;
  91. break;
  92. case Constant.MouldOperationType.UnMouldPlan:
  93. this.Text = "撤销报工";
  94. break;
  95. default:
  96. return;
  97. }
  98. ServiceResultEntity sre = PCModuleProxyNew.Service.HandleRequest(cre);
  99. this.dgvMould.DataSource = sre.Data.Tables[0];
  100. if (hasLoad)
  101. {
  102. ClientRequestEntity creLoad = new ClientRequestEntity();
  103. creLoad.NameSpace = "FPC1004";
  104. creLoad.Name = "GetFPC1004LoadData";
  105. creLoad.Properties["MouldOperationType"] = (int)_mouldOperationType;
  106. ServiceResultEntity sreLoad = PCModuleProxyNew.Service.HandleRequest(creLoad);
  107. this.ftcScrapReason.ValueMember = "dictionaryid";
  108. this.ftcScrapReason.DisplayMember = "dictionaryvalue";
  109. this.ftcScrapReason.DataSource = sreLoad.Data.Tables[0];
  110. }
  111. if(_mouldOperationType == Constant.MouldOperationType.MouldPlan)
  112. {
  113. ClientRequestEntity creLoad = new ClientRequestEntity();
  114. creLoad.NameSpace = "FPC1004";
  115. creLoad.Name = "GetFPC1004MouldPlanData";
  116. creLoad.Properties["goodsid"] = (this.dgvMould.DataSource as DataTable).Rows[0]["GoodsID"];
  117. ServiceResultEntity sreLoad = PCModuleProxyNew.Service.HandleRequest(creLoad);
  118. this.ftcMouldPlan.ValueMember = "plan_id";
  119. this.ftcMouldPlan.DisplayMember = "plan_code";
  120. this.ftcMouldPlan.DataSource = sreLoad.Data.Tables[0];
  121. }
  122. //this.dgvMould.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect;
  123. }
  124. catch (Exception ex)
  125. {
  126. // 对异常进行共通处理
  127. ExceptionManager.HandleEventException(this.ToString(),
  128. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  129. }
  130. }
  131. /// <summary>
  132. /// 查询
  133. /// </summary>
  134. /// <param name="sender"></param>
  135. /// <param name="e"></param>
  136. private void tsbtnSave_Click(object sender, EventArgs e)
  137. {
  138. try
  139. {
  140. if (!this.CheckInput())
  141. {
  142. return;
  143. }
  144. ClientRequestEntity cre = new ClientRequestEntity();
  145. cre.NameSpace = "FPC1004";
  146. cre.Name = "SetFPC1004Data";
  147. cre.Properties["MouldOperationType"] = (int)_mouldOperationType;
  148. if (this.dkGoodsCode.Visible)
  149. {
  150. cre.Properties["GoodsID"] = this.dkGoodsCode.GoodsID;
  151. cre.Properties["GoodsCode"] = this.dkGoodsCode.GoodsCode;
  152. }
  153. if (this.ftcScrapReason.Visible)
  154. {
  155. cre.Properties["ScrapReason"] = this.ftcScrapReason.SelectedValue;
  156. cre.Properties["ScrapResponsibility"] = this.txtScrapResponsibility.Text;
  157. }
  158. if (this.ftcMouldPlan.Visible)
  159. {
  160. cre.Properties["mould_plan_id"] = this.ftcMouldPlan.SelectedValue;
  161. }
  162. cre.Properties["Remarks"] = this.txtRemarks.Text;
  163. List<string> ids = new List<string>();
  164. foreach (DataRow item in (this.dgvMould.DataSource as DataTable).Rows)
  165. {
  166. ids.Add(item["MouldID"].ToString());
  167. }
  168. cre.Properties["MouldIDs"] = string.Join(",", ids);
  169. ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
  170. {
  171. return PCModuleProxyNew.Service.HandleRequest(cre);
  172. });
  173. if (sre != null)
  174. {
  175. if (sre.Status == Constant.ServiceResultStatus.Success)
  176. {
  177. // 提示信息
  178. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, this.Text, "保存"),
  179. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  180. this.DialogResult = DialogResult.OK;
  181. this.Close();
  182. }
  183. else if (!string.IsNullOrWhiteSpace(sre.Message))
  184. {
  185. MessageBox.Show(sre.Message,
  186. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  187. }
  188. }
  189. else
  190. {
  191. // 提示信息
  192. MessageBox.Show("保存失败",
  193. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  194. }
  195. }
  196. catch (Exception ex)
  197. {
  198. // 对异常进行共通处理
  199. ExceptionManager.HandleEventException(this.ToString(),
  200. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  201. }
  202. }
  203. /// <summary>
  204. /// 排序
  205. /// </summary>
  206. /// <param name="sender"></param>
  207. /// <param name="e"></param>
  208. private void dgvMould_Sorted(object sender, EventArgs e)
  209. {
  210. this.dgvMould.IsSetInputColumnsColor = true;
  211. }
  212. /// <summary>
  213. /// 自适应列宽
  214. /// </summary>
  215. /// <param name="sender"></param>
  216. /// <param name="e"></param>
  217. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  218. {
  219. this.dgvMould.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  220. }
  221. /// <summary>
  222. /// 关闭画面
  223. /// </summary>
  224. /// <param name="sender"></param>
  225. /// <param name="e"></param>
  226. private void tsbtnClose_Click(object sender, EventArgs e)
  227. {
  228. this.Close();
  229. }
  230. #endregion
  231. #region 私有方法
  232. /// <summary>
  233. /// 保存前画面数据验证
  234. /// </summary>
  235. /// <returns></returns>
  236. private bool CheckInput()
  237. {
  238. if ((this.dgvMould.DataSource as DataTable).Rows.Count == 0)
  239. {
  240. MessageBox.Show("没有选择任何模具",
  241. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  242. MessageBoxDefaultButton.Button1);
  243. this.txtRemarks.Focus();
  244. return false;
  245. }
  246. if (this.dkGoodsCode.Visible && this.dkGoodsCode.GoodsID == null)
  247. {
  248. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "产品型号"),
  249. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  250. MessageBoxDefaultButton.Button1);
  251. this.dkGoodsCode.Focus();
  252. return false;
  253. }
  254. if (this.ftcScrapReason.Visible && this.ftcScrapReason.SelectedValue == null)
  255. {
  256. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "报废原因"),
  257. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  258. MessageBoxDefaultButton.Button1);
  259. this.ftcScrapReason.Focus();
  260. return false;
  261. }
  262. if (this.ftcMouldPlan.Visible && this.ftcMouldPlan.SelectedValue == null)
  263. {
  264. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "生产计划"),
  265. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  266. MessageBoxDefaultButton.Button1);
  267. this.ftcScrapReason.Focus();
  268. return false;
  269. }
  270. return true;
  271. }
  272. #endregion
  273. }
  274. }