public EchantillonDonne Read(int id_echantillon, int id_rdv) { EchantillonDonne echantillonDonne = null; if (OpenConnection()) { command = manager.CreateCommand(); EchantillonDAO echantillonManager = new EchantillonDAO(); RendezVousDAO rendezVousManager = new RendezVousDAO(); command.CommandText = "SELECT * " + "FROM echantillon_donne " + "WHERE id_echantillon = @id_echantillon AND " + "id_rdv = @id_rdv"; command.Parameters.AddWithValue("@id_echantillon", id_echantillon); command.Parameters.AddWithValue("@id_rdv", id_rdv); dataReader = command.ExecuteReader(); while (dataReader.Read()) { echantillonDonne = new EchantillonDonne(); echantillonDonne.Echantillon = echantillonManager.Read((int)dataReader["id_echantillon"], true); echantillonDonne.RendezVous = rendezVousManager.Read((int)dataReader["id_rdv"], true); echantillonDonne.Quantite = (int)dataReader["quantite"]; } dataReader.Close(); CloseConnection(); } return(echantillonDonne); }
public List <EchantillonDonne> ReadAllFromRendezVous(int id_rdv) { List <EchantillonDonne> liste_echantillons_donnes = new List <EchantillonDonne>(); if (OpenConnection()) { EchantillonDonne echantillonDonne = new EchantillonDonne(); EchantillonDAO echantillonManager = new EchantillonDAO(); RendezVousDAO rendezVousManager = new RendezVousDAO(); ProduitDAO produitManager = new ProduitDAO(); command = manager.CreateCommand(); command.CommandText = "SELECT ed.id_echantillon, ed.id_rdv, ed.quantite AS echantillonQuantite, p.id_produit " + "FROM produit p " + "join echantillon e on e.id_produit = p.id_produit " + "join echantillon_donne ed on ed.id_echantillon = e.id_echantillon " + "where id_rdv =@id_rdv "; command.Parameters.AddWithValue("@id_rdv", id_rdv); // Lecture des résultats dataReader = command.ExecuteReader(); Debug.WriteLine("ICI "); while (dataReader.Read()) { echantillonDonne = new EchantillonDonne(); echantillonDonne.Echantillon = echantillonManager.Read((int)dataReader["id_echantillon"], true); echantillonDonne.Produit = produitManager.Read((int)dataReader["id_produit"], true); echantillonDonne.Quantite = (int)dataReader["echantillonQuantite"]; echantillonDonne.RendezVous = rendezVousManager.Read(id_rdv, true); liste_echantillons_donnes.Add(echantillonDonne); } dataReader.Close(); CloseConnection(); } return(liste_echantillons_donnes); }