예제 #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.Page.User.Identity.IsAuthenticated)
     {
         FormsAuthentication.RedirectToLoginPage();
     }
     else
     {
         //Need to know if employee or standard user, hopefully a quick select will be fine?
         system    = new ClubBaistSystem();
         upCurrent = new UserPermission();
         loc       = new LocHour();
         upCurrent = system.GetUser(Page.User.Identity.Name);
         if (upCurrent.EmployeeFlag)
         {
             //User is employee so load all features. (Admin User can change username)
             tbUser.Enabled = true;
         }
         else if (upCurrent.ApprovedFlag)
         {
             //User is standard user so load single user only functions. (Cannot change username)
             tbUser.Text    = Page.User.Identity.Name;
             tbUser.Enabled = false;
         }
         else
         {
             //User is not employee or approved so don't do anything. Disable the wizard completely.
             wizAddReservation.Enabled = false;
             wizAddReservation.Visible = false;
         }
     }
 }
예제 #2
0
        public LocHour GetHours(short shLocationID, DateTime date)
        {
            LocHour  locationHours = new LocHour();
            LocHours hoursMan      = new LocHours();

            locationHours = hoursMan.GetHours(shLocationID, date);

            return(locationHours);
        }
예제 #3
0
        protected void wizAddReservation_NextButtonClick(object sender, WizardNavigationEventArgs e)
        {
            if (wizAddReservation.ActiveStepIndex == 0) //Checks to make sure that the current step is the first step
            {
                //ClubBaistSystem system = new ClubBaistSystem();

                loc = system.GetHours(Convert.ToInt16(ddlLocations.Text), DateTime.Now); //loc now contains location hours and any althours

                //Now need to get any current reservations
                reservationList = new List <Reservation>();
                reservationList = system.GetReservations(Convert.ToInt16(ddlLocations.Text), DateTime.Now);

                //Use that data to fill the calendar control and drop down control
                GenerateDisabledDays();
            }
        }
예제 #4
0
        protected void calReservations_SelectionChanged(object sender, EventArgs e)
        {
            DateTime selected  = calReservations.SelectedDate;
            TimeSpan startTime = new TimeSpan();
            TimeSpan endTime   = new TimeSpan();

            loc = system.GetHours(Convert.ToInt16(ddlLocations.Text), DateTime.Now);

            startTime = loc.DefaultOpen;
            endTime   = loc.DefaultClose;

            if (loc.AltHours != null)
            {
                foreach (AltLocHour alt in loc.AltHours) //Check list of alternate hours for a location
                {
                    if (alt.Date == selected)            //if alternate hours were found for the selected date then modify the start and end times
                    {
                        startTime = alt.AltOpenTime;
                        endTime   = alt.AltCloseTime;
                    }
                }
            }

            List <int> times = new List <int>();

            for (int i = startTime.Hours; i < endTime.Hours; i += 2)
            {
                times.Add(i);
            }

            reservationList = system.GetReservations(Convert.ToInt16(ddlLocations.Text), DateTime.Now);

            foreach (Reservation reserve in reservationList)
            {
                if (reserve.DateTime.Date == selected.Date)
                {
                    times.Remove(reserve.DateTime.Hour);
                }
            }

            ddlStartTime.DataSource = times;
            ddlStartTime.DataBind();
            labStartTime.Visible = true;
            ddlStartTime.Visible = true;
        }
예제 #5
0
        public void GenerateDisabledDays() //Generate additional diabled days based on selected user for whom the reservation is being created under
        {
            OneOffs = new List <DateTime>();
            loc     = system.GetHours(Convert.ToInt16(ddlLocations.Text), DateTime.Now);
            foreach (AltLocHour alt in loc.AltHours)
            {
                if (!alt.OpenToday)
                {
                    OneOffs.Add(alt.Date);
                }
            }

            foreach (Reservation reserve in reservationList)
            {
                if (reserve.Email == tbUser.Text)
                {
                    OneOffs.Add(reserve.DateTime);
                }
            }
        }
예제 #6
0
        //functions to add or get location hours should go here

        public LocHour GetHours(short shLocationID, DateTime date)
        {
            LocHour locationHours = new LocHour();

            locationHours.LocationID = shLocationID;
            //in here I need to run stored proc and fill in my custom object locHour
            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                SqlCommand GetHoursCommand = new SqlCommand("spGetHours", connection);
                GetHoursCommand.CommandType = CommandType.StoredProcedure;

                SqlParameter LocationIDParameter = new SqlParameter();
                LocationIDParameter.ParameterName = "@locationID";
                LocationIDParameter.Value         = shLocationID;
                LocationIDParameter.Direction     = ParameterDirection.Input;
                LocationIDParameter.SqlDbType     = SqlDbType.SmallInt;
                GetHoursCommand.Parameters.Add(LocationIDParameter);

                SqlParameter DateParameter = new SqlParameter();
                DateParameter.ParameterName = "@date";
                DateParameter.Value         = date.ToShortDateString();
                DateParameter.Direction     = ParameterDirection.Input;
                DateParameter.SqlDbType     = SqlDbType.Date;
                GetHoursCommand.Parameters.Add(DateParameter);

                SqlParameter StatusParameter = new SqlParameter();
                StatusParameter.ParameterName = "@Status";
                StatusParameter.SqlDbType     = SqlDbType.Int;
                StatusParameter.Direction     = ParameterDirection.ReturnValue;

                GetHoursCommand.Parameters.Add(StatusParameter);

                connection.Open();
                SqlDataReader dr = GetHoursCommand.ExecuteReader();
                //int iCount = 0;
                if (dr.HasRows)
                {
                    locationHours.AltHours = new List <AltLocHour>(); //this line negates my old counter var
                    while (dr.Read())
                    {
                        locationHours.DefaultOpen  = dr.GetTimeSpan(0);
                        locationHours.DefaultClose = dr.GetTimeSpan(1);
                        if (dr.FieldCount > 2) //Alt hours exist
                        {
                            //if (iCount == 0)
                            //{
                            //locationHours.AltHours = new List<AltLocHour>();
                            //}
                            AltLocHour alt = new AltLocHour();

                            alt.Date = dr.GetDateTime(2);
                            try { alt.OpenToday = dr.GetBoolean(3); }
                            catch { alt.OpenToday = false; }
                            try { alt.AltOpenTime = dr.GetTimeSpan(4); }
                            catch { alt.AltOpenTime = new TimeSpan(); }
                            try { alt.AltCloseTime = dr.GetTimeSpan(5); }
                            catch { alt.AltCloseTime = new TimeSpan(); }

                            locationHours.AltHours.Add(alt);
                        }
                        else //alt hours don't exist
                        {
                        }
                        //iCount++;
                    }
                }
            }
            return(locationHours);
        }