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<DefectPositionSet> PositionDefects = new List<DefectPositionSet>();
|
public string PositionNum { get; set; }
|
|
|
public string ProduceNum { get; set; }
|
|
List<string> AllDefects = new List<string>();
|
|
public CtrlDefectsInPosition(List<string> allDefects, string positionNum, List<DefectPositionSet> positionDefects, string produceNum)
|
{
|
InitializeComponent();
|
|
PositionDefects = positionDefects;
|
PositionNum = positionNum;
|
ProduceNum = "产品" + produceNum;
|
AllDefects = new List<string>(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<DefectPositionSet> GetPositionDefects()
|
{
|
List<DefectPositionSet> list = new List<DefectPositionSet>();
|
|
|
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;
|
}
|
}
|
}
|