F_PC_0101_1_2.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PC_0101_1_2.cs
  5. * 2.功能描述:操作时间及备注录入
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2015/09/25 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Windows.Forms;
  12. using System.Data;
  13. using Dongke.IBOSS.PRD.Basics.BaseControls;
  14. using Dongke.IBOSS.PRD.Basics.BaseResources;
  15. using Dongke.IBOSS.PRD.WCF.Proxys;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.WCF.DataModels;
  18. namespace Dongke.IBOSS.PRD.Client.PCModule
  19. {
  20. public partial class F_PC_0101_1_2 : FormBase
  21. {
  22. #region 成员变量
  23. // 实例窗体
  24. //private F_PC_0101 _fpc0101;
  25. private DataTable _dtBindSource = null;
  26. //模具状态
  27. private int _GMouldStatus = 0;
  28. #endregion
  29. #region 构造函数
  30. //public F_PC_0101_1_2(F_PC_0101 fpc0101, string titleStr)
  31. //{
  32. // InitializeComponent();
  33. // this._titleStr = titleStr;
  34. // this._fpc0101 = fpc0101;
  35. // this._fpc0101.SetTimeOrRemarks(null, "");
  36. // this.Text = _titleStr;
  37. // this.btnSave.Text = ButtonText.BTN_SAVE;
  38. //}
  39. //public F_PC_0101_1_2(DataTable dtBindSource, string titleStr)
  40. //{
  41. // InitializeComponent();
  42. // _dtBindSource = dtBindSource;
  43. // this.Text = titleStr;
  44. // this.btnSave.Text = ButtonText.BTN_SAVE;
  45. // this.btnCancel.Text = ButtonText.BTN_CLOSE;
  46. // this.txtGroutingLineCode.Text = dtBindSource.Rows[0]["GroutingLineCode"].ToString();
  47. //}
  48. public F_PC_0101_1_2(DataTable dtBindSource, string titleStr, int GMouldStatus)
  49. {
  50. InitializeComponent();
  51. _dtBindSource = dtBindSource;
  52. this.Text = titleStr;
  53. this._GMouldStatus = GMouldStatus;
  54. this.btnSave.Text = ButtonText.BTN_SAVE;
  55. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  56. if (GMouldStatus != 6)
  57. {
  58. this.txtGroutingLineCode.Text = dtBindSource.Rows[0]["GroutingLineCode"].ToString();
  59. }
  60. if (GMouldStatus == 0 || GMouldStatus == 1)
  61. {
  62. this.btnDelete.Visible = true;
  63. this.dgvGroutingLineDetail.AllowUserToDeleteRows = true;
  64. }
  65. }
  66. public int GroutingLineID
  67. {
  68. get;
  69. set;
  70. }
  71. public string GroutingLineCode
  72. {
  73. get
  74. {
  75. return this.txtGroutingLineCode.Text;
  76. }
  77. set
  78. {
  79. this.txtGroutingLineCode.Text = value;
  80. }
  81. }
  82. public DateTime LineOPTimeStamp
  83. {
  84. get;
  85. set;
  86. }
  87. #endregion
  88. #region 事件
  89. /// <summary>
  90. /// 保存按钮事件
  91. /// </summary>
  92. /// <param name="sender"></param>
  93. /// <param name="e"></param>
  94. private void btnSave_Click(object sender, EventArgs e)
  95. {
  96. try
  97. {
  98. DataTable dtName = this.dgvGroutingLineDetail.DataSource as DataTable;
  99. dtName.AcceptChanges();
  100. if (dtName.Rows.Count == 0)
  101. {
  102. MessageBox.Show("没有选择任何数据", this.Text,
  103. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  104. return;
  105. }
  106. dtName.TableName = "GMouldRecord";
  107. if (this.pnlMouldStatus.Visible)
  108. {
  109. if (!dtName.Columns.Contains("MouldStatus"))
  110. {
  111. dtName.Columns.Add("MouldStatus", typeof(int));
  112. dtName.Columns.Add("ScrapReason", typeof(int));
  113. dtName.Columns.Add("ScrapResponsibility");
  114. }
  115. int ms = (this.rabMouldStatus1.Checked ? 1 : (this.rabMouldStatus3.Checked ? 3 : 4));
  116. foreach (DataRow item in dtName.Rows)
  117. {
  118. // 非条码模具
  119. if (item["MouldID"] + "" == "")
  120. {
  121. continue;
  122. }
  123. item["MouldStatus"] = ms;
  124. if (ms == 4)
  125. {
  126. item["ScrapReason"] = this.ftcScrapReason.SelectedValue;
  127. item["ScrapResponsibility"] = this.txtScrapResponsibility.Text;
  128. }
  129. }
  130. }
  131. int returnRow = 0;
  132. if (this._GMouldStatus == 0)
  133. {
  134. // 停用
  135. returnRow = (int)DoAsync(new BaseAsyncMethod(() =>
  136. {
  137. return PCModuleProxy.Service.StopGroutingLineDetail(dtName);
  138. }));
  139. }
  140. else if (this._GMouldStatus == 7)
  141. {
  142. ClientRequestEntity cre = new ClientRequestEntity();
  143. cre.NameSpace = "F_PC_0101_1_2";
  144. cre.Name = "DeactivatedGroutingLineDetail";
  145. DataSet ds = new DataSet();
  146. ds.Tables.Add(dtName);
  147. cre.Data = ds;
  148. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  149. returnRow = sre.OtherStatus;
  150. }
  151. else if (this._GMouldStatus == 1)
  152. {
  153. // 启用
  154. returnRow = (int)DoAsync(new BaseAsyncMethod(() =>
  155. {
  156. return PCModuleProxy.Service.StartGroutingLineDetail(dtName);
  157. }));
  158. }
  159. else if (this._GMouldStatus == 2)
  160. {
  161. // 维修
  162. returnRow = (int)DoAsync(new BaseAsyncMethod(() =>
  163. {
  164. return PCModuleProxy.Service.RepairStartGroutingLineDetail(dtName);
  165. }));
  166. }
  167. else if (this._GMouldStatus == 3)
  168. {
  169. //维修结束
  170. returnRow = (int)DoAsync(new BaseAsyncMethod(() =>
  171. {
  172. return PCModuleProxy.Service.RepairEndGroutingLineDetail(dtName);
  173. }));
  174. }
  175. else if (this._GMouldStatus == 4)
  176. {
  177. //换模
  178. returnRow = (int)DoAsync(new BaseAsyncMethod(() =>
  179. {
  180. return PCModuleProxy.Service.ChangeGMouldStartGroutingLineDetail(dtName);
  181. }));
  182. }
  183. else if (this._GMouldStatus == 5)
  184. {
  185. //变产
  186. returnRow = (int)DoAsync(new BaseAsyncMethod(() =>
  187. {
  188. return PCModuleProxy.Service.UpdateLineStartGroutingLineDetail(dtName);
  189. }));
  190. }
  191. else if (this._GMouldStatus == 6)
  192. {
  193. //整线变产
  194. returnRow = (int)DoAsync(new BaseAsyncMethod(() =>
  195. {
  196. return PCModuleProxy.Service.UpdateAllLineStartGroutingLineDetail(dtName, this.GroutingLineID, this.LineOPTimeStamp);
  197. }));
  198. }
  199. else if (this._GMouldStatus == 7)
  200. {
  201. // 卸模
  202. returnRow = (int)DoAsync(new BaseAsyncMethod(() =>
  203. {
  204. return PCModuleProxy.Service.UnloadGroutingLineDetail(dtName);
  205. }));
  206. }
  207. if (returnRow > 0)
  208. {
  209. //成功
  210. MessageBox.Show(this.Text + "成功", this.Text,
  211. MessageBoxButtons.OK, MessageBoxIcon.Information);
  212. this.DialogResult = DialogResult.OK;
  213. }
  214. else if (returnRow == -500)
  215. {
  216. MessageBox.Show("数据已经被修改,请重新编辑", this.Text,
  217. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  218. this.DialogResult = DialogResult.No;
  219. }
  220. else
  221. {
  222. //失败
  223. MessageBox.Show(this.Text + "失败", this.Text,
  224. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  225. this.DialogResult = DialogResult.No;
  226. }
  227. }
  228. catch (Exception ex)
  229. {
  230. // 对异常进行共通处理
  231. ExceptionManager.HandleEventException(this.ToString(),
  232. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  233. }
  234. }
  235. /// <summary>
  236. /// 窗体加载事件
  237. /// </summary>
  238. /// <param name="sender"></param>
  239. /// <param name="e"></param>
  240. private void F_PC_0101_1_2_Load(object sender, EventArgs e)
  241. {
  242. try
  243. {
  244. this.dgvGroutingLineDetail.AutoGenerateColumns = false;
  245. DateTime accountDate = CommonModuleProxy.Service.GetAccountDate();
  246. this.txtDateStart.Value = accountDate;
  247. this.dgvGroutingLineDetail.DataSource = _dtBindSource;
  248. // 设置可输入单元格的颜色
  249. this.dgvGroutingLineDetail.IsSetInputColumnsColor = true;
  250. if (this._GMouldStatus == 4 || this._GMouldStatus == 5 || this._GMouldStatus == 6 || this._GMouldStatus == 7)
  251. {
  252. DataRow[] dr = _dtBindSource.Select("MouldID is not null");
  253. if (dr != null && dr.Length > 0)
  254. {
  255. this.pnlMouldStatus.Visible = true;
  256. ClientRequestEntity creLoad = new ClientRequestEntity();
  257. creLoad.NameSpace = "FPC1004";
  258. creLoad.Name = "GetFPC1004LoadData";
  259. creLoad.Properties["MouldOperationType"] = (int)Constant.MouldOperationType.OnLineToScrap;
  260. ServiceResultEntity sreLoad = PCModuleProxyNew.Service.HandleRequest(creLoad);
  261. this.ftcScrapReason.ValueMember = "dictionaryid";
  262. this.ftcScrapReason.DisplayMember = "dictionaryvalue";
  263. this.ftcScrapReason.DataSource = sreLoad.Data.Tables[0];
  264. }
  265. }
  266. }
  267. catch (Exception ex)
  268. {
  269. // 对异常进行共通处理
  270. ExceptionManager.HandleEventException(this.ToString(),
  271. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  272. }
  273. }
  274. /// <summary>
  275. /// 关闭按钮事件
  276. /// </summary>
  277. /// <param name="sender"></param>
  278. /// <param name="e"></param>
  279. private void btnCancel_Click(object sender, EventArgs e)
  280. {
  281. this.Close();
  282. }
  283. /// <summary>
  284. /// 自适应
  285. /// </summary>
  286. /// <param name="sender"></param>
  287. /// <param name="e"></param>
  288. private void btnAdaptive_Click(object sender, EventArgs e)
  289. {
  290. this.dgvGroutingLineDetail.AutoResizeColumns();
  291. }
  292. /// <summary>
  293. /// 条码模具去向(报废)
  294. /// </summary>
  295. /// <param name="sender"></param>
  296. /// <param name="e"></param>
  297. private void rabMouldStatus4_CheckedChanged(object sender, EventArgs e)
  298. {
  299. this.pnlScrap.Visible = this.rabMouldStatus4.Checked;
  300. }
  301. #endregion
  302. private void btnDelete_Click(object sender, EventArgs e)
  303. {
  304. if (this.dgvGroutingLineDetail.CurrentRow == null)
  305. {
  306. return;
  307. }
  308. try
  309. {
  310. this.dgvGroutingLineDetail.Rows.Remove(this.dgvGroutingLineDetail.CurrentRow);
  311. }
  312. catch (Exception ex)
  313. {
  314. // 对异常进行共通处理
  315. ExceptionManager.HandleEventException(this.ToString(),
  316. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  317. }
  318. }
  319. }
  320. }