Ejemplo n.º 1
0
        protected void btn_confirm_Click(object sender, EventArgs e)
        {
            //load sessiion queue
            List <Queue> sessionQueue = DBconnection.viewSessionQueue(session.Id, type);

            if (sessionQueue.Count != 0)      //check if queue contains any members
            {
                //check if reservation is same as capacity
                if (session.Reservations == session.Capacity)
                {
                    //load the top queue member in to a Reservation object
                    Reservation nextInQ = new Reservation(sessionQueue[0].SessionID, DateTime.Now, sessionQueue[0].UserID, sessionQueue[0].SessionTitle, sessionQueue[0].ReservationDate);
                    DBconnection.reserveSession(nextInQ, type);         //add above reservation to a database
                    DBconnection.removeQueue(sessionQueue[0].Id, "ID"); //remove queue member that has been added to a reservation
                }
            }
            else
            {
                //if queue does not exists, remove one reservation and update number of session's reservation
                int reservationsNumber = session.Reservations - 1;
                DBconnection.updateSessionReservation(type, reservationsNumber, reservation);
            }


            DBconnection.deleteRecord("Reservation", reservation.ReservationID, "ID");



            Session["message"] = "Your reservation has been cancelled. Thank you";
            Response.Redirect("Message.aspx");
        }
        protected void btn_confirmBooking_Click(object sender, EventArgs e)
        {
            if (queue)
            {
                //add reservation to queue
                DBconnection.addToQueue(user.Id, s.Id, type);
                Session["message"] = "Thank you. Your reservation will be booked as soon as a space becomes available. ";
            }
            //store details necessary for compling a reservation in r object (Reservation class)
            else if (!queue)
            {
                //add reservation to database
                DBconnection.reserveSession(reservation, type);


                //increment the number of reservations for particular session
                int updatedReservation = s.Reservations + 1;

                //update number of reservations for particular session
                DBconnection.updateSessionReservation(type, updatedReservation, reservation);

                Session["message"] = "Thank you for booking a session. You can check your booking details in your profile. We are looking forward to see you";
            }

            Response.Redirect("Message.aspx");
        }