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 System.Diagnostics; using Infragistics.Win.UltraWinGrid.ExcelExport; using System.IO; namespace Core.LZMes.Client.UIK { public partial class UIK050080 : FrmBase { public UIK050080() { InitializeComponent(); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": this.DoQuery(); break; case "Export": this.DoExport(); break; } } private void DoQuery() { try { string in_start_time = this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd"); string in_end_time = this.ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd"); string C_SPEC_STL_GRD = ""; string C_IN_YARD = ""; string C_OUT_YARD = ""; string I_C_IN_YARD = ""; string I_C_OUT_YARD = ""; int queryType = 8; try { queryType = int.Parse(this.ultraComboEditor5.Value.ToString()); } catch (Exception Ex1) { MessageBox.Show("选择统计类型!"); } CoreClientParam ccp = new CoreClientParam(); if(this.checkBox3.Checked == false&&this.checkBox5.Checked==false) { MessageBox.Show("请选择查询条件!"); return; } else { this.dataSet1.Tables[0].Clear(); if(this.checkBox3.Checked) { C_SPEC_STL_GRD = this.ultraComboEditor1.Text.ToString(); } else { C_SPEC_STL_GRD = ""; } if(this.checkBox5.Checked) { I_C_IN_YARD = this.ultraComboEditor3.Text.Trim().ToString(); if (I_C_IN_YARD == "热送") { C_IN_YARD = "1"; } else { C_IN_YARD = "2"; } } else { C_IN_YARD = ""; } ccp.ServerName = "UIK.UIK05.UIK050070"; ccp.MethodName = "DoQuery"; ccp.ServerParams = new object[] { in_start_time, in_end_time, C_SPEC_STL_GRD, C_IN_YARD, queryType }; ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); DataRowCollection drc1 = this.dataSet1.Tables[0].Rows; return; } } catch (Exception Ex) { MessageBox.Show(Ex.ToString()); } } private void UIK050080_Load(object sender, EventArgs e) { this.checkBox3.Checked = false; this.checkBox5.Checked = false; this.ultraComboEditor1.Enabled = false; this.ultraComboEditor3.Enabled = false; } private void checkBox5_CheckedChanged(object sender, EventArgs e) { if (!this.checkBox5.Checked) { this.ultraComboEditor3.Enabled = false; } else { this.ultraComboEditor3.Enabled = true; } } private void checkBox3_CheckedChanged(object sender, EventArgs e) { if (!this.checkBox3.Checked) { this.ultraComboEditor1.Enabled = false; } else { this.ultraComboEditor1.Enabled = true; } } private void DoExport() { try { if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK) { string fileName = this.saveFileDialog1.FileName; ultraGridExcelExporter1.Export(ultraGrid1, fileName); System.Diagnostics.Process.Start(fileName); } //string fileName = this.saveFileDialog1.FileName; //this.ExportDataWithSaveDialog(ref ultraGrid1,fileName); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } public void ExportDataWithSaveDialog(ref UltraGrid myGrid1, string strFileName) { try { if (myGrid1.Rows.Count == 0) return; if (strFileName.Length == 0) strFileName = "未命名"; SaveFileDialog dlg = new SaveFileDialog(); dlg.Title = "保存"; dlg.OverwritePrompt = true; dlg.Filter = "Excel文件(*.xls)|*.xls"; dlg.AddExtension = true; dlg.FileName = strFileName; if (dlg.ShowDialog() == DialogResult.OK) { strFileName = dlg.FileName; using (UltraGridExcelExporter ultraGridExcelExporter1 = new UltraGridExcelExporter()) { ultraGridExcelExporter1.Export(myGrid1, strFileName); } if (MessageBox.Show("数据导出成功!\n需要打开所导出文件吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ProcessStartInfo p = new ProcessStartInfo(strFileName); p.WorkingDirectory = Path.GetDirectoryName(strFileName); Process.Start(p); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }