public ActionResult DelAccount(int id) { TBL_ADMIN _id = db.TBL_ADMIN.Find(id); db.TBL_ADMIN.Remove(_id); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult EditAccount(TBL_ADMIN adGet) { var adList = db.TBL_ADMIN.Where(model => model.AD_ID == adGet.AD_ID).FirstOrDefault(); adList.AD_NAME = adGet.AD_NAME; adList.AD_PASSWORD = adGet.AD_PASSWORD; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult tlogin(TBL_ADMIN a) { TBL_ADMIN ad = db.TBL_ADMIN.Where(x => x.AD_Name == a.AD_Name && x.AD_PASSWORD == a.AD_PASSWORD).SingleOrDefault(); if (ad != null) { Session["ad_id"] = ad.AD_ID; return(RedirectToAction("Dashboard")); } else { ViewBag.msg = "Invalid username and Password"; } return(View()); }
public ActionResult AdminLogin(TBL_ADMIN admin) { TBL_ADMIN tblAdmin = database.TBL_ADMIN.Where(x => x.AD_NAME == admin.AD_NAME && x.AD_PASSWORD == admin.AD_PASSWORD).SingleOrDefault(); if (tblAdmin != null) { Session["AD_ID"] = tblAdmin.AD_ID; return(RedirectToAction("DiaryDashboard")); } else { ViewBag.msg = "Invalid Username or Password"; } return(View()); }
public ActionResult AddAccount(TBL_ADMIN adGet) { //Session["AD_ADMIN"] = 1; List <TBL_ADMIN> adList = db.TBL_ADMIN.OrderByDescending(model => model.AD_ID).ToList(); TBL_ADMIN adVar = new TBL_ADMIN(); adVar.AD_NAME = adGet.AD_NAME; adVar.AD_PASSWORD = adGet.AD_PASSWORD; db.TBL_ADMIN.Add(adGet); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Login(FormCollection form) { string taikhoan = form["taikhoan"].ToString(); string matkhau = form["matkhau"].ToString(); TBL_ADMIN adminVar = db.TBL_ADMIN.Where(model => model.AD_NAME == taikhoan && model.AD_PASSWORD == matkhau).SingleOrDefault(); if (adminVar != null) { Session["ADMIN"] = adminVar.AD_ID; return(RedirectToAction("Index", "Home")); } else { ViewBag.Error = "* Sai tài khoản hoặc mật khẩu!"; } return(View()); }