FrmRepInspection.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.ResultConrtrol;
  10. using Core.StlMes.Client.ZGMil.Signature;
  11. using CoreFS.CA06;
  12. using Infragistics.Win.UltraWinGrid;
  13. using System;
  14. using System.Collections;
  15. using System.Collections.Generic;
  16. using System.ComponentModel;
  17. using System.Data;
  18. using System.Drawing;
  19. using System.Linq;
  20. using System.Text;
  21. using System.Windows.Forms;
  22. namespace Core.StlMes.Client.ZGMil.Report
  23. {
  24. public partial class FrmRepInspection : FrmBase
  25. {
  26. private string departm = "";
  27. private string plineCode = "";
  28. private string[] plineCodes = { };
  29. public FrmRepInspection()
  30. {
  31. InitializeComponent();
  32. this.IsLoadUserView = true;
  33. }
  34. private void FrmRepInspection_Load(object sender, EventArgs e)
  35. {
  36. cmbDate.Value = DateTime.Parse(DateTime.Today.ToString());
  37. NativeMethodNew na = new NativeMethodNew(this.ob);
  38. departm = UserInfo.GetDepartment();
  39. plineCode = na.GetPCode(departm);//获取 用户 对应的产线
  40. plineCodes = BaseMethod.GetPlineCode(ValidDataPurviewIds, ob);
  41. cmbEndDate.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 20:59:59"));
  42. cmbDate.Value = DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 21:00:00"));
  43. TubeRoll.SetComboItemHeight(cmbBc);
  44. TubeRoll.SetComboItemHeight(cmbBz);
  45. if (plineCode == "C010")
  46. {
  47. ultraTabControl1.Tabs[0].Visible = false;
  48. ultraTabControl1.Tabs[1].Visible = true;
  49. }
  50. else if (plineCode == "C008" || plineCode == "C009" || plineCode == "C017")
  51. {
  52. ultraTabControl1.Tabs[0].Visible = true;
  53. ultraTabControl1.Tabs[1].Visible = false;
  54. }
  55. else
  56. {
  57. ultraTabControl1.Tabs[0].Visible = true;
  58. ultraTabControl1.Tabs[1].Visible = true;
  59. }
  60. }
  61. /// <summary>
  62. /// 重写基类方法
  63. /// </summary>
  64. /// <param name="sender"></param>
  65. /// <param name="ToolbarKey"></param>
  66. public override void ToolBar_Click(object sender, string ToolbarKey)
  67. {
  68. switch (ToolbarKey)
  69. {
  70. case "Query":
  71. doQuery();
  72. break;
  73. case "Save":
  74. doSave();
  75. break;
  76. case "Export":
  77. doExport();
  78. break;
  79. case "DoExport":
  80. doExport2();
  81. break;
  82. case "Print":
  83. doPrint();
  84. break;
  85. case "Close":
  86. this.Close();
  87. break;
  88. }
  89. }
  90. /// <summary>
  91. /// 导出
  92. /// </summary>
  93. private void doExport2()
  94. {
  95. if (plineCode == "C010")
  96. {
  97. GridHelper.ulGridToExcel(ultraGrid2, "探伤台账");
  98. }
  99. else
  100. {
  101. GridHelper.ulGridToExcel(ultraGrid1, "探伤台账");
  102. }
  103. }
  104. private void chkDate_CheckedChanged(object sender, EventArgs e)
  105. {
  106. if (chkDate.Checked) { cmbDate.Enabled = true; } else { cmbDate.Enabled = false; }
  107. if (chkBc.Checked) { cmbBc.Enabled = true; } else { cmbBc.Enabled = false; }
  108. if (chkBz.Checked) { cmbBz.Enabled = true; } else { cmbBz.Enabled = false; }
  109. if (chkJudge.Checked) { textJudge.Enabled = true; } else { textJudge.Enabled = false; }
  110. }
  111. /// <summary>
  112. /// 查询
  113. /// </summary>
  114. private void doQuery()
  115. {
  116. ArrayList list = new ArrayList();
  117. string date = "";
  118. string endDate = "";
  119. string bc = "";
  120. string bz = "";
  121. string judge_stove_no = "";
  122. if (chkDate.Checked)
  123. {
  124. if (DataTimeUtil.JudgeTime(DateTime.Parse(cmbDate.Value.ToString()), DateTime.Parse(cmbEndDate.Value.ToString())) == 0)
  125. {
  126. MessageUtil.ShowTips("您所选择的日期区域不对,请重新选择!");
  127. return;
  128. }
  129. else
  130. {
  131. date = cmbDate.Value.ToString();
  132. endDate = cmbEndDate.Value.ToString();
  133. }
  134. }
  135. if (chkBz.Checked)
  136. {
  137. if (cmbBz.Text.Trim() == "")
  138. {
  139. //MessageUtil.ShowTips("班组不能为空!");
  140. //return;
  141. bz = "";
  142. }
  143. else
  144. {
  145. bz = cmbBz.Value.ToString();
  146. }
  147. }
  148. if (chkBc.Checked)
  149. {
  150. if (cmbBc.Text.Trim() == "")
  151. {
  152. bc = "";
  153. }
  154. else
  155. {
  156. bc = cmbBc.Value.ToString();
  157. }
  158. }
  159. if (chkJudge.Checked)
  160. {
  161. if (textJudge.Text.Trim() == "")
  162. {
  163. judge_stove_no = "";
  164. }
  165. else
  166. {
  167. judge_stove_no = textJudge.Value.ToString();
  168. }
  169. }
  170. WaitingForm2 wf = new WaitingForm2("正在加载,请稍候....");
  171. DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.report.FrmRepInspection.queryMinResult", new Object[] { date, endDate, bc, bz, plineCode, plineCodes, judge_stove_no }, this.ob);
  172. if (plineCode == "C010")
  173. {
  174. GridHelper.CopyDataToDatatable(dt, this.dataTable2, true);
  175. GridHelper.RefreshAndAutoSize(this.ultraGrid2);
  176. }
  177. else {
  178. GridHelper.CopyDataToDatatable(dt, this.dataTable1, true);
  179. GridHelper.RefreshAndAutoSize(this.ultraGrid1);
  180. }
  181. wf.Close();
  182. }
  183. /// <summary>
  184. /// 修改
  185. /// </summary>
  186. private void doSave()
  187. {
  188. UltraGrid ultraGrid = new UltraGrid();
  189. if (this.ultraTabControl1.Tabs[0].Active)
  190. {
  191. ultraGrid = ultraGrid1;
  192. }
  193. if (this.ultraTabControl1.Tabs[1].Active)
  194. {
  195. ultraGrid = ultraGrid2;
  196. }
  197. ultraGrid.UpdateData();
  198. IQueryable<UltraGridRow> checkMagRows = ultraGrid.Rows.AsQueryable().Where(" CHK = 'True'");
  199. if (checkMagRows.Count() == 0)
  200. {
  201. MessageUtil.ShowTips("请选择需要修改的信息!");
  202. return;
  203. }
  204. ArrayList parm = new ArrayList();
  205. foreach (UltraGridRow uRow in checkMagRows)
  206. {
  207. FeedSawResultEntity matZcTity = new FeedSawResultEntity();
  208. matZcTity.JudgeStoveNo = uRow.Cells["JUDGE_STOVE_NO"].Text.ToString();
  209. matZcTity.PlineCode = uRow.Cells["PLINE_CODE"].Text.ToString();
  210. if (uRow.Cells["COL_SHIFT1"].Value.ToString().Equals("早班"))
  211. {
  212. matZcTity.ColShift = "1";
  213. }
  214. else if (uRow.Cells["COL_SHIFT1"].Value.ToString().Equals("中班"))
  215. {
  216. matZcTity.ColShift = "2";
  217. }
  218. else if (uRow.Cells["COL_SHIFT1"].Value.ToString().Equals("夜班"))
  219. {
  220. matZcTity.ColShift = "3";
  221. }
  222. else if (uRow.Cells["COL_SHIFT1"].Value.ToString().Equals("常白班"))
  223. {
  224. matZcTity.ColShift = "0";
  225. }
  226. else
  227. {
  228. matZcTity.ColShift = uRow.Cells["COL_SHIFT1"].Value.ToString();
  229. }
  230. if (uRow.Cells["COL_GROUP1"].Value.ToString().Equals("甲"))
  231. {
  232. matZcTity.ColGroup = "1";
  233. }
  234. else if (uRow.Cells["COL_GROUP1"].Value.ToString().Equals("乙"))
  235. {
  236. matZcTity.ColGroup = "2";
  237. }
  238. else if (uRow.Cells["COL_GROUP1"].Value.ToString().Equals("丙"))
  239. {
  240. matZcTity.ColGroup = "3";
  241. }
  242. else if (uRow.Cells["COL_GROUP1"].Value.ToString().Equals("丁"))
  243. {
  244. matZcTity.ColGroup = "4";
  245. }
  246. else
  247. {
  248. matZcTity.ColGroup = uRow.Cells["COL_GROUP1"].Value.ToString();
  249. }
  250. matZcTity.StartTime = uRow.Cells["END_INSPECTION_TIME"].Text.ToString();
  251. matZcTity.Remark = "探伤";
  252. string matTity = JSONFormat.Format(matZcTity);
  253. parm.Add(matTity);
  254. }
  255. if (MessageUtil.ShowYesNoAndQuestion("是否确认修改?") == DialogResult.No) return;
  256. CoreClientParam ccp = new CoreClientParam();
  257. ccp.ServerName = "com.steering.mes.zgmil.report.FrmFeedSaw";
  258. ccp.MethodName = "doSave";
  259. ccp.ServerParams = new object[] { parm };
  260. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  261. if (ccp.ReturnCode != -1)
  262. {
  263. if (ccp.ReturnInfo.Equals("修改成功!"))
  264. {
  265. doQuery();
  266. MessageUtil.ShowTips(ccp.ReturnInfo);
  267. }
  268. else
  269. {
  270. MessageUtil.ShowTips(ccp.ReturnInfo);
  271. }
  272. }
  273. }
  274. /// <summary>
  275. /// 打印
  276. /// </summary>
  277. private void doExport()
  278. {
  279. string date = "";
  280. string endDate = "";
  281. string bc = "";
  282. string bz = "";
  283. string judgeStoveNo = "";
  284. //if (!chkDate.Checked)
  285. //{
  286. // MessageUtil.ShowTips("请选择生产日期!");
  287. // return;
  288. //}
  289. if (!chkBz.Checked)
  290. {
  291. MessageUtil.ShowTips("请选择班组!");
  292. return;
  293. }
  294. if (!chkBc.Checked)
  295. {
  296. MessageUtil.ShowTips("请选择班次!");
  297. return;
  298. }
  299. if (chkDate.Checked)
  300. {
  301. if (DataTimeUtil.JudgeTime(DateTime.Parse(cmbDate.Value.ToString()), DateTime.Parse(cmbEndDate.Value.ToString())) == 0)
  302. {
  303. MessageUtil.ShowTips("您所选择的日期区域不对,请重新选择!");
  304. return;
  305. }
  306. else
  307. {
  308. date = cmbDate.Value.ToString();
  309. endDate = cmbEndDate.Value.ToString();
  310. }
  311. }
  312. if (chkBz.Checked)
  313. {
  314. if (cmbBz.Text.Trim() == "")
  315. {
  316. //MessageUtil.ShowTips("班组不能为空!");
  317. //return;
  318. bz = "";
  319. }
  320. else
  321. {
  322. bz = cmbBz.Value.ToString();
  323. }
  324. }
  325. if (chkBc.Checked)
  326. {
  327. if (cmbBc.Text.Trim() == "")
  328. {
  329. //MessageUtil.ShowTips("班次不能为空!");
  330. //return;
  331. bc = "";
  332. }
  333. else
  334. {
  335. bc = cmbBc.Value.ToString();
  336. }
  337. }
  338. if (chkJudge.Checked )
  339. {
  340. if (textJudge.Text.Trim() == "")
  341. {
  342. judgeStoveNo = "";
  343. }
  344. else
  345. {
  346. judgeStoveNo = textJudge.ToString();
  347. }
  348. }
  349. doQuery();
  350. ColUserName colU = new ColUserName();
  351. colU.Ob = this.ob;
  352. colU.PlineCode = plineCode;
  353. colU.ColGroup = bz;
  354. colU.ColOrder = bc;
  355. colU.JudgeStoveNo = textJudge.ToString();
  356. colU.StationId = "8";
  357. if (plineCode.Equals("C017"))//460
  358. {
  359. colU.Url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilMTResult460.cpt&format=pdf&__bypagesize__=false";
  360. }
  361. else if (plineCode.Equals("C010"))//168
  362. {
  363. colU.Url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilMTResult168.cpt&format=pdf&__bypagesize__=false";
  364. }
  365. else if (plineCode.Equals("C009"))//258
  366. {
  367. colU.Url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilMTResult258.cpt&format=pdf&__bypagesize__=false";
  368. }
  369. else if (plineCode.Equals("C008"))//250
  370. {
  371. colU.Url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilMTResult250.cpt&format=pdf&__bypagesize__=false";
  372. }
  373. else if (plineCode.Equals("C072"))//508
  374. {
  375. colU.Url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilMTResult508.cpt&__bypagesize__=false";
  376. }
  377. else { colU.Url = ""; }
  378. colU.StartTim = date;
  379. colU.EndTim = endDate;
  380. colU.StrText = "探伤";
  381. colU.Flag = "0";
  382. colU.ShowDialog();
  383. }
  384. /// <summary>
  385. /// 打印探伤报告
  386. /// </summary>
  387. private void doPrint()
  388. {
  389. string bc = "";
  390. string bz = "";
  391. string judge = "";
  392. string PlineCode = "";
  393. string url = "";
  394. if (plineCode == "C010")
  395. {
  396. if (this.ultraGrid2.ActiveRow == null)
  397. {
  398. MessageBox.Show("您未选择任何炉号,不允许进行报表打印", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  399. return;
  400. }
  401. UltraGridRow ugr = ultraGrid2.ActiveRow;
  402. bc = ugr.Cells["COL_SHIFT"].Value.ToString();
  403. bz = ugr.Cells["COL_GROUP"].Value.ToString();
  404. judge = ugr.Cells["JUDGE_STOVE_NO"].Value.ToString() + "-01";
  405. PlineCode = ugr.Cells["PLINE_CODE"].Value.ToString();
  406. url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilInspectionTestReport168.cpt&format=pdf&JUDGE_STOVE_NO=" + judge + "&COL_GROUP=" + bz + "&COL_SHIFT=" + bc;
  407. FrmExcel fre = new FrmExcel(this.ob, url);
  408. fre.AutoSize = true;
  409. fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  410. fre.WindowState = FormWindowState.Maximized;
  411. fre.Show();
  412. }else
  413. {
  414. if (this.ultraGrid1.ActiveRow == null)
  415. {
  416. MessageBox.Show("您未选择任何炉号,不允许进行报表打印", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  417. return;
  418. }
  419. UltraGridRow ugr = ultraGrid1.ActiveRow;
  420. bc = ugr.Cells["COL_SHIFT"].Value.ToString();
  421. bz = ugr.Cells["COL_GROUP"].Value.ToString();
  422. judge = ugr.Cells["JUDGE_STOVE_NO"].Value.ToString() + "-01" ;
  423. PlineCode = ugr.Cells["PLINE_CODE"].Value.ToString();
  424. switch (PlineCode)
  425. {
  426. case "C008": //250
  427. url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilInspectionTestReport250.cpt&format=pdf&JUDGE_STOVE_NO=" + judge + "&COL_GROUP=" + bz + "&COL_SHIFT=" + bc;
  428. break;
  429. case "C009": //258
  430. url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilInspectionTestReport258.cpt&format=pdf&JUDGE_STOVE_NO=" + judge + "&COL_GROUP=" + bz + "&COL_SHIFT=" + bc;
  431. break;
  432. //case "C010": //168
  433. // url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilInspectionTestReport168.cpt&format=pdf&JUDGE_STOVE_NO=" + judge + "&COL_GROUP=" + bz + "&COL_SHIFT=" + bc;
  434. // break;
  435. case "C012": //Arssel
  436. break;
  437. case "C017": //460
  438. url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilInspectionTestReport460.cpt&format=pdf&JUDGE_STOVE_NO=" + judge + "&COL_GROUP=" + bz + "&COL_SHIFT=" + bc;
  439. break;
  440. case "C072": //508
  441. url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilInspectionTestReport508.cpt&JUDGE_STOVE_NO=" + judge + "&COL_GROUP=" + bz + "&COL_SHIFT=" + bc;
  442. break;
  443. }
  444. FrmExcel fre = new FrmExcel(this.ob, url);
  445. fre.AutoSize = true;
  446. fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  447. fre.WindowState = FormWindowState.Maximized;
  448. fre.Show();
  449. }
  450. }
  451. private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
  452. {
  453. if (this.ultraTabControl1.Tabs[1].Active)
  454. {
  455. plineCode = "C010";
  456. }
  457. if (this.ultraTabControl1.Tabs[0].Active)
  458. {
  459. plineCode = "";
  460. }
  461. }
  462. }
  463. }