예제 #1
0
        protected void btnChangePws_Click(object sender, EventArgs e)
        {
            try
            {
                string pwd        = txtpwd.Value;
                string Oldpwd     = txtOldPwd.Value;
                string Confirmpwd = txtConfirmpwd.Value;
                string user       = Session["userDetails"].ToString();

                aspccEntities dataBase = new aspccEntities();
                User          objuser  = dataBase.Users.Where(x => x.UserName == user && x.PassWord == Oldpwd).First();
                if (objuser == null)
                {
                    DivError.Visible = true;
                    lblErrorMsg.Text = "Old password Incorrect";
                }
                else if (Confirmpwd != pwd)
                {
                    DivError.Visible = true;
                    lblErrorMsg.Text = "Password and Confirm password does not match.";
                }
                else
                {
                    objuser.PassWord = Confirmpwd;
                    dataBase.SaveChanges();
                    Response.Redirect("~/Login.aspx");
                }
            }
            catch (Exception ex)
            {
                DivError.Visible = true;
                lblErrorMsg.Text = "Old password Incorrect";
            }
        }