public async Task <ActionResult> Register(TB_LoginOn model) { if (ModelState.IsValid) { using (SubBugEntities db = new SubBugEntities()) { if (await db.TB_LoginOn.FirstOrDefaultAsync(l => l.LoginNo == model.LoginNo) != null) { ModelState.AddModelError("", "用户名已经存在!"); return(View()); } else { model = new TB_LoginOn() { LoginNo = Request.Params["LoginNo"].ToUpper(), LoginPwd = md5.MD5Encrypt(Request.Params["LoginPwd"]), LoginName = Request.Params["LoginName"].ToUpper(), LPhone = Request.Params["LPhone"], ComputerNo = Request.Params["ComputerNo"].ToUpper(), AId = 1 }; db.TB_LoginOn.Add(model); await db.SaveChangesAsync(); return(RedirectToAction("Login", "Account")); } } } return(View(model)); }
public ActionResult DeleteConfirmed(int id) { TB_LoginOn tB_LoginOn = db.TB_LoginOn.Find(id); db.TB_LoginOn.Remove(tB_LoginOn); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "LId,LoginNo,LoginName,LoginPwd,LPhone,ComputerNo,AId")] TB_LoginOn tB_LoginOn) { if (ModelState.IsValid) { db.TB_LoginOn.Add(tB_LoginOn); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AId = new SelectList(db.TB_UserAccess, "AId", "AccessName", tB_LoginOn.AId); return(View(tB_LoginOn)); }
public bool LoginOn(TB_LoginOn login) { using (SubBugEntities db = new SubBugEntities()) { var result = db.TB_LoginOn.Where(l => l.LoginName.Equals(login.LoginName) && l.LoginPwd.Equals(login.LoginPwd)); if (result != null) { return(true); } return(false); } }
public ActionResult SetPwd(TB_LoginOn login) { using (SubBugEntities db = new SubBugEntities()) { var lid = ((TB_LoginOn)Session["LoginName"]).LId; TB_LoginOn lg = db.TB_LoginOn.Where(t => t.LId == lid).FirstOrDefault(); lg.LoginPwd = md5.MD5Encrypt(login.LoginPwd); db.SaveChanges(); Session.Clear(); return(Content("<script>alert('密码修改成功!');window.location.href='Login';</script>")); } }
public ActionResult Edit([Bind(Include = "LId,LoginNo,LoginName,LoginPwd,LPhone,ComputerNo")] TB_LoginOn loginOn) { if (ModelState.IsValid) { using (SubBugEntities db = new SubBugEntities()) { db.Entry(loginOn).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(loginOn)); }
// GET: LoginAccess/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TB_LoginOn tB_LoginOn = db.TB_LoginOn.Find(id); if (tB_LoginOn == null) { return(HttpNotFound()); } return(View(tB_LoginOn)); }
public ActionResult Edit(TB_LoginOn tB_LoginOn) { try { int lid = Convert.ToInt32(Request.Params["LID"]); var lg = db.TB_LoginOn.FirstOrDefault(t => t.LId == lid); lg.AId = tB_LoginOn.AId; db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception) { ViewBag.AId = new SelectList(db.TB_UserAccess, "AId", "AccessName", tB_LoginOn.AId); return(View(tB_LoginOn)); throw; } }
// GET: LoginAccess/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (Session["LoginName"] != null) { var lg = ((TB_LoginOn)Session["LoginName"]).AId; var result = db.TB_LoginOn.Where(t => t.AId == lg); //Console.WriteLine(result); if (lg == 2) { TB_LoginOn tB_LoginOn = db.TB_LoginOn.Find(id); if (tB_LoginOn == null) { return(HttpNotFound()); } return(View(tB_LoginOn)); } } return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); }
// GET: LoginAccess/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (Session["LoginName"] != null) { var lg = ((TB_LoginOn)Session["LoginName"]).AId; var result = db.TB_LoginOn.Where(t => t.AId == lg); //Console.WriteLine(result); if (lg == 2) { TB_LoginOn tB_LoginOn = db.TB_LoginOn.Find(id); if (tB_LoginOn == null) { return(HttpNotFound()); } ViewBag.AId = new SelectList(db.TB_UserAccess, "AId", "AccessName", tB_LoginOn.AId); return(View(tB_LoginOn)); } } return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); }
public bool LoginOn(TB_LoginOn login) { return(service.LoginOn(login)); }