01.
void
ShowData()
02.
{
03.
04.
string
sql =
"Select productsupplier.*,productsupplierdt.* From productsupplier,productsupplierdt where productsupplier.Id(+) = productsupplierdt.ProductSupplierId Group By ProductSupplierId"
;
05.
06.
string
strdate = Csql.Convert_dateCalendar(txtStartDate.Text);
07.
string
enddate = Csql.Convert_dateCalendar(txtendDate.Text);
08.
09.
10.
11.
if
((txtStartDate.Text !=
string
.Empty) && (txtendDate.Text !=
string
.Empty) && (ddlProduct.SelectedValue !=
"--กรุณาเลือก--"
))
12.
{
13.
14.
dtP = Csql.SELECT_All(
"productsupplier where (DateBuy between '"
+ strdate +
"'AND'"
+ enddate +
"') AND SupplierId='"
+ ddlProduct.SelectedValue +
"'"
);
15.
16.
}
17.
else
if
((txtStartDate.Text !=
string
.Empty) && (txtendDate.Text !=
string
.Empty))
18.
{
19.
dtP = Csql.SELECT_All(
"productsupplier WHERE DateBuy between '"
+ strdate +
"'AND'"
+ enddate +
"'"
);
20.
21.
}
22.
else
if
((txtStartDate.Text ==
string
.Empty) && (txtendDate.Text ==
string
.Empty))
23.
{
24.
dtP = Csql.SELECT_All(
"productsupplier"
);
25.
}
26.
27.
else
28.
{
29.
string
str =
"<script language='javascript'>alert('กรุณาใส่ช่วงวันที่');window.focus ();</script>"
;
30.
Page.RegisterStartupScript(
"onclick"
, str);
31.
32.
return
;
33.
}
34.
35.
if
(dtP.Rows.Count > 0)
36.
{
37.
38.
GV1.DataSource = dtP;
39.
GV1.DataBind();
40.
}
41.
else
42.
{
43.
44.
45.
46.
47.
48.
GV1.DataSource =
null
;
49.
GV1.DataBind();
50.
}
51.
}
52.
53.
protected
void
GV1_RowCreated(
object
sender, GridViewRowEventArgs e )
54.
{
55.
string
strdate = Csql.Convert_dateCalendar(txtStartDate.Text);
56.
string
enddate = Csql.Convert_dateCalendar(txtendDate.Text);
57.
58.
if
(e.Row.RowType == DataControlRowType.DataRow)
59.
{
60.
HyperLink data1 = (HyperLink)e.Row.FindControl(
"data1"
);
61.
HyperLink data2 = (HyperLink)e.Row.FindControl(
"data2"
);
62.
HyperLink data3 = (HyperLink)e.Row.FindControl(
"data3"
);
63.
HyperLink data4 = (HyperLink)e.Row.FindControl(
"data4"
);
64.
65.
66.
67.
string
sql =
"Select productsupplier.*,productsupplierdt.* From productsupplier,productsupplierdt where (productsupplier.DateBuy between '"
+ strdate +
"' AND '"
+ enddate +
"') AND productsupplier.Id = productsupplierdt.ProductSupplierId Group By ProductSupplierId"
;
68.
69.
70.
DataTable dt = Csql.ExecuteReader(sql);
71.
72.
73.
if
(dt.Rows.Count > 0)
74.
{
75.
data1.Text = dt.Rows[e.Row.DataItemIndex][
"ReceiveCode"
].ToString();
76.
data1.NavigateUrl =
"Buy.aspx?actions=Edit&uid="
+ dt.Rows[e.Row.DataItemIndex][
"SupplierId"
].ToString();
77.
data2.Text = dt.Rows[0][
"DateBuy"
].ToString();
78.
data3.Text = dt.Rows[0][
"TotalPrice"
].ToString();
79.
data4.Text = dt.Rows[0][
"Status"
].ToString();
80.
81.
}
82.
}
83.
runid = (e.Row.DataItemIndex + 1) +
"."
;
84.
}