//---------------------------------------------------------------------------------------------
        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);
                }
            }
        }
예제 #2
0
        //-------------------------------------------------------------------
        public override CResultAErreur VerifieDonnees(CObjetDonnee objet)
        {
            CResultAErreur result = CResultAErreur.True;

            try
            {
                CGroupeRestrictionSurType groupe = (CGroupeRestrictionSurType)objet;

                if (groupe.Libelle.Trim() == "")
                {
                    result.EmpileErreur(I.T("The label of the group cannot be empty|291"));
                }

                if (!CObjetDonneeAIdNumerique.IsUnique(groupe, CGroupeRestrictionSurType.c_champLibelle, groupe.Libelle))
                {
                    result.EmpileErreur(I.T("Another group with this label already exists|292"));
                }
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
            }
            return(result);
        }
        //---------------------------------------------------------------------------------------------
        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;
            }
        }
        //----------------------------------------------------------------
        public void Init(IElementARestrictionsSpecifiques element)
        {
            CGroupeRestrictionSurType groupeSel = null;

            if (m_wndListeGroupes.SelectedItems.Count > 0)
            {
                ListViewItem item = m_wndListeGroupes.SelectedItems[0];
                CRelationElement_RestrictionSpecifique rel = item.Tag as CRelationElement_RestrictionSpecifique;
                if (rel != null)
                {
                    groupeSel = rel.GroupeRestriction;
                }
            }
            m_lblLibelleElement.Text    = element.DescriptionElement;
            m_elementARestrictions      = element;
            m_panelDetailGroupe.Visible = false;
            CListeObjetDonneeGenerique <CGroupeRestrictionSurType> lstGroupes = new CListeObjetDonneeGenerique <CGroupeRestrictionSurType>(element.ContexteDonnee);

            m_listeGroupesPossibles.Clear();
            foreach (CGroupeRestrictionSurType groupe in lstGroupes)
            {
                CListeRestrictionsUtilisateurSurType lste = groupe.ListeRestrictions;
                CRestrictionUtilisateurSurType       rest = lste.GetRestriction(element.GetType());
                if (rest.HasRestrictions)
                {
                    m_listeGroupesPossibles.Add(groupe);
                }
            }
            UpdateGroupesPossibles();
            m_wndListeGroupes.BeginUpdate();
            m_wndListeGroupes.Items.Clear();
            m_panelDetailGroupe.Visible = false;
            m_relationEnCours           = null;
            foreach (CRelationElement_RestrictionSpecifique rel in element.ListeRestrictions)
            {
                ListViewItem item = CreateItem(rel);
                m_wndListeGroupes.Items.Add(item);
                if (rel.GroupeRestriction != null)
                {
                    m_listeGroupesPossibles.Remove(rel.GroupeRestriction);
                }
                if (rel.GroupeRestriction.Equals(groupeSel))
                {
                    item.Selected = true;
                }
            }
            m_wndListeGroupes.EndUpdate();


            m_arbreGroupes.BeginUpdate();
            m_arbreGroupes.Nodes.Clear();
            CListeObjetsDonnees lstGroupesActeurs = new CListeObjetsDonnees(m_elementARestrictions.ContexteDonnee, typeof(CGroupeActeur));

            foreach (CGroupeActeur groupe in lstGroupesActeurs)
            {
                if (groupe.RelationsGroupesNecessaires.Count == 0)
                {
                    AddNodeGroupe(groupe, m_arbreGroupes.Nodes);
                }
            }
            m_arbreGroupes.EndUpdate();
        }
        //---------------------------------------------------------------------------------------------
        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);
        }