protected void btnSave_Click(object sender, EventArgs e)
        {
            string      oldpass = Encryptor.MD5Hash(txtOldPass.Text);
            nguoisudung user    = db.nguoisudungs.SingleOrDefault(x => x.matkhau == oldpass);

            if (user != null)
            {
                if (txtNewPass.Text == txtNewPassAgain.Text)
                {
                    user.matkhau = Encryptor.MD5Hash(txtNewPass.Text);
                    db.SubmitChanges();
                    st.Append("$.notify('Đổi mật khẩu thành công',{className: 'success',globalPosition: 'bottom right'});");
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "", st.ToString(), true);
                }
                else
                {
                    st.Append("$.notify('Mật khẩu nhập lại chưa trùng khớp',{className: 'error',globalPosition: 'bottom right'});");
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "", st.ToString(), true);
                }
            }
            else
            {
                st.Append("$.notify('Mật khẩu cũ chưa đúng',{className: 'error',globalPosition: 'bottom right'});");
                ClientScript.RegisterClientScriptBlock(this.GetType(), "", st.ToString(), true);
            }
        }
示例#2
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string      taikhoan = txtTaiKhoan.Text;
            string      matkhau  = Encryptor.MD5Hash(txtMatKhau.Text);
            nguoisudung user     = db.nguoisudungs.SingleOrDefault(x => x.email == taikhoan && x.matkhau == matkhau);

            if (user != null)
            {
                Session["TaiKhoan"] = taikhoan;
                Session["UserID"]   = user.ma;
                Response.Redirect("Default.aspx");
            }
            else
            {
                st.Append("$.notify('Tài khoản hoặc mật khẩu không đúng',{className: 'error',globalPosition: 'top center'});");
                ClientScript.RegisterClientScriptBlock(this.GetType(), "", st.ToString(), true);
            }
        }