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.Diagnostics; using System.Collections; using Infragistics.Win.UltraWinGrid; namespace Core.LZMes.Client.UIC { public partial class UIC020150 : FrmBase { public UIC020150() { 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 DoExport() { try { if (this.ultraGrid1.Rows.Count == 0) { MessageBox.Show("没有可以导出的数据", "提示"); return; } saveFileDialog1.FileName = "酸轧停扎时间" + DateTime.Today.ToShortDateString() + "_01"; saveFileDialog1.Filter = "表格(*.xls)|*.xls"; if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK) { string fName = this.saveFileDialog1.FileName; this.ultraGridExcelExporter1.Export(ultraGrid1, fName); Process.Start(fName); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } public void DoQuery() { try { ArrayList al = new ArrayList(); al.Add("UIC020150_01.SELECT"); al.Add(this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMddHHmmss").Trim()); al.Add(this.ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd").Trim()+"999999"); //查询详细停轧时间 this.dataSet1.Tables[0].Clear(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBQuery"; ccp.MethodName = "doSimpleQuery"; ccp.ServerParams = new object[] { al }; ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); if (this.ultraGrid1.Rows.Count > 0) { DateTime a; string b = ""; foreach (UltraGridRow ugr in this.ultraGrid1.Rows) { b = ugr.Cells["TIMESTART"].Text.ToString(); a = DateTime.Parse(b); if (a.Hour>=0 && a.Hour<8) { ugr.Cells["BC"].Value = "晚班"; } else if (a.Hour >= 8 && a.Hour < 16) { ugr.Cells["BC"].Value = "早班"; } else if (a.Hour >= 16 && a.Hour < 24) { ugr.Cells["BC"].Value = "中班"; } } } this.ultraGrid1.Update(); //停扎时间按班次统计 this.dataSet1.Tables[1].Clear(); string queryDate = this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMddHHmmss").Trim(); string queryDate1 = this.ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd").Trim() + "999999"; 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 ccp1 = new CoreClientParam(); ccp1.ServerName = "UIC.UIC02.UIC020120"; ccp1.MethodName = "query"; ccp1.ServerParams = new object[] { queryDate, queryDate1, queryDate2 }; ccp1.SourceDataTable = this.dataSet1.Tables[1]; this.ExecuteQueryToDataTable(ccp1, CoreInvokeType.Internal); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } private void label2_Click(object sender, EventArgs e) { } private void UIC020150_Load(object sender, EventArgs e) { } } }