Example #1
0
    protected void DaySelected(object sender, EventArgs e)
    {
        DateTime selectedDay = Calendar.SelectedDate;

        if (selectedDay < DateTime.Today)
        {
            msg.Text = "you can't book in the past";
            Calendar.SelectedDate = DateTime.Today;
        }
        ClubBAIST                  cb                   = new ClubBAIST();
        List <Reservation>         TeeTimesForDay       = cb.ReadReservationBatchByTimeFrame(selectedDay, selectedDay.AddDays(1));
        List <StandingReservation> StandingReservations = cb.ReadStandingReservations(1, 1);//get approved and active reservations

        TeeTimesDD.Items.Clear();
        DateTime bufferDateTime = selectedDay.AddHours(7.00);
        bool     offset         = true;

        while (bufferDateTime <= selectedDay.AddHours(18))
        {
            ListItem li = new ListItem();
            li.Text  = bufferDateTime.TimeOfDay.ToString();
            li.Value = MakeFormattedDate(bufferDateTime);

            foreach (Reservation r in TeeTimesForDay)
            {
                if (r.ReservedTime == bufferDateTime)
                {
                    li.Attributes.Add("disabled", "true");
                }
            }
            foreach (StandingReservation sr in StandingReservations)
            {
                if (sr.ReservedTime.DayOfWeek.ToString() == bufferDateTime.DayOfWeek.ToString() && sr.ReservedTime.TimeOfDay.ToString() == bufferDateTime.TimeOfDay.ToString())
                {
                    li.Attributes.Add("disabled", "true");
                }
            }
            TeeTimesDD.Items.Add(li);
            if (offset)
            {
                bufferDateTime = bufferDateTime.AddMinutes(7.00);
                offset         = false;
            }
            else
            {
                bufferDateTime = bufferDateTime.AddMinutes(8.00);
                offset         = true;
            }
        }
    }
    private void AdminStuff()
    {
        //this guy is totally admin
        ClubBAIST cb = new ClubBAIST();

        if (Request.QueryString["u"] != null)
        {
            int  userID = int.Parse(Request.QueryString["u"]);
            User u      = cb.ReadUserByID(userID);
            List <Reservation> reservations = cb.ReadReservationBatchForMember(u.UserID, u.Email);
            ListReservations(reservations);
        }
        else
        {
            List <Reservation> reservations = cb.ReadReservationBatchByTimeFrame(DateTime.Today, DateTime.Today.AddDays(7));
            ListReservations(reservations);
        }
    }
    protected void DaySelected(object sender, EventArgs e)
    {
        DateTime           selectedDay    = Calendar.SelectedDate;
        ClubBAIST          cb             = new ClubBAIST();
        Reservation        thisR          = cb.ReadReservation(int.Parse(Request.QueryString["r"]));
        List <Reservation> TeeTimesForDay = cb.ReadReservationBatchByTimeFrame(selectedDay, selectedDay.AddDays(1));

        TeeTimesDD.Items.Clear();
        DateTime bufferDateTime = selectedDay.AddHours(7.00);
        bool     offset         = true;

        while (bufferDateTime <= selectedDay.AddHours(18))
        {
            ListItem li = new ListItem();
            li.Text  = bufferDateTime.TimeOfDay.ToString();
            li.Value = MakeFormattedDate(bufferDateTime);

            foreach (Reservation r in TeeTimesForDay)
            {
                if (r.ReservedTime == bufferDateTime && r.ReservationID != thisR.ReservationID)
                {
                    li.Attributes.Add("disabled", "true");
                }
            }
            TeeTimesDD.Items.Add(li);
            if (offset)
            {
                bufferDateTime = bufferDateTime.AddMinutes(7.00);
                offset         = false;
            }
            else
            {
                bufferDateTime = bufferDateTime.AddMinutes(8.00);
                offset         = true;
            }
        }
        TeeTimesDD.SelectedValue = MakeFormattedDate(thisR.ReservedTime);
    }
    protected void SearchByTimeFrameButton_Click(object sender, EventArgs e)
    {
        while (TeeTimesTable.Rows.Count > 1)
        {
            TeeTimesTable.Rows.RemoveAt(1);
        }
        DateTime           minDay       = DateTime.Parse(MinDay.Text);
        DateTime           maxDay       = DateTime.Parse(MaxDay.Text);
        ClubBAIST          cb           = new ClubBAIST();
        List <Reservation> reservations = cb.ReadReservationBatchByTimeFrame(minDay, maxDay);

        if (Request.QueryString["u"] != null)
        {
            foreach (Reservation r in reservations.ToList())
            {
                if (r.UserID != int.Parse(Request.QueryString["u"]))
                {
                    reservations.Remove(r);
                }
            }
        }
        ListReservations(reservations);
    }