using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Windows.Forms; using Infragistics.Win; using Infragistics.Win.Misc; namespace Core.StlMes.Client.LgCommon { public partial class ucTemperature : UserControl { private string _Caption = ""; //显示标题 private bool _ExPanded = true; //是否展开 private bool _Expandable = false; //是否可收缩 private int _ExPandedHeight = 0; //展开高度 private UIElementBorderStyle _BorderStyle = UIElementBorderStyle.InsetSoft; #region 属性 /// /// 显示标题 /// [Description("显示标题")] public string Caption { get { return _Caption; } set { if (!value.Equals(_Caption)) { _Caption = value; MainContainer.Text = value; MainContainer.HeaderBorderStyle = (string.IsNullOrEmpty(value) ? UIElementBorderStyle.None : UIElementBorderStyle.Etched); } } } /// /// 展开状态 /// [Description("展开状态")] public bool ExPanded { get { return _ExPanded; } set { if (!value && !_Expandable) value = true; if (value != _ExPanded) { _ExPanded = value; MainContainer.Expanded = value; } } } /// /// 是否可收缩 /// [Description("是否可收缩")] public bool Expandable { get { return _Expandable; } set { if (value != _Expandable) { _Expandable = value; if (!value) { MainContainer.ExpansionIndicator = GroupBoxExpansionIndicator.None; MainContainer.HeaderClickAction = GroupBoxHeaderClickAction.None; ExPanded = true; } else { MainContainer.ExpansionIndicator = GroupBoxExpansionIndicator.Far; MainContainer.HeaderClickAction = GroupBoxHeaderClickAction.ToggleExpansion; if (string.IsNullOrEmpty(_Caption)) Caption = "温度(单位:℃)"; if (value) _ExPanded = MainContainer.Expanded; } MainContainer.Invalidate(); } } } [Description("展开高度")] public int ExPandedHeight { get { return _ExPandedHeight; } } [Description("边框样式")] public new UIElementBorderStyle BorderStyle { get { return _BorderStyle; } set { if (value != _BorderStyle) { _BorderStyle = value; MidContainer.BorderStyle = value; } } } #endregion #region 构造函数 public ucTemperature() { InitializeComponent(); try { this.Caption = "温度(单位:℃)"; ultraGrid1.DisplayLayout.Override.ActiveRowAppearance.FontData.ResetBold(); ultraGrid1.DisplayLayout.Override.RowSelectors = DefaultableBoolean.False; } catch { } } #endregion #region 生成框架 #endregion #region 窗体公共调用 public void ResetData() { if (dataTable1 != null && dataTable1.Rows.Count > 0) dataTable1.Rows.Clear(); } private string TruncSampleTime(string strTime) { strTime = strTime.Trim(); try { if (!string.IsNullOrEmpty(strTime) && strTime.Length >= 12) return strTime.Substring(10); } catch { } return strTime; } /// /// 填充温度信息界面数据 /// public void FillTemperatureData_BOF(Hashtable htOptInfo, DataTable dtSample, DataTable dtStandard) { int iCurr = 0; if (ultraGrid1.ActiveRow != null) iCurr = ultraGrid1.ActiveRow.Index; ultraGrid1.BeginUpdate(); try { lock (this) { int iRows = 2; // 加一条铁水温度、铸机要温 DataRow[] dr = null; if (dtSample != null && dtSample.Rows.Count > 0) dr = dtSample.Select("SAMPLINGNAME = 'TEMPERATURE'", " SAMPLINGDATE"); if (dr != null && dr.Length > 0) iRows += dr.Length; try { dataTable1.Rows.Clear(); DataRow row = null; for (int i = 0; i < iRows; i++) { row = dataTable1.NewRow(); dataTable1.Rows.Add(row); } } catch { } int idx = 0; #region " 铁水温度 " string strValue = "", strTime = ""; if (htOptInfo != null && htOptInfo.Contains("IRONTEMPERATURE")) strValue = htOptInfo["IRONTEMPERATURE"].ToString(); ClsBusinessPack.SetGridTemperature(this.dataTable1, "铁水温度", "", strValue, TruncSampleTime(strTime), idx); idx++; #endregion #region "铸机要温" strValue = ""; strTime = ""; if (htOptInfo != null && htOptInfo.Contains("CCMPLANTEMPT")) strValue = htOptInfo["CCMPLANTEMPT"].ToString(); if (htOptInfo != null && htOptInfo.Contains("CCMPLANTEMPTTIME")) strTime = htOptInfo["CCMPLANTEMPTTIME"].ToString(); ClsBusinessPack.SetGridTemperature(dataTable1, "铸机要温", "", strValue, TruncSampleTime(strTime), idx); idx++; #endregion #region " 实时值 " if (dr != null && dr.Length > 0) { string str = ""; for (int i = 0; i < dr.Length; i++, idx++) { if (i == 0) str = "转炉一倒温度"; else if (i == dr.Length - 1) str = "转炉终点温度"; else str = "转炉过程温度"; ClsBusinessPack.SetGridTemperature(dataTable1, str, "", dr[i]["SAMPLINGVALUE"].ToString(), TruncSampleTime(dr[i]["SAMPLINGDATE"].ToString()), idx); } } #endregion #region " 与标准进行比对 " if (dr != null && dr.Length > 0) { // 一倒温度 ClsBusinessPack.CompareStandard(dtStandard, dataTable1, "L02001", ultraGrid1, 2); //二倒温度 ClsBusinessPack.CompareStandard(dtStandard, dataTable1, "L02004", ultraGrid1, dr.Length + 1); } #endregion } } catch { } finally { ClsControlPack.RefreshAndAutoSize(ultraGrid1); if (iCurr > 0 && ultraGrid1.Rows.Count >= iCurr + 1) { ultraGrid1.Rows[iCurr].Activated = true; ultraGrid1.Rows[iCurr].Selected = false; } ultraGrid1.EndUpdate(); } } /// /// 填充温度信息界面数据 /// public void FillTemperatureData_CAS(Hashtable htOptInfo, DataTable dtSampleBOF, DataTable dtSampleCAS, DataTable dtStandard) { int iCurr = 0; if (ultraGrid1.ActiveRow != null) iCurr = ultraGrid1.ActiveRow.Index; ultraGrid1.BeginUpdate(); try { lock (this) { int iRows = 1; // 加一条转炉出钢温度 DataRow[] dr1 = null, dr2 = null; if (dtSampleBOF != null && dtSampleBOF.Rows.Count > 0) dr1 = dtSampleBOF.Select("SAMPLINGNAME = 'TEMPERATURE'", " SAMPLINGDATE DESC"); if (dtSampleCAS != null && dtSampleCAS.Rows.Count > 0) dr2 = dtSampleCAS.Select("SAMPLINGNAME = 'TEMPERATURE'", " SAMPLINGDATE"); if (dr2 != null && dr2.Length > 0) iRows += dr2.Length; try { dataTable1.Rows.Clear(); DataRow row = null; for (int i = 0; i < iRows; i++) { row = dataTable1.NewRow(); dataTable1.Rows.Add(row); } } catch { } int idx = 0; #region " 转炉出钢温度 " string strValue = "", strTime = ""; if (dr1 != null && dr1.Length > 0) { strValue = dr1[0]["SAMPLINGVALUE"].ToString(); strTime = dr1[0]["SAMPLINGDATE"].ToString(); } ClsBusinessPack.SetGridTemperature(this.dataTable1, "转炉终点温度", "", strValue, TruncSampleTime(strTime), idx); idx++; #endregion #region " 实时值 " if (dr2 != null && dr2.Length > 0) { string str = ""; for (int i = 0; i < dr2.Length; i++, idx++) { if (i == 0) str = "吹氩进站温度"; else if (i == dr2.Length - 1) str = "吹氩出站温度"; else str = "吹氩过程温度"; ClsBusinessPack.SetGridTemperature(this.dataTable1, str, "", dr2[i]["SAMPLINGVALUE"].ToString(), TruncSampleTime(dr2[i]["SAMPLINGDATE"].ToString()), idx); } } #endregion #region " 与标准进行比对 " //出钢终点温度 if (dr1 != null && dr1.Length > 0) ClsBusinessPack.CompareStandard(dtStandard, dataTable1, "L02001", ultraGrid1, 0); //吹氩站温度 if (dr2 != null && dr2.Length > 0) { ClsBusinessPack.CompareStandard(dtStandard, dataTable1, "L02001", ultraGrid1, 1); ClsBusinessPack.CompareStandard(dtStandard, dataTable1, "L02001", ultraGrid1, dr2.Length); } #endregion } } catch { } finally { ClsControlPack.RefreshAndAutoSize(ultraGrid1); if (iCurr > 0 && ultraGrid1.Rows.Count >= iCurr + 1) { ultraGrid1.Rows[iCurr].Activated = true; ultraGrid1.Rows[iCurr].Selected = false; } ultraGrid1.EndUpdate(); } } /// /// 填充温度信息界面数据精炼炉 /// public void FillTemperatureData_LFS(Hashtable htOptInfo, DataTable dtSampleBOF, DataTable dtSampleCAS, DataTable dtSampleLFS, DataTable dtStandard) { int iCurr = 0; if (ultraGrid1.ActiveRow != null) iCurr = ultraGrid1.ActiveRow.Index; ultraGrid1.BeginUpdate(); try { lock (this) { int iRows = 2; //加一条转炉出钢温度 和 吹氩站出站温度 DataRow[] dr1 = null, dr2 = null, dr3 = null; if (dtSampleBOF != null && dtSampleBOF.Rows.Count > 0) dr1 = dtSampleBOF.Select("SAMPLINGNAME = 'TEMPERATURE'", " SAMPLINGDATE DESC"); if (dtSampleCAS != null && dtSampleCAS.Rows.Count > 0) dr2 = dtSampleCAS.Select("SAMPLINGNAME = 'TEMPERATURE'", " SAMPLINGDATE DESC"); if (dtSampleLFS != null && dtSampleLFS.Rows.Count > 0) dr3 = dtSampleLFS.Select("SAMPLINGNAME = 'TEMPERATURE1' or SAMPLINGNAME = 'TEMPERATURE2'", " SAMPLINGDATE ASC"); if (dr3 != null && dr3.Length > 0) iRows += dr3.Length; try { dataTable1.Rows.Clear(); DataRow row = null; for (int i = 0; i < iRows; i++) { row = dataTable1.NewRow(); dataTable1.Rows.Add(row); } } catch { } int idx = 0; #region " 转炉出钢温度 " string strValue = "", strTime = ""; if (dr1 != null && dr1.Length > 0) { strValue = dr1[0]["SAMPLINGVALUE"].ToString(); strTime = dr1[0]["SAMPLINGDATE"].ToString(); } ClsBusinessPack.SetGridTemperature(this.dataTable1, "转炉终点温度", "", strValue, TruncSampleTime(strTime), idx); idx++; #endregion #region " 吹氩站温度 " strValue = ""; strTime = ""; if (dr2 != null && dr2.Length > 0) { strValue = dr2[0]["SAMPLINGVALUE"].ToString(); strTime = dr2[0]["SAMPLINGDATE"].ToString(); } ClsBusinessPack.SetGridTemperature(this.dataTable1, "吹氩出站温度", "", strValue, TruncSampleTime(strTime), idx); idx++; #endregion #region " 实时值 " if (dr3 != null && dr3.Length > 0) { string str = ""; for (int i = 0; i < dr3.Length; i++, idx++) { if (i == 0) str = "精炼炉进站温度"; else if (idx == dr3.Length - 1) str = "精炼炉出站温度"; else str = "精炼炉过程温度"; ClsBusinessPack.SetGridTemperature(this.dataTable1, str, "", dr3[i]["SAMPLINGVALUE"].ToString(), TruncSampleTime(dr3[i]["SAMPLINGDATE"].ToString()), idx); } } #endregion #region " 与标准进行比对 " // 转炉终点温度 if (dr1 != null && dr1.Length > 0) ClsBusinessPack.CompareStandard(dtStandard, dataTable1, "L02001", ultraGrid1, 0); // 吹氩站终点温度 if (dr2 != null && dr2.Length > 0) ClsBusinessPack.CompareStandard(dtStandard, dataTable1, "L02001", ultraGrid1, 1); // 精炼炉温度 if (dr3 != null && dr3.Length > 0) { ClsBusinessPack.CompareStandard(dtStandard, dataTable1, "L02001", ultraGrid1, 2); ClsBusinessPack.CompareStandard(dtStandard, dataTable1, "L02001", ultraGrid1, dr3.Length + 1); } #endregion } } catch { } finally { ClsControlPack.RefreshAndAutoSize(ultraGrid1); if (iCurr > 0 && ultraGrid1.Rows.Count >= iCurr + 1) { ultraGrid1.Rows[iCurr].Activated = true; ultraGrid1.Rows[iCurr].Selected = false; } ultraGrid1.EndUpdate(); } } /// /// 填充温度信息界面数据 /// public void FillTemperatureData_CCM(Hashtable htOptInfo, DataTable dtSampleBOF, DataTable dtSampleCAS, DataTable dtSampleLFS, DataTable dtSampleCCM, DataTable dtStandard) { int iCurr = 0; if (ultraGrid1.ActiveRow != null) iCurr = ultraGrid1.ActiveRow.Index; ultraGrid1.BeginUpdate(); try { lock (this) { int iRows = 3; //加一条转炉出钢温度 吹氩站出站温度 精炼炉温度 DataRow[] dr1 = null, dr2 = null, dr3 = null, dr4 = null; if (dtSampleBOF != null && dtSampleBOF.Rows.Count > 0) dr1 = dtSampleBOF.Select("SAMPLINGNAME = 'TEMPERATURE'", " SAMPLINGDATE DESC"); if (dtSampleCAS != null && dtSampleCAS.Rows.Count > 0) dr2 = dtSampleCAS.Select("SAMPLINGNAME = 'TEMPERATURE'", " SAMPLINGDATE DESC"); if (dtSampleLFS != null && dtSampleLFS.Rows.Count > 0) dr3 = dtSampleLFS.Select("SAMPLINGNAME = 'TEMPERATURE1' or SAMPLINGNAME = 'TEMPERATURE2'", " SAMPLINGDATE DESC"); if (dtSampleCCM != null && dtSampleCCM.Rows.Count > 0) dr4 = dtSampleCCM.Select("SAMPLINGNAME = 'TUNDISHTEMP1' or SAMPLINGNAME = 'TUNDISHTEMP2' or SAMPLINGNAME = 'TUNDISHTEMP_H'", " SAMPLINGDATE ASC"); if (dr4 != null && dr4.Length > 0) iRows += dr4.Length; try { dataTable1.Rows.Clear(); DataRow row = null; for (int i = 0; i < iRows; i++) { row = dataTable1.NewRow(); dataTable1.Rows.Add(row); } } catch { } int idx = 0; #region " 转炉出钢温度 " string strValue = "", strTime = ""; if (dr1 != null && dr1.Length > 0) { strValue = dr1[0]["SAMPLINGVALUE"].ToString(); strTime = dr1[0]["SAMPLINGDATE"].ToString(); } ClsBusinessPack.SetGridTemperature(this.dataTable1, "转炉终点温度", "", strValue, TruncSampleTime(strTime), idx); idx++; #endregion #region " 吹氩站温度 " strValue = ""; strTime = ""; if (dr2 != null && dr2.Length > 0) { strValue = dr2[0]["SAMPLINGVALUE"].ToString(); strTime = dr2[0]["SAMPLINGDATE"].ToString(); } ClsBusinessPack.SetGridTemperature(this.dataTable1, "吹氩出站温度", "", strValue, TruncSampleTime(strTime), idx); idx++; #endregion #region " 精炼炉温度 " strValue = ""; strTime = ""; if (dr3 != null && dr3.Length > 0) { strValue = dr3[0]["SAMPLINGVALUE"].ToString(); strTime = dr3[0]["SAMPLINGDATE"].ToString(); } ClsBusinessPack.SetGridTemperature(this.dataTable1, "精炼炉出站温度", "", strValue, TruncSampleTime(strTime), idx); idx++; #endregion #region " 实时值 " if (dr4 != null && dr4.Length > 0) { string str = "连铸中包温度"; for (int i = 0; i < dr4.Length; i++, idx++) { ClsBusinessPack.SetGridTemperature(this.dataTable1, str, "", dr4[i]["SAMPLINGVALUE"].ToString(), TruncSampleTime(dr4[i]["SAMPLINGDATE"].ToString()), idx); } } #endregion #region " 与标准进行比对 " // 转炉终点温度 if (dr1 != null && dr1.Length > 0) ClsBusinessPack.CompareStandard(dtStandard, dataTable1, "L02001", ultraGrid1, 0); // 吹氩站终点温度 if (dr2 != null && dr2.Length > 0) ClsBusinessPack.CompareStandard(dtStandard, dataTable1, "L02001", ultraGrid1, 1); // 精炼炉终点温度 if (dr3 != null && dr3.Length > 0) ClsBusinessPack.CompareStandard(dtStandard, dataTable1, "L02001", ultraGrid1, 2); // 中包温度标准 if (dr4 != null && dr4.Length > 0) { for (int i = 0; i < dr4.Length; i++) { ClsBusinessPack.CompareStandard(dtStandard, dataTable1, "L02001", ultraGrid1, i + 3); } } #endregion } } catch { } finally { ClsControlPack.RefreshAndAutoSize(ultraGrid1); if (iCurr > 0 && ultraGrid1.Rows.Count >= iCurr + 1) { ultraGrid1.Rows[iCurr].Activated = true; ultraGrid1.Rows[iCurr].Selected = false; } ultraGrid1.EndUpdate(); } } /// /// 填充温度信息界面数据(实绩) /// public void FillTemperatureData_RES(LG_PROCESS PROCESS, DataTable dtSample) { ultraGrid1.BeginUpdate(); try { lock (this) { DataRow[] dr = null; DataRow[] drC = null; DataRow[] drD = null; if (dtSample != null && dtSample.Rows.Count > 0) { dr = dtSample.Select("SAMPLINGNAME LIKE 'TEMPERATURE%' OR SAMPLINGNAME LIKE 'TUNDISHTEMP%' ", " SAMPLINGDATE"); drC = dtSample.Select("(SAMPLINGNAME LIKE 'TEMPERATURE%' OR SAMPLINGNAME LIKE 'TUNDISHTEMP%') AND STATIONCODE LIKE 'C%' ", " SAMPLINGDATE"); drD = dtSample.Select("(SAMPLINGNAME LIKE 'TEMPERATURE%' OR SAMPLINGNAME LIKE 'TUNDISHTEMP%') AND STATIONCODE LIKE 'D%' ", " SAMPLINGDATE"); } int iRows = 0; if (dr != null && dr.Length > 0) iRows = dr.Length; try { dataTable1.Rows.Clear(); DataRow row = null; for (int i = 0; i < iRows; i++) { row = dataTable1.NewRow(); dataTable1.Rows.Add(row); } } catch { } #region " 实时值 " if (dr != null && dr.Length > 0) { string str = ""; string station = ""; int indexC = 0; int indexD = 0; for (int idx = 0; idx < dr.Length; idx++) { station = dr[idx]["STATIONCODE"].ToString(); if (station.Substring(0, 1) == "C") { if (indexC == 0 && drC.Length > 1) { str = "电炉一倒温度"; } else if (indexC == drC.Length - 1) { str = "电炉终点温度"; } else { str = "电炉过程温度"; } indexC++; } if (station.Substring(0, 1) == "D") { if (indexD == 0 && drD.Length > 1) { str = "进站温度"; } else if (indexD == drD.Length - 1) { str = "出站温度"; } else { str = "过程温度"; } indexD++; } //if (idx == 0) //{ // if (PROCESS == LG_PROCESS.BOF) str = "转炉一倒温度"; // else if (PROCESS == LG_PROCESS.CCM) str = "中包第" + Convert.ToString(idx + 1) + "次测温"; // else str = "进站温度"; //} //else if (idx == dr.Length - 1) //{ // if (PROCESS == LG_PROCESS.BOF) str = "转炉终点温度"; // else if (PROCESS == LG_PROCESS.CCM) str = "中包第" + Convert.ToString(idx + 1) + "次测温"; // else str = "出站温度"; //} //else //{ // if (PROCESS == LG_PROCESS.BOF) str = "转炉过程温度"; // else if (PROCESS == LG_PROCESS.CCM) str = "中包第" + Convert.ToString(idx + 1) + "次测温"; // else str = "过程温度"; //} ClsBusinessPack.SetGridTemperature(dataTable1, str, "", dr[idx]["SAMPLINGVALUE"].ToString(), dr[idx]["SAMPLINGDATE"].ToString(), idx); } } #endregion } } catch { } finally { ClsControlPack.RefreshAndAutoSize(ultraGrid1); ultraGrid1.EndUpdate(); } } /// /// 填充温度信息界面数据 /// public void FillTemperatureData_Result(DataTable dtSample, DataTable dtStandard) { int iCurr = 0; if (ultraGrid1.ActiveRow != null) iCurr = ultraGrid1.ActiveRow.Index; ultraGrid1.BeginUpdate(); try { lock (this) { //int iRows = 3; //加一条转炉出钢温度 吹氩站出站温度 精炼炉温度 //try //{ // dataTable1.Rows.Clear(); // DataRow row = null; // for (int i = 0; i < iRows; i++) // { // row = dataTable1.NewRow(); // dataTable1.Rows.Add(row); // } //} //catch { } dataTable1.Rows.Clear(); DataRow row = null; int idx = 0; string strValue = "", strTime = "", strStation = "", strName = ""; for (int i = 0; i < dtSample.Rows.Count; i++) { row = dataTable1.NewRow(); dataTable1.Rows.Add(row); strStation = dtSample.Rows[i]["STATIONCODE"].ToString().Substring(0, 1); if (strStation == "C") { strName = "电炉终点温度"; } else if (strStation == "D") { strName = "氩后大包温度"; } else if (strStation == "E") { strName = "精炼终点温度"; } else if (strStation == "F") { strName = "RH炉终点温度"; } else if (strStation == "I") { strName = "VD炉终点温度"; } else { strName = "连铸中包温度"; } strValue = dtSample.Rows[i]["SAMPLINGVALUE"].ToString(); strTime = dtSample.Rows[i]["SAMPLINGDATE"].ToString(); ClsBusinessPack.SetGridTemperature(this.dataTable1, strName, "", strValue, TruncSampleTime(strTime), idx); idx++; } } } catch { } finally { ClsControlPack.RefreshAndAutoSize(ultraGrid1); ultraGrid1.EndUpdate(); } } #endregion #region 事件 private void SetDelegate() { this.Resize += new System.EventHandler(this.ucAdditive_Resize); this.MainContainer.ExpandedStateChanged += new System.EventHandler(this.ExpandedStateChanged); } private void ucAdditive_Resize(object sender, EventArgs e) { try { if (_Expandable && !_ExPanded) { this.Height = MainContainer.Height; //可收缩,处于收缩状态,不允许修改大小 if (_ExPandedHeight == 0 && this.Parent != null) _ExPandedHeight = this.Parent.Height; } else if (_Expandable && _ExPanded) _ExPandedHeight = this.Height; //可收缩,处于展开状态,记录高度变化 else if (!Expandable) _ExPandedHeight = this.Height; //不可收缩,记录高度变化 } catch { } } private void ExpandedStateChanged(object sender, EventArgs e) { try { ExPanded = MainContainer.Expanded; if (MainContainer.Expanded) this.Height = _ExPandedHeight; else this.Height = MainContainer.Height; } catch { } } #endregion internal void FillTemperatureData_LFS() { throw new NotImplementedException(); } } }