01.
public
partial
class
SalesOrder : Form
02.
{
03.
public
SalesOrder()
04.
{
05.
InitializeComponent();
06.
}
07.
08.
DataTable dt;
09.
int
count = 0;
10.
11.
private
void
Form1_Load(
object
sender, EventArgs e)
12.
{
13.
dt =
new
DataTable();
14.
dt.Columns.Add(
"ลำดับที่"
,
typeof
(
int
));
15.
dt.Columns.Add(
"รหัสสินค้า"
,
typeof
(
string
));
16.
dt.Columns.Add(
"รายการสิน"
,
typeof
(
string
));
17.
dt.Columns.Add(
"จำนวน"
,
typeof
(
int
));
18.
dt.Columns.Add(
"ราคา"
,
typeof
(
int
));
19.
dt.Columns.Add(
"จำนวนเงิน"
,
typeof
(
int
));
20.
}
21.
22.
private
void
addButton_Click(
object
sender, EventArgs e)
23.
{
24.
try
25.
{
26.
count += 1;
27.
28.
int
invoice_amount = 0;
29.
30.
invoice_amount = Convert.ToInt32(invoice_quantity.Text) * Convert.ToInt32(invoice_price.Text);
31.
32.
dt.Rows.Add(count, invoice_product_id.Text, invoice_product.Text, invoice_quantity.Text, invoice_price.Text, invoice_amount);
33.
salesOrderView.DataSource = dt;
34.
35.
invoice_product_id.Clear();
36.
invoice_product.Clear();
37.
invoice_quantity.Clear();
38.
invoice_unit.Clear();
39.
invoice_price.Clear();
40.
}
41.
catch
42.
{
43.
MessageBox.Show(
"คุณยังไม่ได้ทำการกรอกข้อมูล"
);
44.
}
45.
}
46.
}