Ejemplo n.º 1
0
        private void SaveHRMemberEntity()
        {
            if (IsValid)
            {
                try
                {
                    MembershipUser user = ASSecurityManager.GetASPNETUserByMemberID(SecurityMemberID);

                    if (user != null)
                    {
                        user.Email = txtEmailAddress.Text.ToString();

                        if (chkIsUserLocked.Checked == true)
                        {
                            user.IsApproved = false;
                            Membership.UpdateUser(user);
                        }
                        else
                        {
                            user.UnlockUser();
                            user.IsApproved = true;
                            Membership.UpdateUser(user);
                        }



                        MiscUtil.ShowMessage(lblMessage, "Email address has been updated successfully.", false);
                    }
                    else
                    {
                        user = ASSecurityManager.CreateASPNETUserForMember(SecurityMemberID, txtUserID.Text.Trim(), txtPassword.Text.Trim(), txtEmailAddress.Text.Trim());

                        if (chkIsUserLocked.Checked == true)
                        {
                            user.IsApproved = false;
                            Membership.UpdateUser(user);
                        }

                        MiscUtil.ShowMessage(lblMessage, "Login Information has been created successfully.", false);
                    }

                    PrepareInitialView();
                    PrepareEditView();
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
Ejemplo n.º 2
0
        private void SaveMemberAccount()
        {
            try
            {
                Int64 memberID = CurrentMemberID;

                if (memberID > 0)
                {
                    if (CurrentMembershipUser != null)
                    {
                        // validating old password
                        Boolean passwordValidationResult = ASSecurityManager.ValidateASPNETUserPassword(txtUsername.Text, txtOldpassword.Text);

                        if (passwordValidationResult)
                        {
                            ASSecurityManager.ChangeASPNETUserPassword(txtUsername.Text.Trim(), txtOldpassword.Text.Trim(), txtPassword.Text.Trim());

                            MiscUtil.ShowMessage(lblMessage, "Password Changed Successfully", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Incorrect Old Password.", true);
                        }
                    }
                    else
                    {
                        MembershipUser newUser = ASSecurityManager.CreateASPNETUserForMember(CurrentMemberID, txtUsername.Text.Trim(), txtPassword.Text.Trim());

                        if (newUser != null)
                        {
                            MiscUtil.ShowMessage(lblMessage, "New user created successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to create new user.", true);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MiscUtil.ShowMessage(lblMessage, "Failed to create new user.", true);
            }
        }