Ejemplo n.º 1
0
        public static List <ReponseSondage> RecupereListeDereponses(int id)
        {
            using (SqlConnection connection = new SqlConnection(cheminBase))
            {
                connection.Open();

                SqlCommand ListeReponses = new SqlCommand("SELECT* FROM Reponse WHERE FKIDSondage=@ID", connection);
                ListeReponses.Parameters.AddWithValue("@ID", id);
                SqlDataReader datareaderListe = ListeReponses.ExecuteReader();
                datareaderListe.Read();
                List <ReponseSondage> ListeReponse = new List <ReponseSondage>();
                do
                {
                    int            idReponse      = datareaderListe.GetInt32(0);
                    string         Reponse        = datareaderListe.GetString(2);
                    int            NombreDeVote   = datareaderListe.GetInt32(3);
                    ReponseSondage reponseSondage = new ReponseSondage(idReponse, Reponse, NombreDeVote);
                    ListeReponse.Add(reponseSondage);
                }while
                (datareaderListe.Read());

                connection.Close();
                ListeReponses.Parameters.Clear();
                return(ListeReponse);
            }
        }
Ejemplo n.º 2
0
        public static List <ReponseSondage> GetlisteDeReponses(List <string> ListeNonTriee)
        {
            List <ReponseSondage> ListeTriee = new List <ReponseSondage>();

            foreach (string RepValue in ListeNonTriee)
            {
                if (RepValue != "")
                {
                    ReponseSondage reponse = new ReponseSondage(RepValue);
                    ListeTriee.Add(reponse);
                }
            }
            return(ListeTriee);
        }