//添加修改账号 public IActionResult ModifyAdmin() { //展示页面 if (!Request.Method.ToUpper().Equals("POST", StringComparison.OrdinalIgnoreCase) || !Request.HasFormContentType) { // 权限和菜单 ModifyAdminModel model = new ModifyAdminModel(); var layoutModel = this.GetLayoutModel(); if (layoutModel != null) { layoutModel.ToT(ref model); } var roles = CMSAdminBO.GetRoles(0); if (roles != null) { model.Roles = roles.ToList(); } int id = 0; int.TryParse(Request.Query["id"], out id); if (id > 0) { model.PageTitle = "修改账号"; var admin = CMSAdminBO.GetAdminByID(id); if (admin != null && admin.ID > 0) { model.Admin = admin; } } else { model.PageTitle = "添加账号"; } return(View(model)); } else { var msg = new Message(10, "修改失败!"); int id = 0; int.TryParse(Request.Form["id"], out id); string userName = Request.Form["userName"]; string password = Request.Form["password"]; string rePassword = Request.Form["rePassword"]; int roleID = 0; int.TryParse(Request.Form["roleID"], out roleID); byte state = 1; byte.TryParse(Request.Form["state"], out state); var admin = new Admin() { ID = id, UserName = userName, Password = password, RePassword = rePassword, RoleID = roleID, State = state }; if (admin.ID > 0) { msg = CMSAdminBO.UpdateAdminByID(admin); } else { msg = CMSAdminBO.CreateAdmin(admin); } return(new JsonResult(msg)); } }