| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- 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 QCM0202 : FrmBase
- {
- public QCM0202()
- {
- 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();
- System.Data.DataTable datatable = new System.Data.DataTable();
- ccp.ServerName = "QCM.JHY01.JHY0102.QuerryJhyElements";
- ccp.MethodName = "Query";
- ccp.ServerParams = new object[] { steelName, heatNo, STARTTIME, ENDTIME };
- this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- Hashtable ht = (Hashtable)ccp.ReturnObject;
- ArrayList group = ht["group"] as ArrayList;
- ArrayList result = ht["result"] as ArrayList;
- for (int i = 0; i < group.Count; i++)
- {
-
- Hashtable row = (Hashtable)group[i];
- DataRow dr = this.dataSet1.Tables[0].NewRow();
- dr["ASSAY_NO"] = row["ASSAY_NO"];
- dr["BATCH_NO"] = row["BATCH_NO"];
- dr["HEAT_NO"] = row["HEAT_NO"];
- dr["STEEL_CODE"] = row["STEEL_CODE"];
- dr["ASSAY_TYPE"] = row["ASSAY_TYPE"].ToString().Equals("L") ? "熔炼" : "成品";
- dr["CREATE_NAME"] = row["CREATE_NAME"];
- dr["CREATE_TIME"] = row["CREATE_TIME"];
- for (int j = 0; j < result.Count; j++)
- {
- Hashtable chem = (Hashtable)result[j];
- if (chem["ASSAY_NO"].Equals(row["ASSAY_NO"]) && chem["ASSAY_TYPE"].Equals( row["ASSAY_TYPE"]))
- {
- //dr[chem["CHEM_CODE"].ToString()] = chem["CHEM_VALUE"].ToString();
- // dr[chem["CHEM_CODE"].ToString()] = chem["CHEM_VALUE"].ToString();
- if (chem["CHEM_VALUE"] != null)
- {
- Hashtable chem1 = (Hashtable)chem["CHEM_VALUE"];
- foreach (DictionaryEntry item1 in chem1)
- {
- dr[chem["CHEM_CODE"].ToString()] = item1.Value;
- break;
- }
- }
- }
- }
- this.dataSet1.Tables[0].Rows.Add(dr);
-
- }
- }
- catch (Exception ex)
- {
- System.Diagnostics.Debug.WriteLine(ex.ToString());
- MessageBox.Show("系统出错,请联系管理人员", "警告");
- }
- }
- //初始化的时候加载列
- private void QCM0202_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());
- }
- }
- }
- }
|