//--------------------------------------------------------------------------------------------- public static void RemoveRestrictionForElementDonnantDesRestrictions( IElementARestrictionsSpecifiques elt, CGroupeRestrictionSurType groupe, IElementDonnantDesRestrictions elementDonnantDesRestrictions) { CRelationElement_RestrictionSpecifique rel = GetRelationForGroupeRestriction(elt, groupe); if (rel != null) { CRelationElement_RestrictionSpecifique_Application app = rel.GetRelationFor(elementDonnantDesRestrictions); if (app != null) { app.Delete(true); } } }
//--------------------------------------------------------------------------------------------- public static CRelationElement_RestrictionSpecifique GetRelationForGroupeRestriction(IElementARestrictionsSpecifiques elt, CGroupeRestrictionSurType groupe) { CRelationElement_RestrictionSpecifique rel = new CRelationElement_RestrictionSpecifique(elt.ContexteDonnee); if (rel.ReadIfExists(new CFiltreData( CRelationElement_RestrictionSpecifique.c_champIdElement + "=@1 and " + CRelationElement_RestrictionSpecifique.c_champTypeElement + "=@2 and " + CGroupeRestrictionSurType.c_champId + "=@3", elt.Id, elt.GetType().ToString(), groupe.Id))) { return(rel); } return(null); }
//--------------------------------------------------------------------------------------------- public static void AddRestrictionForElementDonnantDesRestrictions( IElementARestrictionsSpecifiques elt, CGroupeRestrictionSurType groupe, IElementDonnantDesRestrictions elementDonnantDesRestrictions) { CRelationElement_RestrictionSpecifique rel = GetRelationForGroupeRestriction(elt, groupe); if (rel == null) { rel = new CRelationElement_RestrictionSpecifique(elt.ContexteDonnee); rel.CreateNewInCurrentContexte(); rel.ElementLie = elt as CObjetDonneeAIdNumerique; rel.GroupeRestriction = groupe; } CRelationElement_RestrictionSpecifique_Application app = rel.GetRelationFor(elementDonnantDesRestrictions); if (app == null) { app = new CRelationElement_RestrictionSpecifique_Application(elt.ContexteDonnee); app.CreateNewInCurrentContexte(); app.RelationElement_Restriction = rel; app.ElementARestrictions = elementDonnantDesRestrictions; } }