ucBaseInfo.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System;
  2. using System.Windows.Forms;
  3. using System.Collections;
  4. using Core.LgMes.Client.Comm;
  5. namespace Core.LgMes.Client.LgJobMgt
  6. {
  7. public partial class ucBaseInfo : UserControl
  8. {
  9. public ucBaseInfo()
  10. {
  11. InitializeComponent();
  12. CStaticMethod.SetUltraGridStyle(ultraGrid1, 2); //设置样式
  13. }
  14. private void ucBaseInfo_Load(object sender, EventArgs e)
  15. {
  16. ultraDataSource1.Rows.Add(new object[] { "", "", "", "" });
  17. }
  18. public void ResetData()
  19. {
  20. try
  21. {
  22. for ( int i = 0; i < this.ultraDataSource1.Band.Columns.Count; i++ )
  23. {
  24. if ( this.ultraDataSource1.Band.Columns[i].DataType == typeof( System.DateTime ))
  25. this.ultraDataSource1.Rows[0][i] = null;
  26. else
  27. this.ultraDataSource1.Rows[0][i] = "";
  28. }
  29. ultraGrid1.Rows[0].Cells["ProcessDur"].Value = "";
  30. }
  31. catch { }
  32. }
  33. public void SetData( Hashtable ar )
  34. {
  35. if ( ar == null || ar.Count == 0 )
  36. return;
  37. int count = this.ultraDataSource1.Band.Columns.Count;
  38. string strKey = "";
  39. for ( int i = 0; i < count; i++ )
  40. {
  41. try
  42. {
  43. strKey = this.ultraDataSource1.Band.Columns[i].Key;
  44. if (ar.Contains(strKey))
  45. {
  46. if (strKey == "SHIFTCODE")
  47. {
  48. string strBc = ar[strKey].ToString().Substring(0,1);
  49. this.ultraDataSource1.Rows[0][i] = strBc == "1" ? "早" : (strBc == "2" ? "中" : "晚");
  50. this.ultraDataSource1.Rows[0]["BB"] = CStaticMethod.ClassConvert(ar[strKey].ToString());
  51. }
  52. else if (strKey == "EQUIPMENTNO")
  53. this.ultraDataSource1.Rows[0][i] = ar[strKey].ToString().Substring(1, 1) + "#脱硫";
  54. else
  55. this.ultraDataSource1.Rows[0][i] = ar[strKey];
  56. }
  57. else
  58. {
  59. if (strKey != "BB")
  60. {
  61. if (this.ultraDataSource1.Band.Columns[i].DataType == typeof(System.DateTime))
  62. this.ultraDataSource1.Rows[0][i] = null;
  63. else
  64. this.ultraDataSource1.Rows[0][i] = "";
  65. }
  66. }
  67. }
  68. catch { }
  69. }
  70. // 计算在站时间
  71. DateTime dt1, dt2;
  72. try
  73. {
  74. if (!string.IsNullOrEmpty(ar["ARRIVETIME"].ToString()) && !string.IsNullOrEmpty(ar["LEAVETIME"].ToString()))
  75. ultraGrid1.Rows[0].Cells["ProcessDur"].Value = CStaticMethod.caculateTimeSeconds(Convert.ToDateTime(ar["ARRIVETIME"]), Convert.ToDateTime(ar["LEAVETIME"]));
  76. else if (!string.IsNullOrEmpty(ar["ARRIVETIME"].ToString()) && string.IsNullOrEmpty(ar["LEAVETIME"].ToString()))
  77. ultraGrid1.Rows[0].Cells["ProcessDur"].Value = CStaticMethod.caculateTimeSeconds(Convert.ToDateTime(ar["ARRIVETIME"]), DateTime.Now);
  78. }
  79. catch { }
  80. }
  81. }
  82. }