Ejemplo n.º 1
0
        // RECUPERATION RESULTAT BDD POUR RESULTAT SONDAGE  !!!!!!!

        public static Resultat RecupererResultatEnBdd(int idSondage)
        {
            using (SqlConnection connection = new SqlConnection(ConnectString))
            {
                connection.Open();

                SqlCommand command = new SqlCommand(@"SELECT * FROM Sondage,Resultat WHERE ID = @id and FK_Id_sondage = @id", connection);

                command.Parameters.AddWithValue("@id", idSondage);
                SqlDataReader reader = command.ExecuteReader();

                reader.Read();

                int    idsondage      = (int)reader["ID"];
                string question       = (string)reader["Questions"];
                string reponse1       = (string)reader["Reponse1"];
                string reponse2       = (string)reader["Reponse2"];
                string reponse3       = (string)reader["Reponse3"];
                bool   choix          = (bool)reader["Choix"];
                bool   actifOuPas     = (bool)reader["ActiveSondage"];
                int    nbreRep1       = (int)reader["NbreVoteReponse1"];
                int    nbrevoterep2   = (int)reader["NbreVoteReponse2"];
                int    nbrevoteRep3   = (int)reader["NbreVoteReponse3"];
                int    nombreDeVotant = (int)reader["NbreVotant"];
                int    fk_id_sondage  = (int)reader["FK_Id_sondage"];

                Sondage  sondage  = new Sondage(idsondage, question, reponse1, reponse2, reponse3, choix, actifOuPas);
                Resultat resultat = new Resultat(sondage, nbreRep1, nbrevoterep2, nbrevoteRep3, nombreDeVotant, fk_id_sondage);
                return(resultat);
            }
        }
Ejemplo n.º 2
0
        public Resultat(Sondage vote, int nbreVoteReponse1, int nbreVoteReponse2, int nbreVoteReponse3, int nbreTotalVotant, int fK_Id_sondage)
        {
            Vote             = vote;
            NbreVoteReponse1 = nbreVoteReponse1;
            NbreVoteReponse2 = nbreVoteReponse2;
            NbreVoteReponse3 = nbreVoteReponse3;
            NbreTotalVotant  = nbreTotalVotant;

            FK_Id_sondage = fK_Id_sondage;
        }
Ejemplo n.º 3
0
        // REQUETE SQL POUR SAVOIR L'ETAT DU SONDAGE EN BDD

        public static void  EtatDuSondageMiseAjour(Sondage sondage)
        {
            using (SqlConnection connection = new SqlConnection(ConnectString))
            {
                connection.Open();
                SqlCommand command = new SqlCommand("UPDATE Sondage SET ActiveSondage = 1  WHERE ID= @idSond ", connection);
                command.Parameters.AddWithValue("@idSond", sondage.ID);
                command.ExecuteNonQuery();
            }
        }
Ejemplo n.º 4
0
        public Resultat(Sondage vote, int nbreVoteReponse1, int nbreVoteReponse2, int nbreVoteReponse3, int nbreTotalVotant, int fK_Id_sondage, int poucentageRep1, int poucentageRep2, int poucentageRep3)
        {
            Vote             = vote;
            NbreVoteReponse1 = nbreVoteReponse1;
            NbreVoteReponse2 = nbreVoteReponse2;
            NbreVoteReponse3 = nbreVoteReponse3;
            NbreTotalVotant  = nbreTotalVotant;

            FK_Id_sondage  = fK_Id_sondage;
            PoucentageRep1 = poucentageRep1;
            PoucentageRep2 = poucentageRep2;
            PoucentageRep3 = poucentageRep3;
        }
Ejemplo n.º 5
0
 // CREATION D'UN SONDAGE ET INSERTION EN BASE DE DONNEES
 public static int CreerNouveauSondage(Sondage nouvoSondage)
 {
     using (SqlConnection connection = new SqlConnection(ConnectString))
     {
         connection.Open();
         SqlCommand command = new SqlCommand("Insert into Sondage(Questions,Reponse1,Reponse2,Reponse3,Choix,ActiveSondage) OUTPUT Inserted.ID VALUES (@question,@rep1,@rep2,@rep3,@choix,@nonActif)", connection);
         command.Parameters.AddWithValue("@question", nouvoSondage.Questions);
         command.Parameters.AddWithValue("@rep1", nouvoSondage.Reponse1);
         command.Parameters.AddWithValue("@rep2", nouvoSondage.Reponse2);
         command.Parameters.AddWithValue("@rep3", nouvoSondage.Reponse3);
         command.Parameters.AddWithValue("@choix", nouvoSondage.Choix);
         command.Parameters.AddWithValue("@nonActif", nouvoSondage.ActiveSondage);
         int idInserer = (int)command.ExecuteScalar();
         return(idInserer);
     }
 }
Ejemplo n.º 6
0
        // PAGE VOTE SELECTION DES ELEMENTS DE MON SONDAGE POUR POUVOIR VOTER Recuperation de l'id du sondage

        public static Sondage PageDeVote(int idSondage)
        {
            using (SqlConnection connection = new SqlConnection(ConnectString))
            {
                connection.Open();
                SqlCommand command = new SqlCommand("Select * FROM Sondage WHERE ID=@idSondage", connection);
                command.Parameters.AddWithValue("@idSondage", idSondage);
                SqlDataReader dataReader = command.ExecuteReader();
                dataReader.Read();

                int    id         = (int)dataReader["ID"];
                string question   = (string)dataReader["Questions"];
                string reponse1   = (string)dataReader["Reponse1"];
                string reponse2   = (string)dataReader["Reponse2"];
                string reponse3   = (string)dataReader["Reponse3"];
                bool   choix      = (bool)dataReader["Choix"];
                bool   actifOuPas = (bool)dataReader["ActiveSondage"];


                Sondage sondage = new Sondage(id, question, reponse1, reponse2, reponse3, choix, actifOuPas);
                return(sondage);
            }
        }
Ejemplo n.º 7
0
        // REQUETE DESACTIVATION SONDAGE

        public static Sondage DesactiverSondage(int idSondage)
        {
            using (SqlConnection connection = new SqlConnection(ConnectString))
            {
                connection.Open();

                SqlCommand command = new SqlCommand(@"SELECT * FROM Sondage,Resultat WHERE ID = @idSond and FK_Id_sondage = @idSond", connection);
                command.Parameters.AddWithValue("@idSond", idSondage);
                SqlDataReader reader = command.ExecuteReader();
                reader.Read();

                int    idsondage  = (int)reader["ID"];
                string question   = (string)reader["Questions"];
                string reponse1   = (string)reader["Reponse1"];
                string reponse2   = (string)reader["Reponse2"];
                string reponse3   = (string)reader["Reponse3"];
                bool   choix      = (bool)reader["Choix"];
                bool   actifOuPas = (bool)reader["ActiveSondage"];


                Sondage sondage = new Sondage(idsondage, question, reponse1, reponse2, reponse3, choix, actifOuPas);
                return(sondage);
            }
        }
Ejemplo n.º 8
0
 public creationsondage(Sondage nouvoSondage)
 {
     NouvoSondage = nouvoSondage;
 }
Ejemplo n.º 9
0
 public ResultatVote(Sondage resultatVoteSondage, Resultat resultatVoteResultat)
 {
     ResultatVoteSondage  = resultatVoteSondage;
     ResultatVoteResultat = resultatVoteResultat;
 }