Exemplo n.º 1
0
 protected void gvRules_UpdateCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
 {
     if (e.CommandName == "Update")
     {
         Telerik.Web.UI.RadTextBox txt = (Telerik.Web.UI.RadTextBox)e.Item.FindControl("txtRuleDescription");
         DataTable objDT;
         objDT = (DataTable)Session["DT_Rules"];
         Session["DT_Rules"] = setValue(objDT, e.CommandArgument.ToString(), txt.Text.Trim().ToString());
         gvRules.Rebind();
     }
 }
        protected void gvComments_UpdateCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName.ToString().ToUpper() == "UPDATE")
            {
                Telerik.Web.UI.RadTextBox txt = (Telerik.Web.UI.RadTextBox)e.Item.FindControl("txtRuleDescription");
                DataTable objDT = (DataTable)ViewState["ALERTS"];

                BECommon objBECommon = new BECommon();
                BCommon  objBCommon  = new BCommon();
                objBECommon.IntTransID   = Convert.ToInt64(AppSecurity.Decrypt(Request.QueryString["TransID"].ToString()));
                objBECommon.intTypeID    = 1;
                objBECommon.intCommentID = Convert.ToInt32(e.CommandArgument);
                objBECommon.StrComments  = txt.Text.Trim();
                objBCommon.BDeleteUpdateAlerts(objBECommon);
                ViewState["ALERTS"]   = objDT;
                gvComments.DataSource = objDT;
                gvComments.DataBind();
                BindTransactionsComments();
            }
        }
        protected void ActivityThresholdsGrid_OnItemDataBound(Object sender, Telerik.Web.UI.GridItemEventArgs eventArgs)
        {
            Telerik.Web.UI.RadNumericTextBox thresholdRelativeDateValue;

            Telerik.Web.UI.RadComboBox thresholdRelativeDateQualifier;

            Telerik.Web.UI.RadComboBox thresholdStatusSelection;

            Telerik.Web.UI.RadComboBox thresholdActionSelection;

            Client.Core.Activity.ActivityThreshold threshold;

            System.Collections.Generic.Dictionary <String, String> bindingContexts;


            if (MercuryApplication == null)
            {
                return;
            }


            if ((eventArgs.Item is Telerik.Web.UI.GridEditableItem) && (eventArgs.Item.IsInEditMode))
            {
                Telerik.Web.UI.GridEditableItem editItem = (Telerik.Web.UI.GridEditableItem)eventArgs.Item;


                switch (eventArgs.Item.OwnerTableView.Name)
                {
                case "Thresholds":

                    thresholdRelativeDateValue = (Telerik.Web.UI.RadNumericTextBox)editItem.FindControl("ActivityThresholdRelativeDateValue");

                    thresholdRelativeDateQualifier = (Telerik.Web.UI.RadComboBox)editItem.FindControl("ActivityThresholdRelativeDateQualifier");

                    thresholdStatusSelection = (Telerik.Web.UI.RadComboBox)editItem.FindControl("ActivityThresholdStatusSelection");


                    // RESERVED IF ACTIONS ARE ADDED TO CARE LEVEL ACTIVITY THRESHOLDS

                    //thresholdActionSelection = (Telerik.Web.UI.RadComboBox)editItem.FindControl ("ActivityThresholdActionSelection");


                    //thresholdActionSelection.Items.Clear ();

                    //thresholdActionSelection.Items.Add (new Telerik.Web.UI.RadComboBoxItem ("* No Action Selected", "0"));

                    //foreach (Mercury.Server.Application.Action currentAction in MercuryApplication.ActionsAvailable (false)) {

                    //    thresholdActionSelection.Items.Add (new Telerik.Web.UI.RadComboBoxItem (currentAction.Name, currentAction.Id.ToString ()));

                    //}


                    if (eventArgs.Item.ItemIndex != -1)
                    {
                        threshold = EditCareInterventionActivity.SortedThresholds.Values[eventArgs.Item.ItemIndex];

                        if (threshold != null)
                        {
                            thresholdRelativeDateValue.Value = threshold.RelativeDateValue;

                            thresholdRelativeDateQualifier.SelectedValue = threshold.RelativeDateQualifier.ToString();

                            thresholdStatusSelection.SelectedValue = ((Int32)threshold.Status).ToString();


                            // RESERVED IF ACTIONS ARE ADDED TO CARE LEVEL ACTIVITY THRESHOLDS

                            // thresholdActionSelection.SelectedValue = threshold.Action.Id.ToString ();
                        }
                    }

                    break;

                case "ThresholdParameters":     // RESERVED IF ACTIONS ARE ADDED TO CARE LEVEL ACTIVITY THRESHOLDS

                    Int64 thresholdKey = Int64.Parse((String)((Telerik.Web.UI.GridEditableItem)eventArgs.Item).OwnerTableView.DataKeyValues[eventArgs.Item.ItemIndex]["ThresholdKey"]);

                    threshold = EditCareInterventionActivity.SortedThresholds[thresholdKey];

                    String parameterName = (String)editItem.OwnerTableView.DataKeyValues[eventArgs.Item.ItemIndex]["ParameterName"];

                    Telerik.Web.UI.RadComboBox parameterValueSelection = (Telerik.Web.UI.RadComboBox)eventArgs.Item.FindControl("ActivityThresholdParameterValue");

                    Telerik.Web.UI.RadTextBox parameterFixedValue = (Telerik.Web.UI.RadTextBox)eventArgs.Item.FindControl("ActivityThresholdParameterFixedValue");


                    parameterValueSelection.Items.Clear();

                    if (!threshold.Action.ActionParameters[parameterName].Required)
                    {
                        parameterValueSelection.Items.Add(new Telerik.Web.UI.RadComboBoxItem("* Not Assigned", "0"));
                    }



                    bindingContexts = (new Client.Core.Individual.Case.MemberCase(MercuryApplication)).ParameterValueSelection(threshold.Action.ActionParameters[parameterName].DataType);

                    foreach (String currentBindingContextName in bindingContexts.Keys)
                    {
                        parameterValueSelection.Items.Add(new Telerik.Web.UI.RadComboBoxItem(currentBindingContextName, bindingContexts[currentBindingContextName]));
                    }

                    parameterFixedValue.Enabled = threshold.Action.ActionParameters[parameterName].AllowFixedValue;

                    parameterFixedValue.EmptyMessage = (threshold.Action.ActionParameters[parameterName].AllowFixedValue) ? String.Empty : "(Not Available)";

                    parameterFixedValue.Text = String.Empty;

                    break;
                }
            }

            return;
        }
        protected void WorkQueueItemsGrid_OnNeedDataSource(Object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            if (!e.IsFromDetailTable)
            {
                // MASTER TABLE VIEW NEEDS DATA SOURCE

                switch (e.RebindReason)
                {
                case Telerik.Web.UI.GridRebindReason.InitialLoad:

                case Telerik.Web.UI.GridRebindReason.ExplicitRebind:

                case Telerik.Web.UI.GridRebindReason.PostBackEvent:                 // ALL DATA IS PRE-LOADED

                case Telerik.Web.UI.GridRebindReason.PostbackViewStateNotPersisted: // ALL DATA IS PRE-LOADED


                    Int64 filteredItems = 0;

                    Int64 totalItems = 0;

                    Int32 filterNodeState;


                    List <Mercury.Server.Application.DataFilterDescriptor> filters = new List <Mercury.Server.Application.DataFilterDescriptor> ();

                    filters.Add(MercuryApplication.CreateFilterDescriptor("WorkQueueId", Mercury.Server.Application.DataFilterOperator.IsEqualTo, WorkQueueSelected.Id));


                    totalItems = MercuryApplication.WorkQueueItemsGetCount(filters, false);

                    #region Create Filters from Selections

                    filterNodeState = FilterNodeState("FilterIsCompleted");

                    if (filterNodeState != 1)
                    {
                        filters.Add(MercuryApplication.CreateFilterDescriptor("IsCompleted", Mercury.Server.Application.DataFilterOperator.IsEqualTo, (filterNodeState == 2)));
                    }

                    filterNodeState = FilterNodeState("FilterIsAssigned");

                    if (filterNodeState != 1)
                    {
                        filters.Add(MercuryApplication.CreateFilterDescriptor("IsAssigned", Mercury.Server.Application.DataFilterOperator.IsEqualTo, (filterNodeState == 2)));
                    }

                    filterNodeState = FilterNodeState("FilterHasConstraintDatePassed");

                    if (filterNodeState != 1)
                    {
                        filters.Add(MercuryApplication.CreateFilterDescriptor("HasConstraintDatePassed", Mercury.Server.Application.DataFilterOperator.IsEqualTo, (filterNodeState == 2)));
                    }

                    filterNodeState = FilterNodeState("FilterHasThresholdDatePassed");

                    if (filterNodeState != 1)
                    {
                        filters.Add(MercuryApplication.CreateFilterDescriptor("HasThresholdDatePassed", Mercury.Server.Application.DataFilterOperator.IsEqualTo, (filterNodeState == 2)));
                    }

                    filterNodeState = FilterNodeState("FilterHasDueDatePassed");

                    if (filterNodeState != 1)
                    {
                        filters.Add(MercuryApplication.CreateFilterDescriptor("HasDueDatePassed", Mercury.Server.Application.DataFilterOperator.IsEqualTo, (filterNodeState == 2)));
                    }

                    filterNodeState = FilterNodeState("FilterWithinWorkTimeRestrictions");

                    if (filterNodeState != 1)
                    {
                        filters.Add(MercuryApplication.CreateFilterDescriptor("WithinWorkTimeRestrictions", Mercury.Server.Application.DataFilterOperator.IsEqualTo, (filterNodeState == 2)));
                    }


                    if (FilterNodeState("FilterWorkQueueItemName") == 1)
                    {
                        Telerik.Web.UI.RadComboBox FilterWorkQueueItemNameOperatorSelection = (Telerik.Web.UI.RadComboBox)

                                                                                                  ((Telerik.Web.UI.RadTreeView)BasicFiltersSelection.Items[0].FindControl("BasicFiltersTreeView")).FindNodeByValue("FilterWorkQueueItemName").FindControl("FilterWorkQueueItemNameOperatorSelection");

                        Telerik.Web.UI.RadTextBox FilterWorkQueueItemNameValue = (Telerik.Web.UI.RadTextBox)

                                                                                     ((Telerik.Web.UI.RadTreeView)BasicFiltersSelection.Items[0].FindControl("BasicFiltersTreeView")).FindNodeByValue("FilterWorkQueueItemName").FindControl("FilterWorkQueueItemNameValue");


                        switch (FilterWorkQueueItemNameOperatorSelection.SelectedValue)
                        {
                        case "Contains": filters.Add(MercuryApplication.CreateFilterDescriptor("Name", Mercury.Server.Application.DataFilterOperator.Contains, FilterWorkQueueItemNameValue.Text)); break;

                        case "StartsWith": filters.Add(MercuryApplication.CreateFilterDescriptor("Name", Mercury.Server.Application.DataFilterOperator.StartsWith, FilterWorkQueueItemNameValue.Text)); break;

                        case "EndsWith": filters.Add(MercuryApplication.CreateFilterDescriptor("Name", Mercury.Server.Application.DataFilterOperator.EndsWith, FilterWorkQueueItemNameValue.Text)); break;
                        }
                    }

                    if (FilterNodeState("FilterAssignedToDisplayName") == 1)
                    {
                        Telerik.Web.UI.RadComboBox FilterAssignedToDisplayNameOperatorSelection = (Telerik.Web.UI.RadComboBox)

                                                                                                      ((Telerik.Web.UI.RadTreeView)BasicFiltersSelection.Items[0].FindControl("BasicFiltersTreeView")).FindNodeByValue("FilterAssignedToDisplayName").FindControl("FilterAssignedToDisplayNameOperatorSelection");

                        Telerik.Web.UI.RadTextBox FilterAssignedToDisplayNameValue = (Telerik.Web.UI.RadTextBox)

                                                                                         ((Telerik.Web.UI.RadTreeView)BasicFiltersSelection.Items[0].FindControl("BasicFiltersTreeView")).FindNodeByValue("FilterAssignedToDisplayName").FindControl("FilterAssignedToDisplayNameValue");


                        switch (FilterAssignedToDisplayNameOperatorSelection.SelectedValue)
                        {
                        case "Contains": filters.Add(MercuryApplication.CreateFilterDescriptor("AssignedToUserDisplayName", Mercury.Server.Application.DataFilterOperator.Contains, FilterAssignedToDisplayNameValue.Text)); break;

                        case "StartsWith": filters.Add(MercuryApplication.CreateFilterDescriptor("AssignedToUserDisplayName", Mercury.Server.Application.DataFilterOperator.StartsWith, FilterAssignedToDisplayNameValue.Text)); break;

                        case "EndsWith": filters.Add(MercuryApplication.CreateFilterDescriptor("AssignedToUserDisplayName", Mercury.Server.Application.DataFilterOperator.EndsWith, FilterAssignedToDisplayNameValue.Text)); break;
                        }
                    }
                    #endregion


                    // UPDATE COUNT

                    filteredItems = MercuryApplication.WorkQueueItemsGetCount(WorkQueueViewSelected, filters, false);

                    WorkQueueItemsAvailableCount.Text = filteredItems.ToString() + " / " + totalItems.ToString();

                    WorkQueueItemsGrid.VirtualItemCount = Convert.ToInt32(filteredItems);


                    List <Mercury.Server.Application.DataSortDescriptor> sorts = new List <Server.Application.DataSortDescriptor> ();

                    foreach (Telerik.Web.UI.GridSortExpression currentSortExpression in WorkQueueItemsGrid.MasterTableView.SortExpressions)
                    {
                        switch (currentSortExpression.SortOrder)
                        {
                        case Telerik.Web.UI.GridSortOrder.Ascending:

                        case Telerik.Web.UI.GridSortOrder.Descending:

                            sorts.Add(MercuryApplication.CreateSortDescription(currentSortExpression.FieldName, ((currentSortExpression.SortOrder == Telerik.Web.UI.GridSortOrder.Ascending) ? Mercury.Server.Application.DataSortDirection.Ascending : Mercury.Server.Application.DataSortDirection.Descending)));

                            break;
                        }
                    }


                    Int32 initialRow = (WorkQueueItemsGrid.CurrentPageIndex * WorkQueueItemsGrid.PageSize) + 1;

                    List <Client.Core.Work.WorkQueueItem> workQueueItems = MercuryApplication.WorkQueueItemsGetByViewPage(WorkQueueViewSelected, filters, sorts, initialRow, WorkQueueItemsGrid.PageSize, false);

                    WorkQueueItemsGrid.DataSource = workQueueItems;

                    break;

                default:

                    System.Diagnostics.Debug.WriteLine("Unhandled Master Rebind Reason: " + e.RebindReason);

                    break;
                }
            }

            else   // DETAIL TABLE NEEDS DATA SOURCE

            {
                WorkQueueItemsGrid.MasterTableView.DetailTables[0].DataSource = WorkQueueItemSenders;
            }

            return;
        }
