using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Bro.M141.Process.UI { public partial class CtrlDefectsInPosition : UserControl { public CtrlDefectsInPosition() { InitializeComponent(); } List PositionDefects = new List(); public string PositionNum { get; set; } public string ProduceNum { get; set; } List AllDefects = new List(); public CtrlDefectsInPosition(List allDefects, string positionNum, List positionDefects, string produceNum) { InitializeComponent(); PositionDefects = positionDefects; PositionNum = positionNum; ProduceNum = "产品" + produceNum; AllDefects = new List(allDefects.OrderBy(u => u)); fpDefects.AutoScroll = true; this.Load += CtrlDefectsInPosition_Load; chkSelectAll.CheckedChanged += ChkSelectAll_CheckedChanged; } private void ChkSelectAll_CheckedChanged(object? sender, EventArgs e) { foreach (Control c in fpDefects.Controls) { if (c is Sunny.UI.UICheckBox chk) { chk.Checked = chkSelectAll.Checked; } } } private void CtrlDefectsInPosition_Load(object? sender, EventArgs e) { lblPosition.Text = $"{PositionNum}"; label1.Text = ProduceNum; fpDefects.Controls.Clear(); AllDefects.ForEach(s => { Sunny.UI.UICheckBox chk = new Sunny.UI.UICheckBox(); chk.Text = s; chk.Checked = PositionDefects.Any(u => u.Code == s); fpDefects.Controls.Add(chk); }); } public List GetPositionDefects() { List list = new List(); foreach (Control c in fpDefects.Controls) { if (c is Sunny.UI.UICheckBox chk) { if (chk.Checked) { DefectPositionSet pSet = new DefectPositionSet() { Code = chk.Text, PositionNum = lblPosition.Text, ProduceIndex = label1.Text.Replace("产品", "") //PositionNum2 = PositionNum2, }; list.Add(pSet); } } } return list; } } }