예제 #1
0
        /// <summary>
        /// Remplit les zones de base liées à ce type pour une entrée de Agenda
        /// </summary>
        /// <param name="entree"></param>
        /// <param name="element"></param>
        /// <returns></returns>
        public CResultAErreur InitEntreeManuelleFor(CEntreeAgenda entree, CObjetDonneeAIdNumerique element)
        {
            CResultAErreur result = CResultAErreur.True;

            if (entree == null)
            {
                result.EmpileErreur(I.T("Fill an empty Diary Entry is impossible|345"));
                return(result);
            }
            if (element == null)
            {
                result.EmpileErreur(I.T("Entry creation on null element is impossible|346"));
                return(result);
            }
            entree.TypeEntree = this;
            foreach (CRelationTypeEntreeAgenda_TypeElementAAgenda relation in RelationsTypeElementsAAgenda)
            {
                if (relation.TypeElements == element.GetType() && relation.LienMaitre)
                {
                    CRelationEntreeAgenda_ElementAAgenda newRel = new CRelationEntreeAgenda_ElementAAgenda(entree.ContexteDonnee);
                    newRel.CreateNewInCurrentContexte();
                    newRel.RelationTypeEntree_TypeElement = relation;
                    newRel.ElementLie   = element;
                    newRel.EntreeAgenda = entree;
                    return(result);
                }
            }
            result.EmpileErreur(I.T("No relation on @1 type exists for Diary Entry Type @2|347", element.GetType() + Libelle));
            return(result);
        }
예제 #2
0
        public bool AddElementLieSurType(CObjetDonneeAIdNumerique element, IRelationTypeElementALien_TypeElement relType)
        {
            if (element == null)
            {
                return(false);
            }
            Hashtable tableRelationsExistantes = new Hashtable();
            CRelationEntreeAgenda_ElementAAgenda laRelation = null;

            foreach (CRelationEntreeAgenda_ElementAAgenda rel in RelationsElementsAgenda)
            {
                if (rel.RelationTypeEntree_TypeElement.Id == relType.Id)
                {
                    laRelation = rel;
                    tableRelationsExistantes[rel.ElementLie] = rel;
                }
            }

            bool bCreate = false;

            if (relType.Multiple && element != null)
            {
                if (tableRelationsExistantes[element] == null)
                {
                    bCreate = true;
                }
            }
            else
            {
                if (tableRelationsExistantes.Count != 0)
                {
                    laRelation.ElementLie = element;
                }
                else
                {
                    bCreate = true;
                }
            }
            if (bCreate)
            {
                CRelationEntreeAgenda_ElementAAgenda rel = new CRelationEntreeAgenda_ElementAAgenda(ContexteDonnee);
                rel.CreateNewInCurrentContexte();
                rel.EntreeAgenda = this;
                rel.ElementLie   = element;
                rel.RelationTypeEntree_TypeElement = (CRelationTypeEntreeAgenda_TypeElementAAgenda)relType;
            }
            return(true);
        }