01.
Private
Sub
ShowData()
02.
03.
Dim
sql
As
String
=
""
04.
sb.Remove(0, sb.Length())
05.
sb.Append(
"SELECT RentDetail.RentID, RentDetail.FameeID, Fame.FameName, Fame.Category, Customer.CusName, Rent.RentDate, Rent.ReturnDate, Rent.RentStatus, RentDetail.zzz "
)
06.
sb.Append(
" FROM RentDetail,Fame,Rent,Customer"
)
07.
sb.Append(
" WHERE RentDetail.FameeID=Fame.FameeID"
)
08.
sb.Append(
" AND RentDetail.RentID=Rent.RentID"
)
09.
sb.Append(
" AND Rent.CusID=Customer.CusID"
)
10.
sb.Append(
" AND Rent.RentStatus = 'ยืม' ORDER BY Rent.ReturnDate ASC"
)
11.
sql = sb.ToString
12.
13.
14.
If
IsFind =
True
Then
15.
ds.Tables(
"RentDetail"
).Clear()
16.
End
If
17.
18.
da =
New
OleDbDataAdapter(sql, Conn)
19.
da.Fill(ds,
"RentDetail"
)
20.
If
ds.Tables(
"RentDetail"
).Rows.Count <> 0
Then
21.
IsFind =
True
22.
23.
With
dgvFile
24.
.
ReadOnly
=
True
25.
.DataSource = ds.Tables(
"RentDetail"
)
26.
27.
End
With
28.
29.
Else
30.
IsFind =
True
31.
dgvFile.DataSource =
Nothing
32.
MessageBox.Show(
"ไม่พบรายการในฐานข้อมูล"
,
"ผลการทำงาน"
, MessageBoxButtons.OK, MessageBoxIcon.Information)
33.
End
If
34.
35.
36.
If
dgvFile.RowCount > 0
Then
37.
Dim
i
As
Integer
= 0
38.
39.
Dim
d1
As
Date
= DateTime.Now
40.
41.
For
i = 0
To
dgvFile.Rows.Count - 1
42.
43.
44.
Dim
d2
As
Date
= dgvFile.Rows(i).Cells(6).Value
45.
Dim
timee
As
Integer
= DateDiff(DateInterval.Day, d1, d2).ToString
46.
47.
dgvFile.Rows(i).Cells(8).Value = timee
48.
49.
Next
50.
51.
52.
53.
End
If
54.
55.
56.
57.
58.
59.
60.
FormatDatagrid()
61.
End
Sub