using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using CoreFS.CA06; using System.Collections; using Infragistics.Win.UltraWinGrid; using Infragistics.Excel; using Infragistics.Win; using System.Diagnostics; using Microsoft.Office.Interop.Excel; namespace Core.LZMes.Client.QCM { public partial class QCM020201 : FrmBase { public QCM020201() { InitializeComponent(); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": this.DoQuery(); break; case "InExport": // 导出实绩 DoExport(); break; } } private void DoQuery() { try { this.dataSet1.Clear(); string heatNo = this.textBox1.Text; //炉号 string steelName = this.textBox2.Text; //牌号 String STARTTIME = this.dateTimePicker1.Value.ToString("yyyy-MM-dd"); String ENDTIME = this.dateTimePicker2.Value.ToString("yyyy-MM-dd"); if (this.dateTimePicker1.Value > this.dateTimePicker2.Value) { MessageBox.Show("日期查询条件开始日期大于结束日期!!!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } //查询数据库里的数据 CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "QCM.JHY01.JHY0102.QuerryJhyElements"; ccp.MethodName = "QueryNew"; ccp.ServerParams = new object[] { steelName, heatNo, STARTTIME, ENDTIME }; ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("系统出错,请联系管理人员", "警告"); } } //初始化的时候加载列 private void QCM020201_Load(object sender, EventArgs e) { dateTimePicker1.Value = DateTime.Now.Date.AddDays(-2); //获取成分实绩中总共有多少元素 System.Data.DataTable chemtable = new System.Data.DataTable(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "QCM.JHY01.JHY0102.QuerryJhyElements"; ccp.MethodName = "QueryElement"; ccp.SourceDataTable = chemtable; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); //把在后端查询到的元素数据加入 for (int i = 0; i < chemtable.Rows.Count; i++) { this.dataSet1.Tables[0].Columns.Add(chemtable.Rows[i]["CHEM_CODE"].ToString(), typeof(System.String)); } //this.DoQuery();//查询 } private void DoExport() { try { if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK) { string fileName = this.saveFileDialog1.FileName; ultraGridExcelExporter1.Export(ultraGrid1, fileName); } } catch (Exception EX) { MessageBox.Show(EX.ToString()); } } } }