ZcPassApplyFrm.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using Core.StlMes.Client.Judge.Commons;
  5. using Core.StlMes.Client.Judge.Controls;
  6. using CoreFS.CA06;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Data;
  10. using System.Linq;
  11. using System.Windows.Forms;
  12. namespace Core.StlMes.Client.Judge.Forms
  13. {
  14. public partial class ZcPassApplyFrm : FrmBase
  15. {
  16. private QcmZcPassApplyCtrl _zcPassApplyCtrl;
  17. private QcmZcAllChemPhyCtrl _zcAllChemPhyCtrl;
  18. private Dal _d;
  19. public ZcPassApplyFrm()
  20. {
  21. InitializeComponent();
  22. IsLoadUserView = true;
  23. }
  24. public override void ToolBar_Click(object sender, string ToolbarKey)
  25. {
  26. base.ToolBar_Click(sender, ToolbarKey);
  27. switch (ToolbarKey)
  28. {
  29. case "Query":
  30. Query();
  31. break;
  32. case "Audite":
  33. Audite();
  34. break;
  35. case "FoldQuery":
  36. FoldQuery();
  37. break;
  38. case "Export":
  39. GridHelper.ulGridToExcel(_zcPassApplyCtrl.UltraGrid1, "放行信息");
  40. break;
  41. }
  42. }
  43. protected override void OnLoad(EventArgs e)
  44. {
  45. base.OnLoad(e);
  46. _zcAllChemPhyCtrl.SetChemPhyResultError();
  47. }
  48. private string passType = "";
  49. private void SteelMakingPassApplyFrm_Load(object sender, EventArgs e)
  50. {
  51. passType = CustomInfo;
  52. _d = new Dal(ob);
  53. _zcPassApplyCtrl = new QcmZcPassApplyCtrl(splitContainer2.Panel1, ob, this.UserInfo.GetDeptid());
  54. _zcPassApplyCtrl.UltraGrid1.AfterRowActivate += zgPassApplyCtrl_AfterRowActivate;
  55. _zcAllChemPhyCtrl = new QcmZcAllChemPhyCtrl(ultraExpandableGroupBoxPanel2, ob, _zcPassApplyCtrl.UltraGrid1, "", "zcPass");
  56. labelComboBox1.ComboBox.Value = "2";
  57. labelComboBox1.Checked = true;
  58. if (passType == "Quality")
  59. {
  60. ClsBaseInfo.FillComBaseInfo(labelComboBox1.ComboBox, "4075", ob, false);
  61. //判定结果只显示内控合格和不合格。 40740101内控合格 40740102内控不合格
  62. DataTable dt = (DataTable)labelComboBox1.ComboBox.DataSource;
  63. DataRow dr = dt.NewRow();
  64. dr["BASECODE"] = "2";
  65. dr["BASENAME"] = "未处置";
  66. dt.Rows.InsertAt(dr, 0);
  67. dt.AcceptChanges();
  68. dt.DefaultView.RowFilter = "BASECODE <> '407501'";
  69. ClsBaseInfo.SetComboItemHeight(labelComboBox1.ComboBox);
  70. }
  71. labelComboBox1.SelecteValue = "2"; ;
  72. labelDateTimePicker6.Value = DateTime.Now.Date.AddDays(-3);
  73. labelDateTimePicker5.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  74. }
  75. private void Audite()
  76. {
  77. var chkRows = _zcPassApplyCtrl.UltraGrid1.Rows.Where(a => a.GetValue("chk") == "True");
  78. if (chkRows.Count() == 0)
  79. {
  80. MessageUtil.ShowWarning("没有需要审核的记录!");
  81. return;
  82. }
  83. string passApplyNo = "";
  84. string passApplySeq = "";
  85. List<string[]> parms = new List<string[]>();
  86. foreach (var row in chkRows)
  87. {
  88. DataRow drPassApply = _d.GetRowByXmlId("JdgQcmZcPassApplyDAL.queryByPassApplyNo", row.GetValue("passApplyNo"));
  89. DataRow drCrtAuditStep = _d.GetRowByXmlId("JdgQcmZcPassFlow.getCrtAuditStep", row.GetValue("passApplyNo"));
  90. DataRow drMaxAuditStep = _d.GetRowByXmlId("JdgQcmZcPassFlow.getMaxAuditStep", row.GetValue("passApplyNo"));
  91. DataRow drJudgeApply = _d.GetRowByXmlId("QcmZgJugdeApplyDAL.QueryByBatchNo", row.GetValue("jugdeApplyCode"),
  92. row.GetValue("judgeStoveNo"), row.GetValue("batchNo"));
  93. if (drPassApply["validflag"].ToString() == "0")
  94. {
  95. MessageUtil.ShowWarning("该放行申请记录已被删除,无法操作!", _zcPassApplyCtrl.UltraGrid1, row);
  96. return;
  97. }
  98. else if (int.Parse(row.GetValue("auditStep")) < int.Parse(drCrtAuditStep["auditStep"].ToString()) - 1)
  99. {
  100. MessageUtil.ShowWarning("第" + (int.Parse(drCrtAuditStep["auditStep"].ToString()) - 1) + "步骤审核完毕,不能修改第"
  101. + row.GetValue("auditStep") + "步骤审核结果!", _zcPassApplyCtrl.UltraGrid1, row);
  102. return;
  103. }
  104. else if (int.Parse(row.GetValue("auditStep")) == int.Parse(drCrtAuditStep["auditStep"].ToString()) - 1
  105. && drCrtAuditStep["auditResult"].ToString() != "")
  106. {
  107. MessageUtil.ShowWarning("第" + drCrtAuditStep["auditStep"].ToString() + "步骤审核完毕,不能修改第"
  108. + row.GetValue("auditStep") + "步骤审核结果!", _zcPassApplyCtrl.UltraGrid1, row);
  109. return;
  110. }
  111. else if (int.Parse(row.GetValue("auditStep")) > int.Parse(drCrtAuditStep["auditStep"].ToString()))
  112. {
  113. MessageUtil.ShowWarning("第" + drCrtAuditStep["auditStep"].ToString() + "步骤审核未完成,不能提前操作第"
  114. + row.GetValue("auditStep") + "步骤审核!", _zcPassApplyCtrl.UltraGrid1, row);
  115. return;
  116. }
  117. else if (drPassApply["type"].ToString() == "0" && drPassApply["judgeResultCode"].ToString() != "40740704"
  118. && drPassApply["judgeResultCode"].ToString() != "40740708")
  119. {
  120. MessageUtil.ShowWarning("只能审核综合判定结果不合格的炉号!", _zcPassApplyCtrl.UltraGrid1, row);
  121. return;
  122. }
  123. else if (drJudgeApply == null || drJudgeApply["validflag"].ToString() != "20")
  124. {
  125. MessageUtil.ShowWarning("此炉号已撤销判定,不能修改审核结果!", _zcPassApplyCtrl.UltraGrid1, row);
  126. return;
  127. }
  128. else if (drJudgeApply != null && (drJudgeApply["judgeResult"].ToString() == "40740701" || drJudgeApply["judgeResult"].ToString() == "40740707"))
  129. {
  130. MessageUtil.ShowWarning("此炉号已判定合格,不能修改审核结果!", _zcPassApplyCtrl.UltraGrid1, row);
  131. return;
  132. }
  133. else if (drPassApply["type"].ToString() == "1" && drPassApply["auditResult"].ToString() == "1")
  134. {
  135. MessageUtil.ShowWarning("此炉号已放行通过,不能修改审核结果!", _zcPassApplyCtrl.UltraGrid1, row);
  136. return;
  137. }
  138. passApplyNo = row.GetValue("passApplyNo");
  139. passApplySeq = row.GetValue("passApplySeq");
  140. string[] parm = new string[] { row.GetValue("passApplyNo"), row.GetValue("auditStep") };
  141. parms.Add(parm);
  142. }
  143. PopupAudite popupAudit = new PopupAudite("审核", passType, true);
  144. popupAudit.CmbAuditType.Caption = "处置方式";
  145. if (passType == "Quality")
  146. {
  147. ClsBaseInfo.FillComBaseInfo(popupAudit.CmbAuditType.ComboBox, "4075", ob, false);
  148. ((DataTable)popupAudit.CmbAuditType.ComboBox.DataSource).DefaultView.RowFilter = "BASECODE <> '407501'";
  149. }
  150. string auditeResult = "";
  151. string memo = "";
  152. if (popupAudit.ShowDialog() != System.Windows.Forms.DialogResult.OK)
  153. {
  154. return;
  155. }
  156. else
  157. {
  158. memo = popupAudit.TxtAudit.Text.Trim();
  159. auditeResult = popupAudit.CmbAuditType.ComboBox.Value.ToString2();
  160. }
  161. var ccp = _d.Set("com.steering.pss.judge.Bll.BllZcColligatePassApply.Audite", parms, UserInfo.GetUserID(), UserInfo.GetUserName(),
  162. auditeResult, memo);
  163. if (ccp.ReturnInfo != "")
  164. {
  165. MessageUtil.ShowError(ccp.ReturnInfo);
  166. return;
  167. }
  168. else
  169. {
  170. MessageUtil.ShowTips("操作成功!");
  171. }
  172. Relocate(passApplyNo);
  173. }
  174. private void labelDateTimePicker4_CheckBox_CheckedChanged(object sender, EventArgs e)
  175. {
  176. labelDateTimePicker5.DateTimeEnabled = labelDateTimePicker6.Checked;
  177. }
  178. private void Relocate(string passApplyNo)
  179. {
  180. Query();
  181. var row = _zcPassApplyCtrl.UltraGrid1.Rows.Where(a => a.GetValue("passApplyNo") == passApplyNo).FirstOrDefault();
  182. if (row != null)
  183. {
  184. row.Activate();
  185. }
  186. }
  187. public void Query()
  188. {
  189. try
  190. {
  191. this.Cursor = Cursors.WaitCursor;
  192. _zcAllChemPhyCtrl.ClearChemPhyData();
  193. string batchNo = labelTextBox5.Checked ? labelTextBox5.Text.Trim() : "";
  194. string judgeStoveNo = labelTextBox6.Checked ? labelTextBox6.Text.Trim() : "";
  195. string auditState = labelComboBox1.Checked ? labelComboBox1.SelecteValue.ToString2() : "";
  196. string timeB = labelDateTimePicker6.Checked ? labelDateTimePicker6.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
  197. string timeE = labelDateTimePicker6.Checked ? labelDateTimePicker5.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
  198. _zcPassApplyCtrl.AuditeQuery(judgeStoveNo, batchNo, timeB, timeE, passType, auditState, "1");
  199. }
  200. finally
  201. {
  202. this.Cursor = Cursors.Default;
  203. }
  204. }
  205. void zgPassApplyCtrl_AfterRowActivate(object sender, EventArgs e)
  206. {
  207. try
  208. {
  209. this.Cursor = Cursors.WaitCursor;
  210. _zcAllChemPhyCtrl.UltraTabControl2_SelectedTabChanged(null, null);
  211. }
  212. finally
  213. {
  214. this.Cursor = Cursors.Default;
  215. }
  216. }
  217. public string[] GetChemJudgeStoveNos(string matNo, string curProcess)
  218. {
  219. if (curProcess.ToCharArray()[0] < 'D')
  220. {
  221. DataRow drTrack = _d.GetRowByXmlId("JdgMatBcQcmTrack.getByMatNoFirstRow", matNo, "D");
  222. return new string[] { drTrack["judgeStoveNo"].ToString(), "A" };
  223. }
  224. else
  225. {
  226. DataRow drTrack = _d.GetRowByXmlId("JdgMatBcQcmTrack.getByMatNoFirstRow", matNo, curProcess);
  227. if (drTrack != null)
  228. {
  229. DataRow drJudge = _d.GetRowByXmlId("JdgQcmBcJudge.getByJudgeId", drTrack["jugdeConvicted"].ToString());
  230. if (drJudge["chemResult"].ToString() != "")
  231. {
  232. return new string[] { drTrack["judgeStoveNo"].ToString(), curProcess };
  233. }
  234. else
  235. {
  236. curProcess = ((char)(curProcess.ToCharArray()[0] - 1)).ToString();
  237. return GetChemJudgeStoveNos(matNo, curProcess);
  238. }
  239. }
  240. else
  241. {
  242. curProcess = ((char)(curProcess.ToCharArray()[0] - 1)).ToString();
  243. return GetChemJudgeStoveNos(matNo, curProcess);
  244. }
  245. }
  246. }
  247. private void labelTextBox6_TextBox_KeyDown(object sender, KeyEventArgs e)
  248. {
  249. if (e.KeyData == Keys.Enter)
  250. {
  251. Query();
  252. }
  253. }
  254. private void FoldQuery()
  255. {
  256. if (!this.toolMenu.Toolbars[0].Tools.Exists("FoldQuery")) return;
  257. panel5.Visible = !panel5.Visible;
  258. if (panel5.Visible)
  259. {
  260. this.toolMenu.Toolbars[0].Tools["FoldQuery"].SharedProps.Caption = "折叠查询区域";
  261. }
  262. else
  263. {
  264. this.toolMenu.Toolbars[0].Tools["FoldQuery"].SharedProps.Caption = "展开查询区域";
  265. }
  266. }
  267. private void ZcPassApplyFrm_Shown(object sender, EventArgs e)
  268. {
  269. FoldQuery();
  270. }
  271. }
  272. }