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 UIC020140 : FrmBase { public UIC020140() { InitializeComponent(); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": this.DoQuery(); break; case "Export": this.DoExport(); break; case "Save": this.DoSave(); break; case "Update": this.DoUpdate(); 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()); } } private void JZExport() { try { if (this.ultraGrid4.Rows.Count == 0) { MessageBox.Show("没有可以导出的数据", "提示"); return; } saveFileDialog1.FileName = "热轧班组节奏" + DateTime.Today.ToShortDateString() + "_01"; saveFileDialog1.Filter = "表格(*.xls)|*.xls"; if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK) { string fName1 = this.saveFileDialog1.FileName; this.ultraGridExcelExporter1.Export(ultraGrid4, fName1); Process.Start(fName1); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } public void DoQuery() { try { ArrayList al = new ArrayList(); al.Add("UIC020140_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); Color color = Color.FromArgb(255, 255, 255); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in ultraGrid1.Rows) { string status = ugr.Cells["CHKFLAG"].Value.ToString().Trim(); if ("1".Equals(status)) { ugr.Cells["CHKTIME"].Appearance.BackColor = Color.Pink; } } 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 = "queryhot"; ccp1.ServerParams = new object[] { queryDate, queryDate1, queryDate2 }; ccp1.SourceDataTable = this.dataSet1.Tables[1]; this.ExecuteQueryToDataTable(ccp1, CoreInvokeType.Internal); this.dataSet2.Tables[0].Clear(); CoreClientParam ccp2 = new CoreClientParam(); ccp2.ServerName = "UIC.UIC02.UIC020120"; ccp2.MethodName = "queryTeam"; ccp2.ServerParams = new object[] { queryDate, queryDate1, queryDate2 }; ccp2.SourceDataTable = this.dataSet2.Tables[0]; this.ExecuteQueryToDataTable(ccp2, CoreInvokeType.Internal); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } private void label2_Click(object sender, EventArgs e) { } private void DoSave() { try { if (MessageBox.Show("确认保存?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; ArrayList al = new ArrayList(); ArrayList list = null; string num1 = "";//日历时间 string num2 = "";//停轧时间 string strBC = "";//班次 string strTime = ""; string strProdLine = ""; foreach (UltraGridRow ugr in this.ultraGrid1.Rows) { if (ugr.Cells["CHK"].Text == "True") { list = new ArrayList(); list.Add("UIC020140_01.UPDATE"); list.Add(ugr.Cells["CHKRESON"].Text.Trim()); list.Add(ugr.Cells["CHKNAME"].Text.Trim()); list.Add(ugr.Cells["BUGLOCAION"].Text.Trim()); list.Add(ugr.Cells["PRDSMOD"].Text.Trim()); list.Add(ugr.Cells["TIMESTART"].Text.Trim()); al.Add(list); } } if (al.Count == 0) { MessageBox.Show("没有修改的数据(红色行),保存无效", "提示"); return; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBSave"; ccp.MethodName = "doXmlSave"; ccp.ServerParams = new object[] { al }; ccp.IfShowErrMsg = false; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); this.DoQuery(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("系统发生异常,请与管理员联系", "提示"); } } private void DoUpdate() { try { if (MessageBox.Show("确认保存?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; ArrayList al = new ArrayList(); ArrayList list = null; string num1 = "";//日历时间 string num2 = "";//停轧时间 string strBC = "";//班次 string strTime = ""; string strProdLine = ""; foreach (UltraGridRow ugr in this.ultraGrid1.Rows) { if (ugr.Cells["CHK"].Text == "True") { list = new ArrayList(); list.Add("UIC020140_02.UPDATE"); list.Add(ugr.Cells["CHKRESON"].Text.Trim()); list.Add(ugr.Cells["CHKNAME"].Text.Trim()); list.Add(ugr.Cells["BUGLOCAION"].Text.Trim()); list.Add(ugr.Cells["PRDSMOD"].Text.Trim()); list.Add(ugr.Cells["TIMESTART"].Text.Trim()); al.Add(list); } } if (al.Count == 0) { MessageBox.Show("没有修改的数据(红色行),保存无效", "提示"); return; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBSave"; ccp.MethodName = "doXmlSave"; ccp.ServerParams = new object[] { al }; ccp.IfShowErrMsg = false; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); this.DoQuery(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("系统发生异常,请与管理员联系", "提示"); } } private void UIC020140_Load(object sender, EventArgs e) { } private void ultraButton1_Click(object sender, EventArgs e) { this.JZExport(); } } }