geboshi_V1/LeatherProject/LeatherApp/Page/FSelDefect.cs

47 lines
1.6 KiB
C#
Raw Normal View History

2024-03-07 14:03:22 +08:00
using Sunny.UI;
using System.Collections.Generic;
using System.Linq;
namespace LeatherApp.Page
{
public partial class FSelDefect : UIEditForm
{
public List<string> lstCodes = new List<string>();
public FSelDefect(List<string> codes)
{
InitializeComponent();
init(codes);
}
private void init(List<string> codes)
{
var list = Config.defectItemList.Select(x => new { code = x.Value<string>("code"), name = x.Value<string>("name") }).ToList();
foreach(var item in list)
{
UICheckBox uiCheckbox=new UICheckBox();
uiCheckbox.Tag = item.code;
uiCheckbox.Text = item.name;
if(codes==null || codes.Count==0)
uiCheckbox.Checked = true;
else
uiCheckbox.Checked = codes.Contains(item.code);
this.flowLayoutPanel1.Controls.Add(uiCheckbox);
}
}
private void btnOK_Click(object sender, System.EventArgs e)
{
for (int i = 0; i < this.flowLayoutPanel1.Controls.Count; i++)
{
UICheckBox uiCheckbox = this.flowLayoutPanel1.Controls[i] as UICheckBox;
if (uiCheckbox.Checked)
lstCodes.Add(uiCheckbox.Tag.ToString());
}
if (lstCodes.Count < 1)
{
UIMessageTip.ShowError("必需选择缺陷!", 2000);
return;
}
}
}
}