/// <summary>
        /// Adds the schedule columns.
        /// </summary>
        private void AddScheduleColumns()
        {
            ScheduleService scheduleService = new ScheduleService(new RockContext());

            // limit Schedules to ones that have a CheckInStartOffsetMinutes
            var scheduleQry = scheduleService.Queryable().Where(a => a.CheckInStartOffsetMinutes != null && a.IsActive);

            // limit Schedules to the Category from the Filter
            int scheduleCategoryId = CategoryCache.Get(Rock.SystemGuid.Category.SCHEDULE_SERVICE_TIMES.AsGuid()).Id;

            scheduleQry = scheduleQry.Where(a => a.CategoryId == scheduleCategoryId);

            // clear out any existing schedule columns just in case schedules been added/removed
            var scheduleList = scheduleQry.ToList().OrderBy(a => a.ToString()).ToList();

            var checkBoxEditableFields = gGroupLocationSchedule.Columns.OfType <CheckBoxEditableField>().ToList();

            foreach (var field in checkBoxEditableFields)
            {
                gGroupLocationSchedule.Columns.Remove(field);
            }

            foreach (var item in scheduleList)
            {
                string dataFieldName = string.Format("scheduleField_{0}", item.Id);

                CheckBoxEditableField field = new CheckBoxEditableField {
                    HeaderText = item.Name.Replace(" ", "<br/>"), DataField = dataFieldName
                };
                gGroupLocationSchedule.Columns.Add(field);
            }
        }
예제 #2
0
        /// <summary>
        /// Adds the schedule columns.
        /// </summary>
        private void AddScheduleColumns()
        {
            ScheduleService scheduleService = new ScheduleService();

            // limit Schedules to ones that have a CheckInStartOffsetMinutes
            var scheduleQry = scheduleService.Queryable().Where(a => a.CheckInStartOffsetMinutes != null);

            // limit Schedules to the Category from the Filter
            int?scheduleCategoryId = pCategory.SelectedValueAsInt() ?? Rock.Constants.All.Id;

            if (scheduleCategoryId != Rock.Constants.All.Id)
            {
                scheduleQry = scheduleQry.Where(a => a.CategoryId == scheduleCategoryId);
            }
            else
            {
                // NULL (or 0) means Shared, so specifically filter so to show only Schedules with CategoryId NULL
                scheduleQry = scheduleQry.Where(a => a.CategoryId == null);
            }

            var scheduleList = scheduleQry.OrderBy(a => a.Name).Select(a => new { a.Id, a.Name }).ToList();

            foreach (var item in scheduleList)
            {
                string dataFieldName = string.Format("scheduleField_{0}", item.Id);

                CheckBoxEditableField field = new CheckBoxEditableField {
                    HeaderText = item.Name, DataField = dataFieldName
                };
                gGroupLocationSchedule.Columns.Add(field);
            }
        }
