Question

I am programming a database(DB) in Lazarus as a project and for increased complexity have NOT downloaded any additional libraries. The software is intended to allow customers to check availability of hiring a villa and them make a booking if the villa is available.

Declaring records and writing them to a file acts as a table for my DB. Reading/Writing/Deleting the records in my files has been achieved successfully and I now move on to the point where I use this data to make bookings.

I have 3 tables:

  • Clients
  • Villas
  • Bookings

Now, my problem comes in with the bookings table. How do I make my application know that a villa has already been booked for the period in which a new booking wants to be made. (basically double booking shouldn't be allowed) So far as mentioned, I can only read/write and delete records in my tables and now move on to the booking stage. Please ask if further info is needed

I'm thinking of using the Tcalendar but have no idea how to program with it or even if that is the simple way of doing it. Any tips please?

Was it helpful?

Solution

You have to solve two distinct problems:

  1. Implement logic (not visible to the user) that determines whether a requested booking is available or whether the villa is booked for some or all of the requested period.
  2. Implement some kind of visual display for the user to see when a villa is booked.

TCalendar would only help you with the second part, which is the least interesting (because you don't really need a visual interface, you could simply pop up a message that says "Villa Not Available").

To write the logic that will tell you whether a booking is available, you will need to refine your data model (or, if you've done that already, explain it to us in more detail). Specific questions you need to address are:

  1. Do you issue bookings against individual villas ("I want to book the Butterfly House for one week starting July 1") or against an inventory of identical villas ("I want to book one of your two-bedroom villas for one week starting July 1").
  2. You need to decide how you're going to store the booking information. When I've tried a task like this in the past, I've found it easiest to store a record for each night of each reservation then, for a request, do a separate query to determine if I can satisfy that individual night. A request for which I can satisfy all nights is bookable.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top