Exemplo n.º 5
0
        protected void CarePlanInterventionGrid_OnItemCommand(Object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (MemberCaseCarePlan == null)
            {
                return;
            }

            Mercury.Server.Application.MemberCaseModificationResponse response;

            switch (e.CommandName)
            {
            case Telerik.Web.UI.RadGrid.InitInsertCommandName:

                break;

            case Telerik.Web.UI.RadGrid.PerformInsertCommandName:

                #region Perform Insert of New Intervention


                // RETREIVE REFERENCES TO ALL TEMPLATED CONTROLS

                RadioButtonList AddCarePlanInterventionTypeSelection = (RadioButtonList)e.Item.FindControl("AddCarePlanInterventionTypeSelection");

                if (AddCarePlanInterventionTypeSelection == null)
                {
                    return;
                }

                Telerik.Web.UI.RadTextBox AddCarePlanInterventionName = (Telerik.Web.UI.RadTextBox)e.Item.FindControl("AddCarePlanInterventionName");

                if (AddCarePlanInterventionName == null)
                {
                    return;
                }

                Telerik.Web.UI.RadComboBox AddCarePlanInterventionExistingSelection = (Telerik.Web.UI.RadComboBox)e.Item.FindControl("AddCarePlanInterventionExistingSelection");

                if (AddCarePlanInterventionExistingSelection == null)
                {
                    return;
                }


                Int64 selectedBaselineInterventionId = (AddCarePlanInterventionTypeSelection.SelectedValue == "0") ? Convert.ToInt64(AddCarePlanInterventionExistingSelection.SelectedValue) : 0;

                String carePlanInterventionName = (AddCarePlanInterventionTypeSelection.SelectedValue == "1") ? AddCarePlanInterventionName.Text : String.Empty;


                response = MercuryApplication.MemberCaseCarePlanIntervention_Add(ParentMemberCasePage.Case, MemberCaseCarePlan.Id, selectedBaselineInterventionId, carePlanInterventionName);

                if (response.HasException)
                {
                    ParentMemberCasePage.ExceptionMessage = response.Exception.Message;
                }

                else
                {
                    ParentMemberCasePage.Case = new Client.Core.Individual.Case.MemberCase(MercuryApplication, response.MemberCase);
                }


                #endregion

                break;

            case Telerik.Web.UI.RadGrid.DeleteCommandName:

                //response = MercuryApplication.MemberCaseCarePlanIntervention_Delete (ParentMemberCasePage.Case, CarePlan.Interventions[e.Item.ItemIndex].Id);

                //if (response.HasException) { ParentMemberCasePage.ExceptionMessage = response.Exception.Message; }

                //else { ParentMemberCasePage.Case = new Client.Core.Individual.Case.MemberCase (MercuryApplication, response.MemberCase); }

                break;

            case Telerik.Web.UI.RadGrid.CancelCommandName:

            case Telerik.Web.UI.RadGrid.RebindGridCommandName:

                //CarePlanInterventionGrid.DataSource = CarePlan.Interventions;

                //CarePlanInterventionGrid.DataBind ();

                CarePlanInterventionGrid.Rebind();

                break;

            default:

                break;
            }

            return;
        }
