01.
private
List<
string
> array =
new
List<
string
>();
02.
string
C = DateTime.Now.ToString(
"dd/MM/yyyy"
);
03.
private
void
textBox1_KeyDown_1(
object
sender,KeyEventArgs e)
04.
{
05.
if
(e.KeyCode == Keys.Enter)
06.
{
07.
if
(textBox1.Text.Length >= 15 || textBox1.Text.Length < 5)
08.
{
09.
MessageBox.Show(
"Number Invalid"
);
10.
textBox1.Text =
""
;
11.
return
;
12.
}
13.
string
str = ((TextBox) sender).Text;
14.
if
(!array.Contains(str))
15.
{
16.
array.Add(str);
17.
int
Number = Convert.ToInt32(textBox3.Text.ToString());
18.
string
nb = (++Number).ToString();
19.
textBox3.Text = nb;
20.
textBox2.Text = textBox1.Text.Substring(0, 4);
21.
label5.Text = textBox1.Text;
22.
string
log =
"CheckStock.txt"
;
23.
this
.textBox1.Multiline =
true
;
24.
if
(File.Exists(log) ==
true
)
25.
{
26.
f =
new
FileInfo(log);
27.
StreamWriter sw = f.AppendText();
28.
sw.WriteLine(C +
"\t"
+ A +
"\t"
+ B +
"\t"
+ textBox1.Text +
"\t"
+ textBox2.Text +
"\t"
+
"1"
);
29.
textBox1.Text =
""
;
30.
sw.Close();
31.
}
32.
else
if
(File.Exists(log) ==
false
)
33.
{
34.
f =
new
FileInfo(log);
35.
StreamWriter sw = f.CreateText();
36.
sw.WriteLine(C +
"\t"
+ A +
"\t"
+ B +
"\t"
+ textBox1.Text +
"\t"
+ textBox2.Text +
"\t"
+
"1"
);
37.
textBox1.Text =
""
;
38.
sw.Close();
39.
}
40.
}
41.
else
42.
{
43.
MessageBox.Show(
"aaaa"
);
44.
}
45.
}
46.
}