Category.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using SourceGrid;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. namespace OTSIncAReportApp._1_UI.OTSReportExport
  13. {
  14. public partial class Category : Form
  15. {
  16. List<string> CheckTheOptions = new List<string>();
  17. DataTable ElementList = new DataTable();
  18. public List<string> OutElementList = new List<string>();
  19. /// <summary>
  20. /// 窗体是否修改
  21. /// </summary>
  22. public bool IsModify = false;
  23. public List<string> vs = new List<string>();
  24. Hashtable table;
  25. public Category(List<string> a_ElementList,DataTable AllList)
  26. {
  27. InitializeComponent();
  28. ElementList = AllList;
  29. CheckTheOptions = a_ElementList;
  30. OutElementList = a_ElementList;
  31. #region 国际化语言
  32. OTSCommon.Language lan = new OTSCommon.Language(this);
  33. table = lan.GetNameTable(this.Name);
  34. #endregion
  35. }
  36. private void Category_Load(object sender, EventArgs e)
  37. {
  38. for (int i = 0; i < ElementList.Rows.Count; i++)
  39. {
  40. checkedListBox1.Items.Add(ElementList.Rows[i]["StrName"].ToString());
  41. }
  42. for (int i = 0; i < checkedListBox1.Items.Count; i++)
  43. {
  44. if (CheckTheOptions.Count == 0)
  45. {
  46. checkedListBox1.SetItemChecked(i, true);
  47. }
  48. else
  49. {
  50. for (int a = 0; a < CheckTheOptions.Count; a++)
  51. {
  52. if (ElementList.Rows[i]["STDId"].ToString() == CheckTheOptions[a].ToString())
  53. checkedListBox1.SetItemChecked(i, true);
  54. }
  55. }
  56. }
  57. }
  58. /// <summary>
  59. /// 确定按钮
  60. /// </summary>
  61. /// <param name="sender"></param>
  62. /// <param name="e"></param>
  63. private void button3_Click(object sender, EventArgs e)
  64. {
  65. OutElementList.Clear();
  66. for (int i=0;i< checkedListBox1.Items.Count;i++)
  67. {
  68. if (checkedListBox1.GetItemChecked(i))
  69. {
  70. OutElementList.Add(checkedListBox1.Items[i].ToString());
  71. vs.Add(ElementList.Rows[i]["STDId"].ToString());
  72. }
  73. }
  74. IsModify = true;
  75. this.Close();
  76. }
  77. /// <summary>
  78. /// 取消按钮
  79. /// </summary>
  80. /// <param name="sender"></param>
  81. /// <param name="e"></param>
  82. private void button4_Click(object sender, EventArgs e)
  83. {
  84. this.Close();
  85. }
  86. }
  87. }