革博士程序V1仓库
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

47 строки
1.6 KiB

  1. using Sunny.UI;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace LeatherApp.Page
  5. {
  6. public partial class FSelDefect : UIEditForm
  7. {
  8. public List<string> lstCodes = new List<string>();
  9. public FSelDefect(List<string> codes)
  10. {
  11. InitializeComponent();
  12. init(codes);
  13. }
  14. private void init(List<string> codes)
  15. {
  16. var list = Config.defectItemList.Select(x => new { code = x.Value<string>("code"), name = x.Value<string>("name") }).ToList();
  17. foreach(var item in list)
  18. {
  19. UICheckBox uiCheckbox=new UICheckBox();
  20. uiCheckbox.Tag = item.code;
  21. uiCheckbox.Text = item.name;
  22. if(codes==null || codes.Count==0)
  23. uiCheckbox.Checked = true;
  24. else
  25. uiCheckbox.Checked = codes.Contains(item.code);
  26. this.flowLayoutPanel1.Controls.Add(uiCheckbox);
  27. }
  28. }
  29. private void btnOK_Click(object sender, System.EventArgs e)
  30. {
  31. for (int i = 0; i < this.flowLayoutPanel1.Controls.Count; i++)
  32. {
  33. UICheckBox uiCheckbox = this.flowLayoutPanel1.Controls[i] as UICheckBox;
  34. if (uiCheckbox.Checked)
  35. lstCodes.Add(uiCheckbox.Tag.ToString());
  36. }
  37. if (lstCodes.Count < 1)
  38. {
  39. UIMessageTip.ShowError("必需选择缺陷!", 2000);
  40. return;
  41. }
  42. }
  43. }
  44. }