Exemplo n.º 1
0
    protected void ChangePasswordPushButton_Click(object sender, EventArgs e)
    {
        string js = "";

        try
        {
            if (ChangeUserPassword.NewPassword == "1234")
            {
                js = "alert('Password can not be set to \"1234\"!');";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "status", js, true);
            }
            else if (ChangeUserPassword.NewPassword == ChangeUserPassword.CurrentPassword)
            {
                js = "alert('New password should be different from the current password');";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "status", js, true);
            }
            else
            {
                BLL_Infra_UserCredentials objUser = new BLL_Infra_UserCredentials();
                int sts = objUser.Update_UserPassword(Convert.ToInt32(Session["USERID"]), DMS.DES_Encrypt_Decrypt.Encrypt(ChangeUserPassword.CurrentPassword.Trim()), DMS.DES_Encrypt_Decrypt.Encrypt(ChangeUserPassword.NewPassword.Trim()));

                if (sts == 1)
                {
                    FormsAuthentication.SignOut();
                    Session.RemoveAll();
                    Session.Abandon();

                    js = "alert('Password has been changed successfully. Please log-in again.');window.location.href='Login.aspx';";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "status", js, true);
                }
                else if (sts == 0)
                {
                    lblMsg.Text = "Current password is incorrect!";
                }
            }
        }
        catch { }
    }