예제 #1
0
 public static AdherentDAO GetUnDetailAdherentDAO()
 {
     if (unDetailAdherentDAO == null)
     {
         unDetailAdherentDAO = new AdherentDAO();
     }
     return(unDetailAdherentDAO);
 }
예제 #2
0
        // Affichage détail élève
        public static List <Adherent> GetDetailAdherents()
        {
            int      id_adherent;
            string   nom_adherent;
            string   prenom_adherent;
            DateTime ddn_adherent;
            long     numtel_adherent;
            string   email_adherent;
            long     numparent_adherent;
            string   autoprelev_adherent;
            string   sexe_adherent;
            DateTime datemaj_adherent;
            string   archive_adherent;
            int      id_classe;
            string   classe;
            Adherent unDetailAdherentDAO;

            // Connexion à la BD
            SqlConnection maConnexion = ConnexionBD.GetConnexionBD().GetSqlConnexion();
            // Création d'une liste vide d'objets Adherents
            List <Adherent> lesAdherents = new List <Adherent>();
            SqlCommand      cmd          = new SqlCommand();

            cmd.Connection  = maConnexion;
            cmd.CommandText = "SELECT id_adherent, nom_adherent, prenom_adherent, ddn_adherent, numtel_adherent, email_adherent, numparent_adherent, autoprelev_adherent, sexe_adherent, datemaj_adherent, archive_adherent, libelle_classe, adh.id_classe FROM dbo.adherent as adh, dbo.classe as c WHERE adh.id_classe = c.id_classe";
            SqlDataReader monReader = cmd.ExecuteReader();

            // Remplissage de la liste
            while (monReader.Read())
            {
                id_adherent        = Int32.Parse(monReader["id_adherent"].ToString());
                ddn_adherent       = DateTime.Parse(monReader["ddn_adherent"].ToString());
                numtel_adherent    = long.Parse(monReader["numtel_adherent"].ToString());
                numparent_adherent = long.Parse(monReader["numparent_adherent"].ToString());
                datemaj_adherent   = DateTime.Parse(monReader["datemaj_adherent"].ToString());
                id_classe          = Int32.Parse(monReader["id_classe"].ToString());

                // Nom Adherent
                if (monReader["nom_adherent"] == DBNull.Value)
                {
                    nom_adherent = default(string);
                }
                else
                {
                    nom_adherent = monReader["nom_adherent"].ToString();
                }
                // Prénom Adherent
                if (monReader["prenom_adherent"] == DBNull.Value)
                {
                    prenom_adherent = default(string);
                }
                else
                {
                    prenom_adherent = monReader["prenom_adherent"].ToString();
                }
                // Mail Adherent
                if (monReader["email_adherent"] == DBNull.Value)
                {
                    email_adherent = default(string);
                }
                else
                {
                    email_adherent = monReader["email_adherent"].ToString();
                }

                // Sexe Adherent
                if (monReader["sexe_adherent"] == DBNull.Value)
                {
                    sexe_adherent = default(string);
                }
                else
                {
                    sexe_adherent = monReader["sexe_adherent"].ToString();
                }
                // Archive Adherent
                if (monReader["archive_adherent"] == DBNull.Value)
                {
                    archive_adherent = default(string);
                }
                else
                {
                    archive_adherent = monReader["archive_adherent"].ToString();
                }
                //Classe
                if (monReader["libelle_classe"] == DBNull.Value)
                {
                    classe = default(string);
                }
                else
                {
                    classe = monReader["libelle_classe"].ToString();
                }
                // Autoprelev
                if (monReader["autoprelev_adherent"] == DBNull.Value)
                {
                    autoprelev_adherent = default(string);
                }
                else
                {
                    autoprelev_adherent = monReader["autoprelev_adherent"].ToString();
                }

                unDetailAdherentDAO = new Adherent(id_adherent, nom_adherent, prenom_adherent, ddn_adherent, numtel_adherent, email_adherent, numparent_adherent, autoprelev_adherent, sexe_adherent, datemaj_adherent, archive_adherent, id_classe, classe);
                lesAdherents.Add(unDetailAdherentDAO);
            }
            // Fermeture de la connexion
            maConnexion.Close();
            return(lesAdherents);
        }