// ajoute une collection d'atelier a un participant pour la table participer : plusieurs nouvelles occurences possible
        public void dbAjoutAtelier(Benevoles unBenevole, List <Atelier> lesAteliers)
        {
            // ne va servir que lors de la creation d'un nouveau benevoles dans la bdd
            // va update l'id pour qu'il colle a celui en bdd puis va
            unBenevole.updateID();
            DAOFactory db = new DAOFactory();

            db.connecter();

            String req;
            int    i = 0;

            while (lesAteliers.Count > i)
            {
                Atelier unA = lesAteliers[i];

                req = "insert into participer values ( '"
                      + unBenevole.Id + "' , '"
                      + unA.Id + "' ); "

                      + " insert into intervention values ( "
                      + " ' " + unBenevole.Email + " ' , "
                      + unA.Id + " ) ; "
                ;

                db.execSQLWrite(req);
                i++;
            }

            req = " insert into intervenir values ( "
                  + " '" + unBenevole.Email + " ' , "
                  + unBenevole.Id + " ) ; ";

            db.execSQLWrite(req);
        }
        // recree les occurences de la table participer en bdd pour correspondre au derniere modification.
        public void executeParticipe(Benevoles unB, String exMail = null)
        {
            Atelier    unA;
            DAOFactory db = new DAOFactory();

            db.connecter();

            // on detruire les occurences
            String req = "Delete From participer where id = " + unB.Id + " ;"

                         + " delete From intervenir "
                         + " where email ='" + exMail + "' ;"

                         + " delete From intervention "
                         + "where email ='" + exMail + "' ;"
            ;

            db.execSQLWrite(req);


            int i = 0;

            // on les recrees grace a une boucle
            while (i < unB.LesAtelier.Count)
            {
                unA = unB.LesAtelier.ElementAt(i);
                req = "insert into participer values (" + unB.Id + ", "
                      + unA.Id + ") ;"

                      + " insert into intervention values ( "
                      + " '" + unB.Email + " ' , "
                      + unA.Id + " ) ; "


                ;

                i++;
                db.execSQLWrite(req);
            }

            req = " insert into intervenir values ( "
                  + " '" + unB.Email + " ' , "
                  + unB.Id + " ) ; ";

            db.execSQLWrite(req);
        }
Пример #3
0
        public void executeSQLmodifAtelier(Atelier unAtelier)
        {
            String req = "update atelier  set "
                         + " nom = '" + unAtelier.Nom + "' , "
                         + "capacite = " + unAtelier.Capacite
                         + " where id = " + unAtelier.Id + " ;";

            DAOFactory db = new DAOFactory();

            db.connecter();
            db.execSQLWrite(req);
        }
        // recree les occurences de la table participer en bdd pour correspondre au derniere modification.
        public void executeParticipe(Participant unP, String exMail = null)
        {
            Atelier    unA;
            DAOFactory db = new DAOFactory();

            db.connecter();

            String req = "Delete From participer where id = " + unP.Id + " ;";

            db.execSQLWrite(req);

            int i = 0;

            while (i < unP.LesAtelier.Count)
            {
                unA = unP.LesAtelier.ElementAt(i);
                req = "insert into participer values (" + unP.Id + ", "
                      + unA.Id + ") ;";
                i++;
                db.execSQLWrite(req);
            }
        }
        // modifie un participant en bdd
        public void executeSQLmodifInscription(Participant unParticipant)
        {
            String req = "update participants set "
                         + " nom = '" + unParticipant.Nom + "' , "
                         + "prenom = '" + unParticipant.Prenom + "' , "
                         + "adresse = '" + unParticipant.Adresse + "' , "
                         + "portable = '" + unParticipant.Portable + "' , "
                         + "type = '" + unParticipant.Type + "' , "
                         + "nombre_Participation = " + unParticipant.NbParticipant
                         + "where id = " + unParticipant.Id + " ;";

            DAOFactory db = new DAOFactory();

            db.connecter();
            db.execSQLWrite(req);
        }
        } // fin getAllParticipant()

        #region execution BDD inscription

        // inscript un participant en BDD
        public void executeSQLinscription(Participant unParticipant)
        {
            String req = "insert into participants values ( '"
                         + unParticipant.Nom + "' , '"
                         + unParticipant.Prenom + "' , '"
                         + unParticipant.Adresse + "' , '"
                         + unParticipant.Portable + "' , '"
                         + unParticipant.Type + "' , '"
                         + unParticipant.NbParticipant + "' );";

            // req = "insert into participants ( nom, prenom, adresse, portable, type, nombre_Participation)  values ( 'aze' , 'aze', 'az', 'aze', 'truc', 1);";

            DAOFactory db = new DAOFactory();

            db.connecter();
            db.execSQLWrite(req);
        }
        // inscript un Benevole en BDD
        public void executeSQLinscription(Benevoles unParticipant)
        {
            String req = "insert into participants values ( '"
                         + unParticipant.Nom + "' , '"
                         + unParticipant.Prenom + "' , '"
                         + unParticipant.Adresse + "' , '"
                         + unParticipant.Portable + "' , '"
                         + unParticipant.Type + "' , "
                         + unParticipant.NbParticipant + " );" +

                         "insert into intervention values ('" + unParticipant.Email + "' , "
                         + 1 + ") ;"

                         + "insert into intervenir values ('" + unParticipant.Email + "', "
                         + unParticipant.Id + ") ;";

            DAOFactory db = new DAOFactory();

            db.connecter();
            db.execSQLWrite(req);
        }
        // ajoute une collection d'atelier a un participant pour la table participer : plusieurs nouvelles occurences possible
        public void dbAjoutAtelier(Participant unParticipant, List <Atelier> lesAteliers)
        {
            unParticipant.updateID();
            DAOFactory db = new DAOFactory();

            db.connecter();

            int i = 0;

            while (lesAteliers.Count > i)
            {
                Atelier unA = lesAteliers[i];

                String req = "insert into participer values ( '"
                             + unParticipant.Id + "' , '"
                             + unA.Id + "' ); ";


                db.execSQLWrite(req);
                i++;
            }
        }