In my program I have 4 files Customers, Tables, Bookings and TableBookingLink. I have completed the bookings fine but I wanted to tweak the code so that if a table isn't available then it wont be visible or will be displayed in red. However, after 30 mins the table should be shown back in the listbox of Table IDs and should be able to be booked again. Here is the save routine of my booking:
Private Sub CmdSaveBooking_click()
Dim t As Table
Dim tchannel As Integer
Dim c As Customer
Dim cchannel As Integer
Dim b As Booking
Dim bchannel As Integer
Dim tbl As TableBookingLink
Dim tblchannel As Integer
Dim TableRecordCount As Integer
Dim CustomerRecordCount As Integer
Dim BookingRecordCount As Integer
Dim TableBookingLinkCount As Integer 'index
Dim ListAmount As Integer
StartTimer.Enabled = False
bchannel = FreeFile
Open BookingFile For Random As bchannel Len = BookingLength
tblchannel = FreeFile
Open TableBookingLinkFile For Random As tblchannel Len = TableBookingLinkLength
cchannel = FreeFile
Open CustomerFile For Random As cchannel Len = CustomerLength
tchannel = FreeFile
Open TableFile For Random As tchannel Len = TableLength
CustomerRecordCount = 1
Get cchannel, CustomerRecordCount, c
Do While c.CustomerID <> TxtSelectedCustomerID.Text
CustomerRecordCount = CustomerRecordCount + 1
Get cchannel, CustomerRecordCount, c
Loop
ListAmount = 0
Do While ListAmount <= LstSelectedTableID.ListCount - 1
TableRecordCount = 1
Get tchannel, TableRecordCount, t
Do While t.TableID <> LstSelectedTableID.List(ListAmount)
TableRecordCount = TableRecordCount + 1
Get tchannel, TableRecordCount, t
Loop
b.BookingID = TxtBookingID.Text
b.CustomerID = TxtSelectedCustomerID.Text
b.CostOfMeal = TxtCostOfMeal.Text
b.StartTime = TxtTime.Text
b.Waiter = ComboWaiters
b.TheDate = TxtDate.Text
b.NumberOfPeople = TxtNumberOfPeople.Text
b.Booked = True
tbl.BookingID = TxtBookingID.Text
tbl.TableID = t.TableID
Booking_Active = Booking_Active + 1
TableBookingLink_Active = TableBookingLink_Active + 1
Put tblchannel, TableBookingLink_Active, tbl
Put bchannel, Booking_Active, b
ListAmount = ListAmount + 1
MsgBox "Table booked"
Loop
Close tblchannel
Close bchannel
Close cchannel
End Sub
Thanks in advance
Private Sub CmdSaveBooking_click()
Dim t As Table
Dim tchannel As Integer
Dim c As Customer
Dim cchannel As Integer
Dim b As Booking
Dim bchannel As Integer
Dim tbl As TableBookingLink
Dim tblchannel As Integer
Dim TableRecordCount As Integer
Dim CustomerRecordCount As Integer
Dim BookingRecordCount As Integer
Dim TableBookingLinkCount As Integer 'index
Dim ListAmount As Integer
StartTimer.Enabled = False
bchannel = FreeFile
Open BookingFile For Random As bchannel Len = BookingLength
tblchannel = FreeFile
Open TableBookingLinkFile For Random As tblchannel Len = TableBookingLinkLength
cchannel = FreeFile
Open CustomerFile For Random As cchannel Len = CustomerLength
tchannel = FreeFile
Open TableFile For Random As tchannel Len = TableLength
CustomerRecordCount = 1
Get cchannel, CustomerRecordCount, c
Do While c.CustomerID <> TxtSelectedCustomerID.Text
CustomerRecordCount = CustomerRecordCount + 1
Get cchannel, CustomerRecordCount, c
Loop
ListAmount = 0
Do While ListAmount <= LstSelectedTableID.ListCount - 1
TableRecordCount = 1
Get tchannel, TableRecordCount, t
Do While t.TableID <> LstSelectedTableID.List(ListAmount)
TableRecordCount = TableRecordCount + 1
Get tchannel, TableRecordCount, t
Loop
b.BookingID = TxtBookingID.Text
b.CustomerID = TxtSelectedCustomerID.Text
b.CostOfMeal = TxtCostOfMeal.Text
b.StartTime = TxtTime.Text
b.Waiter = ComboWaiters
b.TheDate = TxtDate.Text
b.NumberOfPeople = TxtNumberOfPeople.Text
b.Booked = True
tbl.BookingID = TxtBookingID.Text
tbl.TableID = t.TableID
Booking_Active = Booking_Active + 1
TableBookingLink_Active = TableBookingLink_Active + 1
Put tblchannel, TableBookingLink_Active, tbl
Put bchannel, Booking_Active, b
ListAmount = ListAmount + 1
MsgBox "Table booked"
Loop
Close tblchannel
Close bchannel
Close cchannel
End Sub
Thanks in advance