frmConfigElementsRow.cs.svn-base 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using CoreFS.CA06;
  9. using Infragistics.Win;
  10. using Infragistics.Win.UltraWinGrid;
  11. using System.Security.Cryptography;
  12. using System.Xml;
  13. using System.Configuration;
  14. using System.IO;
  15. namespace Core.LgMes.Client.LgIntegrationQuery
  16. {
  17. public partial class frmConfigElementsRow : Core.Mes.Client.Common.frmStyleBase
  18. {
  19. public DataSet _dsSet;
  20. public bool _setFlag = false;
  21. //密钥
  22. string encryptKey = "HNSTCGLG";
  23. //默认密钥向量
  24. byte[] Keys = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
  25. public frmConfigElementsRow()
  26. {
  27. InitializeComponent();
  28. }
  29. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  30. {
  31. switch (e.Tool.Key)
  32. {
  33. case "All":
  34. foreach (DataRow dr in _dsSet.Tables[0].Rows)
  35. {
  36. dr["选择"] = true;
  37. }
  38. break;
  39. case "AllCancel":
  40. foreach (DataRow dr in _dsSet.Tables[0].Rows)
  41. {
  42. dr["选择"] = false;
  43. }
  44. break;
  45. case "OK":
  46. this._dsSet.AcceptChanges();
  47. _setFlag = true;
  48. SetElementsRow();
  49. this.Close();
  50. break;
  51. case "Cancel":
  52. _dsSet.RejectChanges();
  53. this.Close();
  54. break;
  55. }
  56. }
  57. private void frmConfigElementsRow_Load(object sender, EventArgs e)
  58. {
  59. string strElementsRow = ElementsConfig.GetElementsRow(); //调用函数获取要显示的列名
  60. string[] strERow = strElementsRow.Split('*');
  61. this.ultraGrid1.DataSource = this._dsSet.Tables[0];
  62. this.ultraGrid1.DisplayLayout.Bands[0].Columns[0].Width = 58;
  63. this.ultraGrid1.DisplayLayout.Bands[0].Columns[0].Header.Caption = "成分编号";
  64. this.ultraGrid1.DisplayLayout.Bands[0].Columns[0].CellActivation = Activation.NoEdit;
  65. this.ultraGrid1.DisplayLayout.Bands[0].Columns[1].Width = 65;
  66. this.ultraGrid1.DisplayLayout.Bands[0].Columns[1].Header.Caption = "成分编码";
  67. this.ultraGrid1.DisplayLayout.Bands[0].Columns[1].CellActivation = Activation.NoEdit;
  68. this.ultraGrid1.DisplayLayout.Bands[0].Columns[2].Width = 65;
  69. this.ultraGrid1.DisplayLayout.Bands[0].Columns[2].Header.Caption = "成分名称";
  70. this.ultraGrid1.DisplayLayout.Bands[0].Columns[2].CellActivation = Activation.NoEdit;
  71. foreach (DataRow dr in _dsSet.Tables[0].Rows)
  72. {
  73. for (int i = 0; i < strERow.Length; i++)
  74. {
  75. if (dr["BaseName"].ToString() == strERow[i] && !string.IsNullOrEmpty(strERow[i]))
  76. dr["选择"] = true;
  77. if (dr["BaseName"].ToString() == "As" && strERow[i].ToString() == "Asn")
  78. dr["选择"] = true;
  79. }
  80. }
  81. }
  82. /// <summary>
  83. /// 将设置好的列名保存到文件
  84. /// </summary>
  85. private void SetElementsRow()
  86. {
  87. string strElementsRow = "";
  88. foreach (DataRow dr in _dsSet.Tables[0].Rows)
  89. {
  90. if (Convert.ToBoolean(dr["选择"]) == true)
  91. {
  92. if (dr["BaseName"].ToString() == "As")
  93. {
  94. strElementsRow += "Asn" + "*";
  95. }
  96. else
  97. {
  98. strElementsRow += dr["BaseName"].ToString() + "*";
  99. }
  100. }
  101. }
  102. ElementsConfig.SetElementsRow(strElementsRow);
  103. }
  104. private void ultraGrid1_CellChange(object sender, CellEventArgs e)
  105. {
  106. int RowIndex = e.Cell.Row.Index;
  107. if (Convert.ToBoolean(_dsSet.Tables[0].Rows[RowIndex]["选择"]) == true)
  108. _dsSet.Tables[0].Rows[RowIndex]["选择"] = false;
  109. else
  110. _dsSet.Tables[0].Rows[RowIndex]["选择"] = true;
  111. }
  112. private void textBox1_MouseClick(object sender, MouseEventArgs e)
  113. {
  114. DialogFormula from = new DialogFormula(this);
  115. from._dsSet = _dsSet;
  116. from.ShowDialog();
  117. }
  118. private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
  119. {
  120. }
  121. }
  122. }