Пример #1
0
    /// <summary>
    /// Shows the edit.
    /// </summary>
    /// <param name="groupRoleId">The group role id.</param>
    protected void ShowEdit(int groupRoleId)
    {
        pnlList.Visible    = false;
        pnlDetails.Visible = true;

        GroupRoleService groupRoleService = new GroupRoleService();
        GroupRole        groupRole        = groupRoleService.Get(groupRoleId);
        bool             readOnly         = false;

        hfGroupRoleId.Value = groupRoleId.ToString();
        LoadDropDowns();

        if (groupRole != null)
        {
            iconIsSystem.Visible       = groupRole.IsSystem;
            hfGroupRoleId.Value        = groupRole.Id.ToString();
            tbName.Text                = groupRole.Name;
            tbDescription.Text         = groupRole.Description;
            ddlGroupType.SelectedValue = groupRole.GroupTypeId.ToString();
            tbSortOrder.Text           = groupRole.SortOrder != null?groupRole.SortOrder.ToString() : string.Empty;

            tbMaxCount.Text = groupRole.MaxCount != null?groupRole.MaxCount.ToString() : string.Empty;

            tbMinCount.Text = groupRole.MinCount != null?groupRole.MinCount.ToString() : string.Empty;

            readOnly = groupRole.IsSystem;

            if (groupRole.IsSystem)
            {
                lActionTitle.Text = ActionTitle.View(GroupRole.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }
            else
            {
                lActionTitle.Text = ActionTitle.Edit(GroupRole.FriendlyTypeName);
                btnCancel.Text    = "Cancel";
            }
        }
        else
        {
            lActionTitle.Text          = ActionTitle.Add(GroupRole.FriendlyTypeName);
            iconIsSystem.Visible       = false;
            hfGroupRoleId.Value        = 0.ToString();
            tbName.Text                = string.Empty;
            tbDescription.Text         = string.Empty;
            ddlGroupType.SelectedValue = null;
            tbSortOrder.Text           = string.Empty;
            tbMinCount.Text            = string.Empty;
            tbMaxCount.Text            = string.Empty;
        }

        tbName.ReadOnly        = readOnly;
        tbDescription.ReadOnly = readOnly;
        ddlGroupType.Enabled   = !readOnly;
        tbSortOrder.ReadOnly   = readOnly;
        tbMaxCount.ReadOnly    = readOnly;
        tbMinCount.ReadOnly    = readOnly;

        btnSave.Visible = !readOnly;
    }
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="benevolenceTypeId">The benevolence type identifier.</param>
        private void ShowDetail(int benevolenceTypeId)
        {
            pnlDetails.Visible = true;
            var             rockContext     = new RockContext();
            BenevolenceType benevolenceType = null;

            if (benevolenceTypeId != 0)
            {
                benevolenceType   = new BenevolenceTypeService(new RockContext()).Get(benevolenceTypeIdPageParameter);
                lActionTitle.Text = ActionTitle.Edit(BenevolenceType.FriendlyTypeName).FormatAsHtmlTitle();
                pdAuditDetails.SetEntity(benevolenceType, ResolveRockUrl("~"));
            }

            if (benevolenceType == null)
            {
                benevolenceType = new BenevolenceType
                {
                    Id                   = 0,
                    IsActive             = true,
                    ShowFinancialResults = true
                };

                lActionTitle.Text = ActionTitle.Add(BenevolenceType.FriendlyTypeName).FormatAsHtmlTitle();

                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            tbName.Text                    = benevolenceType.Name;
            tbDescription.Text             = benevolenceType.Description;
            ceLavaTemplate.Text            = benevolenceType.RequestLavaTemplate;
            cbShowFinancialResults.Checked = benevolenceType.ShowFinancialResults;
            cbIsActive.Checked             = benevolenceType.IsActive;

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;

            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(BenevolenceType.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(BenevolenceType.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            tbName.ReadOnly         = readOnly;
            tbDescription.ReadOnly  = readOnly;
            ceLavaTemplate.ReadOnly = readOnly;
            cbIsActive.Enabled      = !readOnly;

            SetHighlightLabelVisibility(benevolenceType, readOnly);

            btnSave.Visible = !readOnly;
        }
        /// <summary>
        /// Shows the mode where the user is only viewing an existing exclusion
        /// </summary>
        private void ShowViewMode()
        {
            if (!IsViewMode())
            {
                return;
            }

            var canEdit = CanEdit();

            pnlEditDetails.Visible = false;
            pnlViewDetails.Visible = true;
            HideSecondaryBlocks(false);
            pdAuditDetails.Visible = canEdit;

            btnEdit.Visible   = canEdit;
            btnDelete.Visible = canEdit;

            var exclusion  = GetExclusion();
            var streakType = GetStreakType();

            lReadOnlyTitle.Text = ActionTitle.View(StreakTypeExclusion.FriendlyTypeName).FormatAsHtmlTitle();
            var locationName = exclusion.Location != null ? exclusion.Location.Name : "Unspecified";

            var descriptionList = new DescriptionList();

            descriptionList.Add("Streak Type", streakType.Name);
            descriptionList.Add("Location", locationName);

            lExclusionDescription.Text = descriptionList.Html;
        }
Пример #4
0
        /// <summary>
        /// Shows the mode where the user is only viewing an existing streak type
        /// </summary>
        private void ShowViewMode()
        {
            if (!IsViewMode())
            {
                return;
            }

            var canEdit = CanEdit();

            pnlEditDetails.Visible = false;
            pnlViewDetails.Visible = true;
            HideSecondaryBlocks(false);
            pdAuditDetails.Visible = canEdit;

            btnEdit.Visible   = canEdit;
            btnDelete.Visible = canEdit;

            var enrollment = GetStreak();
            var streakType = GetStreakType();

            lReadOnlyTitle.Text = ActionTitle.View(Streak.FriendlyTypeName).FormatAsHtmlTitle();
            btnRebuild.Enabled  = streakType.IsActive;

            lPersonHtml.Text = GetPersonHtml();

            var descriptionList = new DescriptionList();

            descriptionList.Add("Streak Type", streakType.Name);
            descriptionList.Add("Enrollment Date", enrollment.EnrollmentDate.ToShortDateString());

            if (enrollment.Location != null)
            {
                descriptionList.Add("Location", enrollment.Location.Name);
            }

            lEnrollmentDescription.Text = descriptionList.Html;

            var streakDetailsList = new DescriptionList();

            streakDetailsList.Add("Current Streak", GetStreakStateString(enrollment.CurrentStreakCount, enrollment.CurrentStreakStartDate));
            streakDetailsList.Add("Longest Streak", GetStreakStateString(enrollment.LongestStreakCount, enrollment.LongestStreakStartDate, enrollment.LongestStreakEndDate));

            lStreakData.Text = streakDetailsList.Html;

            RenderStreakChart();
            SetLinkVisibility(btnAttempts, AttributeKey.AttemptsPage);

            // Show the count of successful attempts on the button
            var successfulAttemptCount = GetSuccessfulAttemptCount();

            if (successfulAttemptCount > 0)
            {
                btnAttempts.Text = string.Format(@"<i class=""fa fa-medal""></i> Achievements <span class=""badge"">{0}</span>", successfulAttemptCount);
            }
            else
            {
                btnAttempts.Text = @"<i class=""fa fa-medal""></i> Achievements";
            }
        }
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="pledgeId">The pledge identifier.</param>
        public void ShowDetail(int pledgeId)
        {
            pnlDetails.Visible = true;
            var frequencyTypeGuid = new Guid(Rock.SystemGuid.DefinedType.FINANCIAL_FREQUENCY);

            ddlFrequencyType.BindToDefinedType(DefinedTypeCache.Read(frequencyTypeGuid), true);

            FinancialPledge pledge = null;

            if (pledgeId > 0)
            {
                pledge            = new FinancialPledgeService(new RockContext()).Get(pledgeId);
                lActionTitle.Text = ActionTitle.Edit(FinancialPledge.FriendlyTypeName).FormatAsHtmlTitle();
            }

            if (pledge == null)
            {
                pledge            = new FinancialPledge();
                lActionTitle.Text = ActionTitle.Add(FinancialPledge.FriendlyTypeName).FormatAsHtmlTitle();
            }

            var isReadOnly  = !IsUserAuthorized(Authorization.EDIT);
            var isNewPledge = pledge.Id == 0;

            hfPledgeId.Value = pledge.Id.ToString();
            if (pledge.PersonAlias != null)
            {
                ppPerson.SetValue(pledge.PersonAlias.Person);
            }
            else
            {
                ppPerson.SetValue(null);
            }
            ppPerson.Enabled = !isReadOnly;
            apAccount.SetValue(pledge.Account);
            apAccount.Enabled = !isReadOnly;
            tbAmount.Text     = !isNewPledge?pledge.TotalAmount.ToString() : string.Empty;

            tbAmount.ReadOnly = isReadOnly;

            dpDateRange.LowerValue = pledge.StartDate;
            dpDateRange.UpperValue = pledge.EndDate;
            dpDateRange.ReadOnly   = isReadOnly;

            ddlFrequencyType.SelectedValue = !isNewPledge?pledge.PledgeFrequencyValueId.ToString() : string.Empty;

            ddlFrequencyType.Enabled = !isReadOnly;

            if (isReadOnly)
            {
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(FinancialPledge.FriendlyTypeName);
                lActionTitle.Text      = ActionTitle.View(BlockType.FriendlyTypeName);
                btnCancel.Text         = "Close";
            }

            btnSave.Visible = !isReadOnly;
        }
Пример #6
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        public void ShowDetail(string itemKey, int itemKeyValue)
        {
            // return if unexpected itemKey
            if (itemKey != "campusId")
            {
                return;
            }

            pnlDetails.Visible = true;

            // Load depending on Add(0) or Edit
            Campus campus = null;

            if (!itemKeyValue.Equals(0))
            {
                campus            = new CampusService(new RockContext()).Get(itemKeyValue);
                lActionTitle.Text = ActionTitle.Edit(Campus.FriendlyTypeName).FormatAsHtmlTitle();
            }
            else
            {
                campus = new Campus {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(Campus.FriendlyTypeName).FormatAsHtmlTitle();
            }

            hfCampusId.Value   = campus.Id.ToString();
            tbCampusName.Text  = campus.Name;
            tbCampusCode.Text  = campus.ShortCode;
            tbPhoneNumber.Text = campus.PhoneNumber;
            ppCampusLeader.SetValue(campus.LeaderPersonAlias != null ? campus.LeaderPersonAlias.Person : null);

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(Campus.FriendlyTypeName);
            }

            if (campus.IsSystem)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlySystem(Campus.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(Campus.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            tbCampusName.ReadOnly = readOnly;
            btnSave.Visible       = !readOnly;
        }
Пример #7
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="DeviceId">The device identifier.</param>
        public void ShowDetail(int kioskId)
        {
            pnlDetails.Visible = true;
            Kiosk kiosk = null;

            var rockContext = new RockContext();

            if (!kioskId.Equals(0))
            {
                kiosk             = new KioskService(rockContext).Get(kioskId);
                lActionTitle.Text = ActionTitle.Edit(Kiosk.FriendlyTypeName).FormatAsHtmlTitle();
            }

            if (kiosk == null)
            {
                kiosk = new Kiosk {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(Kiosk.FriendlyTypeName).FormatAsHtmlTitle();
            }

            hfKioskId.Value = kiosk.Id.ToString();

            tbName.Text        = kiosk.Name;
            tbDescription.Text = kiosk.Description;
            tbIPAddress.Text   = kiosk.IPAddress;

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(Kiosk.FriendlyTypeName);
            }

            pCategory.SetValue(kiosk.CategoryId);

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(Kiosk.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            tbName.ReadOnly        = readOnly;
            tbDescription.ReadOnly = readOnly;

            tbAccessKey.Text = kiosk.AccessKey;
            if (tbAccessKey.Text.IsNullOrWhiteSpace())
            {
                tbAccessKey.Text = Guid.NewGuid().ToString();
            }

            btnSave.Visible = !readOnly;
            BindDropDownList(kiosk);
        }
Пример #8
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="routeId">The route identifier.</param>
        public void ShowDetail(int routeId)
        {
            pnlDetails.Visible = true;

            PageRoute pageRoute = null;

            if (!routeId.Equals(0))
            {
                pageRoute         = new PageRouteService(new RockContext()).Get(routeId);
                lActionTitle.Text = ActionTitle.Edit(PageRoute.FriendlyTypeName).FormatAsHtmlTitle();
                pdAuditDetails.SetEntity(pageRoute, ResolveRockUrl("~"));
            }

            if (pageRoute == null)
            {
                pageRoute = new PageRoute {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(PageRoute.FriendlyTypeName).FormatAsHtmlTitle();
                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            hfPageRouteId.Value = pageRoute.Id.ToString();
            ppPage.SetValue(pageRoute.Page);

            ShowSite();

            tbRoute.Text       = pageRoute.Route;
            cbIsGlobal.Checked = pageRoute.IsGlobal;

            // render UI based on Authorized and IsSystem. Do IsSystem check first so the IsUserAuthorized check can overwrite the settings.
            nbEditModeMessage.Text = string.Empty;

            if (pageRoute.IsSystem)
            {
                nbEditModeMessage.Text = EditModeMessage.System(PageRoute.FriendlyTypeName);

                ppPage.Enabled     = false;
                tbRoute.ReadOnly   = true;
                cbIsGlobal.Enabled = true;
                btnSave.Visible    = true;
            }

            if (!IsUserAuthorized(Authorization.EDIT))
            {
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(PageRoute.FriendlyTypeName);

                lActionTitle.Text = ActionTitle.View(PageRoute.FriendlyTypeName).FormatAsHtmlTitle();
                btnCancel.Text    = "Close";

                ppPage.Enabled     = false;
                tbRoute.ReadOnly   = true;
                cbIsGlobal.Enabled = false;
                btnSave.Visible    = false;
            }
        }
Пример #9
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="binaryFile">The binary file.</param>
        public void ShowBinaryFileDetail(BinaryFile binaryFile)
        {
            pnlDetails.Visible = true;
            hfBinaryFileId.SetValue(binaryFile.Id);

            if (binaryFile.BinaryFileTypeId.HasValue)
            {
                fsFile.BinaryFileTypeGuid = new BinaryFileTypeService(new RockContext()).Get(binaryFile.BinaryFileTypeId.Value).Guid;
            }

            tbName.Text        = binaryFile.FileName;
            tbDescription.Text = binaryFile.Description;
            tbMimeType.Text    = binaryFile.MimeType;
            ddlBinaryFileType.SetValue(binaryFile.BinaryFileTypeId);

            btnEditLabelContents.Visible =
                fsFile.BinaryFileId.HasValue &&
                !string.IsNullOrWhiteSpace(GetAttributeValue("EditLabelPage")) &&
                fsFile.BinaryFileTypeGuid == Rock.SystemGuid.BinaryFiletype.CHECKIN_LABEL.AsGuid();

            Guid?workflowTypeGuid = GetAttributeValue("Workflow").AsGuidOrNull();

            btnRerunWorkflow.Visible = workflowTypeGuid.HasValue;

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(BinaryFile.FriendlyTypeName);
            }

            phAttributes.Controls.Clear();

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(BinaryFile.FriendlyTypeName);
                btnCancel.Text    = "Close";
                Rock.Attribute.Helper.AddDisplayControls(binaryFile, phAttributes);
                fsFile.Enabled = false;
                fsFile.Label   = "View File";
            }
            else
            {
                Rock.Attribute.Helper.AddEditControls(binaryFile, phAttributes, true, BlockValidationGroup);
            }

            tbName.ReadOnly           = readOnly;
            tbDescription.ReadOnly    = readOnly;
            tbMimeType.ReadOnly       = readOnly;
            ddlBinaryFileType.Enabled = !readOnly;

            btnSave.Visible = !readOnly;
        }
Пример #10
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="groupMemberScheduleTemplateId">The group member schedule template identifier.</param>
        public void ShowDetail(int groupMemberScheduleTemplateId)
        {
            pnlDetails.Visible = true;

            // Load depending on Add(0) or Edit
            GroupMemberScheduleTemplate groupMemberScheduleTemplate = null;

            if (!groupMemberScheduleTemplateId.Equals(0))
            {
                groupMemberScheduleTemplate = new GroupMemberScheduleTemplateService(new RockContext()).Get(groupMemberScheduleTemplateId);
                lActionTitle.Text           = ActionTitle.Edit(GroupMemberScheduleTemplate.FriendlyTypeName).FormatAsHtmlTitle();
                pdAuditDetails.SetEntity(groupMemberScheduleTemplate, ResolveRockUrl("~"));
            }

            if (groupMemberScheduleTemplate == null)
            {
                groupMemberScheduleTemplate = new GroupMemberScheduleTemplate {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(GroupMemberScheduleTemplate.FriendlyTypeName).FormatAsHtmlTitle();

                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            hfGroupMemberScheduleTemplateId.Value = groupMemberScheduleTemplate.Id.ToString();
            tbName.Text = groupMemberScheduleTemplate.Name;
            if (groupMemberScheduleTemplate.Schedule != null)
            {
                sbSchedule.iCalendarContent = groupMemberScheduleTemplate.Schedule.iCalendarContent;
            }
            else
            {
                sbSchedule.iCalendarContent = string.Empty;
            }

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(GroupMemberScheduleTemplate.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(GroupMemberScheduleTemplate.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            tbName.ReadOnly = readOnly;
            btnSave.Visible = !readOnly;
        }
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        public void ShowDetail(string itemKey, int itemKeyValue)
        {
            if (!itemKey.Equals("pageRouteId"))
            {
                return;
            }

            pnlDetails.Visible = true;

            PageRoute pageRoute = null;

            if (!itemKeyValue.Equals(0))
            {
                pageRoute         = new PageRouteService().Get(itemKeyValue);
                lActionTitle.Text = ActionTitle.Edit(PageRoute.FriendlyTypeName);
            }
            else
            {
                pageRoute = new PageRoute {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(PageRoute.FriendlyTypeName);
            }

            hfPageRouteId.Value = pageRoute.Id.ToString();
            ppPage.SetValue(pageRoute.Page);
            tbRoute.Text = pageRoute.Route;

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized("Edit"))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(PageRoute.FriendlyTypeName);
            }

            if (pageRoute.IsSystem)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlySystem(PageRoute.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(PageRoute.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            ppPage.Enabled   = !readOnly;
            tbRoute.ReadOnly = readOnly;
            btnSave.Visible  = !readOnly;
        }
        public void ShowDetail(GroupRole groupRole)
        {
            if (groupRole.Id > 0)
            {
                lActionTitle.Text = ActionTitle.Edit(GroupRole.FriendlyTypeName);
            }
            else
            {
                lActionTitle.Text = ActionTitle.Add(GroupRole.FriendlyTypeName);
            }

            LoadDropDowns();

            hfGroupRoleId.Value        = groupRole.Id.ToString();
            tbName.Text                = groupRole.Name;
            tbDescription.Text         = groupRole.Description;
            ddlGroupType.SelectedValue = groupRole.GroupTypeId.ToString();
            tbSortOrder.Text           = groupRole.SortOrder != null?groupRole.SortOrder.ToString() : string.Empty;

            tbMaxCount.Text = groupRole.MaxCount != null?groupRole.MaxCount.ToString() : string.Empty;

            tbMinCount.Text = groupRole.MinCount != null?groupRole.MinCount.ToString() : string.Empty;

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized("Edit"))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(GroupRole.FriendlyTypeName);
            }

            if (groupRole.IsSystem)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlySystem(GroupRole.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(GroupRole.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            tbName.ReadOnly        = readOnly;
            tbDescription.ReadOnly = readOnly;
            ddlGroupType.Enabled   = !readOnly;
            tbSortOrder.ReadOnly   = readOnly;
            tbMaxCount.ReadOnly    = readOnly;
            tbMinCount.ReadOnly    = readOnly;
            btnSave.Visible        = !readOnly;
        }
Пример #13
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="groupTypeId">The group type id.</param>
        protected void ShowEdit(int groupTypeId)
        {
            pnlList.Visible    = false;
            pnlDetails.Visible = true;

            GroupTypeService groupTypeService = new GroupTypeService();
            GroupType        groupType        = groupTypeService.Get(groupTypeId);
            bool             readOnly         = false;

            ChildGroupTypesDictionary = new Dictionary <int, string>();
            LocationTypesDictionary   = new Dictionary <int, string>();

            if (groupType != null)
            {
                hfGroupTypeId.Value = groupType.Id.ToString();
                tbName.Text         = groupType.Name;
                tbDescription.Text  = groupType.Description;
                ddlDefaultGroupRole.SelectedValue = (groupType.DefaultGroupRoleId ?? None.Id).ToString();
                groupType.ChildGroupTypes.ToList().ForEach(a => ChildGroupTypesDictionary.Add(a.Id, a.Name));
                groupType.LocationTypes.ToList().ForEach(a => LocationTypesDictionary.Add(a.LocationTypeValueId, a.LocationTypeValue.Name));
                readOnly = groupType.IsSystem;

                if (groupType.IsSystem)
                {
                    lActionTitle.Text = ActionTitle.View(GroupType.FriendlyTypeName);
                    btnCancel.Text    = "Close";
                }
                else
                {
                    lActionTitle.Text = ActionTitle.Edit(GroupType.FriendlyTypeName);
                    btnCancel.Text    = "Cancel";
                }
            }
            else
            {
                lActionTitle.Text = ActionTitle.Add(GroupType.FriendlyTypeName);

                hfGroupTypeId.Value = 0.ToString();
                tbName.Text         = string.Empty;
                tbDescription.Text  = string.Empty;
            }

            iconIsSystem.Visible        = readOnly;
            ddlDefaultGroupRole.Enabled = !readOnly;
            tbName.ReadOnly             = readOnly;
            tbDescription.ReadOnly      = readOnly;
            btnSave.Visible             = !readOnly;

            BindChildGroupTypesGrid();
            BindLocationTypesGrid();
        }
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="marketingCampaignAdTypeId">The marketing campaign ad type id.</param>
        protected void ShowEdit(int marketingCampaignAdTypeId)
        {
            pnlList.Visible    = false;
            pnlDetails.Visible = true;

            MarketingCampaignAdTypeService marketingCampaignAdTypeService = new MarketingCampaignAdTypeService();
            MarketingCampaignAdType        marketingCampaignAdType        = marketingCampaignAdTypeService.Get(marketingCampaignAdTypeId);
            bool readOnly = false;

            AttributesState = new List <Attribute>().ToDto();

            if (marketingCampaignAdType != null)
            {
                hfMarketingCampaignAdTypeId.Value = marketingCampaignAdType.Id.ToString();
                tbName.Text = marketingCampaignAdType.Name;
                ddlDateRangeType.SelectedValue = ((int)marketingCampaignAdType.DateRangeType).ToString();

                AttributeService attributeService = new AttributeService();

                var qry = attributeService.GetByEntityTypeId(new MarketingCampaignAd().TypeId).AsQueryable()
                          .Where(a => a.EntityTypeQualifierColumn.Equals("MarketingCampaignAdTypeId", StringComparison.OrdinalIgnoreCase) &&
                                 a.EntityTypeQualifierValue.Equals(marketingCampaignAdType.Id.ToString()));

                AttributesState = qry.ToList().ToDto();

                readOnly = marketingCampaignAdType.IsSystem;

                if (marketingCampaignAdType.IsSystem)
                {
                    lActionTitle.Text = ActionTitle.View(MarketingCampaignAdType.FriendlyTypeName);
                    btnCancel.Text    = "Close";
                }
                else
                {
                    lActionTitle.Text = ActionTitle.Edit(MarketingCampaignAdType.FriendlyTypeName);
                    btnCancel.Text    = "Cancel";
                }
            }
            else
            {
                lActionTitle.Text = ActionTitle.Add(MarketingCampaignAdType.FriendlyTypeName);

                hfMarketingCampaignAdTypeId.Value = 0.ToString();
                tbName.Text = string.Empty;
            }

            iconIsSystem.Visible = readOnly;
            btnSave.Visible      = !readOnly;

            BindMarketingCampaignAdAttributeTypeGrid();
        }
Пример #15
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="routeId">The route identifier.</param>
        public void ShowDetail(int routeId)
        {
            pnlDetails.Visible = true;

            PageRoute pageRoute = null;

            if (!routeId.Equals(0))
            {
                pageRoute         = new PageRouteService(new RockContext()).Get(routeId);
                lActionTitle.Text = ActionTitle.Edit(PageRoute.FriendlyTypeName).FormatAsHtmlTitle();
            }

            if (pageRoute == null)
            {
                pageRoute = new PageRoute {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(PageRoute.FriendlyTypeName).FormatAsHtmlTitle();
            }

            hfPageRouteId.Value = pageRoute.Id.ToString();
            ppPage.SetValue(pageRoute.Page);
            tbRoute.Text = pageRoute.Route;

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(PageRoute.FriendlyTypeName);
            }

            if (pageRoute.IsSystem)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlySystem(PageRoute.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(PageRoute.FriendlyTypeName).FormatAsHtmlTitle();
                btnCancel.Text    = "Close";
            }

            ppPage.Enabled   = !readOnly;
            tbRoute.ReadOnly = readOnly;
            btnSave.Visible  = !readOnly;
        }
Пример #16
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        public void ShowDetail(string itemKey, int itemKeyValue)
        {
            pnlDetails.Visible = true;
            var frequencyTypeGuid = new Guid(Rock.SystemGuid.DefinedType.FINANCIAL_FREQUENCY);

            ddlFrequencyType.BindToDefinedType(DefinedTypeCache.Read(frequencyTypeGuid));
            FinancialPledge pledge;

            if (itemKeyValue > 0)
            {
                pledge            = new FinancialPledgeService().Get(itemKeyValue);
                lActionTitle.Text = ActionTitle.Edit(FinancialPledge.FriendlyTypeName);
            }
            else
            {
                pledge            = new FinancialPledge();
                lActionTitle.Text = ActionTitle.Add(FinancialPledge.FriendlyTypeName);
            }

            var isReadOnly  = !IsUserAuthorized("Edit");
            var isNewPledge = pledge.Id == 0;

            hfPledgeId.Value = pledge.Id.ToString();
            ppPerson.SetValue(pledge.Person);
            ppPerson.Enabled = !isReadOnly;
            fpFund.SetValue(pledge.Account);
            fpFund.Enabled = !isReadOnly;
            tbAmount.Text  = !isNewPledge?pledge.TotalAmount.ToString() : string.Empty;

            tbAmount.ReadOnly = isReadOnly;
            dtpStartDate.Text = !isNewPledge?pledge.StartDate.ToShortDateString() : string.Empty;

            dtpStartDate.ReadOnly = isReadOnly;
            dtpEndDate.Text       = !isNewPledge?pledge.EndDate.ToShortDateString() : string.Empty;

            dtpEndDate.ReadOnly            = isReadOnly;
            ddlFrequencyType.SelectedValue = !isNewPledge?pledge.PledgeFrequencyValueId.ToString() : string.Empty;

            ddlFrequencyType.Enabled = !isReadOnly;

            if (isReadOnly)
            {
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(FinancialPledge.FriendlyTypeName);
                lActionTitle.Text      = ActionTitle.View(BlockType.FriendlyTypeName);
                btnCancel.Text         = "Close";
            }

            btnSave.Visible = !isReadOnly;
        }
Пример #17
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="DeviceId">The device identifier.</param>
        public void ShowDetail(int signCategoryId)
        {
            pnlDetails.Visible = true;
            SignCategory signCategory = null;

            var rockContext = new RockContext();

            if (!signCategoryId.Equals(0))
            {
                signCategory      = new SignCategoryService(rockContext).Get(signCategoryId);
                lActionTitle.Text = ActionTitle.Edit(SignCategory.FriendlyTypeName).FormatAsHtmlTitle();
            }

            if (signCategory == null)
            {
                signCategory = new SignCategory {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(SignCategory.FriendlyTypeName).FormatAsHtmlTitle();
            }

            hfSignCategoryId.Value = signCategory.Id.ToString();

            tbName.Text        = signCategory.Name;
            tbDescription.Text = signCategory.Description;

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(SignCategory.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(SignCategory.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            tbName.ReadOnly        = readOnly;
            tbDescription.ReadOnly = readOnly;

            btnSave.Visible = !readOnly;
        }
Пример #18
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="binaryFile">The binary file.</param>
        public void ShowBinaryFileDetail(BinaryFile binaryFile)
        {
            pnlDetails.Visible = true;
            hfBinaryFileId.SetValue(binaryFile.Id);

            if (binaryFile.BinaryFileTypeId.HasValue)
            {
                fsFile.BinaryFileTypeGuid = new BinaryFileTypeService(new RockContext()).Get(binaryFile.BinaryFileTypeId.Value).Guid;
            }

            tbName.Text        = binaryFile.FileName;
            tbDescription.Text = binaryFile.Description;
            tbMimeType.Text    = binaryFile.MimeType;
            ddlBinaryFileType.SetValue(binaryFile.BinaryFileTypeId);

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(BinaryFile.FriendlyTypeName);
            }

            phAttributes.Controls.Clear();

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(BinaryFile.FriendlyTypeName);
                btnCancel.Text    = "Close";
                Rock.Attribute.Helper.AddDisplayControls(binaryFile, phAttributes);
                fsFile.Enabled = false;
                fsFile.Label   = "View File";
            }
            else
            {
                Rock.Attribute.Helper.AddEditControls(binaryFile, phAttributes, true);
            }

            tbName.ReadOnly           = readOnly;
            tbDescription.ReadOnly    = readOnly;
            tbMimeType.ReadOnly       = readOnly;
            ddlBinaryFileType.Enabled = !readOnly;

            btnSave.Visible = !readOnly;
        }
Пример #19
0
        /// <summary>
        /// Shows the mode where the user is only viewing an existing streak type
        /// </summary>
        private void ShowViewMode()
        {
            if (!IsViewMode())
            {
                return;
            }

            var canEdit = CanEdit();

            pnlEditDetails.Visible = false;
            pnlViewDetails.Visible = true;
            HideSecondaryBlocks(false);
            pdAuditDetails.Visible = canEdit;

            btnEdit.Visible   = canEdit;
            btnDelete.Visible = canEdit;

            var enrollment = GetStreak();
            var streakType = GetStreakType();

            lReadOnlyTitle.Text = ActionTitle.View(Streak.FriendlyTypeName).FormatAsHtmlTitle();
            btnRebuild.Enabled  = streakType.IsActive;

            lPersonHtml.Text = GetPersonHtml();

            var descriptionList = new DescriptionList();

            descriptionList.Add("Streak Type", streakType.Name);
            descriptionList.Add("Enrollment Date", enrollment.EnrollmentDate.ToShortDateString());

            if (enrollment.Location != null)
            {
                descriptionList.Add("Location", enrollment.Location.Name);
            }

            lEnrollmentDescription.Text = descriptionList.Html;

            var streakDetailsList = new DescriptionList();

            streakDetailsList.Add("Current Streak", GetStreakStateString(enrollment.CurrentStreakCount, enrollment.CurrentStreakStartDate));
            streakDetailsList.Add("Longest Streak", GetStreakStateString(enrollment.LongestStreakCount, enrollment.LongestStreakStartDate, enrollment.LongestStreakEndDate));

            lStreakData.Text = streakDetailsList.Html;

            RenderStreakChart();
        }
Пример #20
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="pageRouteId">The page route id.</param>
        protected void ShowEdit(int pageRouteId)
        {
            pnlList.Visible    = false;
            pnlDetails.Visible = true;

            PageRouteService pageRouteService = new PageRouteService();
            PageRoute        pageRoute        = pageRouteService.Get(pageRouteId);
            bool             readOnly;

            if (pageRoute != null)
            {
                hfPageRouteId.Value = pageRoute.Id.ToString();
                ddlPageName.SetValue(pageRoute.PageId);
                tbRoute.Text = pageRoute.Route;
                readOnly     = pageRoute.IsSystem;

                if (pageRoute.IsSystem)
                {
                    lActionTitle.Text = ActionTitle.View(PageRoute.FriendlyTypeName);
                    btnCancel.Text    = "Close";
                }
                else
                {
                    lActionTitle.Text = ActionTitle.Edit(PageRoute.FriendlyTypeName);
                    btnCancel.Text    = "Cancel";
                }
            }
            else
            {
                lActionTitle.Text   = ActionTitle.Add(PageRoute.FriendlyTypeName);
                hfPageRouteId.Value = 0.ToString();
                ddlPageName.SetValue(string.Empty);
                tbRoute.Text = string.Empty;
                readOnly     = false;
            }

            iconIsSystem.Visible = readOnly;
            ddlPageName.Enabled  = !readOnly;
            tbRoute.ReadOnly     = readOnly;
            btnSave.Visible      = !readOnly;
        }
Пример #21
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="DeviceId">The device identifier.</param>
        public void ShowDetail(int signId)
        {
            pnlDetails.Visible = true;
            Sign sign = null;

            var rockContext = new RockContext();

            if (!signId.Equals(0))
            {
                sign = new SignService(rockContext).Get(signId);
                lActionTitle.Text = ActionTitle.Edit(Sign.FriendlyTypeName).FormatAsHtmlTitle();
                SignCategories    = new Dictionary <int, string>();
                foreach (var signCategory in sign.SignCategories)
                {
                    SignCategories.Add(signCategory.Id, signCategory.Name);
                }
            }

            if (sign == null)
            {
                sign = new Sign {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(Sign.FriendlyTypeName).FormatAsHtmlTitle();
                sign.Port         = "9107";
            }

            hfSignId.Value = sign.Id.ToString();

            tbName.Text        = sign.Name;
            tbPIN.Text         = sign.PIN;
            tbDescription.Text = sign.Description;
            tbIPAddress.Text   = sign.IPAddress;

            if (sign.Port.IsNullOrWhiteSpace())
            {
                sign.Port = "9107";
            }
            tbPort.Text = sign.Port;

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(Sign.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(Sign.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            tbName.ReadOnly        = readOnly;
            tbPIN.ReadOnly         = readOnly;
            tbDescription.ReadOnly = readOnly;

            btnSave.Visible = !readOnly;

            BindSignCategories();
        }
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="serviceJobId">The service job identifier.</param>
        public void ShowDetail(int serviceJobId)
        {
            pnlDetails.Visible = true;
            LoadDropDowns();

            // Load depending on Add(0) or Edit
            ServiceJob job = null;

            if (!serviceJobId.Equals(0))
            {
                job = new ServiceJobService(new RockContext()).Get(serviceJobId);
                lActionTitle.Text = ActionTitle.Edit(ServiceJob.FriendlyTypeName).FormatAsHtmlTitle();
            }

            if (job == null)
            {
                job = new ServiceJob {
                    Id = 0, IsActive = true
                };
                lActionTitle.Text = ActionTitle.Add(ServiceJob.FriendlyTypeName).FormatAsHtmlTitle();
            }

            hfId.Value                = job.Id.ToString();
            tbName.Text               = job.Name;
            tbDescription.Text        = job.Description;
            cbActive.Checked          = job.IsActive.HasValue ? job.IsActive.Value : false;
            ddlJobTypes.SelectedValue = job.Class;
            tbNotificationEmails.Text = job.NotificationEmails;
            ddlNotificationStatus.SetValue((int)job.NotificationStatus);
            tbCronExpression.Text = job.CronExpression;

            if (job.Id == 0)
            {
                job.Class = ddlJobTypes.SelectedValue;
                lCronExpressionDesc.Visible = false;
                lLastStatusMessage.Visible  = false;
            }
            else
            {
                lCronExpressionDesc.Text = ExpressionDescriptor.GetDescription(job.CronExpression, new Options {
                    ThrowExceptionOnParseError = false
                });
                lCronExpressionDesc.Visible = true;

                lLastStatusMessage.Text    = job.LastStatusMessage.ConvertCrLfToHtmlBr();
                lLastStatusMessage.Visible = true;
            }

            job.LoadAttributes();
            phAttributes.Controls.Clear();
            Rock.Attribute.Helper.AddEditControls(job, phAttributes, true, BlockValidationGroup);

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(ServiceJob.FriendlyTypeName);
            }

            if (job.IsSystem)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlySystem(ServiceJob.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(ServiceJob.FriendlyTypeName).FormatAsHtmlTitle();
                btnCancel.Text    = "Close";
                Rock.Attribute.Helper.AddDisplayControls(job, phAttributesReadOnly);
                phAttributesReadOnly.Visible = true;
                phAttributes.Visible         = false;
                tbCronExpression.Text        = job.CronExpression;
            }


            tbName.ReadOnly               = readOnly;
            tbDescription.ReadOnly        = readOnly;
            cbActive.Enabled              = !readOnly;
            ddlJobTypes.Enabled           = !readOnly;
            tbNotificationEmails.ReadOnly = readOnly;
            ddlNotificationStatus.Enabled = !readOnly;
            tbCronExpression.ReadOnly     = readOnly;

            btnSave.Visible = !readOnly;
        }
Пример #23
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="metricValueId">The metric value identifier.</param>
        /// <param name="metricId">The metric identifier.</param>
        public void ShowDetail(int metricValueId, int?metricId)
        {
            pnlDetails.Visible = true;

            // Load depending on Add(0) or Edit
            MetricValue metricValue = null;

            if (!metricValueId.Equals(0))
            {
                metricValue       = new MetricValueService(new RockContext()).Get(metricValueId);
                lActionTitle.Text = ActionTitle.Edit(MetricValue.FriendlyTypeName).FormatAsHtmlTitle();
                pdAuditDetails.SetEntity(metricValue, ResolveRockUrl("~"));
            }

            if (metricValue == null && metricId.HasValue)
            {
                metricValue = new MetricValue {
                    Id = 0, MetricId = metricId.Value
                };
                metricValue.Metric = metricValue.Metric ?? new MetricService(new RockContext()).Get(metricValue.MetricId);
                lActionTitle.Text  = ActionTitle.Add(MetricValue.FriendlyTypeName).FormatAsHtmlTitle();
                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            hfMetricValueId.Value = metricValue.Id.ToString();

            LoadDropDowns();

            ddlMetricValueType.SelectedValue = metricValue.MetricValueType.ConvertToInt().ToString();
            tbXValue.Text    = metricValue.XValue;
            tbYValue.Text    = metricValue.YValue.ToString();
            hfMetricId.Value = metricValue.MetricId.ToString();
            tbNote.Text      = metricValue.Note;
            dpMetricValueDateTime.SelectedDate = metricValue.MetricValueDateTime;

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;

            bool canEdit = UserCanEdit;

            if (!canEdit && metricId.HasValue && metricId.Value > 0)
            {
                var metric = new MetricService(new RockContext()).Get(metricId.Value);
                if (metric != null && metric.IsAuthorized(Authorization.EDIT, CurrentPerson))
                {
                    canEdit = true;
                }
            }

            if (!canEdit)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(MetricValue.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(MetricValue.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            CreateDynamicControls(metricValue, true, readOnly);

            ddlMetricValueType.Enabled    = !readOnly;
            tbXValue.ReadOnly             = readOnly;
            tbYValue.ReadOnly             = readOnly;
            tbNote.ReadOnly               = readOnly;
            dpMetricValueDateTime.Enabled = !readOnly;

            btnSave.Visible = !readOnly;
        }
Пример #24
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="deviceId">The device identifier.</param>
        public void ShowDetail(int deviceId)
        {
            pnlDetails.Visible = true;
            Device device = null;

            var rockContext = new RockContext();

            if (!deviceId.Equals(0))
            {
                device            = new DeviceService(rockContext).Get(deviceId);
                lActionTitle.Text = ActionTitle.Edit(Device.FriendlyTypeName).FormatAsHtmlTitle();
                pdAuditDetails.SetEntity(device, ResolveRockUrl("~"));
            }

            if (device == null)
            {
                device = new Device {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(Device.FriendlyTypeName).FormatAsHtmlTitle();

                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            LoadDropDowns();

            hfDeviceId.Value = device.Id.ToString();

            tbName.Text        = device.Name;
            tbDescription.Text = device.Description;
            tbIpAddress.Text   = device.IPAddress;
            cbIsActive.Checked = device.IsActive;
            dvpDeviceType.SetValue(device.DeviceTypeValueId);
            ddlPrintTo.SetValue(device.PrintToOverride.ConvertToInt().ToString());
            ddlPrinter.SetValue(device.PrinterDeviceId);
            ddlPrintFrom.SetValue(device.PrintFrom.ConvertToInt().ToString());
            cbHasCamera.Checked = device.HasCamera;
            ddlCameraBarcodeConfigurationType.SetValue(device.CameraBarcodeConfigurationType.HasValue ? device.CameraBarcodeConfigurationType.ConvertToInt().ToString() : null);

            SetPrinterVisibility();
            SetPrinterSettingsVisibility();
            SetCameraVisibility();

            Guid?orgLocGuid = GlobalAttributesCache.Get().GetValue("OrganizationAddress").AsGuidOrNull();

            if (orgLocGuid.HasValue)
            {
                var locationGeoPoint = new LocationService(rockContext).GetSelect(orgLocGuid.Value, a => a.GeoPoint);
                if (locationGeoPoint != null)
                {
                    geopPoint.CenterPoint = locationGeoPoint;
                    geopFence.CenterPoint = locationGeoPoint;
                }
            }

            if (device.Location != null)
            {
                geopPoint.SetValue(device.Location.GeoPoint);
                geopFence.SetValue(device.Location.GeoFence);
            }

            Locations = new Dictionary <int, string>();
            foreach (var location in device.Locations)
            {
                string path           = location.Name;
                var    parentLocation = location.ParentLocation;
                while (parentLocation != null)
                {
                    path           = parentLocation.Name + " > " + path;
                    parentLocation = parentLocation.ParentLocation;
                }

                Locations.Add(location.Id, path);
            }

            BindLocations();

            Guid mapStyleValueGuid = GetAttributeValue(AttributeKey.MapStyle).AsGuid();

            geopPoint.MapStyleValueGuid = mapStyleValueGuid;
            geopFence.MapStyleValueGuid = mapStyleValueGuid;

            UpdateControlsForDeviceType(device);

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(Device.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(Device.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            tbName.ReadOnly        = readOnly;
            tbDescription.ReadOnly = readOnly;
            tbIpAddress.ReadOnly   = readOnly;
            cbIsActive.Enabled     = !readOnly;
            dvpDeviceType.Enabled  = !readOnly;
            ddlPrintTo.Enabled     = !readOnly;
            ddlPrinter.Enabled     = !readOnly;
            ddlPrintFrom.Enabled   = !readOnly;
            SetHighlightLabelVisibility(device, readOnly);

            btnSave.Visible = !readOnly;
        }
Пример #25
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="campusId">The campus identifier.</param>
        public void ShowDetail(int campusId)
        {
            pnlDetails.Visible = true;

            // Load depending on Add(0) or Edit
            Campus campus = null;

            if (!campusId.Equals(0))
            {
                campus            = new CampusService(new RockContext()).Get(campusId);
                lActionTitle.Text = ActionTitle.Edit(Campus.FriendlyTypeName).FormatAsHtmlTitle();
                pdAuditDetails.SetEntity(campus, ResolveRockUrl("~"));
            }

            if (campus == null)
            {
                campus = new Campus {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(Campus.FriendlyTypeName).FormatAsHtmlTitle();
                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            hfCampusId.Value   = campus.Id.ToString();
            tbCampusName.Text  = campus.Name;
            cbIsActive.Checked = !campus.IsActive.HasValue || campus.IsActive.Value;
            tbDescription.Text = campus.Description;
            dvpCampusStatus.SetValue(campus.CampusStatusValueId);
            dvpCampusType.SetValue(campus.CampusTypeValueId);
            tbCampusCode.Text   = campus.ShortCode;
            tbUrl.Text          = campus.Url;
            tbPhoneNumber.Text  = campus.PhoneNumber;
            lpLocation.Location = campus.Location;

            ddlTimeZone.SetValue(campus.TimeZoneId);
            ppCampusLeader.SetValue(campus.LeaderPersonAlias != null ? campus.LeaderPersonAlias.Person : null);
            kvlServiceTimes.Value = campus.ServiceTimes;

            campus.LoadAttributes();
            avcAttributes.ExcludedAttributes = campus.Attributes.Where(a => !a.Value.IsAuthorized(Rock.Security.Authorization.EDIT, this.CurrentPerson)).Select(a => a.Value).ToArray();
            avcAttributes.AddEditControls(campus);

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(Campus.FriendlyTypeName);
            }

            if (campus.IsSystem)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlySystem(Campus.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(Campus.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            tbCampusName.ReadOnly = readOnly;
            btnSave.Visible       = !readOnly;
        }
Пример #26
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="binaryFileTypeId">The binary file type identifier.</param>
        public void ShowDetail(int binaryFileTypeId)
        {
            pnlDetails.Visible = true;
            BinaryFileType binaryFileType = null;

            var rockContext = new RockContext();

            if (!binaryFileTypeId.Equals(0))
            {
                binaryFileType    = new BinaryFileTypeService(rockContext).Get(binaryFileTypeId);
                lActionTitle.Text = ActionTitle.Edit(BinaryFileType.FriendlyTypeName).FormatAsHtmlTitle();
                pdAuditDetails.SetEntity(binaryFileType, ResolveRockUrl("~"));
            }

            if (binaryFileType == null)
            {
                binaryFileType = new BinaryFileType {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(BinaryFileType.FriendlyTypeName).FormatAsHtmlTitle();

                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            BinaryFileAttributesState = new List <Attribute>();

            hfBinaryFileTypeId.Value = binaryFileType.Id.ToString();
            tbName.Text         = binaryFileType.Name;
            tbDescription.Text  = binaryFileType.Description;
            tbIconCssClass.Text = binaryFileType.IconCssClass;
            cbCacheToServerFileSystem.Checked = binaryFileType.CacheToServerFileSystem;

            if (binaryFileType.CacheControlHeaderSettings != null)
            {
                cpCacheSettings.CurrentCacheablity = JsonConvert.DeserializeObject <RockCacheability>(binaryFileType.CacheControlHeaderSettings);
            }

            cbRequiresViewSecurity.Checked = binaryFileType.RequiresViewSecurity;

            nbMaxWidth.Text  = binaryFileType.MaxWidth.ToString();
            nbMaxHeight.Text = binaryFileType.MaxHeight.ToString();

            ddlPreferredFormat.BindToEnum <Format>();
            ddlPreferredFormat.SetValue(( int )binaryFileType.PreferredFormat);

            ddlPreferredResolution.BindToEnum <Resolution>();
            ddlPreferredResolution.SetValue(( int )binaryFileType.PreferredResolution);

            ddlPreferredColorDepth.BindToEnum <ColorDepth>();
            ddlPreferredColorDepth.SetValue(( int )binaryFileType.PreferredColorDepth);

            cbPreferredRequired.Checked = binaryFileType.PreferredRequired;

            if (binaryFileType.StorageEntityType != null)
            {
                cpStorageType.SelectedValue = binaryFileType.StorageEntityType.Guid.ToString().ToUpper();
            }

            AttributeService attributeService = new AttributeService(rockContext);

            string qualifierValue          = binaryFileType.Id.ToString();
            var    qryBinaryFileAttributes = attributeService.GetByEntityTypeId(new BinaryFile().TypeId, true).AsQueryable()
                                             .Where(a => a.EntityTypeQualifierColumn.Equals("BinaryFileTypeId", StringComparison.OrdinalIgnoreCase) &&
                                                    a.EntityTypeQualifierValue.Equals(qualifierValue));

            BinaryFileAttributesState = qryBinaryFileAttributes.ToList();

            BindBinaryFileAttributesGrid();

            // render UI based on Authorized and IsSystem
            bool readOnly       = false;
            bool restrictedEdit = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(BinaryFileType.FriendlyTypeName);
            }

            if (binaryFileType.IsSystem)
            {
                restrictedEdit         = true;
                nbEditModeMessage.Text = EditModeMessage.System(BinaryFileType.FriendlyTypeName);
            }

            phAttributes.Controls.Clear();
            binaryFileType.LoadAttributes();

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(BinaryFileType.FriendlyTypeName).FormatAsHtmlTitle();
                btnCancel.Text    = "Close";
            }

            if (readOnly)
            {
                Rock.Attribute.Helper.AddDisplayControls(binaryFileType, phAttributes);
            }
            else
            {
                Rock.Attribute.Helper.AddEditControls(binaryFileType, phAttributes, true, BlockValidationGroup);
            }

            // the only thing we'll restrict for restrictedEdit is the Name (plus they won't be able to remove Attributes that are marked as IsSystem
            tbName.ReadOnly = readOnly || restrictedEdit;

            gBinaryFileAttributes.Enabled = !readOnly;
            gBinaryFileAttributes.Columns.OfType <EditField>().First().Visible = !readOnly;
            gBinaryFileAttributes.Actions.ShowAdd = !readOnly;

            // allow these to be edited in restricted edit mode if not readonly
            tbDescription.ReadOnly            = readOnly;
            tbIconCssClass.ReadOnly           = readOnly;
            cbCacheToServerFileSystem.Enabled = !readOnly;
            cpCacheSettings.Enabled           = !readOnly;
            cbRequiresViewSecurity.Enabled    = !readOnly;
            cpStorageType.Enabled             = !readOnly;
            nbMaxWidth.ReadOnly            = readOnly;
            nbMaxHeight.ReadOnly           = readOnly;
            ddlPreferredFormat.Enabled     = !readOnly;
            ddlPreferredResolution.Enabled = !readOnly;
            ddlPreferredColorDepth.Enabled = !readOnly;
            cbPreferredRequired.Enabled    = !readOnly;
            btnSave.Visible = !readOnly;
        }
Пример #27
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        public void ShowDetail(string itemKey, int itemKeyValue)
        {
            // return if unexpected itemKey
            if (itemKey != "serviceJobId")
            {
                return;
            }

            pnlDetails.Visible = true;
            LoadDropDowns();

            // Load depending on Add(0) or Edit
            ServiceJob job;

            if (!itemKeyValue.Equals(0))
            {
                job = new ServiceJobService().Get(itemKeyValue);
                lActionTitle.Text = ActionTitle.Edit(ServiceJob.FriendlyTypeName).FormatAsHtmlTitle();
            }
            else
            {
                job = new ServiceJob {
                    Id = 0, IsActive = true
                };
                lActionTitle.Text = ActionTitle.Add(ServiceJob.FriendlyTypeName).FormatAsHtmlTitle();
            }

            hfId.Value                = job.Id.ToString();
            tbName.Text               = job.Name;
            tbDescription.Text        = job.Description;
            cbActive.Checked          = job.IsActive.HasValue ? job.IsActive.Value : false;
            ddlJobTypes.SelectedValue = job.Class;
            tbNotificationEmails.Text = job.NotificationEmails;
            ddlNotificationStatus.SetValue((int)job.NotificationStatus);
            tbCronExpression.Text = job.CronExpression;

            if (job.Id == 0)
            {
                job.Class = ddlJobTypes.SelectedValue;
            }

            job.LoadAttributes();
            phAttributes.Controls.Clear();
            Rock.Attribute.Helper.AddEditControls(job, phAttributes, true);

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized("Edit"))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(ServiceJob.FriendlyTypeName);
            }

            if (job.IsSystem)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlySystem(ServiceJob.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(ServiceJob.FriendlyTypeName).FormatAsHtmlTitle();
                btnCancel.Text    = "Close";
                Rock.Attribute.Helper.AddDisplayControls(job, phAttributesReadOnly);
                phAttributesReadOnly.Visible = true;
                phAttributes.Visible         = false;
                tbCronExpression.Text        = ExpressionDescriptor.GetDescription(job.CronExpression);
            }

            tbName.ReadOnly               = readOnly;
            tbDescription.ReadOnly        = readOnly;
            cbActive.Enabled              = !readOnly;
            ddlJobTypes.Enabled           = !readOnly;
            tbNotificationEmails.ReadOnly = readOnly;
            ddlNotificationStatus.Enabled = !readOnly;
            tbCronExpression.ReadOnly     = readOnly;

            btnSave.Visible = !readOnly;
        }
Пример #28
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="DeviceId">The device identifier.</param>
        public void ShowDetail(int KioskTypeId)
        {
            pnlDetails.Visible = true;
            KioskType KioskType = null;

            var checkinContext = new RockContext();

            if (!KioskTypeId.Equals(0))
            {
                KioskType         = new KioskTypeService(checkinContext).Get(KioskTypeId);
                lActionTitle.Text = ActionTitle.Edit(KioskType.FriendlyTypeName).FormatAsHtmlTitle();
            }

            if (KioskType == null)
            {
                KioskType = new KioskType {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(KioskType.FriendlyTypeName).FormatAsHtmlTitle();
            }

            hfKioskTypeId.Value = KioskType.Id.ToString();

            tbName.Text        = KioskType.Name;
            tbDescription.Text = KioskType.Description;
            tbMessage.Text     = KioskType.Message;

            Locations = new Dictionary <int, string>();
            foreach (var location in KioskType.Locations)
            {
                string path           = location.Name;
                var    parentLocation = location.ParentLocation;
                while (parentLocation != null)
                {
                    path           = parentLocation.Name + " > " + path;
                    parentLocation = parentLocation.ParentLocation;
                }
                Locations.Add(location.Id, path);
            }

            Schedules = new Dictionary <int, string>();
            foreach (var schedule in KioskType.Schedules)
            {
                Schedules.Add(schedule.Id, schedule.Name);
            }

            BindDropDownList(KioskType);
            BindLocations();
            BindSchedules();

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(KioskType.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(KioskType.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            tbName.ReadOnly        = readOnly;
            tbDescription.ReadOnly = readOnly;

            btnSave.Visible = !readOnly;
        }
Пример #29
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="DeviceId">The device identifier.</param>
        public void ShowDetail(int DeviceId)
        {
            pnlDetails.Visible = true;
            Device Device = null;

            var rockContext = new RockContext();

            if (!DeviceId.Equals(0))
            {
                Device            = new DeviceService(rockContext).Get(DeviceId);
                lActionTitle.Text = ActionTitle.Edit(Device.FriendlyTypeName).FormatAsHtmlTitle();
                pdAuditDetails.SetEntity(Device, ResolveRockUrl("~"));
            }

            if (Device == null)
            {
                Device = new Device {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(Device.FriendlyTypeName).FormatAsHtmlTitle();
                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            LoadDropDowns();

            hfDeviceId.Value = Device.Id.ToString();

            tbName.Text        = Device.Name;
            tbDescription.Text = Device.Description;
            tbIpAddress.Text   = Device.IPAddress;
            ddlDeviceType.SetValue(Device.DeviceTypeValueId);
            ddlPrintTo.SetValue(Device.PrintToOverride.ConvertToInt().ToString());
            ddlPrinter.SetValue(Device.PrinterDeviceId);
            ddlPrintFrom.SetValue(Device.PrintFrom.ConvertToInt().ToString());

            SetPrinterVisibility();
            SetPrinterSettingsVisibility();

            string orgLocGuid = GlobalAttributesCache.Read().GetValue("OrganizationAddress");

            if (!string.IsNullOrWhiteSpace(orgLocGuid))
            {
                Guid locGuid = Guid.Empty;
                if (Guid.TryParse(orgLocGuid, out locGuid))
                {
                    var location = new LocationService(rockContext).Get(locGuid);
                    if (location != null)
                    {
                        geopPoint.CenterPoint = location.GeoPoint;
                        geopFence.CenterPoint = location.GeoPoint;
                    }
                }
            }

            if (Device.Location != null)
            {
                geopPoint.SetValue(Device.Location.GeoPoint);
                geopFence.SetValue(Device.Location.GeoFence);
            }

            Locations = new Dictionary <int, string>();
            foreach (var location in Device.Locations)
            {
                string path           = location.Name;
                var    parentLocation = location.ParentLocation;
                while (parentLocation != null)
                {
                    path           = parentLocation.Name + " > " + path;
                    parentLocation = parentLocation.ParentLocation;
                }
                Locations.Add(location.Id, path);
            }
            BindLocations();

            Guid mapStyleValueGuid = GetAttributeValue("MapStyle").AsGuid();

            geopPoint.MapStyleValueGuid = mapStyleValueGuid;
            geopFence.MapStyleValueGuid = mapStyleValueGuid;

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(Device.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(Device.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            tbName.ReadOnly        = readOnly;
            tbDescription.ReadOnly = readOnly;
            tbIpAddress.ReadOnly   = readOnly;
            ddlDeviceType.Enabled  = !readOnly;
            ddlPrintTo.Enabled     = !readOnly;
            ddlPrinter.Enabled     = !readOnly;
            ddlPrintFrom.Enabled   = !readOnly;

            btnSave.Visible = !readOnly;
        }
Пример #30
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="attributeMatrixTemplateId">The attribute matrix template identifier.</param>
        public void ShowDetail(int attributeMatrixTemplateId)
        {
            pnlView.Visible = true;

            AttributeMatrixTemplate attributeMatrixTemplate = null;
            var rockContext = new RockContext();

            if (!attributeMatrixTemplateId.Equals(0))
            {
                attributeMatrixTemplate = new AttributeMatrixTemplateService(rockContext).Get(attributeMatrixTemplateId);
                lActionTitle.Text       = ActionTitle.Edit(AttributeMatrixTemplate.FriendlyTypeName).FormatAsHtmlTitle();
                pdAuditDetails.SetEntity(attributeMatrixTemplate, ResolveRockUrl("~"));
            }

            if (attributeMatrixTemplate == null)
            {
                attributeMatrixTemplate = new AttributeMatrixTemplate {
                    Id = 0
                };
                attributeMatrixTemplate.FormattedLava = AttributeMatrixTemplate.FormattedLavaDefault;

                lActionTitle.Text = ActionTitle.Add(AttributeMatrixTemplate.FriendlyTypeName).FormatAsHtmlTitle();

                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            hfAttributeMatrixTemplateId.Value = attributeMatrixTemplate.Id.ToString();
            tbName.Text          = attributeMatrixTemplate.Name;
            cbIsActive.Checked   = attributeMatrixTemplate.IsActive;
            tbDescription.Text   = attributeMatrixTemplate.Description;
            tbMinimumRows.Text   = attributeMatrixTemplate.MinimumRows.ToString();
            tbMaximumRows.Text   = attributeMatrixTemplate.MaximumRows.ToString();
            ceFormattedLava.Text = attributeMatrixTemplate.FormattedLava;

            var attributeService = new AttributeService(rockContext);

            AttributesState = attributeService.Get(new AttributeMatrixItem().TypeId, "AttributeMatrixTemplateId", attributeMatrixTemplate.Id.ToString()).AsQueryable()
                              .OrderBy(a => a.Order)
                              .ThenBy(a => a.Name)
                              .ToList();

            BindAttributesGrid();

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(AttributeMatrixTemplate.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(AttributeMatrixTemplate.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            tbName.ReadOnly          = readOnly;
            cbIsActive.Enabled       = !readOnly;
            tbDescription.ReadOnly   = readOnly;
            tbMinimumRows.ReadOnly   = readOnly;
            tbMaximumRows.ReadOnly   = readOnly;
            ceFormattedLava.ReadOnly = readOnly;
            btnSave.Visible          = !readOnly;
        }