コード例 #1
0
        protected void BtnShowAvail_Click(object sender, EventArgs e)
        {
            Lanes LanesStatuses = (Lanes)(Session["Lanes"]);

            // Selected Number of Hours to book (How Long)
            int NumHours = Int32.Parse(DropDownNumHours.SelectedValue);

            // Selected Time Slot to start ex: 0 -> 12pm
            int TimeSlotToStart = Int32.Parse(DropDownTime.SelectedValue);

            // Timeslots they have selected ex: 12pm, 1pm
            List <int> HoursToBook = new List <int>();

            for (int i = 0; i < NumHours; i++)
            {
                HoursToBook.Add(TimeSlotToStart + i);
            }

            // If booking goes past
            if (HoursToBook[HoursToBook.Count() - 1] > 12)
            {
                LblAvailable.Text = "Selected time is over our open hours.\n" +
                                    "Please select a different time slot.";
            }
            else
            {
                int AvailableLane = LanesStatuses.CheckAvailOfAllLanes(HoursToBook);

                if (AvailableLane == -1)
                {
                    LblAvailable.Text      = "It is not available. Please select a different time slot.";
                    LinkBtnPayment.Enabled = false;
                }
                else
                {
                    LblAvailable.Text = "It is available!";

                    LaneTicket LaneTick;
                    int        PlayerNum  = Int32.Parse(DropDownNumPpl.SelectedValue);
                    int        BookedTime = Int32.Parse(DropDownTime.SelectedValue);

                    // 6pm and after -> Night ticket, else -> Day ticket
                    if (Int32.Parse(DropDownTime.SelectedValue) > 5)
                    {
                        LaneTick = (LaneTicket) new NightTicket(NumHours, PlayerNum, AvailableLane, BookedTime);
                    }
                    else
                    {
                        LaneTick = (LaneTicket) new DayTicket(NumHours, PlayerNum, AvailableLane, BookedTime);
                    }

                    Session["LaneTick"]    = LaneTick;
                    LinkBtnPayment.Enabled = true;
                }
            }
        }