protected void Page_Load(object sender, EventArgs e)
        {
            //check if the user has logged in before booking a class
            //if false, redirect the user to a error message page
            if (Session["loginData"] == null)
            {
                Session["message"] = "You must be logged in before booking a session. You will be redirected to home page in 10 seconds.";
                Response.Redirect("Message.aspx");
            }
            //check if the user has selected a session to book
            //if false, redirect the user to Classes.aspx
            else if (Request.QueryString["id"] == null || Request.QueryString["type2"] == null)
            {
                Response.Redirect("Classes.aspx");
            }

            //store user's details in user object
            user = (User)Session["loginData"];

            //store querry string parameters (passed with the url) in two variables
            id   = Int32.Parse(Request.QueryString["id"]);
            type = Request.QueryString["type2"].ToString();



            if (type.Equals("Workshop"))
            {
                s = DBconnection.getWorkshop(id);
            }
            else if (type.Equals("Class"))
            {
                s = DBconnection.getClass(id);
            }


            //check if selected session has any free spaces
            if (s.Capacity == s.Reservations)
            {
                //if true, ask the user if he wants to be added to thr waiting list
                btn_confirmBooking.Text  = "Add to queue";
                BookingMessage.InnerText = "This session is full. Would you like to be added to a waiting list?";
                queue = true;
            }
            else
            {
                queue = false;
                BookingMessage.InnerText = "Booking confirmation:";
            }


            reservation = new Reservation(id, DateTime.Now, user.Id, s.Title, s.StartDate);



            //set labels
            Label1.Text = reservation.SessionTitle;
            Label3.Text = reservation.SessionDate.ToShortDateString();
            Label4.Text = reservation.SessionTitle;
        }
Пример #2
0
        private void displayWaitingLists(List <Queue> queues)
        {
            for (int i = 0; i < queues.Count; i++)
            {
                Session session;
                if (queues[i].SessionType.Equals("Workshop"))
                {
                    session = DBconnection.getWorkshop(queues[i].SessionID);
                }
                else
                {
                    session = DBconnection.getClass(queues[i].SessionID);
                }

                //container div holding each item
                HtmlGenericControl div = new HtmlGenericControl("div");
                listOfreservations.Controls.Add(div);

                //unordered list
                HtmlGenericControl ul = new HtmlGenericControl("ul");
                div.Controls.Add(ul);

                //list item displaying session title and cancel button
                HtmlGenericControl li1 = new HtmlGenericControl("li");
                li1.InnerHtml = "<a href='Message.aspx?cnlQ=" + queues[i].Id + "' onclick=\"return confirm('Are you sure you want to delete?')\" ><img src='/images/cancel_btn.png' /></a> <span>" + session.Title + "</span> ";

                HtmlGenericControl li2 = new HtmlGenericControl("li");
                li2.InnerText = "On: " + session.StartDate.Add(session.Time);

                List <Queue> temp      = DBconnection.viewSessionQueue(queues[i].SessionID, queues[i].SessionType);
                int          waitingNo = 0;

                for (int j = 0; j < temp.Count; j++)
                {
                    temp[j].WaitingNumber = j + 1;

                    if (temp[j].UserID == userData.Id)
                    {
                        queues[i].WaitingNumber = temp[j].WaitingNumber;
                    }
                }



                HtmlGenericControl li3 = new HtmlGenericControl("li");
                li3.InnerText = queues[i].WaitingNumber + " on waiting list";

                ul.Controls.Add(li1);
                ul.Controls.Add(li2);
                ul.Controls.Add(li3);
            }
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["loginData"] == null)
            {
                Response.Redirect("Default.aspx");
            }


            //store data from sessions and string querries
            user = (User)Session["loginData"];              //user's details
            id   = Int32.Parse(Request.QueryString["id"]);  //reservation ID
            type = Request.QueryString["type"].ToString();  //type of session needed for writting to the database


            reservation = DBconnection.getReservation(id, type);


            if (type.Equals("Workshop"))
            {
                session = DBconnection.getWorkshop(reservation.SessionID);
            }
            else if (type.Equals("Class"))
            {
                session = DBconnection.getClass(reservation.SessionID);
            }


            Label2.Text = session.Title;
            Label3.Text = session.StartDate.ToShortDateString() + " " + session.Time.ToString();


            currentDate    = DateTime.Now;                                    //current date and time
            sessionDate    = session.StartDate.Date.Add(session.Time);        //store session's date and time in one DateTime object
            dateDifference = sessionDate.Subtract(currentDate);
            TimeSpan hours24     = new TimeSpan(24, 0, 0);                    //create a timespan of 24h
            int      compareTime = TimeSpan.Compare(dateDifference, hours24); //compare both dates



            if (compareTime == -1)
            {
                Label1.Text         = "You can cancel a session up to 24h before it is scheduled. We apologise for any inconvience";
                btn_confirm.Visible = false;
            }
            else
            {
                Label1.Text = "Are you sure you want to cancel the folloing session?";
            }
        }