using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Windows.Forms; using System.Collections; namespace Core.LgMes.Client.LgJobMgt { public partial class ucBaseInfo : UserControl { public ucBaseInfo() { InitializeComponent(); CStaticMethod.SetUltraGridStyle(ultraGrid1, 2); //设置样式 } private void ucBaseInfo_Load(object sender, EventArgs e) { ultraDataSource1.Rows.Add(new object[] { "", "", "", "" }); } public void ResetData() { try { for ( int i = 0; i < this.ultraDataSource1.Band.Columns.Count; i++ ) { if ( this.ultraDataSource1.Band.Columns[i].DataType == typeof( System.DateTime )) this.ultraDataSource1.Rows[0][i] = null; else this.ultraDataSource1.Rows[0][i] = ""; } ultraGrid1.Rows[0].Cells["ProcessDur"].Value = ""; } catch { } } public void SetData( Hashtable ar ) { if ( ar == null || ar.Count == 0 ) return; int count = this.ultraDataSource1.Band.Columns.Count; string strKey = ""; for ( int i = 0; i < count; i++ ) { try { strKey = this.ultraDataSource1.Band.Columns[i].Key; if (ar.Contains(strKey)) { if (strKey == "SHIFTCODE") { string strBc = ar[strKey].ToString().Substring(0,1); this.ultraDataSource1.Rows[0][i] = strBc == "1" ? "早" : (strBc == "2" ? "中" : "晚"); this.ultraDataSource1.Rows[0]["BB"] = CStaticMethod.ClassConvert(ar[strKey].ToString()); } else if (strKey == "EQUIPMENTNO") this.ultraDataSource1.Rows[0][i] = ar[strKey].ToString().Substring(1, 1) + "#脱硫"; else this.ultraDataSource1.Rows[0][i] = ar[strKey]; } else { if (strKey != "BB") { if (this.ultraDataSource1.Band.Columns[i].DataType == typeof(System.DateTime)) this.ultraDataSource1.Rows[0][i] = null; else this.ultraDataSource1.Rows[0][i] = ""; } } } catch { } } // 计算在站时间 DateTime dt1, dt2; try { if (!string.IsNullOrEmpty(ar["ARRIVETIME"].ToString()) && !string.IsNullOrEmpty(ar["LEAVETIME"].ToString())) ultraGrid1.Rows[0].Cells["ProcessDur"].Value = CStaticMethod.caculateTimeSeconds(Convert.ToDateTime(ar["ARRIVETIME"]), Convert.ToDateTime(ar["LEAVETIME"])); else if (!string.IsNullOrEmpty(ar["ARRIVETIME"].ToString()) && string.IsNullOrEmpty(ar["LEAVETIME"].ToString())) ultraGrid1.Rows[0].Cells["ProcessDur"].Value = CStaticMethod.caculateTimeSeconds(Convert.ToDateTime(ar["ARRIVETIME"]), DateTime.Now); } catch { } } } }