QCM0202.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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 CoreFS.CA06;
  10. using System.Collections;
  11. using Infragistics.Win.UltraWinGrid;
  12. using Infragistics.Excel;
  13. using Infragistics.Win;
  14. using System.Diagnostics;
  15. using Microsoft.Office.Interop.Excel;
  16. namespace Core.LZMes.Client.QCM
  17. {
  18. public partial class QCM0202 : FrmBase
  19. {
  20. public QCM0202()
  21. {
  22. InitializeComponent();
  23. }
  24. public override void ToolBar_Click(object sender, string ToolbarKey)
  25. {
  26. switch (ToolbarKey)
  27. {
  28. case "Query":
  29. this.DoQuery();
  30. break;
  31. case "InExport": // 导出实绩
  32. DoExport();
  33. break;
  34. }
  35. }
  36. private void DoQuery()
  37. {
  38. try
  39. {
  40. this.dataSet1.Clear();
  41. string heatNo = this.textBox1.Text; //炉号
  42. string steelName = this.textBox2.Text; //牌号
  43. String STARTTIME = this.dateTimePicker1.Value.ToString("yyyy-MM-dd");
  44. String ENDTIME = this.dateTimePicker2.Value.ToString("yyyy-MM-dd");
  45. if (this.dateTimePicker1.Value > this.dateTimePicker2.Value)
  46. {
  47. MessageBox.Show("日期查询条件开始日期大于结束日期!!!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  48. return;
  49. }
  50. //查询数据库里的数据
  51. CoreClientParam ccp = new CoreClientParam();
  52. System.Data.DataTable datatable = new System.Data.DataTable();
  53. ccp.ServerName = "QCM.JHY01.JHY0102.QuerryJhyElements";
  54. ccp.MethodName = "Query";
  55. ccp.ServerParams = new object[] { steelName, heatNo, STARTTIME, ENDTIME };
  56. this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  57. Hashtable ht = (Hashtable)ccp.ReturnObject;
  58. ArrayList group = ht["group"] as ArrayList;
  59. ArrayList result = ht["result"] as ArrayList;
  60. for (int i = 0; i < group.Count; i++)
  61. {
  62. Hashtable row = (Hashtable)group[i];
  63. DataRow dr = this.dataSet1.Tables[0].NewRow();
  64. dr["ASSAY_NO"] = row["ASSAY_NO"];
  65. dr["BATCH_NO"] = row["BATCH_NO"];
  66. dr["HEAT_NO"] = row["HEAT_NO"];
  67. dr["STEEL_CODE"] = row["STEEL_CODE"];
  68. dr["ASSAY_TYPE"] = row["ASSAY_TYPE"].ToString().Equals("L") ? "熔炼" : "成品";
  69. dr["CREATE_NAME"] = row["CREATE_NAME"];
  70. dr["CREATE_TIME"] = row["CREATE_TIME"];
  71. for (int j = 0; j < result.Count; j++)
  72. {
  73. Hashtable chem = (Hashtable)result[j];
  74. if (chem["ASSAY_NO"].Equals(row["ASSAY_NO"]) && chem["ASSAY_TYPE"].Equals( row["ASSAY_TYPE"]))
  75. {
  76. //dr[chem["CHEM_CODE"].ToString()] = chem["CHEM_VALUE"].ToString();
  77. // dr[chem["CHEM_CODE"].ToString()] = chem["CHEM_VALUE"].ToString();
  78. if (chem["CHEM_VALUE"] != null)
  79. {
  80. Hashtable chem1 = (Hashtable)chem["CHEM_VALUE"];
  81. foreach (DictionaryEntry item1 in chem1)
  82. {
  83. dr[chem["CHEM_CODE"].ToString()] = item1.Value;
  84. break;
  85. }
  86. }
  87. }
  88. }
  89. this.dataSet1.Tables[0].Rows.Add(dr);
  90. }
  91. }
  92. catch (Exception ex)
  93. {
  94. System.Diagnostics.Debug.WriteLine(ex.ToString());
  95. MessageBox.Show("系统出错,请联系管理人员", "警告");
  96. }
  97. }
  98. //初始化的时候加载列
  99. private void QCM0202_Load(object sender, EventArgs e)
  100. {
  101. dateTimePicker1.Value = DateTime.Now.Date.AddDays(-2);
  102. //获取成分实绩中总共有多少元素
  103. System.Data.DataTable chemtable = new System.Data.DataTable();
  104. CoreClientParam ccp = new CoreClientParam();
  105. ccp.ServerName = "QCM.JHY01.JHY0102.QuerryJhyElements";
  106. ccp.MethodName = "QueryElement";
  107. ccp.SourceDataTable = chemtable;
  108. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  109. //把在后端查询到的元素数据加入
  110. for (int i = 0; i < chemtable.Rows.Count; i++)
  111. {
  112. this.dataSet1.Tables[0].Columns.Add(chemtable.Rows[i]["CHEM_CODE"].ToString(), typeof(System.String));
  113. }
  114. //this.DoQuery();//查询
  115. }
  116. private void DoExport()
  117. {
  118. try
  119. {
  120. if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)
  121. {
  122. string fileName = this.saveFileDialog1.FileName;
  123. ultraGridExcelExporter1.Export(ultraGrid1, fileName);
  124. }
  125. }
  126. catch (Exception EX)
  127. {
  128. MessageBox.Show(EX.ToString());
  129. }
  130. }
  131. }
  132. }