/// <summary> /// 更新职务基本信息 /// </summary> /// <param name="positionId"></param> /// <param name="positionName"></param> /// <param name="positionTypeIds"></param> /// <returns></returns> public AuthorizationDS.PositionRow UpdatePosition(int positionId, string positionName, List <int> positionTypeIds) { AuthorizationDS.PositionRow position = DS.Position.FindByPositionId(positionId); position.PositionName = positionName; PositionTA.Update(position); BusinessObjects.AuthorizationDS.PositionAndPositionTypeRow[] oldPositionTypes = position.GetPositionAndPositionTypeRows(); foreach (AuthorizationDS.PositionAndPositionTypeRow oldPositionType in oldPositionTypes) { if (!positionTypeIds.Contains(oldPositionType.PositionTypeId)) { oldPositionType.Delete(); } else { positionTypeIds.Remove(oldPositionType.PositionTypeId); } } foreach (int positionTypeId in positionTypeIds) { AuthorizationDS.PositionAndPositionTypeRow newPositionType = this.DS.PositionAndPositionType.NewPositionAndPositionTypeRow(); newPositionType.PositionId = position.PositionId; newPositionType.PositionTypeId = positionTypeId; this.DS.PositionAndPositionType.AddPositionAndPositionTypeRow(newPositionType); } this.PositionAndPositionTypeTA.Update(this.DS.PositionAndPositionType); return(position); }
/// <summary> /// 更新职务隶属组织机构 /// </summary> /// <param name="positionId"></param> /// <param name="organizationUnitId"></param> /// <returns></returns> public AuthorizationDS.PositionRow SetPositionParentOU(int positionId, int organizationUnitId) { if (DS.OrganizationUnit.FindByOrganizationUnitId(organizationUnitId).IsActive) { AuthorizationDS.PositionRow position = DS.Position.FindByPositionId(positionId); position.OrganizationUnitId = organizationUnitId; PositionTA.Update(position); this.BuildPositionOrganizationTreePath(position); return(position); } else { throw new ApplicationException("组织机构处于非激活状态,不能迁移"); } }