/// <summary> /// 加载角色信息 /// </summary> private void LoadRoles() { UsersEO userEO = GetUser(); int leave = GetUserLeave(); // 获取用户等级 // 根据级别绑定用户可选的级别信息 BindddlUserLeave(leave); // 判断开发管理员以上的用户可以对任何用户进行编辑 if (leave >= 90) { this.cblRoles.DataSource = rlManage.Get(" Rl_del = 0", null); } else { IList <MySqlParameter> parm = new List <MySqlParameter>(); StringBuilder strWhere = new StringBuilder(); strWhere.Append(" Rl_id in ( select Rl_id from roleuser where Ur_id =@Ur_id ) and Rl_del = 0 and Rl_name <> @UserEditName "); parm.Add(new MySqlParameter("@Ur_id", GetUserID())); parm.Add(new MySqlParameter("@UserEditName", ConfigurationManager.AppSettings["UserEditName"].ToString())); this.cblRoles.DataSource = rlManage.Get(strWhere.ToString(), parm); //this.cblRoles.DataSource = rlManage.Get(" Rl_id in ( select Rl_id from roleuser where Ur_id = '" + GetUserID() + "') and Rl_del = 0 and Rl_name <> '" + ConfigurationManager.AppSettings["UserEditName"].ToString() + "' "); // 根据用户级别判断该用户是否有用户账号管理的权限 cbAccountManagement.Enabled = false; cbAccountManagement.SelectedValue = userEO.UrId; } this.cblRoles.DataTextField = "Rlname"; this.cblRoles.DataValueField = "RlId"; this.cblRoles.DataBind(); if (this.cblRoles.Items.Count == 0) { this.lkRoleEdit.Visible = true; } }
public ActionResult Detail(int?id) { var _entity = new Domain.SYS_ROLE() { ISCUSTOM = 0 }; if (id != null && id > 0) { _entity = RoleManage.Get(p => p.ID == id); } else { if (!string.IsNullOrEmpty(Request.QueryString["systemId"])) { _entity.FK_BELONGSYSTEM = Request.QueryString["systemId"]; } } ViewData["Systemlist"] = this.SystemManage.LoadSystemInfo(CurrentUser.System_Id); return(View(_entity)); }
public ActionResult Save(Domain.SYS_ROLE entity) { bool isEdit = false; var json = new JsonHelper() { Msg = "保存成功", Status = "n" }; try { if (entity != null) { //判断角色名是否汉字 if (System.Text.RegularExpressions.Regex.IsMatch(entity.ROLENAME.Trim(), "^[\u4e00-\u9fa5]+$")) { if (entity.ROLENAME.Length > 36) { json.Msg = "角色名称最多只能能包含36个汉字"; return(Json(json)); } //添加 if (entity.ID <= 0) { entity.CREATEDATE = DateTime.Now; entity.CREATEPERID = this.CurrentUser.Name; entity.UPDATEDATE = DateTime.Now; entity.UPDATEUSER = this.CurrentUser.Name; } else //修改 { entity.UPDATEDATE = DateTime.Now; entity.UPDATEUSER = this.CurrentUser.Name; isEdit = true; } //判断角色是否重名 if (!this.RoleManage.IsExist(p => p.ROLENAME == entity.ROLENAME && p.ID != entity.ID)) { if (isEdit) { //系统更换 删除所有权限 var _entity = RoleManage.Get(p => p.ID == entity.ID); if (_entity.FK_BELONGSYSTEM != entity.FK_BELONGSYSTEM) { RolePermissionManage.Delete(p => p.ROLEID == _entity.ID); } } if (RoleManage.SaveOrUpdate(entity, isEdit)) { json.Status = "y"; } else { json.Msg = "保存失败"; } } else { json.Msg = "角色名" + entity.ROLENAME + "已被使用,请修改角色名称再提交"; } } else { json.Msg = "角色名称只能包含汉字"; } } else { json.Msg = "未找到需要保存的角色信息"; } if (isEdit) { WriteLog(Common.Enums.enumOperator.Edit, "修改用户角色,结果:" + json.Msg, Common.Enums.enumLog4net.INFO); } else { WriteLog(Common.Enums.enumOperator.Add, "添加用户角色,结果:" + json.Msg, Common.Enums.enumLog4net.INFO); } } catch (Exception e) { json.Msg = "保存用户角色发生内部错误!"; WriteLog(Common.Enums.enumOperator.None, "保存用户角色:", e); } return(Json(json)); }