예제 #3
0
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            var rockContext = new RockContext();

            GroupLocationService groupLocationService = new GroupLocationService(rockContext);
            ScheduleService      scheduleService      = new ScheduleService(rockContext);

            var gridViewRows = gGroupLocationSchedule.Rows;

            foreach (GridViewRow row in gridViewRows.OfType <GridViewRow>())
            {
                int           groupLocationId = int.Parse(gGroupLocationSchedule.DataKeys[row.RowIndex].Value as string);
                GroupLocation groupLocation   = groupLocationService.Get(groupLocationId);
                if (groupLocation != null)
                {
                    foreach (var fieldCell in row.Cells.OfType <DataControlFieldCell>())
                    {
                        CheckBoxEditableField checkBoxTemplateField = fieldCell.ContainingField as CheckBoxEditableField;
                        if (checkBoxTemplateField != null)
                        {
                            CheckBox checkBox   = fieldCell.Controls[0] as CheckBox;
                            string   dataField  = (fieldCell.ContainingField as CheckBoxEditableField).DataField;
                            int      scheduleId = int.Parse(dataField.Replace("scheduleField_", string.Empty));

                            // update GroupLocationSchedule depending on if the Schedule is Checked or not
                            if (checkBox.Checked)
                            {
                                // This schedule is selected, so if GroupLocationSchedule doesn't already have this schedule, add it
                                if (!groupLocation.Schedules.Any(a => a.Id == scheduleId))
                                {
                                    var schedule = scheduleService.Get(scheduleId);
                                    groupLocation.Schedules.Add(schedule);
                                }
                            }
                            else
                            {
                                // This schedule is not selected, so if GroupLocationSchedule has this schedule, delete it
                                if (groupLocation.Schedules.Any(a => a.Id == scheduleId))
                                {
                                    groupLocation.Schedules.Remove(groupLocation.Schedules.FirstOrDefault(a => a.Id == scheduleId));
                                }
                            }
                        }
                    }
                }
            }

            rockContext.SaveChanges();

            Rock.CheckIn.KioskDevice.FlushAll();

            if (_groupTypeId.HasValue)
            {
                NavigateToParentPage(new Dictionary <string, string> {
                    { "CheckinTypeId", _groupTypeId.ToString() }
                });
            }
        }
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            using (new UnitOfWorkScope())
            {
                GroupLocationService groupLocationService = new GroupLocationService();
                ScheduleService      scheduleService      = new ScheduleService();

                RockTransactionScope.WrapTransaction(() =>
                {
                    var gridViewRows = gGroupLocationSchedule.Rows;
                    foreach (GridViewRow row in gridViewRows.OfType <GridViewRow>())
                    {
                        int groupLocationId         = int.Parse(gGroupLocationSchedule.DataKeys[row.RowIndex].Value as string);
                        GroupLocation groupLocation = groupLocationService.Get(groupLocationId);
                        if (groupLocation != null)
                        {
                            foreach (var fieldCell in row.Cells.OfType <DataControlFieldCell>())
                            {
                                CheckBoxEditableField checkBoxTemplateField = fieldCell.ContainingField as CheckBoxEditableField;
                                if (checkBoxTemplateField != null)
                                {
                                    CheckBox checkBox = fieldCell.Controls[0] as CheckBox;
                                    string dataField  = (fieldCell.ContainingField as CheckBoxEditableField).DataField;
                                    int scheduleId    = int.Parse(dataField.Replace("scheduleField_", string.Empty));

                                    // update GroupLocationSchedule depending on if the Schedule is Checked or not
                                    if (checkBox.Checked)
                                    {
                                        // This schedule is selected, so if GroupLocationSchedule doesn't already have this schedule, add it
                                        if (!groupLocation.Schedules.Any(a => a.Id == scheduleId))
                                        {
                                            var schedule = scheduleService.Get(scheduleId);
                                            groupLocation.Schedules.Add(schedule);
                                        }
                                    }
                                    else
                                    {
                                        // This schedule is not selected, so if GroupLocationSchedule has this schedule, delete it
                                        if (groupLocation.Schedules.Any(a => a.Id == scheduleId))
                                        {
                                            groupLocation.Schedules.Remove(groupLocation.Schedules.FirstOrDefault(a => a.Id == scheduleId));
                                        }
                                    }
                                }
                            }

                            groupLocationService.Save(groupLocation, this.CurrentPersonId);
                        }
                    }
                });
            }

            NavigateToParentPage();
        }
