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")); }
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")); }
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")); } }