Пример #1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            string OldPassword       = txtOldPassword.Text;
            string NewPassword       = txtNewPassword.Text;
            string ConfirmedPassword = txtConfirmPassword.Text;

            if (NewPassword != ConfirmedPassword)
            {
                string msg = "Msg: Your New Password Doesnt match the confirmed Password";
                bll.ShowMessage(lblMsg, msg, true);
            }
            else if (SharedCommons.SharedCommons.GenerateMD5Hash(OldPassword) != user.Password)
            {
                string msg = "Msg: Your Old Password Is Incorrect";
                bll.ShowMessage(lblMsg, msg, true);
            }
            else
            {
                if (SharedCommons.SharedCommons.GenerateMD5Hash(NewPassword) == SharedCommons.SharedCommons.GenerateMD5Hash(OldPassword))
                {
                    string msg = "Your new password can't be similar to the old one";
                    bll.ShowMessage(lblMsg, msg, true);
                }
                else if (!bll.ObeysPasswordPolicy(NewPassword, user.CompanyCode))
                {
                    string msg = "Your new password should have a mixture of uppercase & lowercase letters, special characters i.e ?,$ and numbers";
                    bll.ShowMessage(lblMsg, msg, true);
                }
                else
                {
                    user.Password   = SharedCommons.SharedCommons.GenerateMD5Hash(NewPassword);
                    user.ModifiedBy = user.UserId;
                    Result result = bll.ChangeUsersPassword(user.UserId, user.CompanyCode, user.Password, user.UserType, false, "PASSWORD");
                    if (result.StatusCode == "0")
                    {
                        string msg = "Password Changed Successfully";
                        bll.ShowMessage(lblMsg, msg, false);
                    }
                    else
                    {
                        string msg = result.StatusDesc;
                        bll.ShowMessage(lblMsg, msg, true);
                    }
                }
            }
        }
        catch (Exception ex)
        {
            string msg = "FAILED: " + ex.Message;
            bll.ShowMessage(lblMsg, msg, true);
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            string OldPassword       = txtOldPassword.Text;
            string NewPassword       = txtNewPassword.Text;
            string ConfirmedPassword = txtConfirmPassword.Text;

            if (NewPassword != ConfirmedPassword)
            {
                string msg = "Msg: Your New Password Doesnt match the confirmed Password";
                bll.ShowMessage(lblMsg, msg, true);
            }
            else if (bll.GenerateMD5Hash(OldPassword) != user.Password)
            {
                string msg = "Msg: Your Old Password Is Incorrect";
                bll.ShowMessage(lblMsg, msg, true);
            }
            else
            {
                user.Password   = bll.GenerateMD5Hash(NewPassword);
                user.ModifiedBy = user.Id;
                Result result = bll.ChangeUsersPassword(user.Id, user.BankCode, user.Password);
                if (result.StatusCode == "0")
                {
                    string msg = "Password Changed Successfully";
                    bll.ShowMessage(lblMsg, msg, false);
                }
                else
                {
                    string msg = result.StatusDesc;
                    bll.ShowMessage(lblMsg, msg, true);
                }
            }
        }
        catch (Exception ex)
        {
            string msg = "FAILED: " + ex.Message;
            bll.ShowMessage(lblMsg, msg, true);
        }
    }