コード例 #1
0
        public List <Stand> listeStand()
        {
            List <Stand> lesStands = new List <Stand>();

            DAOFactory db = new DAOFactory();

            db.connecter();

            String        req    = "select * from stands;";
            SqlDataReader reader = db.excecSQLRead(req);



            while (reader.Read())
            {
                Stand St = new Stand(

                    id: int.Parse(reader[0].ToString()),
                    idAllee: reader[1].ToString(),
                    idOrdre: reader[2].ToString(),
                    id_equipement: int.Parse(reader[3].ToString()),
                    montantFacture: reader[4].ToString(),
                    nom: reader[5].ToString(),
                    id_partenaires: int.Parse(reader[6].ToString()),
                    surface: reader[7].ToString());


                lesStands.Add(St);
            }

            return(lesStands);
        }
コード例 #2
0
        public List <Partenaire> listePartenaire()
        {
            List <Partenaire> lesPartenaires = new List <Partenaire>();

            DAOFactory db = new DAOFactory();

            db.connecter();

            String        req    = "select * from partenaires;";
            SqlDataReader reader = db.excecSQLRead(req);



            while (reader.Read())
            {
                Partenaire P = new Partenaire(

                    id: int.Parse(reader[0].ToString()),
                    nom: reader[1].ToString(),
                    typePartenaire: int.Parse(reader[2].ToString()));

                lesPartenaires.Add(P);
            }

            return(lesPartenaires);
        }
コード例 #3
0
        public void typePartenaire()
        {
            DAOFactory db = new DAOFactory();

            db.connecter();

            String        req    = "select nom from typePartenaire;";
            SqlDataReader reader = db.excecSQLRead(req);

            reader.Read();
        }
コード例 #4
0
        public void AjouterPartenaire(Partenaire unPartenaire)
        {
            String req = "INSERT INTO partenaires values ( '"
                         + unPartenaire.Nom + "' , '"
                         + unPartenaire.TypePartenaire + "' );";

            DAOFactory daoAddPartenaire = new DAOFactory();

            daoAddPartenaire.connecter();
            daoAddPartenaire.excecSQLRead(req);
        }
コード例 #5
0
        public void ModifierStand(int id_partenaire, String montant, int idStand)
        {
            String req = "UPDATE stands SET id_partenaires = " + id_partenaire +
                         ", montantFacture = " + montant + " where id = " + idStand;


            DAOFactory daoModifStand = new DAOFactory();

            daoModifStand.connecter();
            daoModifStand.excecSQLRead(req);
        }
コード例 #6
0
        // recupere l'id du dernier Benevoles crée en bdd pour le réaffecté au dernier Benevoles inscript en local
        public void bddUpdateID(Benevoles unParticipant)
        {
            DAOFactory db = new DAOFactory();

            db.connecter();

            String        req    = "select max(id) from participants;";
            SqlDataReader reader = db.excecSQLRead(req);

            reader.Read();
            unParticipant.Id = int.Parse(reader[0].ToString());
        }
コード例 #7
0
        // méthode qui génére la liste de tous les Themes.

        public List <Theme> themesParAtelier(int id)
        {
            List <Theme> laListe = new List <Theme>();


            String req = "select themes.nom from atelier INNER JOIN themes ON atelier.id = themes.id_atelier WHERE atelier.id=" + id + ";";

            DAOFactory db = new DAOFactory();

            db.connecter();
            SqlDataReader reader = db.excecSQLRead(req);

            return(laListe);
        }
コード例 #8
0
        // méthode qui génére la liste de tous les Themes.

        public List <Theme> getAllThemes()
        {
            List <Theme> laListe = new List <Theme>();


            String req = "select * from themes;";

            DAOFactory db = new DAOFactory();

            db.connecter();
            SqlDataReader reader = db.excecSQLRead(req);

            return(laListe);
        }
コード例 #9
0
        public void AjouterEquipement(Equipement unEquipement)
        {
            String req = "INSERT INTO equipements values ( '"
                         + unEquipement.ConnexionReseauFilaire + "' , '"
                         + unEquipement.Bar + "' , '"
                         + unEquipement.SalonReception + "' , '"
                         + unEquipement.CabineEssayage + "' , '"
                         + unEquipement.NbrSiege + "' , '"
                         + unEquipement.TablesFournis + "' );";

            DAOFactory daoAddEquipement = new DAOFactory();

            daoAddEquipement.connecter();
            daoAddEquipement.excecSQLRead(req);
        }
