im creating a hotel booking system for my college project and i have managed to prevent the system from overbooking rooms the problem is i want the program to automatically assign rooms to customers.
CODE
Do While DatRoomsDwn.Recordset.EOF = False 'loops through all the booked records in the database
'gets the dates that the rooms have been booked
RoomBookedFrom = DatRoomsDwn.Recordset.Fields("DateBooked").Value
RoomBookedTo = DatRoomsDwn.Recordset.Fields("DateEmpty").Value
'if the proposed bookin falls inbetween two dates allready booked then 1 is added to the pplbooked
If (DateDiff("D", RoomBookedFrom, arrival) <= 0) And (DateDiff("D", arrival, RoomBookedTo) <= 0) Then
pplbooked = pplbooked + 1
End If
If pplbooked = 5 Then Exit Do 'if there are 5 people booked in the proposed time the program exits the loop
DatRoomsDwn.Recordset.MoveNext
Loop
If pplbooked = 5 Then
ErrorYes = True
Reason = "no rooms are available for the proposed date"
GoTo T:
'program rejects the proposed date
Else
DatRoomsDwn.Recordset.AddNew 'else the customer is booked in to a room
txtcusID = txtCusName
txtbookdat = arrival
txtdepartdat = departure
DatRoomsDwn.Recordset.Fields("roomnum").Value = (RoomNum)
MsgBox "customer added to database", , "Booking confirmed" 'message to alert user
End If
as you can see there are five rooms in total and i want to eliminate rooms that are already booked as the program searches through the database then i want the RoomNum variable to assign the lowest room number possible.
i am using visual basic 6 with a data object linked to an access database.
any ideas ?
thanks in advance
This post has been edited by cdm163: 23 Jan, 2008 - 03:41 AM