예제 #5
0
        /// <summary>
        /// Adds the schedule columns.
        /// </summary>
        private void AddScheduleColumns()
        {
            ScheduleService scheduleService = new ScheduleService(new RockContext());

            // limit Schedules to ones that are Active and have a CheckInStartOffsetMinutes
            var scheduleQry = scheduleService.Queryable().Where(a => a.IsActive && a.CheckInStartOffsetMinutes != null);

            // limit Schedules to the Category from the Filter
            int scheduleCategoryId = pCategory.SelectedValueAsInt() ?? Rock.Constants.All.Id;

            if (scheduleCategoryId != Rock.Constants.All.Id)
            {
                scheduleQry = scheduleQry.Where(a => a.CategoryId == scheduleCategoryId);
            }
            else
            {
                // NULL (or 0) means Shared, so specifically filter so to show only Schedules with CategoryId NULL
                scheduleQry = scheduleQry.Where(a => a.CategoryId == null);
            }

            var checkBoxEditableFields = gGroupLocationSchedule.Columns.OfType <CheckBoxEditableField>().ToList();

            foreach (var field in checkBoxEditableFields)
            {
                gGroupLocationSchedule.Columns.Remove(field);
            }

            // clear out any existing schedule columns and add the ones that match the current filter setting
            var scheduleList = scheduleQry.ToList().OrderBy(a => a.Name).ToList();

            var sortedScheduleList = scheduleList.OrderByNextScheduledDateTime();

            foreach (var item in sortedScheduleList)
            {
                string dataFieldName = string.Format("scheduleField_{0}", item.Id);

                CheckBoxEditableField field = new CheckBoxEditableField {
                    HeaderText = item.Name + "<br /><a href='#' style='display: inline' class='fa fa-square-o js-sched-select-all'></a>", DataField = dataFieldName
                };
                field.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
                gGroupLocationSchedule.Columns.Add(field);
            }

            if (!scheduleList.Any())
            {
                nbNotification.Text    = nbNotification.Text = String.Format("<p><strong>Warning</strong></p>No schedules found. Consider <a class='alert-link' href='{0}'>adding a schedule</a> or a different schedule category.", ResolveUrl("~/Schedules"));
                nbNotification.Visible = true;
            }
            else
            {
                nbNotification.Visible = false;
            }
        }
        /// <summary>
        /// Adds the schedule columns.
        /// </summary>
        private void AddScheduleColumns()
        {
            ScheduleService scheduleService = new ScheduleService(new RockContext());

            // limit Schedules to ones that have a CheckInStartOffsetMinutes
            var scheduleQry = scheduleService.Queryable().Where(a => a.CheckInStartOffsetMinutes != null);

            // limit Schedules to the Category from the Filter
            int scheduleCategoryId = rFilter.GetUserPreference("Category").AsIntegerOrNull() ?? Rock.Constants.All.Id;

            if (scheduleCategoryId != Rock.Constants.All.Id)
            {
                scheduleQry = scheduleQry.Where(a => a.CategoryId == scheduleCategoryId);
            }
            else
            {
                // NULL (or 0) means Shared, so specifically filter so to show only Schedules with CategoryId NULL
                scheduleQry = scheduleQry.Where(a => a.CategoryId == null);
            }

            // clear out any existing schedule columns and add the ones that match the current filter setting
            var scheduleList = scheduleQry.ToList().OrderBy(a => a.ToString()).ToList();

            var checkBoxEditableFields = gGroupLocationSchedule.Columns.OfType <CheckBoxEditableField>().ToList();

            foreach (var field in checkBoxEditableFields)
            {
                gGroupLocationSchedule.Columns.Remove(field);
            }

            foreach (var item in scheduleList)
            {
                string dataFieldName = string.Format("scheduleField_{0}", item.Id);

                CheckBoxEditableField field = new CheckBoxEditableField {
                    HeaderText = item.Name, DataField = dataFieldName
                };
                gGroupLocationSchedule.Columns.Add(field);
            }

            if (!scheduleList.Any())
            {
                nbNotification.Text    = nbNotification.Text = String.Format("<p><strong>Warning</strong></p>No schedules found. Consider <a class='alert-link' href='{0}'>adding a schedule</a> or a different schedule category.", ResolveUrl("~/Schedules"));
                nbNotification.Visible = true;
            }
            else
            {
                nbNotification.Visible = false;
            }
        }
        /// <summary>
        /// Adds the schedule columns.
        /// </summary>
        private void AddScheduleColumns()
        {
            ScheduleService scheduleService = new ScheduleService();

            // limit Schedules to ones that have a CheckInStartOffsetMinutes
            var scheduleQry = scheduleService.Queryable().Where(a => a.CheckInStartOffsetMinutes != null);

            // limit Schedules to the Category from the Filter
            int scheduleCategoryId = rFilter.GetUserPreference("Category").AsInteger() ?? Rock.Constants.All.Id;

            if (scheduleCategoryId != Rock.Constants.All.Id)
            {
                scheduleQry = scheduleQry.Where(a => a.CategoryId == scheduleCategoryId);
            }
            else
            {
                // NULL (or 0) means Shared, so specifically filter so to show only Schedules with CategoryId NULL
                scheduleQry = scheduleQry.Where(a => a.CategoryId == null);
            }

            // clear out any existing schedule columns and add the ones that match the current filter setting
            var scheduleList = scheduleQry.ToList().OrderBy(a => a.ToString()).ToList();

            var checkBoxEditableFields = gGroupLocationSchedule.Columns.OfType <CheckBoxEditableField>().ToList();

            foreach (var field in checkBoxEditableFields)
            {
                gGroupLocationSchedule.Columns.Remove(field);
            }

            foreach (var item in scheduleList)
            {
                string dataFieldName = string.Format("scheduleField_{0}", item.Id);

                CheckBoxEditableField field = new CheckBoxEditableField {
                    HeaderText = item.ToString(), DataField = dataFieldName
                };
                gGroupLocationSchedule.Columns.Add(field);
            }

            if (!scheduleList.Any())
            {
                nbNotification.Text    = "No schedules found for the selected schedule category. Try choosing a different schedule category in the filter options.";
                nbNotification.Visible = true;
            }
            else
            {
                nbNotification.Visible = false;
            }
        }
