/// <summary> /// 更新用户所属角色 /// </summary> /// <returns></returns> public ActionResult UpdateUserRole() { try { if (Session["User"] == null) { throw new Exception("你还未登录,请重新登录。"); } //if (string.IsNullOrEmpty(userID)) throw new Exception("用户ID不能为空。"); UserDbContext uc = new UserDbContext("ConnStr1"); List <Roles> datas = uc.GetRoles(string.Empty, true); if (datas != null) { return(View(datas)); } else { return(View(new List <Roles>())); } } catch (Exception ex) { if (ex.Message != null) { } this.ViewBag.ErrMsg = MisBase.BaseUT.GetRootException(ex).Message; string script = MvcUT.ShowAlertAndHref(this, ex.Message, "Index"); return(Content(script)); } }
// // GET: /User/ public ActionResult Index() { List <MisBase.Users.Roles> list = null; UserDbContext uc = new UserDbContext("ConnStr1"); list = uc.GetRoles(string.Empty, true); if (list == null) { list = new List <Roles>(); } return(View(list)); }
/// <summary> /// 获取角色列表 /// </summary> /// <returns></returns> public JsonResult GetRolesComboBox() { UserDbContext udb = new UserDbContext("ConnStr1"); List <Roles> list = udb.GetRoles(string.Empty, true); var list2 = from r in list select new { RoleID = r.RoleID, RoleName = r.RoleName }; JsonResult jr = Json(list2.ToList(), JsonRequestBehavior.AllowGet); return(jr); }
/// <summary> /// 获取角色列表 /// </summary> /// <returns></returns> public JsonResult GetRoles(string page, string rows) { try { UserDbContext udb = new UserDbContext("ConnStr1"); List <Roles> list = udb.GetRoles(string.Empty, true); var list2 = from r in list select new { r.RoleDesc, r.RoleID, r.RoleLevel, r.RoleName, RoleID2 = r.RoleID }; int pagesizeI = int.Parse(rows); //Request["rows"] int pagenumI = int.Parse(page); //Request["page"] var json = new { total = list2.ToList().Count, rows = list2.ToList().Skip((pagenumI - 1) * pagesizeI).Take(pagesizeI).ToArray() }; return(Json(json, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { if (ex.Message != null) { string str = MisBase.BaseUT.GetRootException(ex).Message; } return(new JsonResult()); } }