/// <summary>
 /// Compare les propriétés d'une tranche horaire avec une autre
 /// </summary>
 /// <param name="trancheAComparer"></param>
 /// <returns>true si les propriétés sont identiques</returns>
 public bool HasSameProperties(CHoraireJournalier_Tranche trancheAComparer)
 {
     if (trancheAComparer != null &&
         trancheAComparer.HeureDebut == this.HeureDebut &&
         trancheAComparer.HeureFin == this.HeureFin &&
         trancheAComparer.TypeOccupationHoraire == this.TypeOccupationHoraire)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        //-----------------------------------------------------------------------
        /// <summary>
        /// Compare les propriétés d'un jour particlier avec un autre
        /// </summary>
        /// <param name="jpAComparer"></param>
        /// <returns>true si les propriétés sont identiques (définissent une même règle)</returns>
        public bool HasSameProperties(CCalendrier_JourParticulier jpAComparer)
        {
            if (jpAComparer == null)
            {
                return(false);
            }

            if (jpAComparer.Calendrier != this.Calendrier)
            {
                return(false);
            }

            if (jpAComparer.HoraireJournalier != this.HoraireJournalier)
            {
                return(false);
            }

            if (jpAComparer.TypeOccupationHoraire != this.TypeOccupationHoraire)
            {
                return(false);
            }

            // Compare les tranches horaires
            CListeObjetsDonnees listeThis      = this.TranchesHorairesListe;
            CListeObjetsDonnees listeAComparer = jpAComparer.TranchesHorairesListe;

            if (listeThis.Count != listeAComparer.Count)
            {
                return(false);
            }

            // Trier
            listeThis.Tri      = CHoraireJournalier_Tranche.c_champHeureDebut;
            listeAComparer.Tri = CHoraireJournalier_Tranche.c_champHeureDebut;

            for (int i = 0; i < listeThis.Count; i++)
            {
                CHoraireJournalier_Tranche t1 = (CHoraireJournalier_Tranche)listeThis[i];
                CHoraireJournalier_Tranche t2 = (CHoraireJournalier_Tranche)listeAComparer[i];
                if (!t2.HasSameProperties(t1))
                {
                    return(false);
                }
            }

            // Toutes les comparaisons sont OK
            return(true);
        }
        public bool ApplySameProperties(CCalendrier_JourParticulier jpACopier)
        {
            if (jpACopier == null)
            {
                return(false);
            }
            if (jpACopier == this)
            {
                return(true);
            }

            Calendrier            = jpACopier.Calendrier;
            HoraireJournalier     = jpACopier.HoraireJournalier;
            TypeOccupationHoraire = jpACopier.TypeOccupationHoraire;

            //Recopie les tranches sur les existantes
            int nIndex = 0;
            CListeObjetsDonnees listeMesTranches = TranchesHorairesListe;

            foreach (CHoraireJournalier_Tranche tranche in jpACopier.TranchesHorairesListe)
            {
                CHoraireJournalier_Tranche laTrancheQuiMeVa;
                if (nIndex >= listeMesTranches.Count)
                {
                    laTrancheQuiMeVa = new CHoraireJournalier_Tranche(this.ContexteDonnee);
                    laTrancheQuiMeVa.CreateNewInCurrentContexte();
                }
                else
                {
                    laTrancheQuiMeVa = (CHoraireJournalier_Tranche)listeMesTranches[nIndex];
                }
                laTrancheQuiMeVa.JourParticulier       = this;
                laTrancheQuiMeVa.HeureDebut            = tranche.HeureDebut;
                laTrancheQuiMeVa.HeureFin              = tranche.HeureFin;
                laTrancheQuiMeVa.TypeOccupationHoraire = tranche.TypeOccupationHoraire;
                nIndex++;
            }

            for (nIndex = jpACopier.TranchesHorairesListe.Count; nIndex < listeMesTranches.Count; nIndex++)
            {
                if (!((CObjetDonnee)listeMesTranches[nIndex]).Delete())
                {
                    return(false);
                }
            }
            return(true);
        }
        //-------------------------------------------------------------------
        public override CResultAErreur VerifieDonnees(CObjetDonnee objet)
        {
            CResultAErreur result = CResultAErreur.True;

            try
            {
                CHoraireJournalier_Tranche tranche = (CHoraireJournalier_Tranche)objet;

                // Une tranche horaire ne peut être de durée nulle
                if (tranche.HeureFin == tranche.HeureDebut)
                {
                    result.EmpileErreur(
                        I.T("The time slot duration can not be null|164"));
                }
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
            }
            return(result);
        }