No announcement yet.

Creating a form with multiple control date

  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating a form with multiple control date

    Creating a form with multiple control date

    Hi, I have a database where reservations when I register a reservation creates a record;
    id room
    customer id
    date arrivao
    starting date

    how can I create a form for registration of 10 records simultaneously carrying out this following function;

    calls from the customer database the name and surname of the customer
    I insert the date arrival and departure date
    I select for each of the 10 records the room

    and the form I recorded all 10 bookings with a check that your booking is not already present in the database with the same dates of arrival and departure.

    How do ????

  • #2
    No one knows how to help me?


    • #3
      Hey man:

      the thing is that your question is kinda big... there is a lot involved in it... I would of recommend to watch SC videos in their site, specifically the one that talks about multiple record forms and the use of global variables.



      • #4
        Excuse me, I try to make things easier.
        How do I create a form that I enter one reservation and that checks in the db reservations on that same room there is already a booking in the period that I requested the room is already occupied?


        • #5
          Jeez there are so many ways to do that..
          1: create a form with a table on which you only show a new record where you enter your data. Then use the OnValidate event.
          2: create a form with fields not connected to a table and pressing a custom button check your data.
          ... etc.. It depends how you want to make it. That is the nice thing of scriptcase....


          • #6
            Hello, I knew how to do but once you open the space where you write PHP code, including suggestions on the right I have a button that sums up the control function of date?

            Basically I need a control that does this.

            Before you write in table booking
            controls id_camera if booking is already present in the table with a period at the date FROM AL


            • #7
              what you need is not a date macro, what you need is to create a query to check if there's any other reservation in place... so for that you use the sc_lookup macro

              sc_lookup( res, "SELECT * FROM myreservationstable WHERE room = <room for this reservation> AND <conditions to check up dates>");

              if sc_lookup generates any record then you cant save your reservation.

              I think this is what you are looking for.



              • #8
                Thank you so much for putting me on the right track.
                Then I found the function briefly tell you one thing, my table is called
                and differs;
                id_camera (each has more hotel rooms)
                by (date arrivao)
                to (starting date)

                how do I say this;
                RECORD the RESERVATION only if it is not already present in DB booking id_camera with a time interval FROM - TO FROM TO range of time for a new record with the same id_camera?

                This is the code that would be fine as an event in OnValidate ... but I can not fit

                / **
                * Check for an existing record
                * /

                // SQL statement parameters
                $ Check_table = 'prenotazione_h'; // Table name
                $ Check_where = "from = 'condition'"; // Where clause

                // Check for record
                $ Check_sql = 'SELECT *'
                . 'FROM'. $ Check_table
                . 'WHERE'. $ Check_where;
                sc_select (dataset, $ check_sql);

                if (false == {dataset})
                // Error while supplied to access database
                elseif ({dataset} -> EOF)
                // No records found
                // Record found

                Help me ????????


                • #9
                  Your problem seems easy to solve except that it is not clear enough to us. This is common, the coder understands the problem well but when explaining, its hard for others to get the clear picture. Also English is not clear enough. I suggest you write your statement in pseudo format:
                  A client wants to book a hotel room (assuming you are referring to one hotel, even if more, process is similar). The client does not want a specific room, but knows the duration of stay i.e date of arrival and date of departure. The pseudo code will be similar to this:

                  1. Client enters the date of arrival
                  2. client enters date of departure and presses enter
                  3. system takes these two dates:
                  -- runs an SQL statement with a WHERE CLAUSE...WHERE DateOfArrival >= $DateOfArrival AND DateOfDeparture <= $DateOfDeparture
                  --- DateOfArrival & DateOfDeparture are columns in your table (are u using ms access?)
                  --- $DateOfArrival & $DateOfArrival: are variables that hold the date range entered by the user.

                  There are so many ways to solve your problem and if what we understand is correct, it has multiple solutions

                  1. create a form based on the bookings table ( table that holds rooms already booked). Set this table to start with the search functions. The search feature has excellent date functions. Thus you simply allow the client to search for rooms available based on the date range (i.e arrival date & departure date). The results will show rooms only available, thus the client will only chose from rooms available. The limit on rooms to show can be configured in the form itself, not need to write code in macro.

                  NOTE: I have not found this anywhere on this forum but it is extremely important that your database (schema) is designed correctly and optimal. Any database that is poorly designed will translate into poor application designs, bugs etc.. so if u don't mind post a pic of your database schema (or s subset of it). from that its easy to help you out.