QCM020201.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 QCM020201 : FrmBase
  19. {
  20. public QCM020201()
  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. ccp.ServerName = "QCM.JHY01.JHY0102.QuerryJhyElements";
  53. ccp.MethodName = "QueryNew";
  54. ccp.ServerParams = new object[] { steelName, heatNo, STARTTIME, ENDTIME };
  55. ccp.SourceDataTable = this.dataSet1.Tables[0];
  56. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  57. }
  58. catch (Exception ex)
  59. {
  60. System.Diagnostics.Debug.WriteLine(ex.ToString());
  61. MessageBox.Show("系统出错,请联系管理人员", "警告");
  62. }
  63. }
  64. //初始化的时候加载列
  65. private void QCM020201_Load(object sender, EventArgs e)
  66. {
  67. dateTimePicker1.Value = DateTime.Now.Date.AddDays(-2);
  68. //获取成分实绩中总共有多少元素
  69. System.Data.DataTable chemtable = new System.Data.DataTable();
  70. CoreClientParam ccp = new CoreClientParam();
  71. ccp.ServerName = "QCM.JHY01.JHY0102.QuerryJhyElements";
  72. ccp.MethodName = "QueryElement";
  73. ccp.SourceDataTable = chemtable;
  74. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  75. //把在后端查询到的元素数据加入
  76. for (int i = 0; i < chemtable.Rows.Count; i++)
  77. {
  78. this.dataSet1.Tables[0].Columns.Add(chemtable.Rows[i]["CHEM_CODE"].ToString(), typeof(System.String));
  79. }
  80. //this.DoQuery();//查询
  81. }
  82. private void DoExport()
  83. {
  84. try
  85. {
  86. if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)
  87. {
  88. string fileName = this.saveFileDialog1.FileName;
  89. ultraGridExcelExporter1.Export(ultraGrid1, fileName);
  90. }
  91. }
  92. catch (Exception EX)
  93. {
  94. MessageBox.Show(EX.ToString());
  95. }
  96. }
  97. }
  98. }