UIM020010.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. namespace Core.LZMes.Client.UIM
  11. {
  12. public partial class UIM020010 : FrmBase
  13. {
  14. public UIM020010()
  15. {
  16. InitializeComponent();
  17. }
  18. public override void ToolBar_Click(object sender, string ToolbarKey)
  19. {
  20. switch (ToolbarKey)
  21. {
  22. case "Query":
  23. this.DoQuery();
  24. break;
  25. case "Export":
  26. this.DoExport();
  27. break;
  28. case "Exit":
  29. this.Close();
  30. break;
  31. }
  32. }
  33. private void DoQuery()
  34. {
  35. try
  36. {
  37. this.dataSet1.Tables[0].Clear();
  38. string queryDate = this.ultraDateTimeEditor1.Value == null ? "" : this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd");
  39. string queryDate1 = this.ultraDateTimeEditor2.Value == null ? "" : this.ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd");
  40. if (queryDate.Substring(0, 6) != queryDate1.Substring(0, 6))
  41. {
  42. MessageBox.Show("请确保两个查询日期在同一月份", "错误");
  43. return;
  44. }
  45. string queryDate2 = "";//月累统计截止日期
  46. if (queryDate1.Substring(0, 6) == DateTime.Today.ToString("yyyyMM"))//查询日期为当月
  47. queryDate2 = DateTime.Today.ToString("yyyyMMdd");
  48. else
  49. {
  50. DateTime date = ultraDateTimeEditor2.DateTime;
  51. queryDate2 = date.AddDays(1 - date.Day).AddMonths(1).AddDays(-1).ToString("yyyyMMdd");
  52. }
  53. CoreClientParam ccp = new CoreClientParam();
  54. ccp.ServerName = "UIM.UIM02.UIM020010";
  55. ccp.MethodName = "query";
  56. ccp.ServerParams = new object[] { queryDate,queryDate1,queryDate2 };
  57. //ccp.ServerParams = new object[] { queryDate1, queryDate1, queryDate1 };
  58. ccp.SourceDataTable = this.dataSet1.Tables[0];
  59. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  60. }
  61. catch (Exception EX)
  62. {
  63. MessageBox.Show(EX.ToString());
  64. }
  65. }
  66. private void DoExport()
  67. {
  68. try
  69. {
  70. if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)
  71. {
  72. string fileName = this.saveFileDialog1.FileName;
  73. ultraGridExcelExporter1.Export(ultraGrid1, fileName);
  74. System.Diagnostics.Process.Start(fileName);
  75. }
  76. }
  77. catch (Exception EX)
  78. {
  79. MessageBox.Show(EX.ToString());
  80. }
  81. }
  82. public class CustomMergedCellEvaluatorWithSteelCode : Infragistics.Win.UltraWinGrid.IMergedCellEvaluator
  83. {
  84. public CustomMergedCellEvaluatorWithSteelCode() { }
  85. // 合并相同的单元格
  86. public bool ShouldCellsBeMerged(Infragistics.Win.UltraWinGrid.UltraGridRow row1, Infragistics.Win.UltraWinGrid.UltraGridRow row2, Infragistics.Win.UltraWinGrid.UltraGridColumn column)
  87. {
  88. string process1 = row1.GetCellValue("SPEC_STL_GRD") != null ? row1.GetCellValue("SPEC_STL_GRD").ToString() : "";
  89. string process2 = row2.GetCellValue("SPEC_STL_GRD") != null ? row2.GetCellValue("SPEC_STL_GRD").ToString() : "";
  90. return process1 == process2;
  91. }
  92. }
  93. private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
  94. {
  95. //e.Layout.Bands[0].Columns["RCOILCOUNT"].MergedCellStyle = Infragistics.Win.UltraWinGrid.MergedCellStyle.Always;
  96. //e.Layout.Bands[0].Columns["RCOILCOUNT"].MergedCellEvaluator = new CustomMergedCellEvaluatorWithSteelCode();
  97. //e.Layout.Bands[0].Columns["RCOUNT"].MergedCellStyle = Infragistics.Win.UltraWinGrid.MergedCellStyle.Always;
  98. //e.Layout.Bands[0].Columns["RCOUNT"].MergedCellEvaluator = new CustomMergedCellEvaluatorWithSteelCode();
  99. }
  100. }
  101. }