AnalysisNkChemPopup.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using Core.Mes.Client.Comm.Control;
  2. using CoreFS.CA06;
  3. using Infragistics.Win.UltraWinGrid;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Windows.Forms;
  10. namespace Core.StlMes.Client.Qcm
  11. {
  12. public partial class AnalysisNkChemPopup : FrmBase
  13. {
  14. public AnalysisNkChemPopup(Dictionary<DataRow, List<DataRow>> dicSource)
  15. {
  16. InitializeComponent();
  17. //ultraGrid1.DataSource = dt;
  18. BindData(dicSource);
  19. }
  20. private void BindData(Dictionary<DataRow, List<DataRow>> dicSource)
  21. {
  22. ultraGrid1.BeginUpdate();
  23. Dictionary<string, int> dicChems = new Dictionary<string, int>();
  24. int pCount = 0;
  25. foreach (var pDr in dicSource.Keys)
  26. {
  27. DataRow desDr = dataTable1.NewRow();
  28. desDr["Column1"] = pDr["CIC"];
  29. desDr["Column2"] = pDr["GRADENAME"];
  30. dataTable1.Rows.Add(desDr);
  31. var cDrs = dicSource[pDr];
  32. for (int i = 0; i < cDrs.Count; i++)
  33. {
  34. var cDr = cDrs[i];
  35. string chemName = cDr["CHEM_NAME"].ToString();
  36. string stdMin = cDr["STD_MIN"].ToString();
  37. string stdMinSign = cDr["STD_MIN_SIGN"].ToString();
  38. string stdMax = cDr["STD_MAX"].ToString();
  39. string stdMaxSign = cDr["STD_MAX_SIGN"].ToString();
  40. if (!dicChems.Keys.Contains(chemName))
  41. {
  42. dicChems.Add(chemName, dicChems.Keys.Count);
  43. }
  44. int groupIndex = dicChems[chemName];
  45. ultraGrid1.DisplayLayout.Bands[0].Groups[groupIndex].Header.Caption = chemName;
  46. ultraGrid1.DisplayLayout.Bands[0].Columns[(groupIndex + 1) * 4 - 2].Header.Caption = "符号";
  47. ultraGrid1.DisplayLayout.Bands[0].Columns[(groupIndex + 1) * 4 - 2 + 1].Header.Caption = "下限";
  48. ultraGrid1.DisplayLayout.Bands[0].Columns[(groupIndex + 1) * 4 - 2 + 2].Header.Caption = "符号";
  49. ultraGrid1.DisplayLayout.Bands[0].Columns[(groupIndex + 1) * 4 - 2 + 3].Header.Caption = "上限";
  50. ultraGrid1.Rows[pCount].Cells[(groupIndex + 1) * 4 - 2].Value = stdMinSign;
  51. ultraGrid1.Rows[pCount].Cells[(groupIndex + 1) * 4 - 2 + 1].Value = stdMin;
  52. ultraGrid1.Rows[pCount].Cells[(groupIndex + 1) * 4 - 2 + 2].Value = stdMaxSign;
  53. ultraGrid1.Rows[pCount].Cells[(groupIndex + 1) * 4 - 2 + 3].Value = stdMax;
  54. }
  55. pCount++;
  56. }
  57. foreach (var group in ultraGrid1.DisplayLayout.Bands[0].Groups)
  58. {
  59. int result = 0;
  60. string str = group.Header.Caption.Substring(group.Header.Caption.Length - 1);
  61. if (int.TryParse(str, out result))
  62. {
  63. group.Hidden = true;
  64. }
  65. }
  66. if (ultraGrid1.Rows.Count > 0)
  67. {
  68. ultraGrid1.Rows[0].Cells["Chk"].Value = true;
  69. Compare(ultraGrid1.Rows[0]);
  70. }
  71. GridHelper.RefreshAndAutoSize(ultraGrid1);
  72. ultraGrid1.EndUpdate();
  73. ultraGrid1.UpdateData();
  74. }
  75. private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  76. {
  77. try
  78. {
  79. this.Cursor = Cursors.WaitCursor;
  80. e.Cell.Row.Update();
  81. if (e.Cell.Column.Key == "Chk")
  82. {
  83. UltraGridRow chkRow = e.Cell.Row;
  84. foreach (UltraGridRow row in ultraGrid1.Rows)
  85. {
  86. if (row.Cells["Chk"].Value.ToString() == "True" && row != chkRow)
  87. {
  88. row.Cells["Chk"].Value = false;
  89. row.Update();
  90. }
  91. }
  92. if (e.Cell.Value.ToString() == "True")
  93. {
  94. Compare(e.Cell.Row);
  95. }
  96. }
  97. }
  98. finally
  99. {
  100. this.Cursor = Cursors.Default;
  101. }
  102. }
  103. private void Compare(UltraGridRow chkRow)
  104. {
  105. foreach (var row in ultraGrid1.Rows)
  106. {
  107. for (int i = 0; i < row.Cells.Count; i++)
  108. {
  109. var cell = row.Cells[i];
  110. if (cell.Column.Header.Caption == "符号" || cell.Column.Header.Caption == "下限" || cell.Column.Header.Caption == "上限")
  111. {
  112. if (cell.Value.ToString() != chkRow.GetValue(cell.Column.Key))
  113. {
  114. cell.Appearance.BackColor = Color.FromArgb(255, 106, 106);
  115. }
  116. else
  117. {
  118. cell.Appearance.BackColor = row.Cells[0].Appearance.BackColor;
  119. }
  120. }
  121. }
  122. }
  123. }
  124. }
  125. }