예제 #8
0
        /// <summary>
        /// Handles the RowDataBound event of the gGroupLocationSchedule control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridViewRowEventArgs"/> instance containing the event data.</param>
        protected void gGroupLocationSchedule_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            // add tooltip to header columns
            if (e.Row.RowType == DataControlRowType.Header)
            {
                var scheduleService = new ScheduleService(new RockContext());

                foreach (var cell in e.Row.Cells.OfType <DataControlFieldCell>())
                {
                    if (cell.ContainingField is CheckBoxEditableField)
                    {
                        CheckBoxEditableField checkBoxEditableField = cell.ContainingField as CheckBoxEditableField;
                        int scheduleId = int.Parse(checkBoxEditableField.DataField.Replace("scheduleField_", string.Empty));

                        var schedule = scheduleService.Get(scheduleId);
                        if (schedule != null)
                        {
                            cell.Attributes["title"] = schedule.ToString();
                        }
                    }
                }
            }
            else
            {
                if (e.Row.DataItem != null)
                {
                    var     dataRow    = e.Row.DataItem as System.Data.DataRowView;
                    Literal lGroupName = e.Row.FindControl("lGroupName") as Literal;
                    if (lGroupName != null)
                    {
                        lGroupName.Text = string.Format("{0}<br /><small>{1}</small>", dataRow["GroupName"] as string, dataRow["GroupPath"] as string);
                    }

                    Literal lLocationName = e.Row.FindControl("lLocationName") as Literal;
                    if (lLocationName != null)
                    {
                        lLocationName.Text = string.Format("{0}<br /><small>{1}</small>", dataRow["LocationName"] as string, dataRow["LocationPath"] as string);
                    }
                }
            }
        }
        /// <summary>
        /// Handles the RowDataBound event of the gGroupLocationSchedule control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridViewRowEventArgs"/> instance containing the event data.</param>
        protected void gGroupLocationSchedule_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            // add tooltip to header columns
            if (e.Row.RowType == DataControlRowType.Header)
            {
                var scheduleService = new ScheduleService(new RockContext());

                foreach (var cell in e.Row.Cells.OfType <DataControlFieldCell>())
                {
                    if (cell.ContainingField is CheckBoxEditableField)
                    {
                        CheckBoxEditableField checkBoxEditableField = cell.ContainingField as CheckBoxEditableField;
                        int scheduleId = int.Parse(checkBoxEditableField.DataField.Replace("scheduleField_", string.Empty));

                        var schedule = scheduleService.Get(scheduleId);
                        if (schedule != null)
                        {
                            cell.Attributes["title"] = schedule.ToString();
                        }
                    }
                }
            }
        }