FrmOfflineProcess.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. using com.steering.mes.zgmil.entity;
  2. using Core.Mes.Client.Comm.Control;
  3. using Core.Mes.Client.Comm.Format;
  4. using Core.Mes.Client.Comm.Server;
  5. using Core.Mes.Client.Comm.Tool;
  6. using Core.StlMes.Client.ZGMil.Common;
  7. using Core.StlMes.Client.ZGMil.Entity;
  8. using Core.StlMes.Client.ZGMil.NodeResultQuery;
  9. using Core.StlMes.Client.ZGMil.Popup;
  10. using Core.StlMes.Client.ZGMil.Report;
  11. using Core.StlMes.Client.ZGMil.ResultConrtrol;
  12. using CoreFS.CA06;
  13. using Infragistics.Win.UltraWinGrid;
  14. using System;
  15. using System.Collections;
  16. using System.Collections.Generic;
  17. using System.ComponentModel;
  18. using System.Data;
  19. using System.Drawing;
  20. using System.Linq;
  21. using System.Text;
  22. using System.Windows.Forms;
  23. namespace Core.StlMes.Client.ZGMil.Signature
  24. {
  25. public partial class FrmOfflineProcess : FrmBase
  26. {
  27. private string Process = "";//参数
  28. private string[] arrId;//数据权限
  29. private string[] plineCodes = { };
  30. private DataTable _dtPline = null;
  31. private string basecodeSamll = "";//停机小类值
  32. private string basecodeReason = "";//停机原因值
  33. public FrmOfflineProcess()
  34. {
  35. InitializeComponent();
  36. }
  37. private void FrmOfflineProcess_Load(object sender, EventArgs e)
  38. {
  39. DateTime now = DateTime.Now;
  40. DateTime dt1 = new DateTime(now.Year, now.Month, 1);//当月第一天
  41. DateTime dt2 = dt1.AddMonths(1).AddDays(-1);//当月最后一天
  42. this.StartTime2.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00");
  43. this.EndTime2.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59");
  44. EntityHelper.ShowGridCaption<OfflineProcessEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  45. plineCodes = BaseMethod.GetPlineCode(ValidDataPurviewIds, ob);
  46. Process = this.CustomInfo.ToString();//参数
  47. _dtPline = ServerHelper.GetData("com.steering.mes.zgmil.report.FrmOfflineProcess.JudgeBaseInfo", new object[] { plineCodes }, ob);
  48. //_dtPline.AcceptChanges();
  49. string strPlineNames = string.Join(",", _dtPline.Rows.Cast<DataRow>().Select(a => a["plineName"].ToString()).ToArray());
  50. string strPineCodes = string.Join(",", _dtPline.Rows.Cast<DataRow>().Select(a => a["plineCode"].ToString()).ToArray());
  51. ultraTextEditor1.Text = strPlineNames;
  52. ultraTextEditor1.Tag = strPineCodes;
  53. DataTable dt = TubeRoll.GetComBaseInfo("4113", ob);
  54. cmbLx.DataSource = dt;
  55. cmbLx.ValueMember = "BASECODE";
  56. cmbLx.DisplayMember = "BASENAME";
  57. TubeRoll.SetComboItemHeight(cmbLx);
  58. InitBindColumn();
  59. IsLoadUserView = true;
  60. }
  61. private void InitBindColumn()
  62. {
  63. }
  64. public override void ToolBar_Click(object sender, string ToolbarKey)
  65. {
  66. switch (ToolbarKey)
  67. {
  68. case "Query":
  69. QueryOfflineProcess();
  70. break;
  71. case "Save":
  72. doSave();
  73. break;
  74. case "Audit":
  75. Audit();
  76. break;
  77. case "Close":
  78. this.Close();
  79. break;
  80. case "Export":
  81. GridHelper.ulGridToExcel(ultraGrid1, "离线品管理");
  82. break;
  83. }
  84. }
  85. /// <summary>
  86. /// 调整设料量
  87. /// </summary>
  88. //private void updateInputWt()
  89. //{
  90. // this.ultraGrid1.UpdateData();
  91. // UltraGridRow uRow = this.ultraGrid1.ActiveRow;
  92. // //string departMentid = PipeManageClass.GetDepartIdBySectionId(UserInfo.GetDeptid(), ob);
  93. // string departMentid = UserInfo.GetDeptid();
  94. // if (uRow == null)
  95. // {
  96. // MessageUtil.ShowTips("请选择需要调整的炉信息!");
  97. // return;
  98. // }
  99. // if (Double.Parse(uRow.Cells["InputCount"].Value.ToString3()) < 0)
  100. // {
  101. // MessageUtil.ShowTips("请输入正确的数字!");
  102. // return;
  103. // }
  104. // if (Double.Parse(uRow.Cells["InputWeight"].Value.ToString3()) < 0)
  105. // {
  106. // MessageUtil.ShowTips("请输入正确的数字 !");
  107. // return;
  108. // }
  109. // ArrayList list = new ArrayList();
  110. // list.Add(uRow.Cells["JugdeApplyCode"].Value.ToString());
  111. // list.Add(uRow.Cells["JugdeApplySequeno"].Value.ToString());
  112. // list.Add(uRow.Cells["JudgeStoveNo"].Value.ToString());
  113. // list.Add(uRow.Cells["BatchNo"].Value.ToString());
  114. // list.Add(uRow.Cells["BatchGroudNo"].Value.ToString());
  115. // list.Add(uRow.Cells["InputCount"].Text.ToString3());
  116. // list.Add(uRow.Cells["InputWeight"].Text.ToString3());
  117. // list.Add(UserInfo.GetUserName());
  118. // CoreClientParam ccp = new CoreClientParam();
  119. // ccp.ServerName = "com.steering.mes.signature.FrmInOnlineStore";
  120. // ccp.MethodName = "updateInputWt";
  121. // ccp.ServerParams = new object[] { list };
  122. // ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  123. // if (ccp.ReturnCode != -1)
  124. // {
  125. // if (ccp.ReturnInfo.Equals("调整成功!"))
  126. // {
  127. // QueryZgJugdeApply();
  128. // MessageUtil.ShowTips(ccp.ReturnInfo);
  129. // }
  130. // else
  131. // {
  132. // MessageUtil.ShowTips(ccp.ReturnInfo);
  133. // }
  134. // }
  135. //}
  136. /// <summary>
  137. /// 查询离线数据
  138. /// </summary>
  139. private void QueryOfflineProcess()
  140. {
  141. string plinCode = "";
  142. string jugeNo = "";
  143. string startTim = "";
  144. string endTim = "";
  145. string isAudit = "";
  146. string orderno = "";
  147. string reason = "";
  148. string lxStartTime = "";
  149. string lxEndTime = "";
  150. string departMentid = UserInfo.GetDeptid();
  151. if (this.chkHeatNo2.Checked && this.txtHeatNo2.Text.Trim() != "")
  152. {
  153. jugeNo = this.txtHeatNo2.Text.Trim();
  154. }
  155. if (chkTim2.Checked)
  156. {
  157. if (DateTime.Parse(StartTime2.Value.ToString()) > DateTime.Parse(EndTime2.Value.ToString()))
  158. {
  159. MessageUtil.ShowTips("选择的前面时间不能大于后面的时间!");
  160. return;
  161. }
  162. else
  163. {
  164. startTim = this.StartTime2.Value.ToString("yyyy-MM-dd HH:mm:ss");
  165. endTim = this.EndTime2.Value.ToString("yyyy-MM-dd HH:mm:ss");
  166. }
  167. }
  168. if (lx_check.Checked)
  169. {
  170. if (DateTime.Parse(StartTime2.Value.ToString()) > DateTime.Parse(EndTime2.Value.ToString()))
  171. {
  172. MessageUtil.ShowTips("选择的前面时间不能大于后面的时间!");
  173. return;
  174. }
  175. else
  176. {
  177. lxStartTime = this.lx_text.Value.ToString("yyyy-MM-dd HH:mm:ss");
  178. lxEndTime = this.dateTimePicker1.Value.ToString("yyyy-MM-dd HH:mm:ss");
  179. }
  180. }
  181. if(check_reason.Checked)
  182. {
  183. reason = this.reason.Value.ToString();
  184. }
  185. if (check_orderno.Checked)
  186. {
  187. orderno = this.orderno.Text.Trim();
  188. }
  189. if (chkPlineCode.Checked)
  190. {
  191. plinCode = ultraTextEditor1.Tag.ToString().Replace(",", "', '");
  192. }
  193. if (lx_check.Checked)
  194. {
  195. }
  196. if (chekAudit.Checked)
  197. {
  198. isAudit = proc_chekedAudit(chekAudit.Checked,this.isAudit.Text.Trim());
  199. }
  200. List<OfflineProcessEntity> listSource = EntityHelper.GetData<OfflineProcessEntity>(
  201. "com.steering.mes.signature.FrmInOnlineStore.QueryOfflineProcess", new object[] { jugeNo, startTim, endTim, plinCode, isAudit, reason, orderno, lxStartTime, lxEndTime }, this.ob);
  202. bindingSource2.DataSource = listSource;
  203. //GridHelper.RefreshAndAutoSize(ultraGrid1);
  204. }
  205. ///MESServer/src/com/steering/mes/zgmil/entity/OfflineProcess.java
  206. private string proc_chekedAudit(bool cheked, string str)
  207. {
  208. switch (str)
  209. {
  210. case "未发起评审":
  211. return "0";
  212. case "已发起评审":
  213. return "1";
  214. case "评审通过":
  215. return "2";
  216. default:
  217. return "";
  218. }
  219. }
  220. private void doSave()
  221. {
  222. this.ultraGrid1.UpdateData();
  223. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  224. if (checkMagRows.Count() == 0)
  225. {
  226. MessageUtil.ShowTips("请选择需要保存的数据!");
  227. return;
  228. }
  229. ArrayList parm = new ArrayList();
  230. foreach (UltraGridRow uRow in checkMagRows)
  231. {
  232. OfflineProcessEntity OfflineResult = (OfflineProcessEntity)uRow.ListObject;
  233. string OfflineResultTity = JSONFormat.Format(OfflineResult);
  234. parm.Add(OfflineResultTity);
  235. }
  236. CoreClientParam ccp = new CoreClientParam();
  237. ccp.ServerName = "com.steering.mes.zgmil.report.FrmOfflineProcess";
  238. ccp.MethodName = "doSave";
  239. ccp.ServerParams = new object[] { parm};
  240. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  241. if (ccp.ReturnCode != -1)
  242. {
  243. if (ccp.ReturnInfo.Equals("操作成功"))
  244. {
  245. // DoQueryInList();
  246. QueryOfflineProcess();
  247. MessageUtil.ShowTips(ccp.ReturnInfo);
  248. }
  249. else
  250. {
  251. MessageUtil.ShowTips(ccp.ReturnInfo);
  252. }
  253. }
  254. }
  255. private void Audit()
  256. {
  257. this.ultraGrid1.UpdateData();
  258. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  259. if (checkMagRows.Count() == 0)
  260. {
  261. MessageUtil.ShowTips("请选择需要审核的数据!");
  262. return;
  263. }
  264. ArrayList parm = new ArrayList();
  265. foreach (UltraGridRow uRow in checkMagRows)
  266. {
  267. OfflineProcessEntity offlineResult = (OfflineProcessEntity)uRow.ListObject;
  268. if (offlineResult.Reason1 == "" || offlineResult.Reason2 == "" || offlineResult.Reason3 == "")
  269. {
  270. MessageUtil.ShowTips("请选择离线原因");
  271. return;
  272. }
  273. string OfflineResultTity = JSONFormat.Format(offlineResult);
  274. parm.Add(OfflineResultTity);
  275. }
  276. if (MessageUtil.ShowYesNoAndQuestion("确定需要提交审核?") == DialogResult.No) return;
  277. string userName = UserInfo.GetUserName();
  278. string department = UserInfo.GetDepartment();
  279. CoreClientParam ccp = new CoreClientParam();
  280. ccp.ServerName = "com.steering.mes.zgmil.report.FrmOfflineProcess";
  281. ccp.MethodName = "doAudit";
  282. ccp.ServerParams = new object[] { parm, userName, department };
  283. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  284. if (ccp.ReturnCode != -1)
  285. {
  286. if (ccp.ReturnInfo.Equals("操作成功"))
  287. {
  288. // DoQueryInList();
  289. QueryOfflineProcess();
  290. MessageUtil.ShowTips(ccp.ReturnInfo);
  291. }
  292. else
  293. {
  294. MessageUtil.ShowTips(ccp.ReturnInfo);
  295. }
  296. }
  297. }
  298. private void chkTim2_CheckedChanged(object sender, EventArgs e)
  299. {
  300. this.StartTime2.Enabled = this.EndTime2.Enabled = this.chkTim2.Checked;
  301. }
  302. private void chkHeatNo2_CheckedChanged(object sender, EventArgs e)
  303. {
  304. this.txtHeatNo2.Enabled = this.chkHeatNo2.Checked;
  305. }
  306. private void chekAudit_CheckedChanged(object sender, EventArgs e)
  307. {
  308. this.isAudit.Enabled = this.chekAudit.Checked;
  309. }
  310. private void check_reason_CheckedChanged(object sender, EventArgs e)
  311. {
  312. this.reason.Enabled = this.check_reason.Checked;
  313. }
  314. private void check_orderno_CheckedChanged(object sender, EventArgs e)
  315. {
  316. this.orderno.Enabled = this.check_orderno.Checked;
  317. }
  318. private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  319. {
  320. ChoicePlineFrm frm = new ChoicePlineFrm(_dtPline, ultraTextEditor1.Tag.ToString2(), this.ob);
  321. if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  322. {
  323. ultraTextEditor1.Text = frm.ChoicePlineName;
  324. ultraTextEditor1.Tag = frm.ChoicePlineCode;
  325. }
  326. }
  327. private void chkPlineCode_CheckedChanged(object sender, EventArgs e)
  328. {
  329. this.ultraTextEditor1.Enabled = this.chkPlineCode.Checked;
  330. }
  331. private void Reason2_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  332. {
  333. UltraGridRow row = ultraGrid1.ActiveRow;
  334. string reason1 = "";
  335. if (!row.Cells["Reason1"].Text.Trim().Equals(""))
  336. {
  337. reason1 = row.Cells["Reason1"].Value.ToString();
  338. }
  339. FrmStopSamll fpdc = new FrmStopSamll(reason1, ob);
  340. fpdc.AutoSize = true;
  341. fpdc.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  342. fpdc.Text = "二级原因";
  343. fpdc.ShowDialog();
  344. if (fpdc.DialogResult == System.Windows.Forms.DialogResult.OK)
  345. {
  346. //获取弹出窗体的属性值
  347. row.Cells["Reason2"].Value = fpdc.Basename;
  348. //cmbStopSmall.Value = fpdc.Basename;
  349. basecodeSamll = fpdc.Basecode;
  350. }
  351. chageReason();
  352. }
  353. private void Reason3_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  354. {
  355. UltraGridRow row = ultraGrid1.ActiveRow;
  356. if (row == null) return;
  357. string reason2 = basecodeSamll;
  358. if (!row.Cells["Reason2"].Text.Equals("")) { reason2 = row.Cells["Reason2"].Value.ToString(); }
  359. FrmStopSamll fpdc = new FrmStopSamll(basecodeSamll, ob);
  360. fpdc.AutoSize = true;
  361. fpdc.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  362. fpdc.Text = "三级原因";
  363. fpdc.ShowDialog();
  364. if (fpdc.DialogResult == System.Windows.Forms.DialogResult.OK)
  365. {
  366. //获取弹出窗体的属性值
  367. row.Cells["Reason3"].Value = fpdc.Basename;
  368. //cmbStopReason.Value = fpdc.Basename;
  369. basecodeReason = fpdc.Basecode;
  370. }
  371. chageReason();
  372. }
  373. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  374. {
  375. if (ultraGrid1.ActiveRow == null)
  376. return;
  377. string id = ultraGrid1.ActiveRow.Cells["ResultNo"].Value.ToString();
  378. DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.report.FrmOfflineProcess.QueryOfflineAudits", new object[] { id }, ob);
  379. GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);
  380. for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  381. {
  382. if (ultraGrid2.Rows[i].Cells["ID"].Value.ToString().Equals(id))
  383. {
  384. ultraGrid2.ActiveRow = ultraGrid2.Rows[i];
  385. //ulgridSteelPlan.Rows[i].Selected = true;
  386. return;
  387. }
  388. //else
  389. //{
  390. // ulgridSteelPlan.ActiveRow = ulgridSteelPlan.Rows[i];
  391. // //ulgridSteelPlan.Rows[i].Selected = true;
  392. // return;
  393. //}
  394. }
  395. }
  396. private void ultraGrid1_DoubleClick(object sender, EventArgs e)
  397. {
  398. UltraGridRow row = ultraGrid1.ActiveRow;
  399. string srKey = this.ultraGrid1.ActiveCell.Column.ToString();
  400. if (row.Cells["PlineNameA"].Text != null && srKey == "PlineNameA")
  401. {
  402. row.Cells["PlineNameResponse"].Value = row.Cells["PlineNameA"].Text;
  403. }
  404. if (row.Cells["PlineNameD"].Text != null && srKey == "PlineNameD")
  405. {
  406. row.Cells["PlineNameResponse"].Value = row.Cells["PlineNameD"].Text;
  407. }
  408. if (row.Cells["PlineNameE"].Text != null && srKey == "PlineNameE")
  409. {
  410. row.Cells["PlineNameResponse"].Value = row.Cells["PlineNameE"].Text;
  411. }
  412. if (row.Cells["PlineNameF"].Text != null && srKey == "PlineNameF")
  413. {
  414. row.Cells["PlineNameResponse"].Value = row.Cells["PlineNameF"].Text;
  415. }
  416. }
  417. private void chageReason()
  418. {
  419. string strkey = ultraGrid1.ActiveCell.Column.ToString();
  420. UltraGridRow row = ultraGrid1.ActiveRow;
  421. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  422. foreach (UltraGridRow uRow in checkMagRows)
  423. {
  424. if (Convert.ToBoolean(row.Cells["CHK"].Text) == false) return;
  425. if ( strkey.Equals("Reason2") || strkey.Equals("Reason3"))
  426. {
  427. uRow.Cells[strkey].Value = row.Cells[strkey].Text;
  428. uRow.Cells["Reason1"].Value = row.Cells["Reason1"].Value;
  429. }
  430. }
  431. }
  432. }
  433. }