コード例 #10
0
        public int bddUpdateID()
        {
            DAOFactory db = new DAOFactory();

            db.connecter();

            String        req1    = "select max(id) from equipements;";
            SqlDataReader reader1 = db.excecSQLRead(req1);

            reader1.Read();

            int idMax = int.Parse(reader1[0].ToString());

            return(idMax);
        }
コード例 #11
0
        public void AjouterStand(Stands unStand)
        {
            String req = "INSERT INTO stands values ( '"
                         + unStand.IdAllee + "' , '"
                         + unStand.IdOrdre + "' , '"
                         + unStand.Equipement + "' , '"
                         + unStand.MontantFacture + "' , '"
                         + unStand.Prix + "' , '"
                         + unStand.Nom + "' , '"
                         + unStand.Id_partenaires + "' );";

            DAOFactory daoAddStand = new DAOFactory();

            daoAddStand.connecter();
            daoAddStand.excecSQLRead(req);
        }
コード例 #12
0
        }     // fin tousLesAteliers()

        // permets de définir la liste de participant a un atelier
        public void dbParticipantunAtelier(Atelier unAtelier)
        {
            Participant        unP = new Participant();
            List <Participant> listParticipents = unP.allParticipant();

            int    idA = unAtelier.Id;
            String req = "Select Pt.id " +
                         "From participer Pr " +
                         "inner join participants Pt Pt.id on Pr.id " +
                         "inner join atelier A A.id on Pr.id_atelier " +
                         "where A.id =" + idA + " order by Pt.id ;";

            DAOFactory db = new DAOFactory();

            db.connecter();
            SqlDataReader reader = db.excecSQLRead(req);

            while (reader.Read())
            {
                int index = int.Parse(reader[0].ToString());
                unP = listParticipents.ElementAt(index);
                unAtelier.ajouterParticipant(unP);
            }
        }
