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; namespace Core.LZMes.Client.UIM { public partial class UIM020010 : FrmBase { public UIM020010() { InitializeComponent(); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": this.DoQuery(); break; case "Export": this.DoExport(); break; case "Exit": this.Close(); break; } } private void DoQuery() { try { this.dataSet1.Tables[0].Clear(); string queryDate = this.ultraDateTimeEditor1.Value == null ? "" : this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd"); string queryDate1 = this.ultraDateTimeEditor2.Value == null ? "" : this.ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd"); if (queryDate.Substring(0, 6) != queryDate1.Substring(0, 6)) { MessageBox.Show("请确保两个查询日期在同一月份", "错误"); return; } string queryDate2 = "";//月累统计截止日期 if (queryDate1.Substring(0, 6) == DateTime.Today.ToString("yyyyMM"))//查询日期为当月 queryDate2 = DateTime.Today.ToString("yyyyMMdd"); else { DateTime date = ultraDateTimeEditor2.DateTime; queryDate2 = date.AddDays(1 - date.Day).AddMonths(1).AddDays(-1).ToString("yyyyMMdd"); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIM.UIM02.UIM020010"; ccp.MethodName = "query"; ccp.ServerParams = new object[] { queryDate,queryDate1,queryDate2 }; //ccp.ServerParams = new object[] { queryDate1, queryDate1, queryDate1 }; ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); } catch (Exception EX) { MessageBox.Show(EX.ToString()); } } 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); } } catch (Exception EX) { MessageBox.Show(EX.ToString()); } } public class CustomMergedCellEvaluatorWithSteelCode : Infragistics.Win.UltraWinGrid.IMergedCellEvaluator { public CustomMergedCellEvaluatorWithSteelCode() { } // 合并相同的单元格 public bool ShouldCellsBeMerged(Infragistics.Win.UltraWinGrid.UltraGridRow row1, Infragistics.Win.UltraWinGrid.UltraGridRow row2, Infragistics.Win.UltraWinGrid.UltraGridColumn column) { string process1 = row1.GetCellValue("SPEC_STL_GRD") != null ? row1.GetCellValue("SPEC_STL_GRD").ToString() : ""; string process2 = row2.GetCellValue("SPEC_STL_GRD") != null ? row2.GetCellValue("SPEC_STL_GRD").ToString() : ""; return process1 == process2; } } private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { //e.Layout.Bands[0].Columns["RCOILCOUNT"].MergedCellStyle = Infragistics.Win.UltraWinGrid.MergedCellStyle.Always; //e.Layout.Bands[0].Columns["RCOILCOUNT"].MergedCellEvaluator = new CustomMergedCellEvaluatorWithSteelCode(); //e.Layout.Bands[0].Columns["RCOUNT"].MergedCellStyle = Infragistics.Win.UltraWinGrid.MergedCellStyle.Always; //e.Layout.Bands[0].Columns["RCOUNT"].MergedCellEvaluator = new CustomMergedCellEvaluatorWithSteelCode(); } } }