/// <summary> /// 保存角色、角色功能、角色用户数据 /// </summary> /// <param name="user">用户</param> /// <param name="project">所属系统</param> /// <param name="role">角色</param> /// <param name="roleModules">角色功能</param> /// <param name="roleUsers">角色用户</param> public void SaveRole(int user, int project, Sys_Roles role, Sys_RoleModules[] roleModules, Sys_UserRole[] roleUsers) { using (TransactionScope scope = new TransactionScope()) { if (role.KeyId == 0) { role.ProjID = project; role.RoleCode = AutoRoleCode(project.ToString()); role.CreatedBy = user; role.CreatedOn = DateTime.Now; role.KeyId = _sys_RolesDAO.InsertSys_Roles(role); } else { role.ModifiedBy = user; role.ModifiedOn = DateTime.Now; _sys_RolesDAO.UpdateSys_Roles(role); } var roleModulesDao = new Sys_RoleModulesDAO(); roleModulesDao.SaveRoleModules(roleModules, role.KeyId, user, project); var roleUsersDao = new Sys_UserRoleDAO(); roleUsersDao.SaveRoleUserTable(roleUsers, role.KeyId, user, project); scope.Complete(); } }
/// <summary> /// 返回模块权限 /// </summary> /// <param name="role_id"></param> /// <param name="parent_role_id"></param> /// <param name="module_id"></param> /// <param name="ProjID"></param> /// <returns></returns> public DataTable GetRoleModulesTable(int role_id, int parent_role_id, int module_id, int ProjID) { DataTable source_dt = new Sys_RoleModulesDAO().GetRoleModulesTable(role_id, parent_role_id, module_id, ProjID); DataTable dt = new DataTable(); this.SetRolePrivilegeTableColums(ref dt); foreach (DataRow source_row in source_dt.Rows) { DataRow new_row = dt.NewRow(); this.SetRolePrivilegeTable_DataRow(ref new_row, source_row); dt.Rows.Add(new_row); } return(dt); }