connectionString = "Data Source=NAN-PC\SQLEXPRESS; Initial Catalog=Info_Reserve; Integrated Security=True"
connection = New SqlConnection(connectionString)
strAdd = "SELECT * FROM Info_All "
Try
connection.Open()
cmd = New SqlCommand(strAdd, connection)
SQLReader = cmd.ExecuteReader
If SQLReader.HasRows() Then
Today = FormatDateTime(Now(), DateFormat.ShortDate)
Dim a As Integer
Dim dt = New DataTable
dt.Load(SQLReader)
Dim dRow As DataRow
lsvCurrentStore.Items.Clear()
n = dt.Rows.Count - 1
ReDim InfoStoreCurrent(n)
For Each dRow In dt.Rows
Dim lsv As New ListViewItem
InfoStoreCurrent(a).StoreID = dRow.Item("Store_ID")
InfoStoreCurrent(a).Rent_no = dRow.Item("Rent_No")
InfoStoreCurrent(a).StoreName = dRow.Item("Store_Name")
InfoStoreCurrent(a).Category = dRow.Item("Reserve_Category")
InfoStoreCurrent(a).StoreSize = dRow.Item("Store_Size")
InfoStoreCurrent(a).ReserveDay = dRow.Item("Reserve_Day")
InfoStoreCurrent(a).ExpireDay = dRow.Item("Expire_Day")
If (Today < InfoStoreCurrent(a).ExpireDay) Or (Today = InfoStoreCurrent(a).ExpireDay) Then
lsv.SubItems.Add(dRow("Store_ID"))
lsv.SubItems.Add(dRow("Rent_No"))
lsv.SubItems.Add(dRow("Store_Name"))
lsv.SubItems.Add(dRow("Reserve_Category"))
lsv.SubItems.Add(dRow("Store_Size"))
lsv.SubItems.Add(dRow("Reserve_Day"))
lsv.SubItems.Add(dRow("Expire_Day"))
lsvCurrentStore.Items.Add(lsv)
lsv = Nothing
End If
Next
End If
connection.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
If (Today < InfoStoreCurrent(a).ExpireDay) Or (Today = InfoStoreCurrent(a).ExpireDay) Then
Dim lsv As New ListViewItem(dRow("Store_ID").ToString())
lsv.SubItems.Add(dRow("Rent_No").ToString())
lsv.SubItems.Add(dRow("Store_Name").ToString())
lsv.SubItems.Add(dRow("Reserve_Category").ToString())
lsv.SubItems.Add(dRow("Store_Size").ToString())
lsv.SubItems.Add(dRow("Reserve_Day").ToString())
lsv.SubItems.Add(dRow("Expire_Day").ToString())
lsvCurrentStore.Items.Add(lsv)
End If
If (Today < InfoStoreCurrent(a).ExpireDay) Or (Today = InfoStoreCurrent(a).ExpireDay) Then
Dim lsv As New ListViewItem
lsv.Text = CType(dRow("Store_ID"), String)
lsv.SubItems.Add(CType(dRow("Rent_No"), String))
lsv.SubItems.Add(CType(dRow("Store_Name"), String))
lsv.SubItems.Add(CType(dRow("Reserve_Category"), String))
lsv.SubItems.Add(CType(dRow("Store_Size"), String))
lsv.SubItems.Add(CType(dRow("Reserve_Day"), Date))
lsv.SubItems.Add(CType(dRow("Expire_Day"), Date))
lsvCurrentStore.Items.Add(lsv)
lsvCurrentStore.Columns.Add(HorizontalAlignment.Center)
lsv = Nothing
End If