using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Collections; using System.IO; using System.Diagnostics; using CoreFS.CA06; using Core.Mes.Client.Common; using Infragistics.Win.UltraWinGrid; namespace Core.LgMes.Client.LgDeviceManager { public partial class FrmILHistory : Core.Mes.Client.Common.frmStyleBase//frmModelFormStyle { private ToolsName toolName; //工具名称 private string strInitID = ""; //编号 private RecordsName recordName; //使用记录、维修记录、烘烤记录 public FrmILHistory(ToolsName toolName,string strInitID ,RecordsName recordName,OpeBase oba) { InitializeComponent(); ob = oba; this.toolName = toolName; this.recordName = recordName; this.strInitID = strInitID; this.Text = this.toolName.ToString() + this.recordName.ToString(); } private void FrmILHistory_Load(object sender, EventArgs e) { udteStartS.Value = udteStartE.Value = udteEndS.Value = udteEndE.Value = DateTime.Today; proc_GetID(); chkStart.Checked = true; if (strInitID.Length > 0) { cbmID.Text = strInitID; chkID.Checked = true; } InitData(); proc_GetHistory(); } /// /// 加载铁包号 /// private void proc_GetID() { try { if (this.toolName == ToolsName.铁包) { string strErr = ""; ArrayList arry = new ArrayList(); arry.Add("FrmILHistory_Query1"); CommonClientToServer ccs = new CommonClientToServer(); ccs.ob = this.ob; DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr); if (strErr == "" && ds != null && ds.Tables.Count > 0) { cbmID.Items.Clear(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { cbmID.Items.Add(ds.Tables[0].Rows[i]["铁包编号"]); } } else { MessageBox.Show(this.toolName.ToString() + "编号查询出错!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { MessageBox.Show(this.toolName.ToString() + "编号查询出错!" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } /// /// 查询 /// private void proc_GetHistory() { try { if (this.toolName == ToolsName.铁包) { if (this.recordName == RecordsName.使用记录) { string strErr = ""; string strWhere = ""; string strFrom = "", strTo = ""; if (chkStart.Checked) { strFrom =Convert.ToDateTime(udteStartS.Value).ToString("yyyy-MM-dd"); strTo = Convert.ToDateTime(udteStartE.Value).ToString("yyyy-MM-dd"); strWhere += " and case USETYPE " + "when '1' then to_char(MISTAPHOLESTARTTIME, 'yyyy-MM-dd') " + "when '2' then to_char(BOFTAPPINGSTARTTIME, 'yyyy-MM-dd') " + "end between '" + strFrom + "' and '" + strTo + "'"; } if (chkEnd.Checked) { strFrom = Convert.ToDateTime(udteEndS.Value).ToString("yyyy-MM-dd"); strTo = Convert.ToDateTime(udteEndE.Value).ToString("yyyy-MM-dd"); strWhere += " and to_char(BOFCHANGEENDTIME, 'yyyy-MM-dd') between '" + strFrom + "' and '" + strTo + "'"; } if (chkID.Checked && cbmID.SelectedIndex > -1) { strWhere += " and LADLEID = '" + cbmID.Text.Trim() + "'"; } ArrayList arry = new ArrayList(); ArrayList sqlList = new ArrayList(); arry.Add("FrmILHistory_Query2"); sqlList.Add(strWhere); CoreClientParam CCP_LgEts = new CoreClientParam(); DataTable dt = new DataTable(); CCP_LgEts.ServerName = "Core.LgMes.Server.Common.ComDBQuery"; CCP_LgEts.MethodName = "doQuery"; CCP_LgEts.ServerParams = new object[] { arry, sqlList }; CCP_LgEts.SourceDataTable = dt; this.ExecuteQueryToDataTable(CCP_LgEts, CoreInvokeType.Internal); DataSet ds = new DataSet(); ds.Tables.Add(dt); strErr = CCP_LgEts.ReturnInfo; //try //{ // ((DataSet)ugrdUserinfo.DataSource).Tables[0].Rows.Clear(); //} //catch (Exception) //{ //} if (strErr == "" && ds != null && ds.Tables.Count > 0) { ugrdUserinfo.DataSource = ds.Tables[0]; ugrdUserinfo.DataBind(); } else { MessageBox.Show(this.toolName.ToString() + this.recordName.ToString() + "查询出错!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (this.recordName == RecordsName.维修记录) { string strErr = ""; string strWhere = " and TOOLTYPEID = '铁包'"; string strFrom = "", strTo = ""; if (chkStart.Checked) { strFrom = Convert.ToDateTime(udteStartS.Value).ToString("yyyy-MM-dd"); strTo = Convert.ToDateTime(udteStartE.Value).ToString("yyyy-MM-dd"); strWhere += " and to_char(REPAIRTIME, 'yyyy-MM-dd') between '" + strFrom + "' and '" + strTo + "'"; } if (chkEnd.Checked) { strFrom = Convert.ToDateTime(udteEndS.Value).ToString("yyyy-MM-dd"); strTo = Convert.ToDateTime(udteEndE.Value).ToString("yyyy-MM-dd"); strWhere += " and to_char(REPAIREDTIME, 'yyyy-MM-dd') between '" + strFrom + "' and '" + strTo + "'"; } if (chkID.Checked && cbmID.SelectedIndex > -1) { strWhere += " and REPAIRTOOLID = '" + cbmID.Text.Trim() + "'"; } ArrayList arry = new ArrayList(); ArrayList sqlList = new ArrayList(); arry.Add("FrmILHistory_Query3"); sqlList.Add(strWhere); CoreClientParam CCP_LgEts = new CoreClientParam(); DataTable dt = new DataTable(); CCP_LgEts.ServerName = "Core.LgMes.Server.Common.ComDBQuery"; CCP_LgEts.MethodName = "doQuery"; CCP_LgEts.ServerParams = new object[] { arry, sqlList }; CCP_LgEts.SourceDataTable = dt; this.ExecuteQueryToDataTable(CCP_LgEts, CoreInvokeType.Internal); DataSet ds = new DataSet(); ds.Tables.Add(dt); strErr = CCP_LgEts.ReturnInfo; try { ((DataTable)ugrdUserinfo.DataSource).Rows.Clear(); ugrdUserinfo.DataBind(); } catch (Exception) { } if (strErr == "" && ds != null && ds.Tables.Count > 0) { ugrdUserinfo.DataSource = ds.Tables[0]; } else { MessageBox.Show(this.toolName.ToString() + this.recordName.ToString() + "查询出错!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (this.recordName == RecordsName.烘烤记录) { string strErr = ""; string strWhere = " and TOOLTYPE = '铁包'"; string strFrom = "", strTo = ""; if (chkStart.Checked) { strFrom = Convert.ToDateTime(udteStartS.Value).ToString("yyyy-MM-dd"); strTo = Convert.ToDateTime(udteStartE.Value).ToString("yyyy-MM-dd"); strWhere += " and to_char(BEGINTIME, 'yyyy-MM-dd') between '" + strFrom + "' and '" + strTo + "'"; } if (chkEnd.Checked) { strFrom = Convert.ToDateTime(udteEndS.Value).ToString("yyyy-MM-dd"); strTo = Convert.ToDateTime(udteEndE.Value).ToString("yyyy-MM-dd"); strWhere += " and to_char(ENDTIME, 'yyyy-MM-dd') between '" + strFrom + "' and '" + strTo + "'"; } if (chkID.Checked && cbmID.SelectedIndex > -1) { strWhere += " and FIRINGTOOLID = '" + cbmID.Text.Trim() + "'"; } ArrayList arry = new ArrayList(); ArrayList sqlList = new ArrayList(); arry.Add("FrmILHistory_Query4"); sqlList.Add(strWhere); CoreClientParam CCP_LgEts = new CoreClientParam(); DataTable dt = new DataTable(); CCP_LgEts.ServerName = "Core.LgMes.Server.Common.ComDBQuery"; CCP_LgEts.MethodName = "doQuery"; CCP_LgEts.ServerParams = new object[] { arry, sqlList }; CCP_LgEts.SourceDataTable = dt; this.ExecuteQueryToDataTable(CCP_LgEts, CoreInvokeType.Internal); DataSet ds = new DataSet(); ds.Tables.Add(dt); strErr = CCP_LgEts.ReturnInfo; try { ((DataTable)ugrdUserinfo.DataSource).Rows.Clear(); } catch (Exception) { } if (strErr == "" && ds != null && ds.Tables.Count > 0) { ugrdUserinfo.DataSource = ds.Tables[0]; ugrdUserinfo.DataBind(); } else { MessageBox.Show(this.toolName.ToString() + this.recordName.ToString() + "查询出错!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } catch (Exception ex) { MessageBox.Show(this.toolName.ToString() + this.recordName.ToString() + "查询出错!" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } /// /// 铁包使用记录UltraGrid显示设置 /// private void InitData() { try { UltraGridBand band = this.ugrdUserinfo.DisplayLayout.Bands[0]; band.Columns[0].Header.Caption = "铁包编号"; band.Columns[0].Width = 60; band.Columns[1].Header.Caption = "所处位置"; band.Columns[1].Width = 60; band.Columns[1].CellActivation = Infragistics.Win.UltraWinGrid.Activation.NoEdit; // band.Columns[2].Header.Caption = "使用类别"; band.Columns[2].Width = 60; band.Columns[2].CellActivation = Infragistics.Win.UltraWinGrid.Activation.NoEdit; band.Columns[3].Header.Caption = "铁水包龄"; band.Columns[3].Width = 60; band.Columns[3].CellActivation = Infragistics.Win.UltraWinGrid.Activation.NoEdit; band.Columns[4].Header.Caption = "铁水站接铁开始时刻"; band.Columns[4].Width = 150; band.Columns[4].CellAppearance.ForeColor = Color.Black; band.Columns[4].CellActivation = Infragistics.Win.UltraWinGrid.Activation.NoEdit; band.Columns[5].Header.Caption = "铁水站接铁结束时刻"; band.Columns[5].Width = 150; band.Columns[5].CellAppearance.ForeColor = Color.Black; band.Columns[5].CellActivation = Infragistics.Win.UltraWinGrid.Activation.NoEdit; band.Columns[6].Header.Caption = "脱硫站进站时刻"; band.Columns[6].Width = 150; band.Columns[6].CellAppearance.ForeColor = Color.Black; band.Columns[6].CellActivation = Infragistics.Win.UltraWinGrid.Activation.NoEdit; band.Columns[7].Header.Caption = "脱硫站出站时刻"; band.Columns[7].Width = 150; band.Columns[7].CellAppearance.ForeColor = Color.Black; band.Columns[7].CellActivation = Infragistics.Win.UltraWinGrid.Activation.NoEdit; band.Columns[8].Header.Caption = "转炉兑铁开始时刻"; band.Columns[8].Width = 150; band.Columns[8].CellAppearance.ForeColor = Color.Black; band.Columns[8].CellActivation = Infragistics.Win.UltraWinGrid.Activation.NoEdit; band.Columns[9].Header.Caption = "转炉兑铁结束时刻"; band.Columns[9].Width = 150; band.Columns[9].CellAppearance.ForeColor = Color.Black; band.Columns[9].CellActivation = Infragistics.Win.UltraWinGrid.Activation.NoEdit; } catch { } } private void cbxDateTime1_CheckedChanged(object sender, EventArgs e) { udteStartS.Enabled = udteStartE.Enabled = chkStart.Checked; } private void cbxDateTime2_CheckedChanged(object sender, EventArgs e) { udteEndS.Enabled = udteEndE.Enabled = chkEnd.Checked; } private void cbxID_CheckedChanged(object sender, EventArgs e) { cbmID.Enabled = chkID.Checked; } private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { case "Query": proc_GetHistory(); break; case "Output": try { if (ugrdUserinfo.Rows.Count == 0) return; string strFileName = recordName.ToString() + "_" + DateTime.Today.ToString("yyyy-MM-dd"); strFileName = string.Format(Application.StartupPath + "\\{0}.xls", strFileName); ultraGridExcelExporter1.Export(ugrdUserinfo, strFileName); ProcessStartInfo p = new ProcessStartInfo(strFileName); p.WorkingDirectory = Path.GetDirectoryName(strFileName); Process.Start(p); } catch (Exception ex) { MessageBox.Show(ex.Message); } break; case "Close": this.Close(); break; default: break; } } } }