public int RoleAdd(string RoleName, int Status, string Describe, string PerName) { Roles roles = new Roles(); roles.RoleName = RoleName; roles.Status = Status; roles.Describe = Describe; int i = user.RoleAdd(roles); var a = PerName.Split(','); int roleId = user.GetRoleId(); for (int j = 0; j < a.Length; j++) { RolePermissionRelation relation = new RolePermissionRelation(); relation.RoleId = roleId; relation.PermissionId = int.Parse(a[j]); int result = user.RAPermissionAdd(relation); } Users us = (Users)Session["User"]; if (i > 0) { logs.Add(us.ID, "添加角色", 1); } else { logs.Add(us.ID, "添加角色", 0); } return(i); }