Exemplo n.º 6
0
        private void PopulateLabels()
        {
            Title = SiteUtils.FormatPageTitle(siteSettings, ResourceHelper.GetResourceString("Resource", "ChangePasswordLabel"));

            Control c = Master.FindControl("Breadcrumbs");

            if (c != null)
            {
                BreadcrumbsControl crumbs = (BreadcrumbsControl)c;
                crumbs.ForceShowBreadcrumbs = true;
                crumbs.AddedCrumbs
                    = crumbs.ItemWrapperTop + "<a href='" + SiteRoot + "/Account/ChangePassword.aspx"
                      + "' class='selectedcrumb'>" + ResourceHelper.GetResourceString("Resource", "ChangePasswordLink")
                      + "</a>" + crumbs.ItemWrapperBottom;
            }

            Button changePasswordButton = (Button)ChangePassword1.ChangePasswordTemplateContainer.FindControl("ChangePasswordPushButton");
            Button cancelButton         = (Button)ChangePassword1.ChangePasswordTemplateContainer.FindControl("CancelPushButton");

            if (changePasswordButton != null)
            {
                changePasswordButton.Text = ResourceHelper.GetResourceString("Resource", "ChangePasswordButton");
            }
            else
            {
                log.Debug("couldn't find changepasswordbutton so couldn't set label");
            }

            if (cancelButton != null)
            {
                cancelButton.Text = ResourceHelper.GetResourceString("Resource", "ChangePasswordCancelButton");
            }
            else
            {
                log.Debug("couldn't find cancelbutton so couldn't set label");
            }

            this.ChangePassword1.CancelDestinationPageUrl
                = SiteUtils.GetNavigationSiteRoot() + "/Account/UserProfile.aspx";

            this.ChangePassword1.ChangePasswordFailureText
                = ResourceHelper.GetResourceString("Resource", "ChangePasswordFailureText");

            CompareValidator newPasswordCompare
                = (CompareValidator)ChangePassword1.ChangePasswordTemplateContainer.FindControl("NewPasswordCompare");

            if (newPasswordCompare != null)
            {
                newPasswordCompare.ErrorMessage = ResourceHelper.GetResourceString("Resource", "ChangePasswordMustMatchConfirmMessage");
                newPasswordCompare.ToolTip      = ResourceHelper.GetResourceString("Resource", "ChangePasswordMustMatchConfirmMessage");
            }

            RequiredFieldValidator confirmNewPasswordRequired
                = (RequiredFieldValidator)ChangePassword1.ChangePasswordTemplateContainer.FindControl("ConfirmNewPasswordRequired");

            if (confirmNewPasswordRequired != null)
            {
                confirmNewPasswordRequired.ErrorMessage = ResourceHelper.GetResourceString("Resource", "ChangePasswordConfirmPasswordRequiredMessage");
                confirmNewPasswordRequired.ToolTip      = ResourceHelper.GetResourceString("Resource", "ChangePasswordConfirmPasswordRequiredMessage");
            }

            this.ChangePassword1.ContinueDestinationPageUrl
                = SiteUtils.GetNavigationSiteRoot();

            RequiredFieldValidator newPasswordRequired
                = (RequiredFieldValidator)ChangePassword1.ChangePasswordTemplateContainer.FindControl("NewPasswordRequired");

            if (newPasswordRequired != null)
            {
                newPasswordRequired.ErrorMessage = ResourceHelper.GetResourceString("Resource", "ChangePasswordNewPasswordRequired");
                newPasswordRequired.ToolTip      = ResourceHelper.GetResourceString("Resource", "ChangePasswordNewPasswordRequired");
            }


            RequiredFieldValidator currentPasswordRequired
                = (RequiredFieldValidator)ChangePassword1.ChangePasswordTemplateContainer.FindControl("CurrentPasswordRequired");

            if (currentPasswordRequired != null)
            {
                currentPasswordRequired.ErrorMessage = ResourceHelper.GetResourceString("Resource", "ChangePasswordCurrentPasswordRequiredWarning");
                currentPasswordRequired.ToolTip      = ResourceHelper.GetResourceString("Resource", "ChangePasswordCurrentPasswordRequiredWarning");
            }

            RegularExpressionValidator newPasswordRegex
                = (RegularExpressionValidator)ChangePassword1.ChangePasswordTemplateContainer.FindControl("NewPasswordRegex");

            if (newPasswordRegex != null)
            {
                newPasswordRegex.ErrorMessage = ResourceHelper.GetResourceString("Resource", "ChangePasswordPasswordRegexFailureMessage");
                newPasswordRegex.ToolTip      = ResourceHelper.GetResourceString("Resource", "ChangePasswordPasswordRegexFailureMessage");

                string passwordRegexWarning = MessageTemplate.GetMessage("PasswordStrengthErrorMessage");
                if (passwordRegexWarning.Length > 0)
                {
                    newPasswordRegex.ErrorMessage = passwordRegexWarning;
                    newPasswordRegex.ToolTip      = passwordRegexWarning;
                }

                newPasswordRegex.ValidationExpression = Membership.PasswordStrengthRegularExpression;

                if (Membership.PasswordStrengthRegularExpression.Length == 0)
                {
                    newPasswordRegex.Visible         = false;
                    newPasswordRegex.ValidationGroup = "None";
                }
            }

            CustomValidator newPasswordRulesValidator
                = (CustomValidator)ChangePassword1.ChangePasswordTemplateContainer.FindControl("NewPasswordRulesValidator");

            if (newPasswordRulesValidator != null)
            {
                newPasswordRulesValidator.ServerValidate += new ServerValidateEventHandler(NewPasswordRulesValidator_ServerValidate);
            }

            this.ChangePassword1.SuccessTitleText = String.Empty;
            this.ChangePassword1.SuccessText      = ResourceHelper.GetResourceString("Resource", "ChangePasswordSuccessText");

            if (siteSettings.ShowPasswordStrengthOnRegistration)
            {
                Telerik.Web.UI.RadTextBox NewPassword = (Telerik.Web.UI.RadTextBox)ChangePassword1.ChangePasswordTemplateContainer.FindControl("NewPassword");
                if (NewPassword != null)
                {
                    NewPassword.PasswordStrengthSettings.ShowIndicator = true;
                    NewPassword.PasswordStrengthSettings.RequiresUpperAndLowerCaseCharacters = true;
                    NewPassword.PasswordStrengthSettings.MinimumLowerCaseCharacters          = WebConfigSettings.PasswordStrengthMinimumLowerCaseCharacters;
                    NewPassword.PasswordStrengthSettings.MinimumUpperCaseCharacters          = WebConfigSettings.PasswordStrengthMinimumUpperCaseCharacters;
                    NewPassword.PasswordStrengthSettings.MinimumSymbolCharacters             = siteSettings.MinRequiredNonAlphanumericCharacters;
                    NewPassword.PasswordStrengthSettings.PreferredPasswordLength             = siteSettings.MinRequiredPasswordLength;

                    NewPassword.PasswordStrengthSettings.TextStrengthDescriptions = ResourceHelper.GetResourceString("Resource", "PasswordStrengthDescriptions");
                    NewPassword.PasswordStrengthSettings.CalculationWeightings    = WebConfigSettings.PasswordStrengthCalculationWeightings;
                }
            }

            AddClassToBody("changepasswordpage");
        }
