UIK050080.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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 System.Diagnostics;
  13. using Infragistics.Win.UltraWinGrid.ExcelExport;
  14. using System.IO;
  15. namespace Core.LZMes.Client.UIK
  16. {
  17. public partial class UIK050080 : FrmBase
  18. {
  19. public UIK050080()
  20. {
  21. InitializeComponent();
  22. }
  23. public override void ToolBar_Click(object sender, string ToolbarKey)
  24. {
  25. switch (ToolbarKey)
  26. {
  27. case "Query":
  28. this.DoQuery();
  29. break;
  30. case "Export":
  31. this.DoExport();
  32. break;
  33. }
  34. }
  35. private void DoQuery()
  36. {
  37. try
  38. {
  39. string in_start_time = this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd");
  40. string in_end_time = this.ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd");
  41. string C_SPEC_STL_GRD = "";
  42. string C_IN_YARD = "";
  43. string C_OUT_YARD = "";
  44. string I_C_IN_YARD = "";
  45. string I_C_OUT_YARD = "";
  46. int queryType = 8;
  47. try
  48. {
  49. queryType = int.Parse(this.ultraComboEditor5.Value.ToString());
  50. }
  51. catch (Exception Ex1)
  52. {
  53. MessageBox.Show("选择统计类型!");
  54. }
  55. CoreClientParam ccp = new CoreClientParam();
  56. if(this.checkBox3.Checked == false&&this.checkBox5.Checked==false)
  57. {
  58. MessageBox.Show("请选择查询条件!");
  59. return;
  60. }
  61. else
  62. {
  63. this.dataSet1.Tables[0].Clear();
  64. if(this.checkBox3.Checked)
  65. {
  66. C_SPEC_STL_GRD = this.ultraComboEditor1.Text.ToString();
  67. }
  68. else
  69. {
  70. C_SPEC_STL_GRD = "";
  71. }
  72. if(this.checkBox5.Checked)
  73. {
  74. I_C_IN_YARD = this.ultraComboEditor3.Text.Trim().ToString();
  75. if (I_C_IN_YARD == "热送")
  76. {
  77. C_IN_YARD = "1";
  78. }
  79. else
  80. {
  81. C_IN_YARD = "2";
  82. }
  83. }
  84. else
  85. {
  86. C_IN_YARD = "";
  87. }
  88. ccp.ServerName = "UIK.UIK05.UIK050070";
  89. ccp.MethodName = "DoQuery";
  90. ccp.ServerParams = new object[] { in_start_time, in_end_time, C_SPEC_STL_GRD, C_IN_YARD, queryType };
  91. ccp.SourceDataTable = this.dataSet1.Tables[0];
  92. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  93. DataRowCollection drc1 = this.dataSet1.Tables[0].Rows;
  94. return;
  95. }
  96. }
  97. catch (Exception Ex)
  98. {
  99. MessageBox.Show(Ex.ToString());
  100. }
  101. }
  102. private void UIK050080_Load(object sender, EventArgs e)
  103. {
  104. this.checkBox3.Checked = false;
  105. this.checkBox5.Checked = false;
  106. this.ultraComboEditor1.Enabled = false;
  107. this.ultraComboEditor3.Enabled = false;
  108. }
  109. private void checkBox5_CheckedChanged(object sender, EventArgs e)
  110. {
  111. if (!this.checkBox5.Checked)
  112. {
  113. this.ultraComboEditor3.Enabled = false;
  114. }
  115. else
  116. {
  117. this.ultraComboEditor3.Enabled = true;
  118. }
  119. }
  120. private void checkBox3_CheckedChanged(object sender, EventArgs e)
  121. {
  122. if (!this.checkBox3.Checked)
  123. {
  124. this.ultraComboEditor1.Enabled = false;
  125. }
  126. else
  127. {
  128. this.ultraComboEditor1.Enabled = true;
  129. }
  130. }
  131. private void DoExport()
  132. {
  133. try
  134. {
  135. if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)
  136. {
  137. string fileName = this.saveFileDialog1.FileName;
  138. ultraGridExcelExporter1.Export(ultraGrid1, fileName);
  139. System.Diagnostics.Process.Start(fileName);
  140. }
  141. //string fileName = this.saveFileDialog1.FileName;
  142. //this.ExportDataWithSaveDialog(ref ultraGrid1,fileName);
  143. }
  144. catch (Exception ex)
  145. {
  146. MessageBox.Show(ex.ToString());
  147. }
  148. }
  149. public void ExportDataWithSaveDialog(ref UltraGrid myGrid1, string strFileName)
  150. {
  151. try
  152. {
  153. if (myGrid1.Rows.Count == 0) return;
  154. if (strFileName.Length == 0) strFileName = "未命名";
  155. SaveFileDialog dlg = new SaveFileDialog();
  156. dlg.Title = "保存";
  157. dlg.OverwritePrompt = true;
  158. dlg.Filter = "Excel文件(*.xls)|*.xls";
  159. dlg.AddExtension = true;
  160. dlg.FileName = strFileName;
  161. if (dlg.ShowDialog() == DialogResult.OK)
  162. {
  163. strFileName = dlg.FileName;
  164. using (UltraGridExcelExporter ultraGridExcelExporter1 = new UltraGridExcelExporter())
  165. {
  166. ultraGridExcelExporter1.Export(myGrid1, strFileName);
  167. }
  168. if (MessageBox.Show("数据导出成功!\n需要打开所导出文件吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  169. {
  170. ProcessStartInfo p = new ProcessStartInfo(strFileName);
  171. p.WorkingDirectory = Path.GetDirectoryName(strFileName);
  172. Process.Start(p);
  173. }
  174. }
  175. }
  176. catch (Exception ex)
  177. {
  178. MessageBox.Show(ex.Message);
  179. }
  180. }
  181. }
  182. }