Beispiel #1
0
        public override void Create(CompteRendu compteRendu)
        {
            SqlCommand commande = Connexion.GetInstance().CreateCommand();

            commande.CommandText = "INSERT INTO compterendu (idVisiteurMedical,idContact,idEtablissement,titre,contenu,date) VALUES (@idVisiteurMedical,@idContact,@idEtablissement,@titre,@contenu,@date); SELECT SCOPE_IDENTITY()";
            commande.Parameters.AddWithValue("@idVisiteurMedical", compteRendu.VisiteurMedicalConcerne.Id);
            commande.Parameters.AddWithValue("@idContact", compteRendu.ContactConcerne.Id);
            commande.Parameters.AddWithValue("@idEtablissement", compteRendu.EtablissementConcerne.Id);
            commande.Parameters.AddWithValue("@titre", compteRendu.Titre);
            commande.Parameters.AddWithValue("@contenu", compteRendu.Contenu);
            commande.Parameters.AddWithValue("@date", compteRendu.Date);

            int newId = Convert.ToInt32(commande.ExecuteScalar());

            compteRendu.Id = newId;

            EchantillonDAO echantillonDao = new EchantillonDAO();

            foreach (Echantillon echantillon in compteRendu.ListeEchantillon)
            {
                echantillonDao.Create(echantillon);
            }
        }
Beispiel #2
0
        public override void Update(CompteRendu compteRendu)
        {
            SqlCommand commande = Connexion.GetInstance().CreateCommand();

            commande.CommandText = "UPDATE compterendu  SET idVisiteurMedical = @idVisiteurMedical, idContact = @idContact, idEtablissement = @idEtablissement, titre = @titre, contenu = @contenu, date = @date WHERE id = @id";
            commande.Parameters.AddWithValue("@id", compteRendu.Id);
            commande.Parameters.AddWithValue("@idVisiteurMedical", compteRendu.VisiteurMedicalConcerne.Id);
            commande.Parameters.AddWithValue("@idContact", compteRendu.ContactConcerne.Id);
            commande.Parameters.AddWithValue("@idEtablissement", compteRendu.EtablissementConcerne.Id);
            commande.Parameters.AddWithValue("@titre", compteRendu.Titre);
            commande.Parameters.AddWithValue("@contenu", compteRendu.Contenu);
            commande.Parameters.AddWithValue("@date", compteRendu.Date);
            commande.ExecuteNonQuery();

            commande.CommandText = "DELETE FROM echantillon WHERE idCompteRendu = @id";
            commande.ExecuteNonQuery();

            EchantillonDAO echantillonDao = new EchantillonDAO();

            foreach (Echantillon echantillon in compteRendu.ListeEchantillon)
            {
                echantillonDao.Create(echantillon);
            }
        }
Beispiel #3
0
        public override CompteRendu Read(int id)
        {
            CompteRendu compteRendu = null;
            SqlCommand  commande    = Connexion.GetInstance().CreateCommand();

            commande.CommandText = "SELECT * FROM compterendu WHERE id = @id";
            commande.Parameters.AddWithValue("@id", id);
            SqlDataReader dataReader = commande.ExecuteReader();

            if (dataReader.Read())
            {
                int      idVisiteurMedical = dataReader.GetInt32(1);;
                int      idContact         = dataReader.GetInt32(2);
                int      idEtablissement   = dataReader.GetInt32(3);
                string   titre             = dataReader.GetString(4);
                string   contenu           = dataReader.GetString(5);
                DateTime date = dataReader.GetDateTime(6);
                dataReader.Close();

                EchantillonDAO     echantillonDao   = new EchantillonDAO();
                List <Echantillon> listeEchantillon = echantillonDao.RetrouverListeEchantillon(id);

                VisiteurMedicalDAO visiteurMedicalDao = new VisiteurMedicalDAO();
                VisiteurMedical    visiteurMedical    = visiteurMedicalDao.Read(idVisiteurMedical);

                ContactDAO contactDao = new ContactDAO();
                Contact    contact    = contactDao.Read(idContact);

                EtablissementDAO etablissementDao = new EtablissementDAO();
                Etablissement    etablissement    = etablissementDao.Read(idEtablissement);

                compteRendu = new CompteRendu(id, visiteurMedical, contact, etablissement, titre, contenu, date, listeEchantillon);
            }

            return(compteRendu);
        }