Welcome to Dream.In.Code
Become a VB Expert!

Join 149,458 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,155 people online right now. Registration is fast and FREE... Join Now!




need help with my project

 
Reply to this topicStart new topic

need help with my project

cdm163
23 Jan, 2008 - 03:40 AM
Post #1

New D.I.C Head
*

Joined: 28 Nov, 2007
Posts: 11


My Contributions
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
User is offlineProfile CardPM
+Quote Post

cdm163
RE: Need Help With My Project
23 Jan, 2008 - 04:28 AM
Post #2

New D.I.C Head
*

Joined: 28 Nov, 2007
Posts: 11


My Contributions
No need now i have sorted out the problem by using a boolean array for the rooms that are set to false if someone is already booked to that room
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 01:38PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month