001.
using
System;
002.
using
System.Linq;
003.
using
System.Collections.Generic;
004.
using
System.ComponentModel;
005.
using
System.Data;
006.
using
System.Drawing;
007.
using
System.Text;
008.
using
System.Windows.Forms;
009.
using
System.IO;
010.
using
System.Text.RegularExpressions;
011.
012.
namespace
CheckStock1
013.
{
014.
public
partial
class
SR : Form
015.
{
016.
public
string
A {
get
;
set
; }
017.
public
string
B {
get
;
set
; }
018.
public
SR(
string
data,
string
data2)
019.
{
020.
InitializeComponent();
021.
A = data;
022.
B = data2;
023.
}
024.
private
bool
Check(
string
input)
025.
{
026.
bool
b =
false
;
027.
foreach
(
string
s
in
System.IO.File.OpenText(@
"CheckStock.txt"
).ReadToEnd())
028.
{
029.
if
(s==input)
030.
{
031.
b =
true
;
032.
return
b;
033.
}
034.
}
035.
return
b;
036.
}
037.
private
List<
string
> array =
new
List<
string
>();
038.
private
void
SR_Load(
object
sender, EventArgs e)
039.
{
040.
041.
042.
043.
044.
045.
046.
047.
048.
049.
050.
051.
052.
053.
054.
055.
056.
057.
058.
059.
060.
061.
062.
063.
064.
065.
066.
textBox1.Focus();
067.
textBox3.Text =
"0"
;
068.
}
069.
private
FileInfo f;
070.
private
void
button1_Click_1(
object
sender, EventArgs e)
071.
{
072.
Menu m1 =
new
Menu();
073.
m1.Show();
074.
this
.Hide();
075.
}
076.
077.
string
C = DateTime.Now.ToString(
"dd/MM/yyyy"
);
078.
private
void
textBox1_KeyDown_1(
object
sender,KeyEventArgs e)
079.
{
080.
if
(e.KeyCode == Keys.Enter)
081.
{
082.
if
(textBox1.Text.Length >= 15 || textBox1.Text.Length < 5)
083.
{
084.
MessageBox.Show(
"Number Invalid"
);
085.
textBox1.Text =
""
;
086.
return
;
087.
}
088.
string
str = ((TextBox) sender).Text;
089.
if
(!array.Contains(str))
090.
{
091.
array.Add(str);
092.
int
Number = Convert.ToInt32(textBox3.Text.ToString());
093.
string
nb = (++Number).ToString();
094.
textBox3.Text = nb;
095.
textBox2.Text = textBox1.Text.Substring(0, 4);
096.
label5.Text = textBox1.Text;
097.
string
log =
"CheckStock.txt"
;
098.
this
.textBox1.Multiline =
true
;
099.
if
(File.Exists(log) ==
true
)
100.
{
101.
f =
new
FileInfo(log);
102.
StreamWriter sw = f.AppendText();
103.
sw.WriteLine(C +
"\t"
+ A +
"\t"
+ B +
"\t"
+ textBox1.Text +
"\t"
+ textBox2.Text +
"\t"
+
"1"
);
104.
textBox1.Text =
""
;
105.
sw.Close();
106.
}
107.
else
if
(File.Exists(log) ==
false
)
108.
{
109.
f =
new
FileInfo(log);
110.
StreamWriter sw = f.CreateText();
111.
sw.WriteLine(C +
"\t"
+ A +
"\t"
+ B +
"\t"
+ textBox1.Text +
"\t"
+ textBox2.Text +
"\t"
+
"1"
);
112.
textBox1.Text =
""
;
113.
sw.Close();
114.
}
115.
}
116.
else
117.
{
118.
MessageBox.Show(
"Scan Again"
);
119.
textBox1.Text =
""
;
120.
return
;
121.
}
122.
}
123.
}
124.
}
125.
}