Example #1
0
 /// <summary>
 /// 更新组织机构隶属组织机构
 /// </summary>
 /// <param name="organizationUnitId"></param>
 /// <param name="parentOUId"></param>
 /// <returns></returns>
 public AuthorizationDS.OrganizationUnitRow SetOrganizationUnitParentOU(int organizationUnitId, int?parentOUId)
 {
     if (parentOUId != null)
     {
         if (!this.DS.OrganizationUnit.FindByOrganizationUnitId(parentOUId.GetValueOrDefault()).IsActive)
         {
             throw new ApplicationException("组织机构处于非激活状态,不能迁移");
         }
     }
     AuthorizationDS.OrganizationUnitRow ou = this.DS.OrganizationUnit.FindByOrganizationUnitId(organizationUnitId);
     if (parentOUId == null)
     {
         ou.SetParentOrganizationUnitIdNull();
         ou.OrganizationLevel = 0;
     }
     else
     {
         ou.ParentOrganizationUnitId = parentOUId.GetValueOrDefault();
         AuthorizationDS.OrganizationUnitRow parentOR = OrganizationUnitTA.GetDataById(parentOUId.GetValueOrDefault())[0];
         ou.OrganizationLevel = parentOR.OrganizationLevel + 1;
     }
     this.OrganizationUnitTA.Update(ou);
     this.BuildOUOrganizationTreePath(ou);
     return(ou);
 }
Example #2
0
 /// <summary>
 /// 添加组织机构
 /// </summary>
 /// <param name="organizationUnitName"></param>
 /// <param name="organizationUnitCode"></param>
 /// <param name="parentUnitId"></param>
 /// <param name="organizationUnitTypeId"></param>
 /// <returns></returns>
 public AuthorizationDS.OrganizationUnitRow AddOrganizationUnit(string organizationUnitName, string organizationUnitCode, int?parentUnitId, int?organizationUnitTypeId, int?CostCenterID)
 {
     AuthorizationDS.OrganizationUnitRow result = this.DS.OrganizationUnit.NewOrganizationUnitRow();
     result.OrganizationUnitName = organizationUnitName;
     result.OrganizationUnitCode = organizationUnitCode;
     result.IsActive             = true;
     if (parentUnitId != null)
     {
         result.ParentOrganizationUnitId = parentUnitId.GetValueOrDefault();
         AuthorizationDS.OrganizationUnitRow parentOR = OrganizationUnitTA.GetDataById(parentUnitId.GetValueOrDefault())[0];
         result.OrganizationLevel = parentOR.OrganizationLevel + 1;
     }
     else
     {
         result.OrganizationLevel = 0;
     }
     if (organizationUnitTypeId != null)
     {
         result.OrganizationUnitTypeId = organizationUnitTypeId.GetValueOrDefault();
     }
     if (CostCenterID != null)
     {
         result.CostCenterID = CostCenterID.GetValueOrDefault();
     }
     this.DS.OrganizationUnit.AddOrganizationUnitRow(result);
     this.OrganizationUnitTA.Update(result);
     this.BuildOUOrganizationTreePath(result);
     return(result);
 }