F_PC_0101_1_2.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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 == 1)
  141. {
  142. // 启用
  143. returnRow = (int)DoAsync(new BaseAsyncMethod(() =>
  144. {
  145. return PCModuleProxy.Service.StartGroutingLineDetail(dtName);
  146. }));
  147. }
  148. else if (this._GMouldStatus == 2)
  149. {
  150. // 维修
  151. returnRow = (int)DoAsync(new BaseAsyncMethod(() =>
  152. {
  153. return PCModuleProxy.Service.RepairStartGroutingLineDetail(dtName);
  154. }));
  155. }
  156. else if (this._GMouldStatus == 3)
  157. {
  158. //维修结束
  159. returnRow = (int)DoAsync(new BaseAsyncMethod(() =>
  160. {
  161. return PCModuleProxy.Service.RepairEndGroutingLineDetail(dtName);
  162. }));
  163. }
  164. else if (this._GMouldStatus == 4)
  165. {
  166. //换模
  167. returnRow = (int)DoAsync(new BaseAsyncMethod(() =>
  168. {
  169. return PCModuleProxy.Service.ChangeGMouldStartGroutingLineDetail(dtName);
  170. }));
  171. }
  172. else if (this._GMouldStatus == 5)
  173. {
  174. //变产
  175. returnRow = (int)DoAsync(new BaseAsyncMethod(() =>
  176. {
  177. return PCModuleProxy.Service.UpdateLineStartGroutingLineDetail(dtName);
  178. }));
  179. }
  180. else if (this._GMouldStatus == 6)
  181. {
  182. //整线变产
  183. returnRow = (int)DoAsync(new BaseAsyncMethod(() =>
  184. {
  185. return PCModuleProxy.Service.UpdateAllLineStartGroutingLineDetail(dtName, this.GroutingLineID, this.LineOPTimeStamp);
  186. }));
  187. }
  188. else if (this._GMouldStatus == 7)
  189. {
  190. // 卸模
  191. returnRow = (int)DoAsync(new BaseAsyncMethod(() =>
  192. {
  193. return PCModuleProxy.Service.UnloadGroutingLineDetail(dtName);
  194. }));
  195. }
  196. if (returnRow > 0)
  197. {
  198. //成功
  199. MessageBox.Show(this.Text + "成功", this.Text,
  200. MessageBoxButtons.OK, MessageBoxIcon.Information);
  201. this.DialogResult = DialogResult.OK;
  202. }
  203. else if (returnRow == -500)
  204. {
  205. MessageBox.Show("数据已经被修改,请重新编辑", this.Text,
  206. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  207. this.DialogResult = DialogResult.No;
  208. }
  209. else
  210. {
  211. //失败
  212. MessageBox.Show(this.Text + "失败", this.Text,
  213. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  214. this.DialogResult = DialogResult.No;
  215. }
  216. }
  217. catch (Exception ex)
  218. {
  219. // 对异常进行共通处理
  220. ExceptionManager.HandleEventException(this.ToString(),
  221. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  222. }
  223. }
  224. /// <summary>
  225. /// 窗体加载事件
  226. /// </summary>
  227. /// <param name="sender"></param>
  228. /// <param name="e"></param>
  229. private void F_PC_0101_1_2_Load(object sender, EventArgs e)
  230. {
  231. try
  232. {
  233. this.dgvGroutingLineDetail.AutoGenerateColumns = false;
  234. DateTime accountDate = CommonModuleProxy.Service.GetAccountDate();
  235. this.txtDateStart.Value = accountDate;
  236. this.dgvGroutingLineDetail.DataSource = _dtBindSource;
  237. // 设置可输入单元格的颜色
  238. this.dgvGroutingLineDetail.IsSetInputColumnsColor = true;
  239. if (this._GMouldStatus == 4 || this._GMouldStatus == 5 || this._GMouldStatus == 6 || this._GMouldStatus == 7)
  240. {
  241. DataRow[] dr = _dtBindSource.Select("MouldID is not null");
  242. if (dr != null && dr.Length > 0)
  243. {
  244. this.pnlMouldStatus.Visible = true;
  245. ClientRequestEntity creLoad = new ClientRequestEntity();
  246. creLoad.NameSpace = "FPC1004";
  247. creLoad.Name = "GetFPC1004LoadData";
  248. creLoad.Properties["MouldOperationType"] = (int)Constant.MouldOperationType.OnLineToScrap;
  249. ServiceResultEntity sreLoad = PCModuleProxyNew.Service.HandleRequest(creLoad);
  250. this.ftcScrapReason.ValueMember = "dictionaryid";
  251. this.ftcScrapReason.DisplayMember = "dictionaryvalue";
  252. this.ftcScrapReason.DataSource = sreLoad.Data.Tables[0];
  253. }
  254. }
  255. }
  256. catch (Exception ex)
  257. {
  258. // 对异常进行共通处理
  259. ExceptionManager.HandleEventException(this.ToString(),
  260. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  261. }
  262. }
  263. /// <summary>
  264. /// 关闭按钮事件
  265. /// </summary>
  266. /// <param name="sender"></param>
  267. /// <param name="e"></param>
  268. private void btnCancel_Click(object sender, EventArgs e)
  269. {
  270. this.Close();
  271. }
  272. /// <summary>
  273. /// 自适应
  274. /// </summary>
  275. /// <param name="sender"></param>
  276. /// <param name="e"></param>
  277. private void btnAdaptive_Click(object sender, EventArgs e)
  278. {
  279. this.dgvGroutingLineDetail.AutoResizeColumns();
  280. }
  281. /// <summary>
  282. /// 条码模具去向(报废)
  283. /// </summary>
  284. /// <param name="sender"></param>
  285. /// <param name="e"></param>
  286. private void rabMouldStatus4_CheckedChanged(object sender, EventArgs e)
  287. {
  288. this.pnlScrap.Visible = this.rabMouldStatus4.Checked;
  289. }
  290. #endregion
  291. private void btnDelete_Click(object sender, EventArgs e)
  292. {
  293. if (this.dgvGroutingLineDetail.CurrentRow == null)
  294. {
  295. return;
  296. }
  297. try
  298. {
  299. this.dgvGroutingLineDetail.Rows.Remove(this.dgvGroutingLineDetail.CurrentRow);
  300. }
  301. catch (Exception ex)
  302. {
  303. // 对异常进行共通处理
  304. ExceptionManager.HandleEventException(this.ToString(),
  305. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  306. }
  307. }
  308. }
  309. }