private void SaveData() { var role = new SysRole(); if (RoleID > 0) { role.LoadByIdentity(RoleID); SetData(role); role.Update(); #region 保存角色关系 DataAccess.Delete(typeof(SysRoleRel), string.Format("{0}='{1}'", SysRoleRel.SQLCOL_ROLEID, RoleID)); //从隐藏域中读取勾选的菜单值 var menuIds = SelectedMenuIds.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var menuId in menuIds) { var rel = new SysRoleRel(RoleID, Convert.ToInt32(menuId)); rel.Save(); } #endregion } else { SetData(role); role.Add(); } }