FrmCodeInPut.cs
4.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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 TSA_V.Common;
using TSA_V.DeviceLibrary;
namespace TSA_V
{
public partial class FrmCodeInPut : FrmBase
{
private int CodeNum = 0;
public string PCBCode = "";
public List<string> CodeList = new List<string>();
public FrmCodeInPut()
{
InitializeComponent();
}
private List<TextBox> LittleTextList = new List<TextBox>();
private void FrmCodeInPut_Load(object sender, EventArgs e)
{
this.Focus();
txtPCBCode.Focus();
}
public void SetCount(int count)
{
CodeNum = count;
if (CodeNum <= 0)
{
this.Size = new Size(630, 360);
}
else
{
int width = 48;
for (int i = 1; i <= CodeNum; i++)
{
int addWidth = i * width;
Label lblName = new Label();
lblName.AutoSize = false;
lblName.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
lblName.Location = new System.Drawing.Point(13, 74 + addWidth);
lblName.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
lblName.Name = "lblName" + i.ToString();
lblName.Size = new System.Drawing.Size(201, 21);
lblName.TextAlign = ContentAlignment.MiddleRight;
lblName.TabIndex = 10 + i;
lblName.Text = "PCB小板_" + i.ToString() + "条码:";
this.Controls.Add(lblName);
TextBox txtLittlePCB = new TextBox();
txtLittlePCB.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
txtLittlePCB.Location = new System.Drawing.Point(222, 21 + addWidth);
txtLittlePCB.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
txtLittlePCB.MaxLength = 100;
txtLittlePCB.Name = "txtPCBCode" + i.ToString();
txtLittlePCB.Size = new System.Drawing.Size(306, 29);
txtLittlePCB.TabIndex = 100 + i;
LittleTextList.Add(txtLittlePCB);
this.Controls.Add(txtLittlePCB);
}
this.Size = new Size(630, 360 + width * CodeNum);
btnContinue.Location = new Point(btnContinue.Location.X, btnContinue.Location.Y + width * CodeNum);
btnCancel.Location = new Point(btnCancel.Location.X, btnCancel.Location.Y + width * CodeNum);
}
}
private void btnContinue_Click(object sender, EventArgs e)
{
PCBCode = FormUtil.getValue(txtPCBCode);
if (String.IsNullOrEmpty( PCBCode ))
{
MessageBox.Show(ResourceCulture.GetString("请输入PCB板条码"));
txtPCBCode.Focus();
return;
}
if (CodeNum > 0)
{
CodeList = new List<string>();
int i = 1;
foreach (TextBox text in LittleTextList)
{
string code = FormUtil.getValue(text);
if (String.IsNullOrEmpty(PCBCode))
{
MessageBox.Show("请输入PCB小板_" + i + "条码");
txtPCBCode.Focus();
return;
}
CodeList.Add(code);
i++;
}
}
MesUtil.SetCode(PCBCode, CodeList);
this.Close();
}
private void btnCancel_Click(object sender, EventArgs e)
{
PCBCode = "";
this.Close();
}
private void FrmCodeInPut_FormClosing(object sender, FormClosingEventArgs e)
{
if (MesUtil.CodeISOk.Equals(false))
{
DialogResult result = MessageBox.Show(ResourceCulture.GetString("确定取消条码输入?"), ResourceCulture.GetString("取消条码输入"), MessageBoxButtons.OKCancel);
if (result.Equals(DialogResult.OK))
{
MesUtil.SetCode("", new List<string>());
}
else
{
e.Cancel = true;
}
}
}
private void FrmCodeInPut_Shown(object sender, EventArgs e)
{
this.txtPCBCode.Focus();
}
}
}