ucCcmTimeInfo.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 ucCcmTimeInfo : UserControl
  8. {
  9. public ucCcmTimeInfo()
  10. {
  11. InitializeComponent();
  12. CStaticMethod.SetUltraGridStyle(ultraGrid1, 1); //设置样式
  13. }
  14. private void ucCcmTimeInfo_Load(object sender, EventArgs e)
  15. {
  16. ultraDataSource1.Rows.Add(new object[] { null, null, "", null, null, "", "", null, null });
  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. }
  30. catch { }
  31. }
  32. public void SetData(Hashtable ar)
  33. {
  34. if (ar == null || ar.Count == 0)
  35. return;
  36. int count = this.ultraDataSource1.Band.Columns.Count;
  37. string strKey = "";
  38. for (int i = 0; i < count; i++)
  39. {
  40. try
  41. {
  42. strKey = this.ultraDataSource1.Band.Columns[i].Key;
  43. if (ar.Contains(strKey))
  44. {
  45. if(!string.IsNullOrEmpty(ar[strKey].ToString()))
  46. this.ultraDataSource1.Rows[0][i] = ar[strKey];
  47. else if (this.ultraDataSource1.Band.Columns[i].DataType == typeof(System.DateTime))
  48. this.ultraDataSource1.Rows[0][i] = null;
  49. else
  50. this.ultraDataSource1.Rows[0][i] = "";
  51. }
  52. else
  53. {
  54. if (this.ultraDataSource1.Band.Columns[i].DataType == typeof(System.DateTime))
  55. this.ultraDataSource1.Rows[0][i] = null;
  56. else
  57. this.ultraDataSource1.Rows[0][i] = "";
  58. }
  59. }
  60. catch { }
  61. }
  62. try
  63. {
  64. if (!string.IsNullOrEmpty(this.ultraDataSource1.Rows[0]["BALEPFTIME"].ToString()))
  65. this.ultraDataSource1.Rows[0]["BALEPFTIME1"] = this.ultraDataSource1.Rows[0]["BALEPFTIME"].ToString();
  66. //大包上台时刻
  67. if (!string.IsNullOrEmpty(this.ultraDataSource1.Rows[0]["BALEPFTIME"].ToString()) && !string.IsNullOrEmpty(this.ultraDataSource1.Rows[0]["BALESTARTTIME"].ToString()))
  68. this.ultraDataSource1.Rows[0]["WAITMOULDTIME"] = CStaticMethod.caculateTime(Convert.ToDateTime(this.ultraDataSource1.Rows[0]["BALEPFTIME"]), Convert.ToDateTime(this.ultraDataSource1.Rows[0]["BALESTARTTIME"]));
  69. else if (!string.IsNullOrEmpty(this.ultraDataSource1.Rows[0]["BALEPFTIME"].ToString()) && string.IsNullOrEmpty(this.ultraDataSource1.Rows[0]["BALESTARTTIME"].ToString()))
  70. this.ultraDataSource1.Rows[0]["WAITMOULDTIME"] = CStaticMethod.caculateTime(Convert.ToDateTime(this.ultraDataSource1.Rows[0]["BALEPFTIME"]),DateTime.Now);
  71. //浇钢时间
  72. if (!string.IsNullOrEmpty(this.ultraDataSource1.Rows[0]["BALESTARTTIME"].ToString()) && !string.IsNullOrEmpty(this.ultraDataSource1.Rows[0]["BALEENDTIME"].ToString()))
  73. this.ultraDataSource1.Rows[0]["MOULDTIME"] = CStaticMethod.caculateTime(Convert.ToDateTime(this.ultraDataSource1.Rows[0]["BALESTARTTIME"]), Convert.ToDateTime(this.ultraDataSource1.Rows[0]["BALEENDTIME"]));
  74. else if(!string.IsNullOrEmpty(this.ultraDataSource1.Rows[0]["BALESTARTTIME"].ToString()) && string.IsNullOrEmpty(this.ultraDataSource1.Rows[0]["BALEENDTIME"].ToString()))
  75. this.ultraDataSource1.Rows[0]["MOULDTIME"] = CStaticMethod.caculateTime(Convert.ToDateTime(this.ultraDataSource1.Rows[0]["BALESTARTTIME"]), DateTime.Now);
  76. if (!string.IsNullOrEmpty(this.ultraDataSource1.Rows[0]["MOULDTIME"].ToString()))
  77. {
  78. if (Convert.ToInt32(this.ultraDataSource1.Rows[0]["MOULDTIME"]) < 50)
  79. this.ultraDataSource1.Rows[0]["JJTIME"] = 50 - Convert.ToInt32(this.ultraDataSource1.Rows[0]["MOULDTIME"]);
  80. else
  81. this.ultraDataSource1.Rows[0]["JJTIME"] = 0;
  82. }
  83. else
  84. this.ultraDataSource1.Rows[0]["JJTIME"] = 50;
  85. //预报精度
  86. if (!string.IsNullOrEmpty(this.ultraDataSource1.Rows[0]["planpftime"].ToString()) && !string.IsNullOrEmpty(this.ultraDataSource1.Rows[0]["BALEPFTIME1"].ToString()))
  87. {
  88. TimeSpan tsYCJD;
  89. tsYCJD= Convert.ToDateTime(this.ultraDataSource1.Rows[0]["planpftime"]) - Convert.ToDateTime(this.ultraDataSource1.Rows[0]["BALEPFTIME1"]);
  90. this.ultraDataSource1.Rows[0]["YCJD"] =Convert.ToString( System.Math.Abs(System.Math.Round(tsYCJD.TotalMinutes)));
  91. }
  92. }
  93. catch { }
  94. }
  95. }
  96. }