using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using CoreFS.CA06; using Infragistics.Win; using Infragistics.Win.UltraWinGrid; using System.Security.Cryptography; using System.Xml; using System.Configuration; using System.IO; namespace Core.LgMes.Client.LgIntegrationQuery { public partial class frmConfigElementsRow : Core.Mes.Client.Common.frmStyleBase { public DataSet _dsSet; public bool _setFlag = false; //密钥 string encryptKey = "HNSTCGLG"; //默认密钥向量 byte[] Keys = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF }; public frmConfigElementsRow() { InitializeComponent(); } private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { case "All": foreach (DataRow dr in _dsSet.Tables[0].Rows) { dr["选择"] = true; } break; case "AllCancel": foreach (DataRow dr in _dsSet.Tables[0].Rows) { dr["选择"] = false; } break; case "OK": this._dsSet.AcceptChanges(); _setFlag = true; SetElementsRow(); this.Close(); break; case "Cancel": _dsSet.RejectChanges(); this.Close(); break; } } private void frmConfigElementsRow_Load(object sender, EventArgs e) { string strElementsRow = ElementsConfig.GetElementsRow(); //调用函数获取要显示的列名 string[] strERow = strElementsRow.Split('*'); this.ultraGrid1.DataSource = this._dsSet.Tables[0]; this.ultraGrid1.DisplayLayout.Bands[0].Columns[0].Width = 58; this.ultraGrid1.DisplayLayout.Bands[0].Columns[0].Header.Caption = "成分编号"; this.ultraGrid1.DisplayLayout.Bands[0].Columns[0].CellActivation = Activation.NoEdit; this.ultraGrid1.DisplayLayout.Bands[0].Columns[1].Width = 65; this.ultraGrid1.DisplayLayout.Bands[0].Columns[1].Header.Caption = "成分编码"; this.ultraGrid1.DisplayLayout.Bands[0].Columns[1].CellActivation = Activation.NoEdit; this.ultraGrid1.DisplayLayout.Bands[0].Columns[2].Width = 65; this.ultraGrid1.DisplayLayout.Bands[0].Columns[2].Header.Caption = "成分名称"; this.ultraGrid1.DisplayLayout.Bands[0].Columns[2].CellActivation = Activation.NoEdit; foreach (DataRow dr in _dsSet.Tables[0].Rows) { for (int i = 0; i < strERow.Length; i++) { if (dr["BaseName"].ToString() == strERow[i] && !string.IsNullOrEmpty(strERow[i])) dr["选择"] = true; if (dr["BaseName"].ToString() == "As" && strERow[i].ToString() == "Asn") dr["选择"] = true; } } } /// /// 将设置好的列名保存到文件 /// private void SetElementsRow() { string strElementsRow = ""; foreach (DataRow dr in _dsSet.Tables[0].Rows) { if (Convert.ToBoolean(dr["选择"]) == true) { if (dr["BaseName"].ToString() == "As") { strElementsRow += "Asn" + "*"; } else { strElementsRow += dr["BaseName"].ToString() + "*"; } } } ElementsConfig.SetElementsRow(strElementsRow); } private void ultraGrid1_CellChange(object sender, CellEventArgs e) { int RowIndex = e.Cell.Row.Index; if (Convert.ToBoolean(_dsSet.Tables[0].Rows[RowIndex]["选择"]) == true) _dsSet.Tables[0].Rows[RowIndex]["选择"] = false; else _dsSet.Tables[0].Rows[RowIndex]["选择"] = true; } private void textBox1_MouseClick(object sender, MouseEventArgs e) { DialogFormula from = new DialogFormula(this); from._dsSet = _dsSet; from.ShowDialog(); } private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e) { } } }