コード例 #13
0
        // méthode qui génére la liste de tous les ateliers.
        public List <Atelier> tousLesAteliers()
        {
            // on  veut recuperai la liste de tous les participants et les rangers dans leurs Class :
            // Soit Participant || Soit Benevoles
            List <Atelier> laListe = new List <Atelier>();

            /**//*
             *
             * String req = "select * from participants Pt " +
             *  "left join participer Pr on Pr.id = Pt.id " +
             *  "left join atelier Ar on Ar.id = Pr.id " +
             *  "left join intervenir Ir on  Pt.id = Ir.id " +
             *  "left join intervention I on Ir.email = I.email " +
             *  "left join participants on Pt.id = Ar.id_participants " +
             *  "order by Pt.id;";
             */
            String req = "select * from atelier Ar " +
                         "left join participants Pt on Pt.id = Ar.id_participants " +
                         "left join participer Pr on Ar.id = Pr.id_atelier " +
                         "left join participants Ps on Pr.id = Ps.id " +
                         "left join intervenir Ir on Pt.id = Ir.id " +
                         "left join intervention I on Ir.email = I.email " +
                         "order by Ar.id;";

            DAOFactory db = new DAOFactory();

            db.connecter();
            SqlDataReader reader = db.excecSQLRead(req);

            int next = -1; // va servir a savoir si on change d'inscript


            while (reader.Read()) // pour chaque ligne on associe 1 inscript a un atelier et son intervenant
            {
                // permets d'avoir les informations sur l'atelier
                int    idAtelier = 0;
                String nomA      = " null ";
                int    capa      = 0;
                if (reader[0].ToString().Length > 0 &&
                    reader[1].ToString().Length > 0 &&
                    reader[2].ToString().Length > 0)
                {
                    idAtelier = int.Parse(reader[0].ToString());
                    nomA      = reader[1].ToString();
                    capa      = int.Parse(reader[2].ToString());
                }

                // sert pour avoir les informations sur l'intervenant de l'atelier
                int    idI              = 0;
                String nomI             = " null ";
                String prenomI          = " null ";
                String adresseI         = " null ";
                String portableI        = " null ";
                String typeI            = " null ";
                int    nbParticipationI = 0;

                if (reader[4].ToString().Length > 0 &&
                    reader[5].ToString().Length > 0 &&
                    reader[6].ToString().Length > 0 &&
                    reader[7].ToString().Length > 0 &&
                    reader[8].ToString().Length > 0 &&
                    reader[9].ToString().Length > 0 &&
                    reader[10].ToString().Length > 0)
                {
                    idI              = int.Parse(reader[4].ToString());
                    nomI             = reader[5].ToString();
                    prenomI          = reader[6].ToString();
                    adresseI         = reader[7].ToString();
                    portableI        = reader[8].ToString();
                    typeI            = reader[9].ToString();
                    nbParticipationI = int.Parse(reader[10].ToString());
                }

                // Permets d'avoir les informations de l'inscript
                int    idP       = 0;
                String nomP      = "";
                String prenomP   = "";
                String adresseP  = "";
                String portableP = "";
                String typeP     = "";
                // int nbParticipation = 0;

                if (reader[12].ToString().Length > 0 &&
                    reader[13].ToString().Length > 0 &&
                    reader[14].ToString().Length > 0 &&
                    reader[15].ToString().Length > 0 &&
                    reader[16].ToString().Length > 0 &&
                    reader[17].ToString().Length > 0 &&
                    reader[18].ToString().Length > 0)
                {
                    idP       = int.Parse(reader[13].ToString());
                    nomP      = reader[14].ToString();
                    prenomP   = reader[15].ToString();
                    adresseP  = reader[16].ToString();
                    portableP = reader[17].ToString();
                    typeP     = reader[18].ToString();
                    // nbParticipation = int.Parse(reader[18].ToString());
                }

                // sert si l'inscript est un Benevole
                String emailB;
                if (reader[20].ToString().Length > 0)
                {
                    emailB = reader[20].ToString();
                }
                else
                {
                    emailB = "impossible";
                }



                // on sait qu'il s'agit d'un intervenant, donc on peu l'initialiser ici
                Participant intervenant = new Participant(idI, nomI, prenomI, adresseI, portableI, typeI);

                // on initialise egalement l'atelier
                Atelier Ar = new Atelier(idAtelier, nomA, capa, intervenant);

                // on verifie qu'on a bien toute les donnee pour cree le Participant
                if (idP.ToString().Length > 0 &&
                    nomP.ToString().Length > 0 &&
                    prenomP.ToString().Length > 0 &&
                    adresseP.ToString().Length > 0 &&
                    portableP.ToString().Length > 0 &&
                    typeP.ToString().Length > 0)
                {
                    // on verifie s'il ne s'agit pas d'un Benevole
                    if (emailB == "impossible")
                    {
                        Participant pt = new Participant(idP, nomP, prenomP, adresseP, portableP, typeP);

                        Ar.ajouterParticipant(pt);
                    }
                    else // sinon il s'agit d'un Benevole
                    {
                        Benevoles bs = new Benevoles(idP,
                                                     nomP,
                                                     prenomP,
                                                     adresseP,
                                                     portableP,
                                                     typeP,
                                                     emailB);

                        Ar.ajouterParticipant(bs);
                    }
                }
                if (next != Ar.Id)
                {
                    next = Ar.Id;

                    laListe.Add(Ar);
                }
                else
                {
                    int indexA = 0;
                    while (indexA < laListe.Count)
                    {
                        Atelier unA = laListe.ElementAt(indexA);
                        if (unA.Id == Ar.Id)
                        {
                            Boolean cancel = false;
                            int     indexP = 0;
                            while (indexP < unA.Participants.Count)
                            {
                                // verifie si les id sont identique,
                                // si oui le participant est deja dans la liste de l'atelier
                                if (unA.Participants.ElementAt(indexP).Id.Equals(Ar.Participants.ElementAt(0).Id))
                                {
                                    cancel = true;
                                }
                                indexP++;
                            }
                            // ne reste faux que si le participants n'est pas deja inscript a l'atelier
                            if (cancel == false)
                            {
                                unA.ajouterParticipant(Ar.Participants.ElementAt(0));
                            }
                        }
                        indexA++;
                    }
                }
            } /**/
            return(laListe);
        }     // fin tousLesAteliers()