ucBaseInfo.cs 3.5 KB

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