FrmSetting.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Windows.Forms;
  4. namespace Uninpho.Tools.components.DataManager
  5. {
  6. public partial class FrmSetting : DevExpress.XtraEditors.XtraForm
  7. {
  8. public Dictionary<string, decimal> Condition = new Dictionary<string, decimal>();
  9. public FrmSetting(Dictionary<string, decimal> filterCondition)
  10. {
  11. InitializeComponent();
  12. setUI(filterCondition);
  13. }
  14. private void setUI(Dictionary<string, decimal> filterCondition)
  15. {
  16. foreach (var item in this.Controls)
  17. {
  18. if (item is GroupBox)
  19. {
  20. foreach (var ctl in (item as GroupBox).Controls)
  21. {
  22. if (ctl is CheckBoxInput)
  23. {
  24. foreach (KeyValuePair<string, decimal> kvp in filterCondition)
  25. {
  26. bool isChecked = kvp.Key == (ctl as CheckBoxInput).ColumnName;
  27. if (isChecked)
  28. {
  29. (ctl as CheckBoxInput).Checked = isChecked;
  30. (ctl as CheckBoxInput).Value = kvp.Value;
  31. break;
  32. }
  33. }
  34. }
  35. }
  36. }
  37. }
  38. }
  39. private void btnOK_Click(object sender, EventArgs e)
  40. {
  41. foreach (var item in this.Controls)
  42. {
  43. if (item is GroupBox)
  44. {
  45. foreach (var ctl in (item as GroupBox).Controls)
  46. {
  47. if (ctl is CheckBoxInput&& (ctl as CheckBoxInput).Checked&& (ctl as CheckBoxInput).Value!=0)
  48. {
  49. this.Condition.Add((ctl as CheckBoxInput).ColumnName, (ctl as CheckBoxInput).Value);
  50. }
  51. }
  52. }
  53. }
  54. this.DialogResult = DialogResult.OK;
  55. }
  56. private void btnCancle_Click(object sender, EventArgs e)
  57. {
  58. this.DialogResult = DialogResult.Cancel;
  59. }
  60. private void checkBoxInput9_Load(object sender, EventArgs e)
  61. {
  62. }
  63. }
  64. }