public ActionResult Index(DoctorAccount dacount, RegionalCenterAccount reaccount, NationalCenterAccount naccount) { UserOperation UOpertation = new UserOperation(); List <DoctorAccount> SelectedDocs = new List <DoctorAccount>(); List <string> result = new List <string>(); result = UOpertation.userType(dacount); var type = result[0]; var userID = result[1]; if (type != "") { HttpCookie cookie = new HttpCookie("username", reaccount.UserName); HttpCookie cookieID = new HttpCookie("userID", userID); HttpCookie cookieType = new HttpCookie("userType", type); Response.Cookies.Add(cookie); Response.Cookies.Add(cookieID); Response.Cookies.Add(cookieType); if (type == "administrator") { return(RedirectToAction("Index", "Nation")); } if (type == "region") { return(RedirectToAction("Index", "Region")); } if (type == "doctor") { return(RedirectToAction("Index", "EnterPatInfor")); } else { return(View()); } } else { ViewBag.message = "用户名或密码错误"; return(View()); } }
public ActionResult addNewAccount(string userRole, string userName, string realName, string Password) { try { UserOperation uoperation = new UserOperation(); var username = HttpContext.Request.Cookies["username"].Value.ToString(); var userId = HttpContext.Request.Cookies["userID"].Value.ToString(); int userID = Convert.ToInt16(userId); var name = userName; var duplicate = uoperation.duplicaionName(name); if (duplicate) { var type = userRole; if (type == "医生账号") { DoctorAccount daccount = new DoctorAccount(); daccount.UserName = userName; daccount.PassWord = Password; daccount.Hospital = realName; daccount.RegionalCenterAccountID = userID; daccount.ChiefDoctor = realName; RegionalCenterAccount rca = new RegionalCenterAccount();//制定region账号 DataContainer.DoctorAccountSet.Add(daccount); DataContainer.SaveChanges(); } return(this.Json(new { OK = true, Message = "添加成功" })); } else { ViewBag.message = "添加失败,该用户名已存在"; return(this.Json(new { OK = false, Message = "添加失败,此用户名已存在" })); } } catch (DbEntityValidationException dbEx) { var str = dbEx.ToString(); return(this.Json(new { OK = false, Message = str })); } }