Ejemplo n.º 1
0
        public ActionResult Add(string userName, string passWord, string chucNang, string trangThai)
        {
            ViewBag.Title = "Thêm tài khoản mới";
            var product = new User();

            product.userName  = userName;
            product.passWord  = passWord;
            product.chucNang  = chucNang;
            product.trangThai = trangThai;

            if (ModelState.IsValid)
            {
                try
                {
                    var dao = new DbAcessUsers();
                    dao.AddUser(product);
                    return(RedirectToAction("Index"));
                }
                catch
                {
                }
            }
            ViewBag.Error = "Tên tài khoản đã tồn tại ";
            return(View("Add"));
        }
Ejemplo n.º 2
0
 public ActionResult Delete(int id)
 {
     try
     {
         ViewBag.Title = "Xóa tài khoản";
         var dao = new DbAcessUsers();
         dao.Delete(id);
     }
     catch
     {
     }
     return(Redirect("~/Admin/Account/Index"));
 }
Ejemplo n.º 3
0
        public ActionResult Login(string username, string password)
        {
            ViewBag.Title = "Đăng nhập " + username;
            DbAcessUsers dao  = new DbAcessUsers();
            var          user = dao.GetByUP(username, password);

            if (user != null)
            {
                Session["username"] = username;
                if (user.chucNang == "admin")
                {
                    return(RedirectToAction("../Account/Index"));
                }
                else
                {
                    return(Redirect("../../Home/Index"));
                }
            }
            else
            {
                ViewBag.LoginError = "Đăng nhập không thành công";
                return(View("Login"));
            }
        }