Exemplo n.º 7
0
        void NewPasswordRulesValidator_ServerValidate(
            object source,
            ServerValidateEventArgs args)
        {
            CustomValidator validator = source as CustomValidator;

            validator.ErrorMessage = string.Empty;

            if (args.Value.Length < Membership.MinRequiredPasswordLength)
            {
                args.IsValid = false;
                validator.ErrorMessage
                    += ResourceHelper.GetResourceString("Resource", "ChangePasswordMinimumLengthWarning") + " "
                       + Membership.MinRequiredPasswordLength.ToInvariantString() + "<br />";
                validator.ToolTip
                    += ResourceHelper.GetResourceString("Resource", "ChangePasswordMinimumLengthWarning") + " "
                       + Membership.MinRequiredPasswordLength.ToInvariantString() + "<br />";
            }

            if (!HasEnoughNonAlphaNumericCharacters(args.Value))
            {
                args.IsValid = false;
                validator.ErrorMessage
                    += ResourceHelper.GetResourceString("Resource", "ChangePasswordMinNonAlphanumericCharsWarning")
                       + Membership.MinRequiredNonAlphanumericCharacters.ToInvariantString() + "<br />";
                validator.ToolTip
                    += ResourceHelper.GetResourceString("Resource", "ChangePasswordMinNonAlphanumericCharsWarning")
                       + Membership.MinRequiredNonAlphanumericCharacters.ToInvariantString() + "<br />";
            }

            TextBox currentPassword
                = (TextBox)ChangePassword1.ChangePasswordTemplateContainer.FindControl("CurrentPassword");

            Telerik.Web.UI.RadTextBox newPassword
                = (Telerik.Web.UI.RadTextBox)ChangePassword1.ChangePasswordTemplateContainer.FindControl("NewPassword");

            SiteUser currentUser = SiteUtils.GetCurrentSiteUser();

            if (currentUser != null)
            {
                if (currentPassword != null)
                {
                    switch (Membership.Provider.PasswordFormat)
                    {
                    case MembershipPasswordFormat.Clear:
                        if (currentPassword.Text != currentUser.Password)
                        {
                            args.IsValid = false;
                            validator.ErrorMessage
                                += ResourceHelper.GetResourceString("Resource", "ChangePasswordCurrentPasswordIncorrectWarning") + "<br />";
                            validator.ToolTip
                                += ResourceHelper.GetResourceString("Resource", "ChangePasswordCurrentPasswordIncorrectWarning") + "<br />";
                        }
                        break;

                    case MembershipPasswordFormat.Encrypted:

                        break;

                    case MembershipPasswordFormat.Hashed:

                        break;
                    }
                }
            }

            if ((newPassword != null) && (currentPassword != null))
            {
                if (newPassword.Text == currentPassword.Text)
                {
                    args.IsValid = false;
                    validator.ErrorMessage
                        += ResourceHelper.GetResourceString("Resource", "ChangePasswordNewMatchesOldWarning") + "<br />";
                    validator.ToolTip
                        += ResourceHelper.GetResourceString("Resource", "ChangePasswordNewMatchesOldWarning") + "<br />";
                }
            }
        }