예제 #1
0
        public int Read_IdEchantillon_FromNomConcentration(string nom, int concentration)
        {
            int id = 0;

            if (OpenConnection())
            {
                ProduitDAO          produitManager           = new ProduitDAO();
                EchantillonDonneDAO enchantillonDonneManager = new EchantillonDonneDAO();

                command             = manager.CreateCommand();
                command.CommandText = "SELECT id_echantillon " +
                                      "FROM echantillon " +
                                      "JOIN produit on produit.id_produit = echantillon.id_produit " +
                                      "WHERE produit.nom = @nom AND echantillon.concentration = @concentration";

                command.Parameters.AddWithValue("@nom", nom);
                command.Parameters.AddWithValue("@concentration", concentration);

                // Lecture des résultats
                dataReader = command.ExecuteReader();

                while (dataReader.Read())
                {
                    id = (int)dataReader["id_echantillon"];
                }
                dataReader.Close();
                CloseConnection();
            }

            return(id);
        }
예제 #2
0
        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);
        }
예제 #3
0
        //public void Create(Echantillon echantillon)
        //{
        //    if (OpenConnection())
        //    {
        //        command = manager.CreateCommand();
        //        command.CommandText = "INSERT INTO echantillon " +
        //                              "(id_produit, quantite, concentration, libelle) " +
        //                              "VALUES (@id_produit, @quantite, @concentration, @libelle)";

        //        command.Parameters.AddWithValue("@id_produit", echantillon.Produit.Id_produit);
        //        command.Parameters.AddWithValue("@quantite", echantillon.Quantite);
        //        command.Parameters.AddWithValue("@concentration", echantillon.Concentration);
        //        command.Parameters.AddWithValue("@libelle", echantillon.Libelle);


        //        command.ExecuteNonQuery();

        //        CloseConnection();
        //    }
        //}

        public Echantillon Read(int id_echantillon, bool isReadFromEchantillonDonnes)
        {
            Echantillon echantillon = new Echantillon();

            if (OpenConnection())
            {
                ProduitDAO          produitManager           = new ProduitDAO();
                EchantillonDonneDAO enchantillonDonneManager = new EchantillonDonneDAO();

                command             = manager.CreateCommand();
                command.CommandText = "SELECT * " +
                                      "FROM echantillon " +
                                      "WHERE id_echantillon = @id_echantillon";

                command.Parameters.AddWithValue("@id_echantillon", id_echantillon);

                // Lecture des résultats
                dataReader = command.ExecuteReader();

                while (dataReader.Read())
                {
                    echantillon.Id_echantillon = (int)dataReader["id_echantillon"];
                    echantillon.Produit        = produitManager.Read((int)dataReader["id_produit"], isReadFromEchantillonDonnes);
                    echantillon.Quantite       = (int)dataReader["quantite"];
                    echantillon.Concentration  = (int)dataReader["concentration"];
                    echantillon.Libelle        = (string)dataReader["libelle"];

                    if (!isReadFromEchantillonDonnes)
                    {
                        //Debug.WriteLine("   JE NE SUIS PAS LU ET C BIEN");
                        echantillon.Liste_echantillons_donnes = enchantillonDonneManager.ReadAllFromEchantillon(echantillon);
                    }
                }
                dataReader.Close();
                CloseConnection();
            }

            return(echantillon);
        }