public ActionResult AdminLogIn(NewAdmin newAdmin) { var uname = newAdmin.Username; var passwd = newAdmin.Password; var que = db.NewAdmins.Where(s => s.Username == uname).FirstOrDefault(); if (que != null) { if (que.Password == passwd) { Session["DeptOfAdmin"] = que.Department; return(RedirectToAction("AdminCanSelect")); } else { ViewBag.pass = "******"; return(View()); } } else { ViewBag.uname = "Invalid Username"; return(View()); } }
private void BtnAdmin_Click(object sender, RoutedEventArgs e) { NewAdmin newAdmin = new NewAdmin(); newAdmin.Show(); this.Close(); }
public ActionResult DeleteConfirmed(int id) { NewAdmin newAdmin = db.NewAdmins.Find(id); db.NewAdmins.Remove(newAdmin); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Username,Password,Department")] NewAdmin newAdmin) { if (ModelState.IsValid) { db.Entry(newAdmin).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(newAdmin)); }
public ActionResult Create([Bind(Include = "Id,Username,Password,Department")] NewAdmin newAdmin) { if (ModelState.IsValid) { db.NewAdmins.Add(newAdmin); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(newAdmin)); }
// GET: NewAdmins/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } NewAdmin newAdmin = db.NewAdmins.Find(id); if (newAdmin == null) { return(HttpNotFound()); } return(View(newAdmin)); }
public async Task <ActionResult> Create(NewAdmin info) { string name, error, loginName; if (CookieHelper.HasCookie(out name, out error) == false) { return(RedirectToAction("", "LoginUI")); } else { new RoleHelper().GetRoles(name, out role, out department1Code, out loginName); ViewData["VisitorRole"] = role; ViewData["username"] = loginName; } try { using (mlrmsEntities db = new mlrmsEntities()) { var userList = db.sysadmin.Where(m => m.AdminCode == info.UserCode); if (userList.Count() > 0) { ModelState.AddModelError("UserCode", "该管理员已存在"); return(View(info)); } sysadmin item = new sysadmin(); item.AdminName = info.UserName; item.CreateDate = DateTime.Now; item.AdminCode = info.UserCode; item.AdminType = 1; item.AdminPwd = EncryptHelper.GetEncrypt("123456"); db.sysadmin.Add(item); int result = await db.SaveChangesAsync(); return(RedirectToAction("", "administrator")); } } catch (Exception ex) { LogHelper.Error("创建管理员失败", ex); ViewData["status"] = "false"; } return(View(info)); }
private void AddAdminBt_Click(object sender, EventArgs e) { var form = new NewAdmin(); form.ShowDialog(this); }