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.Globalization;
011.
012.
namespace
ExcellenceSportHH
013.
{
014.
public
partial
class
frmCheckingSheet : Form
015.
{
016.
public
frmCheckingSheet()
017.
{
018.
InitializeComponent();
019.
}
020.
021.
private
string
_ValueLocationID;
022.
private
string
_ValueNameCheck;
023.
public
string
ValueLocationID
024.
{
025.
get
026.
{
027.
return
this
._ValueLocationID;
028.
}
029.
set
030.
{
031.
this
._ValueLocationID = value;
032.
}
033.
}
034.
035.
public
string
ValueNameCheck
036.
{
037.
get
038.
{
039.
return
this
._ValueNameCheck;
040.
}
041.
set
042.
{
043.
this
._ValueNameCheck = value;
044.
}
045.
}
046.
047.
public
void
LoadInfor()
048.
{
049.
StreamReader sr =
new
StreamReader(
"\\Program Files\\ExcellenceSportHH\\CheckStock.txt"
);
050.
051.
string
[] split =
new
string
[11];
052.
split = sr.ReadLine().Split(
','
);
053.
txtbarcode.Focus();
054.
055.
056.
057.
}
058.
059.
public
void
btnSave_Click(
object
sender, EventArgs e)
060.
{
061.
try
062.
{
063.
if
(txtbarcode.Text ==
""
)
064.
{
065.
MessageBox.Show(
"Input your Barcode"
);
066.
txtbarcode.Focus();
067.
}
068.
069.
if
(txtbarcode.Text !=
""
)
070.
{
071.
072.
try
073.
{
074.
StreamReader sr =
new
StreamReader(
"\\Program Files\\ExcellenceSportHH\\CheckStock.txt"
);
075.
do
while
(sr.Peek() > -1)
076.
{
077.
string
[] split =
new
string
[11];
078.
split = sr.ReadLine().Split(
','
);
079.
List<
string
> updateLines =
new
List<
string
>();
080.
foreach
(var line
in
sr.ReadLine())
081.
{
082.
if
(split[0] == txtbarcode.Text)
083.
{
084.
085.
split[8] = (
int
.Parse(split[8]) + 1).ToString();
086.
split[9] = _ValueNameCheck;
087.
split[10] = DateTime.Now.ToString(
"yyyy-MM-dd HH:mm:ss"
);
088.
089.
}
090.
sr.Close();
091.
แล้วค่ามันไม่ยอม update
092.
updateLines.Add(
string
.Join(
","
, split));
093.
sr.Close();
094.
}
095.
}
while
(sr.ReadLine() !=
null
);
096.
sr.Close();
097.
}
098.
catch
(Exception ex) { MessageBox.Show(ex.ToString()); }
099.
MessageBox.Show(
"Complete..."
);
100.
101.
txtbarcode.Text =
""
;
102.
txtVN.Text =
""
;
103.
txtColor.Text =
""
;
104.
txtSize.Text =
""
;
105.
txtStyle.Text =
""
;
106.
txtCollection.Text =
""
;
107.
txtPrice.Text =
""
;
108.
txtQtyAll.Text =
""
;
109.
txtbarcode.Focus();
110.
}
111.
}
112.
catch
(Exception ex)
113.
{
114.
MessageBox.Show(ex.ToString());
115.
}
116.
}
117.
118.
private
void
mnuLogout_Click(
object
sender, EventArgs e)
119.
{
120.
frmLogin backward =
new
frmLogin();
121.
backward.Show();
122.
this
.Close();
123.
}
124.
125.
private
void
txtbarcode_KeyDown(
object
sender, KeyEventArgs e)
126.
{
127.
if
(e.KeyCode == Keys.Enter)
128.
{
129.
if
(txtbarcode.Text !=
""
)
130.
{
131.
string
[] split =
new
string
[11];
132.
133.
StreamReader sr =
new
StreamReader(
"\\Program Files\\ExcellenceSportHH\\CheckStock.txt"
);
134.
135.
try
136.
{
137.
do
while
(sr.Peek() > -1 )
138.
{
139.
split = sr.ReadLine().Split(
','
);
140.
string
barcode = split[0];
141.
if
(
string
.Compare(barcode, txtbarcode.Text.Trim(),
true
) == 0)
142.
{
143.
144.
txtVN.Text = split[1];
145.
txtStyle.Text = split[2];
146.
txtColor.Text = split[3];
147.
txtSize.Text = split[4];
148.
txtPrice.Text = split[5];
149.
txtCollection.Text = split[6];
150.
txtQtyAll.Text = split[7];
151.
btnSave.Focus();
152.
}
153.
}
while
(sr.ReadLine() !=
null
);
154.
}
155.
catch
(Exception ex)
156.
{
157.
MessageBox.Show(ex.ToString());
158.
}
159.
}
160.
else
161.
{
162.
MessageBox.Show(
"Not found this barcode, Plese check again!!"
);
163.
txtbarcode.Focus();
164.
txtbarcode.SelectAll();
165.
}
166.
}
167.
}
168.
169.
private
void
mnuReport_Click(
object
sender, EventArgs e)
170.
{
171.
frmReport Nextpage =
new
frmReport();
172.
Nextpage.LocationCode =
this
._ValueLocationID;
173.
Nextpage.Show();
174.
this
.Hide();
175.
}
176.
177.
private
void
mnuExit_Click(
object
sender, EventArgs e)
178.
{
179.
Application.Exit();
180.
}
181.
182.
private
void
frmCheckingSheet_Load(
object
sender, EventArgs e)
183.
{
184.
CultureInfo us = System.Globalization.CultureInfo.GetCultureInfo(
"en-US"
);
185.
}
186.
}
187.
}