2024-12-02 15:02:39 +08:00
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using Sunny.UI;
|
2024-03-07 14:03:22 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace LeatherApp.Page
|
|
|
|
|
{
|
|
|
|
|
public partial class FSelDefect : UIEditForm
|
|
|
|
|
{
|
|
|
|
|
public List<string> lstCodes = new List<string>();
|
2024-12-02 15:02:39 +08:00
|
|
|
|
private string _modelName;
|
|
|
|
|
public FSelDefect(string modelName, List<string> codes)
|
2024-03-07 14:03:22 +08:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2024-12-02 15:02:39 +08:00
|
|
|
|
_modelName = modelName;
|
|
|
|
|
init(modelName, codes);
|
2024-03-07 14:03:22 +08:00
|
|
|
|
}
|
2024-12-02 15:02:39 +08:00
|
|
|
|
private void init(string modelName, List<string> codes)
|
2024-03-07 14:03:22 +08:00
|
|
|
|
{
|
2024-12-02 15:02:39 +08:00
|
|
|
|
JArray defectItemList;
|
|
|
|
|
Config.LoadModelDefectItemList(modelName, out defectItemList);
|
|
|
|
|
var list = defectItemList.Select(x => new { code = x.Value<string>("code"), name = x.Value<string>("name") }).ToList();
|
2024-03-07 14:03:22 +08:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|