Example #1
0
        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 void ModifyED(int quantite)
        {
            EchantillonDonneDAO echantillonDonneManager = new EchantillonDonneDAO();
            EchantillonDonne    echantillonDonne        = new EchantillonDonne();

            echantillonDonne.Quantite = quantite;
            echantillonDonneManager.Update(echantillonDonne);
        }
Example #3
0
        public void Create(EchantillonDonne echantillon_donne)
        {
            if (OpenConnection())
            {
                command             = manager.CreateCommand();
                command.CommandText = "INSERT INTO echantillon_donne " +
                                      "(id_echantillon, id_rdv, quantite) " +
                                      "VALUES (@id_echantillon ,@id_rdv , @quantite)";
                command.Parameters.AddWithValue("@id_echantillon", echantillon_donne.Echantillon.Id_echantillon);
                command.Parameters.AddWithValue("@id_rdv", echantillon_donne.RendezVous.Id_rdv);
                command.Parameters.AddWithValue("@quantite", echantillon_donne.Quantite);

                command.ExecuteNonQuery();
                CloseConnection();
            }
        }
Example #4
0
        public void Update(EchantillonDonne echantillonDonne)
        {
            if (OpenConnection())
            {
                command             = manager.CreateCommand();
                command.CommandText = "UPDATE echantillon_donne " +
                                      "SET quantite=@quantite " +
                                      "WHERE  id_echantillon=@id " +
                                      "AND id_rdv=@id_rdv";
                command.Parameters.AddWithValue("@id", echantillonDonne.Echantillon.Id_echantillon);
                command.Parameters.AddWithValue("@id_rdv", echantillonDonne.RendezVous.Id_rdv);
                command.Parameters.AddWithValue("@quantite", echantillonDonne.Quantite);

                command.ExecuteNonQuery();

                CloseConnection();
            }
        }
        public string ReadDoubleID(string table, int id1, int id2)
        {
            string response = "";

            if (table.Equals("echantillon_donne"))
            {
                EchantillonDonneDAO  echantillonDonneManager = new EchantillonDonneDAO();
                EchantillonDonne     echantillonDonne        = echantillonDonneManager.Read(id1, id2);
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                if (echantillonDonne == null)
                {
                    response = "null";
                }
                else
                {
                    response = serializer.Serialize(echantillonDonne);
                }
            }

            return(response);
        }
Example #6
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);
        }
        public string AddModifyED(string nom, int concentration, int id_rdv, int quantite, string addOrModify)
        {
            string response = "";
            EchantillonDonneDAO echantillonDonneManager = new EchantillonDonneDAO();
            RendezVousDAO       rendezVousManager       = new RendezVousDAO();
            EchantillonDAO      echantillonManager      = new EchantillonDAO();
            ProduitDAO          produitDAO = new ProduitDAO();

            int echantillonLu = echantillonManager.Read_IdEchantillon_FromNomConcentration(nom, concentration);

            EchantillonDonne echantillonDonne = new EchantillonDonne();

            echantillonDonne.RendezVous  = rendezVousManager.Read(id_rdv, true);
            echantillonDonne.Echantillon = echantillonManager.Read(echantillonLu, true);
            echantillonDonne.Quantite    = quantite;
            echantillonDonne.Produit     = produitDAO.ReadFromNom(nom, true);

            if (addOrModify.Equals("add")) // ADD
            {
                if (echantillonDonneManager.Read(echantillonDonne.Echantillon.Id_echantillon,
                                                 echantillonDonne.RendezVous.Id_rdv) == null)
                {
                    echantillonDonneManager.Create(echantillonDonne);
                    response = "Add done !";
                }
                else
                {
                    response = "Allready exist !";
                }
            }
            else // MODIFY
            {
                echantillonDonneManager.Update(echantillonDonne);
                response = "Modify done !";
            }
            return(response);
        }