//FORM2
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;
using AinB;
namespace AinB
{
public partial class MO : Form
{
public MO()
{
InitializeComponent();
}
private void MO_Load(object sender, EventArgs e)
{
string[] LabName = { "校验设备:", "MO/SN:", "公司产区:" };
string[] ButName = { "锁 定", "退 出", "维修区" };
string[] ButClick = { "Save", "Out", "ToRep" };
for (int i = 0; i < 3; i++)
{
Label Alab = new Label();
Alab.Text = LabName[i];
Alab.Location = new Point(20, 50 * (i + 1));
Alab.Size = new Size(65, 20);
MOpanel.Controls.Add(Alab);
if (i < 2)
{
TextBox Abox = new TextBox();
Abox.Name = "T_" + i.ToString();
Abox.Text = Abox.Text.Trim();
Abox.Location = new Point(85, 49 * (i + 1));
Abox.Size = new Size(200, 20);
MOpanel.Controls.Add(Abox);
}
if (i == 2)
{
ComboBox Bbox = new ComboBox();
Bbox.Name = "T_" + i.ToString();
Bbox.Location = new Point(85, 49 * (i + 1));
Bbox.Size = new Size(200, 20);
Bbox.Items.Add("STKC");
Bbox.Items.Add("STPS");
Bbox.Items.Add("STCD");
Bbox.Items.Add("STJX");
Bbox.Text = Bbox.Text.Trim();
Bbox.DropDownStyle = ComboBoxStyle.DropDownList;
MOpanel.Controls.Add(Bbox);
}
Button Abut = new Button();
Abut.Name = ButClick[i];
Abut.Text = ButName[i];
Abut.BackColor = Color.SkyBlue;
Abut.Location = new Point(100 * (i + 1), 200);
Abut.Size = new Size(80, 25);
Abut.Click += new EventHandler(But_Click);
MOpanel.Controls.Add(Abut);
}
}
private void But_Click(object sender, EventArgs e)
{
//定义触发点击的按钮
Button but = sender as Button;
//存储设备名称、MO信息
string IMISN, MO="",ST="";
Meth meth = new Meth();
foreach (Control c in MOpanel.Controls)
{
if (c is TextBox && c.Name == "T_0")
{
IMISN = (c.Text).Trim();
if (IMISN.Length == 0 || IMISN == "") { MessageBox.Show($"校验设备不能为空!");return; }
}
if (c is TextBox && c.Name == "T_1")
{
MO = (c.Text).Trim();
}
if(c is ComboBox && c.Name == "T_2")
{
ST = (c.Text).Trim();
if (ST.Length == 0 || ST == "") { MessageBox.Show($"公司产区不能为空!"); return; }
}
}
try
{
if (but.Name == "Save")
{
if (MO==""||MO.Length==0) { MessageBox.Show($"MO/SN不能为空!"); return; }
this.Hide();
ToB f3 = new ToB();
f3.Text = "生产区";
f3.FName = f3.Text;
f3.MO = MO;
f3.ST=ST;
f3.MdiParent = AinB.Index.ActiveForm;
f3.Location = new Point(0, 0);
f3.Size = new Size(600, 400);
f3.Show();
}
else if (but.Name == "Out")
{
this.Dispose();
this.Close();
//Application.Exit();
}
else if (but.Name == "ToRep")
{
this.Hide();
ToB f3 = new ToB();
f3.Text = "维修区";
f3.FName = f3.Text;
f3.MdiParent = AinB.Index.ActiveForm;
f3.Location = new Point(0, 0);
f3.Size = new Size(600, 400);
f3.Show();
}
}
catch { }
}
}
}