| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- 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);
- }
- }
- }
- }
|