FrmCcmWeightReport.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Core.Mes.Client.Common;
  10. using Infragistics.Win.UltraWinGrid;
  11. using System.Collections;
  12. using Infragistics.Win;
  13. using System.Diagnostics;
  14. using System.IO;
  15. using CoreFS.CA06;
  16. using Core.LgMes.Client.Comm;
  17. namespace Core.LgMes.Client.lgIntegrationQuery
  18. {
  19. public partial class FrmCcmWeightReport : frmStyleBase
  20. {
  21. public FrmCcmWeightReport()
  22. {
  23. InitializeComponent();
  24. }
  25. private UltraGridRow currRow = null;
  26. public override void ToolBar_Click(object sender, string ToolbarKey)
  27. {
  28. switch (ToolbarKey)
  29. {
  30. case "Query":
  31. {
  32. proc_Query();
  33. break;
  34. }
  35. case "Save":
  36. {
  37. proc_Add("Edit");
  38. proc_Query();
  39. break;
  40. }
  41. case "Export":
  42. {
  43. try
  44. {
  45. if (ultraGrid1.Rows.Count == 0) return;
  46. string strFileName = "合金验收记录" + DateTime.Now.ToString("yyyyMMdd");
  47. SaveFileDialog dlg = new SaveFileDialog();
  48. dlg.Title = "保存";
  49. dlg.OverwritePrompt = true;
  50. dlg.Filter = "Excel文件(*.xls)|*.xls";
  51. dlg.AddExtension = true;
  52. dlg.FileName = strFileName;
  53. if (dlg.ShowDialog() == DialogResult.OK)
  54. {
  55. strFileName = dlg.FileName;
  56. ultraGridExcelExporter1.Export(ultraGrid1, strFileName);
  57. if (MessageBox.Show("数据导出成功!\r\n需要打开所导出文件吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  58. {
  59. ultraGridExcelExporter1.Export(ultraGrid1, strFileName);
  60. ProcessStartInfo p = new ProcessStartInfo(strFileName);
  61. p.WorkingDirectory = Path.GetDirectoryName(strFileName);
  62. Process.Start(p);
  63. }
  64. }
  65. }
  66. catch (Exception ex)
  67. {
  68. MessageBox.Show(ex.Message);
  69. }
  70. break;
  71. }
  72. case "Close":
  73. {
  74. this.Close();
  75. break;
  76. }
  77. }
  78. }
  79. public void proc_Query()
  80. {
  81. if (ultraDateTimeEditor2.DateTime.Date.Subtract(ultraDateTimeEditor1.DateTime.Date).Days > 60)
  82. {
  83. MessageBox.Show("查询时间不可超过2个月。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  84. return;
  85. }
  86. if (ultraDateTimeEditor1.DateTime.Date > ultraDateTimeEditor2.DateTime.Date)
  87. {
  88. MessageBox.Show("查询开始日期不能大于结束日期!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  89. return;
  90. }
  91. Cursor oldCursor = this.Cursor;
  92. this.Cursor = Cursors.WaitCursor;
  93. try
  94. {
  95. this.dataTable1.Clear();
  96. string sqlStr = @"SELECT TO_CHAR(T.OPTDATE, 'YYYY-MM-DD HH24:MI:SS') OPTDATE,
  97. DECODE(SUBSTR(T.SHIFTCODE, 1, 1), '1', '早', '2', '中', '3', '晚') SHIFTGROUP,
  98. DECODE(SUBSTR(T.SHIFTCODE, 1, 1),
  99. '1',
  100. '甲',
  101. '2',
  102. '乙',
  103. '3',
  104. '丙',
  105. '丁') SHIFTCLASS,
  106. DECODE(T.STATIONCODE,'01','6#','02','5#','7#') STATIONCODE,
  107. T.HEATNO,
  108. T.PLANSTEEL,
  109. T1.PLAN_LINES FACT_ROUTE,
  110. T.BILLETSECTION,
  111. T.BILLETSECTION2,
  112. NVL(T.PFBALEWGT, 0) - NVL(T.BALELEAVEWGT, 0) JGWGT,
  113. T2.WEIGHT,
  114. SENDSMPOPTOR1,
  115. SENDSMPOPTOR2,
  116. SENDSMPOPTOR3,
  117. CONFIRMOPTOR
  118. FROM (SELECT * FROM STL_CCM_OPTINFO UNION SELECT * FROM J#STL_CCM_OPTINFO) T
  119. LEFT JOIN PPC_STEEL_HEAT T1
  120. ON T.HEATNO = T1.HEATNO
  121. LEFT JOIN (SELECT SUBSTR(SLAB_NO, 1, 9) || 'A' HEATNO,
  122. SUM(NVL(WEIGHT_WGT, SLAB_WGT / 1000)) WEIGHT
  123. FROM STL_INCISION_VIEW
  124. GROUP BY SUBSTR(SLAB_NO, 1, 9) || 'A') T2
  125. ON T.HEATNO = T2.HEATNO
  126. WHERE NVL(T.BALESTARTTIME, T.OPTDATE) BETWEEN TO_DATE('{0}','YYYY-MM-DD HH24:MI:SS') AND TO_DATE('{1}','YYYY-MM-DD HH24:MI:SS')
  127. AND DISPOSALTIME = '01'
  128. ORDER BY T.STATIONCODE,NVL(T.BALESTARTTIME, T.OPTDATE)";
  129. if (ultraDateTimeEditor1.DateTime.Date > ultraDateTimeEditor2.DateTime.Date)
  130. {
  131. MessageBox.Show("查询开始日期不能大于结束日期!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  132. return;
  133. }
  134. string strFrom = ultraDateTimeEditor1.DateTime.ToString("yyyy-MM-dd") + " 00:00:00";
  135. string strTo = ultraDateTimeEditor2.DateTime.ToString("yyyy-MM-dd") + " 23:59:59";
  136. sqlStr = string.Format(sqlStr, strFrom, strTo);
  137. //调用服务端方法
  138. CoreClientParam CCP_LgEts = new CoreClientParam();
  139. DataTable dt = new DataTable();
  140. CCP_LgEts.ServerName = "Core.LgMes.Server.Common.ComDBExecute";
  141. CCP_LgEts.MethodName = "doSimpleQuery";
  142. CCP_LgEts.ServerParams = new object[] { sqlStr };
  143. CCP_LgEts.SourceDataTable = dt;
  144. this.ExecuteQueryToDataTable(CCP_LgEts, CoreInvokeType.Internal);
  145. DataSet ds = new DataSet();
  146. if (dt != null && dt.Rows.Count > 0)
  147. {
  148. this.dataTable1.Rows.Clear();
  149. DataRow dr;
  150. for (int iRow = 0; iRow < dt.Rows.Count; iRow++)
  151. {
  152. dr = this.dataTable1.NewRow();
  153. for (int jCol = 0; jCol < dt.Columns.Count; jCol++)
  154. {
  155. if (dt.Columns[jCol].ColumnName == "FACT_ROUTE")
  156. {
  157. dr[dt.Columns[jCol].ColumnName] = CStaticMethod.analysPlan_Lines(dt.Rows[iRow][jCol].ToString());
  158. }
  159. else
  160. {
  161. dr[dt.Columns[jCol].ColumnName] = dt.Rows[iRow][jCol];
  162. }
  163. }
  164. this.dataTable1.Rows.Add(dr);
  165. }
  166. }
  167. ultraGrid1.UpdateData();
  168. if (ultraGrid1.Rows.Count > 0)
  169. {
  170. ultraGrid1.ActiveCell = ultraGrid1.Rows[0].Cells["STATIONCODE"];
  171. ultraGrid1.Rows[0].Cells["STATIONCODE"].Selected = false;
  172. }
  173. //this.proc_SetUltraGridReadOnly(ultraGrid1);
  174. ArrayList alistColumns = new ArrayList();
  175. alistColumns.Add("JGWGT");
  176. alistColumns.Add("WEIGHT");
  177. alistColumns.Add("SENDSMPOPTOR1");
  178. alistColumns.Add("SENDSMPOPTOR2");
  179. alistColumns.Add("SENDSMPOPTOR3");
  180. proc_Statics(ref ultraGrid1, alistColumns, true, " {0:############0.0}");
  181. }
  182. catch
  183. { }
  184. finally
  185. {
  186. this.Cursor = oldCursor;
  187. }
  188. }
  189. public void proc_Add(string flag)
  190. {
  191. try
  192. {
  193. this.ultraGrid1.UpdateData();
  194. if (dataTable1.Rows.Count > 0)
  195. {
  196. string strErr = "";
  197. string strMess = "";
  198. if (flag == "Add")
  199. {
  200. ArrayList arry = new ArrayList();
  201. arry.Add("frmAlloy.Insert");
  202. string str1 = ultraGrid1.ActiveRow.Cells["STATIONCODE"].Text;
  203. string str2 = ultraGrid1.ActiveRow.Cells["LK"].Text;
  204. string str3 = ultraGrid1.ActiveRow.Cells["GGM"].Text;
  205. string str4 = ultraGrid1.ActiveRow.Cells["GT"].Text;
  206. string str5 = ultraGrid1.ActiveRow.Cells["GM"].Text;
  207. string str6 = ultraGrid1.ActiveRow.Cells["ZTJ"].Text;
  208. string str7 = ultraGrid1.ActiveRow.Cells["ZTMT"].Text;
  209. string str8 = ultraGrid1.ActiveRow.Cells["TT"].Text;
  210. string str9 = ultraGrid1.ActiveRow.Cells["JSMK"].Text;
  211. string str10 = ultraGrid1.ActiveRow.Cells["ZTGT"].Text;
  212. string str11 = ultraGrid1.ActiveRow.Cells["MT"].Text;
  213. string str12 = ultraGrid1.ActiveRow.Cells["GTGT"].Text;
  214. string str13 = ultraGrid1.ActiveRow.Cells["JLZ"].Text;
  215. string str14 = ultraGrid1.ActiveRow.Cells["RHGZJ"].Text;
  216. string str15 = ultraGrid1.ActiveRow.Cells["DGYSQ"].Text;
  217. string str16 = ultraGrid1.ActiveRow.Cells["HZYSH"].Text;
  218. string str17 = this.UserInfo.GetUserName();
  219. arry.Add(str1);
  220. arry.Add(str2);
  221. arry.Add(str3);
  222. arry.Add(str4);
  223. arry.Add(str5);
  224. arry.Add(str6);
  225. arry.Add(str7);
  226. arry.Add(str8);
  227. arry.Add(str9);
  228. arry.Add(str10);
  229. arry.Add(str11);
  230. arry.Add(str12);
  231. arry.Add(str13);
  232. arry.Add(str14);
  233. arry.Add(str15);
  234. arry.Add(str16);
  235. arry.Add(str17);
  236. CommonClientToServer cctos = new CommonClientToServer();
  237. cctos.ob = this.ob;
  238. cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBSave",
  239. "doSimpleSave", arry, out strErr);
  240. this.proc_setCellReadOnly(currRow, true);
  241. currRow = null;
  242. }
  243. else if (flag == "Edit")
  244. {
  245. ArrayList arry = new ArrayList();
  246. arry.Add("frmCcmWeight1.Update");
  247. string str1 = ultraGrid1.ActiveRow.Cells["SENDSMPOPTOR1"].Text;
  248. string str2 = ultraGrid1.ActiveRow.Cells["SENDSMPOPTOR2"].Text;
  249. string str3 = ultraGrid1.ActiveRow.Cells["SENDSMPOPTOR3"].Text;
  250. string str4 = ultraGrid1.ActiveRow.Cells["CONFIRMOPTOR"].Text;
  251. string str5 = ultraGrid1.ActiveRow.Cells["HEATNO"].Text;
  252. arry.Add(str1);
  253. arry.Add(str2);
  254. arry.Add(str3);
  255. arry.Add(str4);
  256. arry.Add(str5);
  257. CommonClientToServer cctos = new CommonClientToServer();
  258. cctos.ob = this.ob;
  259. cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBSave",
  260. "doSimpleSave", arry, out strErr);
  261. arry.Clear();
  262. arry.Add("frmCcmWeight2.Update");
  263. arry.Add(str1);
  264. arry.Add(str2);
  265. arry.Add(str3);
  266. arry.Add(str4);
  267. arry.Add(str5);
  268. cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBSave",
  269. "doSimpleSave", arry, out strErr);
  270. this.proc_setCellReadOnly(currRow, true);
  271. currRow = null;
  272. }
  273. if (strErr == "")
  274. {
  275. dataTable1.AcceptChanges();
  276. //JJBStaticFunction.SetRowEdit(ultraGrid1);
  277. if (!string.IsNullOrEmpty(strMess))
  278. MessageBox.Show(strMess, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  279. }
  280. else
  281. {
  282. MessageBox.Show("保存失败!输入信息已经存在或数据无效。", "错误");
  283. }
  284. if (ultraGrid1.ActiveCell != null)
  285. ultraGrid1.ActiveCell.Activated = false;
  286. }
  287. }
  288. catch (System.Exception ex)
  289. {
  290. Console.WriteLine(ex.ToString());
  291. }
  292. }
  293. private void proc_setCellReadOnly(UltraGridRow row, bool bReadOnly)
  294. {
  295. try
  296. {
  297. if (row == null)
  298. return;
  299. if (bReadOnly)
  300. {
  301. row.Activation = Activation.ActivateOnly;
  302. row.CellAppearance.BackColor = Color.White;
  303. foreach (Infragistics.Win.UltraWinGrid.UltraGridCell cell in row.Cells)
  304. {
  305. cell.CancelUpdate();
  306. }
  307. }
  308. else
  309. {
  310. row.Activation = Activation.AllowEdit;
  311. row.CellAppearance.BackColor = Color.Khaki;
  312. }
  313. }
  314. catch (Exception ex)
  315. {
  316. MessageBox.Show(ex.Message);
  317. }
  318. }
  319. private void proc_SetUltraGridReadOnly(Infragistics.Win.UltraWinGrid.UltraGridBase ultGrid)
  320. {
  321. foreach (UltraGridRow row in ultGrid.Rows)
  322. {
  323. row.Activation = Activation.ActivateOnly;
  324. }
  325. }
  326. public void proc_Statics(ref UltraGrid ultraGrid, ArrayList alistColumns, bool clearExists, string strFormat)
  327. {
  328. try
  329. {
  330. if (alistColumns == null)
  331. {
  332. return;
  333. }
  334. UltraGridBand band = ultraGrid.DisplayLayout.Bands[0];
  335. if (clearExists)
  336. band.Summaries.Clear();
  337. SummarySettings summary = null;
  338. UltraGridColumn cl = null;
  339. foreach (UltraGridColumn column in ultraGrid.DisplayLayout.Bands[0].Columns)
  340. {
  341. if (column.RowLayoutColumnInfo.OriginX == 0)
  342. {
  343. cl = column;
  344. break;
  345. }
  346. }
  347. summary = band.Summaries.Add(SummaryType.Count, cl);
  348. summary.SummaryDisplayArea = SummaryDisplayAreas.BottomFixed;
  349. summary.SummaryPosition = SummaryPosition.UseSummaryPositionColumn;
  350. summary.DisplayFormat = "合计:";
  351. summary.Appearance.TextHAlign = Infragistics.Win.HAlign.Center;
  352. summary.Appearance.TextVAlign = Infragistics.Win.VAlign.Middle;
  353. summary.Appearance.FontData.Bold = DefaultableBoolean.True;
  354. if (string.IsNullOrEmpty(strFormat.Trim()))
  355. {
  356. strFormat = " {0:############0.00}";
  357. }
  358. for (int i = 0; i < alistColumns.Count; i++)
  359. {
  360. try
  361. {
  362. summary = band.Summaries.Add(SummaryType.Sum, band.Columns[alistColumns[i].ToString()]);
  363. summary.SummaryDisplayArea = SummaryDisplayAreas.BottomFixed;
  364. summary.SummaryPosition = SummaryPosition.UseSummaryPositionColumn;
  365. summary.DisplayFormat = strFormat;
  366. summary.Appearance.TextHAlign = Infragistics.Win.HAlign.Right;
  367. summary.Appearance.TextVAlign = Infragistics.Win.VAlign.Middle;
  368. summary.Appearance.FontData.Bold = DefaultableBoolean.True;
  369. summary.Appearance.ForeColor = Color.DarkBlue;
  370. summary.Appearance.BackColor = Color.White;
  371. }
  372. catch { }
  373. }
  374. band.Override.SummaryFooterCaptionVisible = Infragistics.Win.DefaultableBoolean.False;
  375. }
  376. catch { }
  377. }
  378. private void FrmCcmWeightReport_Load(object sender, EventArgs e)
  379. {
  380. ultraDateTimeEditor1.DateTime = DateTime.Today;
  381. ultraDateTimeEditor2.DateTime = DateTime.Today;
  382. }
  383. }
  384. }