| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- using Core.Mes.Client.Comm.Control;
- using CoreFS.CA06;
- using Infragistics.Win.UltraWinGrid;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Windows.Forms;
- namespace Core.StlMes.Client.Qcm
- {
- public partial class AnalysisNkChemPopup : FrmBase
- {
- public AnalysisNkChemPopup(Dictionary<DataRow, List<DataRow>> dicSource)
- {
- InitializeComponent();
- //ultraGrid1.DataSource = dt;
- BindData(dicSource);
- }
- private void BindData(Dictionary<DataRow, List<DataRow>> dicSource)
- {
- ultraGrid1.BeginUpdate();
- Dictionary<string, int> dicChems = new Dictionary<string, int>();
- int pCount = 0;
- foreach (var pDr in dicSource.Keys)
- {
- DataRow desDr = dataTable1.NewRow();
- desDr["Column1"] = pDr["CIC"];
- desDr["Column2"] = pDr["GRADENAME"];
- dataTable1.Rows.Add(desDr);
- var cDrs = dicSource[pDr];
- for (int i = 0; i < cDrs.Count; i++)
- {
- var cDr = cDrs[i];
- string chemName = cDr["CHEM_NAME"].ToString();
- string stdMin = cDr["STD_MIN"].ToString();
- string stdMinSign = cDr["STD_MIN_SIGN"].ToString();
- string stdMax = cDr["STD_MAX"].ToString();
- string stdMaxSign = cDr["STD_MAX_SIGN"].ToString();
- if (!dicChems.Keys.Contains(chemName))
- {
- dicChems.Add(chemName, dicChems.Keys.Count);
- }
- int groupIndex = dicChems[chemName];
- ultraGrid1.DisplayLayout.Bands[0].Groups[groupIndex].Header.Caption = chemName;
- ultraGrid1.DisplayLayout.Bands[0].Columns[(groupIndex + 1) * 4 - 2].Header.Caption = "符号";
- ultraGrid1.DisplayLayout.Bands[0].Columns[(groupIndex + 1) * 4 - 2 + 1].Header.Caption = "下限";
- ultraGrid1.DisplayLayout.Bands[0].Columns[(groupIndex + 1) * 4 - 2 + 2].Header.Caption = "符号";
- ultraGrid1.DisplayLayout.Bands[0].Columns[(groupIndex + 1) * 4 - 2 + 3].Header.Caption = "上限";
- ultraGrid1.Rows[pCount].Cells[(groupIndex + 1) * 4 - 2].Value = stdMinSign;
- ultraGrid1.Rows[pCount].Cells[(groupIndex + 1) * 4 - 2 + 1].Value = stdMin;
- ultraGrid1.Rows[pCount].Cells[(groupIndex + 1) * 4 - 2 + 2].Value = stdMaxSign;
- ultraGrid1.Rows[pCount].Cells[(groupIndex + 1) * 4 - 2 + 3].Value = stdMax;
- }
- pCount++;
- }
- foreach (var group in ultraGrid1.DisplayLayout.Bands[0].Groups)
- {
- int result = 0;
- string str = group.Header.Caption.Substring(group.Header.Caption.Length - 1);
- if (int.TryParse(str, out result))
- {
- group.Hidden = true;
- }
- }
- if (ultraGrid1.Rows.Count > 0)
- {
- ultraGrid1.Rows[0].Cells["Chk"].Value = true;
- Compare(ultraGrid1.Rows[0]);
- }
- GridHelper.RefreshAndAutoSize(ultraGrid1);
- ultraGrid1.EndUpdate();
- ultraGrid1.UpdateData();
- }
- private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- try
- {
- this.Cursor = Cursors.WaitCursor;
- e.Cell.Row.Update();
- if (e.Cell.Column.Key == "Chk")
- {
- UltraGridRow chkRow = e.Cell.Row;
- foreach (UltraGridRow row in ultraGrid1.Rows)
- {
- if (row.Cells["Chk"].Value.ToString() == "True" && row != chkRow)
- {
- row.Cells["Chk"].Value = false;
- row.Update();
- }
- }
- if (e.Cell.Value.ToString() == "True")
- {
- Compare(e.Cell.Row);
- }
- }
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- private void Compare(UltraGridRow chkRow)
- {
- foreach (var row in ultraGrid1.Rows)
- {
- for (int i = 0; i < row.Cells.Count; i++)
- {
- var cell = row.Cells[i];
- if (cell.Column.Header.Caption == "符号" || cell.Column.Header.Caption == "下限" || cell.Column.Header.Caption == "上限")
- {
- if (cell.Value.ToString() != chkRow.GetValue(cell.Column.Key))
- {
- cell.Appearance.BackColor = Color.FromArgb(255, 106, 106);
- }
- else
- {
- cell.Appearance.BackColor = row.Cells[0].Appearance.BackColor;
- }
- }
- }
- }
- }
- }
- }
|