You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
3.1 KiB
101 lines
3.1 KiB
4 years ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.ComponentModel;
|
||
|
using System.Data;
|
||
|
using System.Drawing;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using System.Windows.Forms;
|
||
|
|
||
|
namespace QMAPP.WinForm.Forms.Mend
|
||
|
{
|
||
|
public partial class MendReasonSubDefects : Form
|
||
|
{
|
||
|
private Defect topdefect;
|
||
|
private List<Defect> SubDefects;
|
||
|
|
||
|
public MendReasonSubDefects()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
}
|
||
|
|
||
|
public MendReasonSubDefects(Defect topdefect, List<Defect> SubDefects):this()
|
||
|
{
|
||
|
// TODO: Complete member initialization
|
||
|
this.topdefect = topdefect;
|
||
|
this.SubDefects = SubDefects;
|
||
|
}
|
||
|
|
||
|
private void btnCancel_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
this.Close();
|
||
|
}
|
||
|
|
||
|
private void btnConfirm_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
if (this.topdefect != null)
|
||
|
{
|
||
|
this.topdefect.SubDefects.Clear();
|
||
|
foreach (var cb in flpDefects.Controls)
|
||
|
{
|
||
|
var checkbox = cb as CheckBox;
|
||
|
if (checkbox != null && checkbox.Checked)
|
||
|
{
|
||
|
Defect defect = checkbox.Tag as Defect;
|
||
|
if (defect != null)
|
||
|
{
|
||
|
this.topdefect.SubDefects.Add(defect);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
this.Close();
|
||
|
}
|
||
|
|
||
|
private void MendReasonSubDefects_Load(object sender, EventArgs e)
|
||
|
{
|
||
|
if(topdefect!=null)
|
||
|
{
|
||
|
lblTopName.Text=topdefect.Description;
|
||
|
}
|
||
|
|
||
|
if (this.SubDefects != null)
|
||
|
{
|
||
|
flpDefects.Controls.Clear();
|
||
|
foreach (var defect in SubDefects)
|
||
|
{
|
||
|
var checkbox = new CheckBox();
|
||
|
checkbox.Appearance = Appearance.Button;
|
||
|
checkbox.TextAlign = ContentAlignment.MiddleCenter;
|
||
|
checkbox.Height = 50;
|
||
|
checkbox.AutoSize = true;
|
||
|
checkbox.MinimumSize = new System.Drawing.Size { Height = 50 };
|
||
|
checkbox.Text = defect.Key.Trim('-') + "/" + defect.Description;
|
||
|
checkbox.Tag = defect;
|
||
|
if(topdefect.SubDefects.Exists(p=>p.Key==defect.Key))
|
||
|
{
|
||
|
checkbox.Checked=true;
|
||
|
checkbox.BackColor = Color.Orange;
|
||
|
}
|
||
|
checkbox.CheckedChanged += new EventHandler(checkbox_CheckedChanged);
|
||
|
flpDefects.Controls.Add(checkbox);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void checkbox_CheckedChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
var checkbox = sender as CheckBox;
|
||
|
if (checkbox.Checked)
|
||
|
{
|
||
|
checkbox.BackColor = Color.Orange;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
checkbox.BackColor = SystemColors.Control;
|
||
|
checkbox.UseVisualStyleBackColor = true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|