Private Sub ShowData()
Dim sql As String = ""
sb.Remove(0, sb.Length())
sb.Append("SELECT RentDetail.RentID, RentDetail.FameeID, Fame.FameName, Fame.Category, Customer.CusName, Rent.RentDate, Rent.ReturnDate, Rent.RentStatus, RentDetail.zzz ")
sb.Append(" FROM RentDetail,Fame,Rent,Customer")
sb.Append(" WHERE RentDetail.FameeID=Fame.FameeID")
sb.Append(" AND RentDetail.RentID=Rent.RentID")
sb.Append(" AND Rent.CusID=Customer.CusID")
sb.Append(" AND Rent.RentStatus = 'ยืม' ORDER BY Rent.ReturnDate ASC")
sql = sb.ToString
If IsFind = True Then
ds.Tables("RentDetail").Clear()
End If
da = New OleDbDataAdapter(sql, Conn)
da.Fill(ds, "RentDetail")
If ds.Tables("RentDetail").Rows.Count <> 0 Then
IsFind = True
With dgvFile
.ReadOnly = True
.DataSource = ds.Tables("RentDetail")
End With
Else
IsFind = True
dgvFile.DataSource = Nothing
MessageBox.Show("ไม่พบรายการในฐานข้อมูล", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
If dgvFile.RowCount > 0 Then
Dim i As Integer = 0
Dim d1 As Date = DateTime.Now
For i = 0 To dgvFile.Rows.Count - 1
Dim d2 As Date = dgvFile.Rows(i).Cells(6).Value
Dim timee As Integer = DateDiff(DateInterval.Day, d1, d2).ToString
dgvFile.Rows(i).Cells(8).Value = timee
Next
End If
'dr.Close()
FormatDatagrid()
End Sub
Tag : .NET, Ms Access, VB.NET, VS 2008 (.NET 3.x), VS 2010 (.NET 4.x)