Esempio n. 1
0
 //-------------------------------------------------------------------------
 public CFormEditionHoraireJournalier(CHoraireJournalier horaire, CListeObjetsDonnees liste)
     : base(horaire, liste)
 {
     // Cet appel est requis par le Concepteur Windows Form.
     InitializeComponent();
 }
        public void SetUptTest()
        {
            CResultAErreur result = CResultAErreur.True;

            CTimosTestMetierApp.AssureInit();
            m_contexteDonnee = new CContexteDonnee(CTimosTestMetierApp.SessionClient.IdSession, true, false);

            //Création de l'acteur de test
            CActeur acteur = new CActeur(m_contexteDonnee);

            if (!acteur.ReadIfExists(new CFiltreData(CActeur.c_champNom + "=@1",
                                                     c_strNomActeur)))
            {
                acteur.CreateNew();
                acteur.Nom    = c_strNomActeur;
                acteur.Prenom = "Youcef";
                result        = acteur.CommitEdit();
                Assert.IsTrue(result.Result);
            }
            m_nIdActeur = acteur.Id;

            // Création des Types d'occupation horraire
            // Repos
            CTypeOccupationHoraire toRepos = new CTypeOccupationHoraire(m_contexteDonnee);

            if (!toRepos.ReadIfExists(
                    new CFiltreData(CTypeOccupationHoraire.c_champLibelle + "=@1", c_strRepos)))
            {
                toRepos.CreateNew();
                toRepos.Libelle  = c_strRepos;
                toRepos.Priorite = 10;
                result           = toRepos.CommitEdit();
                Assert.IsTrue(result.Result);
            }
            m_nIdOccupationRepos = toRepos.Id;
            // Jour
            CTypeOccupationHoraire toJour = new CTypeOccupationHoraire(m_contexteDonnee);

            if (!toJour.ReadIfExists(
                    new CFiltreData(CTypeOccupationHoraire.c_champLibelle + "=@1", c_strJour)))
            {
                toJour.CreateNew();
                toJour.Libelle  = c_strJour;
                toJour.Priorite = 50;
                result          = toJour.CommitEdit();
                Assert.IsTrue(result.Result);
            }
            m_nIdOccupationJour = toJour.Id;
            // Astreinte
            CTypeOccupationHoraire toAstreinte = new CTypeOccupationHoraire(m_contexteDonnee);

            if (!toAstreinte.ReadIfExists(
                    new CFiltreData(CTypeOccupationHoraire.c_champLibelle + "=@1", c_strAstreinte)))
            {
                toAstreinte.CreateNew();
                toAstreinte.Libelle  = c_strAstreinte;
                toAstreinte.Priorite = 100;
                result = toAstreinte.CommitEdit();
                Assert.IsTrue(result.Result);
            }
            m_nIdOccupationAstreinte = toAstreinte.Id;

            // Création de l'Horaire journalier
            CHoraireJournalier horaire = new CHoraireJournalier(m_contexteDonnee);

            if (!horaire.ReadIfExists(
                    new CFiltreData(CHoraireJournalier.c_champLibelle + "=@1", c_strLabelHoraireJournalier)))
            {
                horaire.CreateNew();
                horaire.Libelle = c_strLabelHoraireJournalier;
                result          = horaire.CommitEdit();
                Assert.IsTrue(result.Result);
            }
            m_nIdHoraireJournalier = horaire.Id;

            // Création du Calendier
            CCalendrier calendrier = new CCalendrier(m_contexteDonnee);

            if (!calendrier.ReadIfExists(
                    new CFiltreData(CCalendrier.c_champLibelle + "=@1", c_strLabelCalendrier)))
            {
                calendrier.CreateNew();
                calendrier.Libelle          = c_strLabelCalendrier;
                calendrier.Acteur           = acteur;
                calendrier.HoraireParDefaut = horaire;
                result = calendrier.CommitEdit();
                Assert.IsTrue(result.Result);
            }
            m_nIdCalendrier = calendrier.Id;

            // CRéation de l'EO de test
            CTypeEntiteOrganisationnelle tpEO = new CTypeEntiteOrganisationnelle(m_contexteDonnee);

            if (!tpEO.ReadIfExists(
                    new CFiltreData(CTypeEntiteOrganisationnelle.c_champLibelle + "=@1", c_strLabelTypeEO)))
            {
                tpEO.CreateNew();
                tpEO.Libelle = c_strLabelTypeEO;
                Assert.IsTrue(tpEO.CommitEdit());
            }
            m_nIdTypeEO = tpEO.Id;

            CEntiteOrganisationnelle eo = new CEntiteOrganisationnelle(m_contexteDonnee);

            if (!eo.ReadIfExists(
                    new CFiltreData(CEntiteOrganisationnelle.c_champLibelle + "=@1", c_strLabelEO)))
            {
                eo.CreateNew();
                eo.Libelle    = c_strLabelEO;
                eo.TypeEntite = tpEO;
                Assert.IsTrue(eo.CommitEdit());
            }
            m_nIdEO = eo.Id;

            // Affecte l'EO à l'acteur de test
            acteur.AjouterEO(m_nIdEO);
        }