Ejemplo n.º 1
0
        public List <object> QuenMatKhau(string username)
        {
            List <object> ls = new List <object>();

            dt = db.LayDuLieu("select * from TaiKhoan where TaiKhoan='" + username + "'");
            if (dt.Rows.Count <= 0)
            {
                ls.Add(0);
            }
            else
            {
                if (Convert.ToBoolean(dt.Rows[0][2]) == false)
                {
                    ls.Add(-1);
                }
                else
                {
                    ls.Add(1);
                    matkhausesion ctk = new matkhausesion();
                    ctk.tentaikhoan = Convert.ToString(dt.Rows[0][0]);
                    ls.Add(ctk);
                }
            }
            return(ls);
        }
Ejemplo n.º 2
0
        public ActionResult DoiMatKhau(string Password)
        {
            matkhausesion ds = (matkhausesion)Session["matkhau_Session"];
            TaiKhoan      tk = new TaiKhoan();

            tk.UserName = ds.tentaikhoan;
            tk.MatKhau  = Encrypter.MD5Hash(Password);
            tk.Remember = true;
            if (db.Update(tk))
            {
                return(Json(new { success = true, ms = "Thêm thành công" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { success = false, ms = "Thêm khong thành công" }, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 3
0
        public ActionResult QuenMatKhau(TaiKhoan tk)
        {
            // var result = db.CheckAcount(l.UserName, Encrypter.MD5Hash(l.PassWord));


            if (ModelState.IsValid)
            {
                var lk     = db.QuenMatKhau(tk.UserName);
                var result = Convert.ToInt32(lk[0]);
                switch (result)
                {
                case 0:
                    ModelState.AddModelError("", "Tài khoản không tồn tại");
                    break;

                case 1:

                    matkhausesion acc = lk[1] as matkhausesion;
                    Session.Add("matkhau_Session", acc);
                    //SessionHelper.SetSession(new UserSession() { UserName = l.UserName });
                    return(RedirectToAction("DoiMatKhau", "LoginAdmin", acc));

                case -1:
                    ModelState.AddModelError("", "Tài khoản đang bị khóa");
                    break;

                default:
                    ModelState.AddModelError("", "User name không đúng");
                    break;
                }
                ;
            }
            else
            {
                ModelState.AddModelError("", "User name không đúng");
            }
            return(View(tk));
        }