Example #1
0
 /// <summary>
 /// Ajoute un membre à la base de données
 /// </summary>
 /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
 /// <param name="membreDTO">Le membre à ajouter</param>
 public void Add(string connectionString, MembreDTO membreDTO)
 {
     if (string.IsNullOrEmpty(connectionString))
     {
         throw new DAOException("Les paramètres de connexion n'ont pas été initialisé.");
     }
     try
     {
         using (MySqlConnection connection = new MySqlConnection(connectionString))
         {
             connection.Open();
             MySqlCommand addPreparedStatement = new MySqlCommand(MembreDAO.ADD_REQUEST, connection);
             addPreparedStatement.Parameters.AddWithValue("@nom", membreDTO.Nom);
             addPreparedStatement.Parameters.AddWithValue("@prenom", membreDTO.Prenom);
             addPreparedStatement.Parameters.AddWithValue("@adresse", membreDTO.Adresse);
             addPreparedStatement.Parameters.AddWithValue("@ville", membreDTO.Ville);
             addPreparedStatement.Parameters.AddWithValue("@telephone", membreDTO.Telephone);
             addPreparedStatement.Parameters.AddWithValue("@email", membreDTO.Email);
             addPreparedStatement.Parameters.AddWithValue("@sexe", membreDTO.Sexe);
             addPreparedStatement.Parameters.AddWithValue("@dateNaissance", membreDTO.DateNaissance);
             addPreparedStatement.Prepare();
             addPreparedStatement.ExecuteNonQuery();
         }
     }
     catch (MySqlException mySqlException)
     {
         throw new DAOException(mySqlException.Message, mySqlException);
     }
 }
 public FormInscription(GestionSport gestionSport, MembreDTO membreDTO)
 {
     FormIsLoading = true;
     gestionSportApp = gestionSport;
     MembreDTO = membreDTO;
     InitializeComponent();
 }
 public void Delete(string connectionString, MembreDTO membreDTO)
 {
     try
     {
         this.membreDAO.Delete(connectionString, membreDTO);
     }
     catch (DAOException daoException)
     {
         throw new ServiceException(daoException.Message, daoException);
     }
 }
 public void ModifierMembre(string connectionString, MembreDTO membreDTO)
 {
     try
     {
         membreService.ModifierMembre(connectionString, membreDTO);
     }
     catch (ServiceException serviceException)
     {
         throw new FacadeException(serviceException.Message, serviceException);
     }
 }
 public void Inscrire(string connectionString, MembreDTO membreDTO, SeanceDTO seanceDTO)
 {
     try
     {
         inscriptionService.Inscrire(connectionString, membreDTO, seanceDTO);
     }
     catch (ServiceException serviceException)
     {
         throw new FacadeException(serviceException.Message, serviceException);
     }
 }
 public MembreDTO RechercherMembre(string connectionString, MembreDTO membreDTO)
 {
     MembreDTO membreRecherche = null;
     try
     {
         membreRecherche = this.membreService.RechercherMembre(connectionString, membreDTO);
     }
     catch (ServiceException serviceException)
     {
         throw new FacadeException(serviceException.Message, serviceException);
     }
     return membreRecherche;
 }
 public MembreDTO Find(string connectionString, MembreDTO membreDTO)
 {
     MembreDTO membreRecherche = null;
     try
     {
         membreRecherche = this.membreDAO.Find(connectionString, membreDTO);
     }
     catch (DAOException daoException)
     {
         throw new ServiceException(daoException.Message, daoException);
     }
     return membreRecherche;
 }
 public List<VisiteDTO> RechercherVisitesParMembre(string connectionString, MembreDTO membreDTO)
 {
     List<VisiteDTO> visitesRecherche = null;
     try
     {
         visitesRecherche = this.visiteService.RechercherVisitesParMembre(connectionString, membreDTO);
     }
     catch (ServiceException serviceException)
     {
         throw new FacadeException(serviceException.Message, serviceException);
     }
     return visitesRecherche;
 }
        public MembreDTO GetSelectedMembre(GestionSport gestionSport)
        {
            MembreDTO membreSelected = null;
            var currentRow = this.CurrentRow;

            if (!currentRow.IsNewRow)   //Si la row clické n'est pas la dernière qui est toujours vide.
            {
                int membreId = Convert.ToInt32(this.Rows[currentRow.Index].Cells["idMembre"].Value);
                MembreDTO membreDTO = new MembreDTO();
                membreDTO.IdMembre = membreId;
                membreSelected = gestionSport.MembreFacade.RechercherMembre(gestionSport.ConnectionString, membreDTO);
            }
            return membreSelected;
        }
 public void EnregistrerMembre(string connectionString, MembreDTO membreDTO)
 {
     if (membreDTO == null)
     {
         throw new ServiceException("Le membre ne peut être null");
     }
     try
     {
         Add(connectionString, membreDTO);
     }
     catch (DAOException daoException)
     {
         throw new ServiceException(daoException.Message, daoException);
     }
 }
Example #11
0
        /// <summary>
        /// Trouve tous les membres de la base de données
        /// </summary>
        /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
        /// <returns>La liste de tous les membres</returns>
        public List<MembreDTO> FindByNomComplet(string connectionString, MembreDTO membreDTO)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new DAOException("Les paramètres de connexion n'ont pas été initialisé.");
            }

            List<MembreDTO> listeDTO = null;

            try
            {
                using (MySqlConnection connection = new MySqlConnection(connectionString))
                {
                    connection.Open();
                    MySqlCommand findByNomCompletPreparedStatement = new MySqlCommand(MembreDAO.FIND_BY_NOM_COMPLET_REQUEST, connection);
                    if(string.IsNullOrEmpty(membreDTO.Nom))
                    {
                        membreDTO.Nom = string.Empty;
                    }
                    if (string.IsNullOrEmpty(membreDTO.Prenom))
                    {
                        membreDTO.Prenom = string.Empty;
                    }
                    findByNomCompletPreparedStatement.Parameters.AddWithValue("@nom", "%" + membreDTO.Nom + "%");
                    findByNomCompletPreparedStatement.Parameters.AddWithValue("@prenom", "%" + membreDTO.Prenom + "%");
                    findByNomCompletPreparedStatement.Prepare();
                    using (MySqlDataReader dataReader = findByNomCompletPreparedStatement.ExecuteReader())
                    {
                        if (dataReader.HasRows) // Si la requête n'est pas vide
                        {
                            listeDTO = new List<MembreDTO>();
                            while (dataReader.Read())
                            {
                                MembreDTO unMembreDTO = new MembreDTO();
                                unMembreDTO.IdMembre = dataReader.GetInt32(0);
                                unMembreDTO.Nom = dataReader.GetString(1);
                                unMembreDTO.Prenom = dataReader.GetString(2);
                                unMembreDTO.Adresse = dataReader.GetString(3);
                                unMembreDTO.Ville = dataReader.GetString(4);
                                unMembreDTO.Telephone = dataReader.GetString(5);
                                unMembreDTO.Email = dataReader.GetString(6);
                                unMembreDTO.Sexe = dataReader.GetString(7);
                                unMembreDTO.DateNaissance = dataReader.GetDateTime(8);

                                listeDTO.Add(unMembreDTO);
                            }
                        }
                    }
                }
            }
            catch (MySqlException mySqlException)
            {
                throw new DAOException(mySqlException.Message, mySqlException);
            }
            return listeDTO;
        }
        /// <summary>
        /// Liste tous les inscriptions.
        /// </summary>
        /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
        /// <returns>Une liste de tous les inscriptions s'il y en a, sinon null.</returns>
        public List<InscriptionDTO> ReadAll(string connectionString)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new DAOException("Les paramètres de connexion n'ont pas été initialisé.");
            }

            List<InscriptionDTO> listeInscriptionDTO = null;

            try
            {
                using (MySqlConnection connection = new MySqlConnection(connectionString))
                {
                    connection.Open();
                    MySqlCommand readAllPreparedStatement = new MySqlCommand(InscriptionDAO.READ_ALL_REQUEST, connection);
                    readAllPreparedStatement.Prepare();

                    using (MySqlDataReader dataReader = readAllPreparedStatement.ExecuteReader())
                    {

                        if (dataReader.HasRows)
                        {
                            listeInscriptionDTO = new List<InscriptionDTO>();

                            while (dataReader.Read())
                            {
                                InscriptionDTO uneInscriptionDTO = new InscriptionDTO();
                                uneInscriptionDTO.IdInscription = dataReader.GetInt32(0);
                                MembreDTO membreDTO = new MembreDTO();
                                membreDTO.IdMembre = dataReader.GetInt32(1);
                                uneInscriptionDTO.Membre = membreDTO;

                                SeanceDTO seanceDTO = new SeanceDTO();
                                seanceDTO.IdSeance = dataReader.GetInt32(2);
                                uneInscriptionDTO.Seance = seanceDTO;
                                uneInscriptionDTO.DateInscription = dataReader.GetDateTime(3);
                                uneInscriptionDTO.FlagPaiement = dataReader.GetBoolean(4);
                                uneInscriptionDTO.FlagSupprime = dataReader.GetBoolean(5);

                                listeInscriptionDTO.Add(uneInscriptionDTO);
                            }
                        }
                    }
                }
            }
            catch (SqlException sqlException)
            {
                throw new DAOException(sqlException.Message, sqlException);
            }
            return listeInscriptionDTO;
        }
        /// <summary>
        /// Liste tous les inscriptions en lien avec une séance.
        /// </summary>
        /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
        /// <param name="horarieDTO">Représente la séance qui sera recherché dans les inscriptions.</param>
        /// <returns>Une liste de tous les inscriptions associé à une séance s'il y en a, sinon null.</returns>
        public List<InscriptionDTO> FindBySeance(string connectionString, SeanceDTO seanceDTO)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new DAOException("Les paramètres de connexion n'ont pas été initialisé.");
            }

            List<InscriptionDTO> listeIncriptions = null;

            try
            {
                using (MySqlConnection connection = new MySqlConnection(connectionString))
                {
                    connection.Open();
                    MySqlCommand findBySeancePreparedStatement = new MySqlCommand(InscriptionDAO.FIND_BY_SEANCE_REQUEST, connection);
                    findBySeancePreparedStatement.Parameters.AddWithValue("@idSeance", seanceDTO.IdSeance);
                    findBySeancePreparedStatement.Prepare();
                    using (MySqlDataReader dataReader = findBySeancePreparedStatement.ExecuteReader())
                    {
                        if (dataReader.HasRows)
                        {
                            listeIncriptions = new List<InscriptionDTO>();
                            while (dataReader.Read())
                            {
                                InscriptionDTO uneInscriptionDTO = new InscriptionDTO();
                                uneInscriptionDTO.IdInscription = dataReader.GetInt32(0);
                                MembreDTO unMembreDTO = new MembreDTO();
                                unMembreDTO.IdMembre = dataReader.GetInt32(1);
                                uneInscriptionDTO.Membre = unMembreDTO;
                                SeanceDTO uneSeanceDTO = new SeanceDTO();
                                uneSeanceDTO.IdSeance = dataReader.GetInt32(2);
                                uneInscriptionDTO.Seance = uneSeanceDTO;
                                uneInscriptionDTO.DateInscription = dataReader.GetDateTime(3);
                                uneInscriptionDTO.FlagPaiement = dataReader.GetBoolean(4);
                                uneInscriptionDTO.FlagSupprime = dataReader.GetBoolean(5);
                                listeIncriptions.Add(uneInscriptionDTO);
                            }
                        }
                    }
                }
            }
            catch (SqlException sqlException)
            {
                throw new DAOException(sqlException.Message, sqlException);
            }

            return listeIncriptions;
        }
        /// <summary>
        /// Recherche d'une inscription.
        /// </summary>
        /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
        /// <param name="inscriptionDTO">Rerpésente l'inscription qui sera recherché.</param>
        /// <returns>Une inscription si elle existe, sinon null.</returns>
        public InscriptionDTO Find(string connectionString, InscriptionDTO inscriptionDTO)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new DAOException("Les paramètres de connexion n'ont pas été initialisé.");
            }

            InscriptionDTO uneInscriptionDTO = null;

            try
            {
                using (MySqlConnection connection = new MySqlConnection(connectionString))
                {
                    connection.Open();
                    MySqlCommand findPreparedStatement = new MySqlCommand(InscriptionDAO.FIND_REQUEST, connection);
                    findPreparedStatement.Parameters.AddWithValue("@idInscription", inscriptionDTO.IdInscription);
                    findPreparedStatement.Prepare();
                    using (MySqlDataReader dataReader = findPreparedStatement.ExecuteReader())
                    {

                        if (dataReader.Read())
                        {
                            uneInscriptionDTO = new InscriptionDTO();
                            uneInscriptionDTO.IdInscription = dataReader.GetInt32(0);
                            MembreDTO membreDTO = new MembreDTO();
                            membreDTO.IdMembre = dataReader.GetInt32(1);
                            uneInscriptionDTO.Membre = membreDTO;
                            SeanceDTO seanceDTO = new SeanceDTO();
                            seanceDTO.IdSeance = dataReader.GetInt32(2);
                            uneInscriptionDTO.Seance = seanceDTO;
                            uneInscriptionDTO.DateInscription = dataReader.GetDateTime(3);
                            uneInscriptionDTO.FlagPaiement = dataReader.GetBoolean(4);
                            uneInscriptionDTO.FlagSupprime = dataReader.GetBoolean(5);
                        }
                    }
                }
            }
            catch (SqlException sqlException)
            {
                throw new DAOException(sqlException.Message, sqlException);
            }

            return uneInscriptionDTO;
        }
Example #15
0
        /// <summary>
        /// Trouve un membre dans la base de données
        /// </summary>
        /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
        /// <param name="membreDTO">Le membre à trouver</param>
        /// <returns>Le membre trouvé</returns>
        public MembreDTO Find(string connectionString, MembreDTO membreDTO)
        {
            MembreDTO unMembreDTO = null;

            if (string.IsNullOrEmpty(connectionString))
            {
                throw new DAOException("Les paramètres de connexion n'ont pas été initialisé.");
            }
            try
            {
                using (MySqlConnection connection = new MySqlConnection(connectionString))
                {
                    connection.Open();
                    MySqlCommand findPreparedStatement = new MySqlCommand(MembreDAO.FIND_REQUEST, connection);
                    findPreparedStatement.Parameters.AddWithValue("@idMembre", membreDTO.IdMembre);
                    findPreparedStatement.Prepare();
                    using (MySqlDataReader dataReader = findPreparedStatement.ExecuteReader())
                    {
                        if (dataReader.HasRows) // Si la requête n'est pas vide
                        {
                            if (dataReader.Read()) // Lecture de la ligne du dataReader
                            {
                                unMembreDTO = new MembreDTO();
                                unMembreDTO.IdMembre = dataReader.GetInt32(0);
                                unMembreDTO.Nom = dataReader.GetString(1);
                                unMembreDTO.Prenom = dataReader.GetString(2);
                                unMembreDTO.Adresse = dataReader.GetString(3);
                                unMembreDTO.Ville = dataReader.GetString(4);
                                unMembreDTO.Telephone = dataReader.GetString(5);
                                unMembreDTO.Email = dataReader.GetString(6);
                                unMembreDTO.Sexe = dataReader.GetString(7);
                                unMembreDTO.DateNaissance = dataReader.GetDateTime(8);

                            }
                        }
                    }
                }
            }
            catch (MySqlException mySqlException)
            {
                throw new DAOException(mySqlException.Message, mySqlException);
            }
            return unMembreDTO;
        }
        /// <summary>
        /// Lit tous les abonnements.
        /// </summary>
        /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
        /// <returns>Une liste de tous les abonnements, s'il y en a, sinon null.</returns>
        public List<AbonnementGymDTO> ReadAll(string connectionString)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new DAOException("Les paramètres de connexion n'ont pas été initialisé.");
            }

            List<AbonnementGymDTO> listeAbonnements = null;
            try
            {
                using (MySqlConnection connection = new MySqlConnection(connectionString))
                {
                    connection.Open();
                    MySqlCommand readAllPreparedStatement = new MySqlCommand(AbonnementGymDAO.READ_ALL_REQUEST, connection);
                    readAllPreparedStatement.Prepare();
                    using (MySqlDataReader dataReader = readAllPreparedStatement.ExecuteReader())
                    {
                        if (dataReader.HasRows)     //S'il y a des rows.
                        {
                            listeAbonnements = new List<AbonnementGymDTO>();    //On initialise la liste.

                            //idMembre, duree, cout, dateAbonnement, flagSuppri
                            while (dataReader.Read())
                            {
                                AbonnementGymDTO abonnementGymDTO = new AbonnementGymDTO();
                                abonnementGymDTO.IdAbonnement = dataReader.GetInt32(0);

                                //Membre
                                MembreDTO membreDTO = new MembreDTO();
                                membreDTO.IdMembre = dataReader.GetInt32(1);
                                abonnementGymDTO.Membre = membreDTO;

                                abonnementGymDTO.Duree = dataReader.GetInt32(2);
                                abonnementGymDTO.Cout = dataReader.GetInt32(3);
                                abonnementGymDTO.DateAbonnement = dataReader.GetDateTime(4);
                                abonnementGymDTO.FlagSupprime = dataReader.GetBoolean(5);

                                listeAbonnements.Add(abonnementGymDTO);
                            }
                        }
                    }
                }
            }
            catch (InvalidCastException invalidCastException)
            {
                throw new DAOException(invalidCastException.Message, invalidCastException);
            }
            catch (SqlException sqlException)
            {
                throw new DAOException(sqlException.Message, sqlException);
            }
            return listeAbonnements;
        }
        public List<VisiteDTO> RechercherVisitesParMembre(string connectionString, MembreDTO membreDTO)
        {
            List<VisiteDTO> visitesRechercheParMembre = null;

            if (membreDTO == null)
            {
                throw new ServiceException("Le membre ne peut pas être null.");
            }

            try
            {
                visitesRechercheParMembre = new List<VisiteDTO>();
                visitesRechercheParMembre = FindByMembre(connectionString, membreDTO);
                if (visitesRechercheParMembre == null)
                {
                    throw new ServiceException("Aucune visite");
                }
                return visitesRechercheParMembre;
            }
            catch (DAOException daoException)
            {
                throw new ServiceException(daoException.Message, daoException);
            }
        }
        /// <inheritedoc/>
        public void Inscrire(string connectionString, MembreDTO membreDTO, SeanceDTO seanceDTO)
        {
            if (membreDTO == null)
            {
                throw new ServiceException("Le membre ne peut être null");
            }
            if (seanceDTO == null)
            {
                throw new ServiceException("La séance ne peut être null");
            }
            try
            {
                MembreDTO unMembreDTO = membreDAO.Find(connectionString, membreDTO);

                if (unMembreDTO == null)
                {
                    throw new ServiceException("Le membre passé en paramètre n'existe pas");
                }

                SeanceDTO uneSeanceDTO = seanceDAO.Find(connectionString, seanceDTO);

                if (uneSeanceDTO == null)
                {
                    throw new ServiceException("La séance passée en paramètre n'existe pas");
                }

                // Si la date d'inscription est plus grande que la date limite pour s'inscrire à la séance
                DateTime dateInscription = DateTime.Now;
                if (dateInscription.CompareTo(uneSeanceDTO.DateSeance) > 0)
                {
                    throw new ServiceException("La date d'inscription est dépassée");
                }

                // Si le membre est déjà inscrit à la séance à laquelle il veut s'inscrire ou
                // Si le membre est déjà inscrit à une autre séance qui se déroule en même temps
                List<InscriptionDTO> ListeInscriptionDTO = inscriptionDAO.FindByMembre(connectionString, membreDTO);
                if (ListeInscriptionDTO != null && ListeInscriptionDTO.Any())
                {
                    foreach (InscriptionDTO inscription in ListeInscriptionDTO)
                    {
                        if (inscription.Membre.IdMembre == unMembreDTO.IdMembre
                            && inscription.Seance.IdSeance == uneSeanceDTO.IdSeance
                            && !inscription.FlagSupprime)
                        {
                            throw new ServiceException("Le membre est déjà inscrit à la séance à laquelle il veut s'inscrire");
                        }
                        if (inscription.Seance.DateSeance.Equals(uneSeanceDTO.DateSeance)
                            && inscription.Seance.HeureDebut == uneSeanceDTO.HeureDebut)
                        {
                            throw new ServiceException("Le membre est déjà inscrit à une autre séance au même moment");
                        }
                    }
                }

                // Si la limite de place pour une séance est atteinte
                if (uneSeanceDTO.NbPlaces == uneSeanceDTO.LimitePlace)
                {
                    throw new ServiceException("La limite de place est atteinte pour cette séance");
                }

                // Si le membre a un retard de paiement; À implémenter au besoin
                InscriptionDTO uneInscriptionDTO = new InscriptionDTO();
                uneInscriptionDTO.Membre = unMembreDTO;
                uneInscriptionDTO.Seance = uneSeanceDTO;
                uneInscriptionDTO.DateInscription = dateInscription;

                Add(connectionString, uneInscriptionDTO);
                uneSeanceDTO.NbPlaces++;
                this.seanceDAO.Update(connectionString, uneSeanceDTO);  //On incrémente le nombre de personne dans le cours.
            }
            catch (DAOException daoException)
            {
                throw new ServiceException(daoException.Message, daoException);
            }
        }
 public List<VisiteDTO> FindByMembre(string connectionString, MembreDTO membreDTO)
 {
     List<VisiteDTO> listeVisite = null;
     try
     {
         listeVisite = visiteDAO.FindByMembre(connectionString,membreDTO);
     }
     catch (DAOException daoException)
     {
         throw new ServiceException(daoException.Message, daoException);
     }
     return listeVisite;
 }
Example #20
0
        /// <summary>
        /// Recherche toutes les visites d'un membre.
        /// </summary>
        /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
        /// <param name="membreDTO">Le membre duquel on veut les visites</param>
        /// <returns></returns>
        public List<VisiteDTO> FindByMembre(string connectionString, MembreDTO membreDTO)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new DAOException("Les paramètres de connexion n'ont pas été initialisé.");
            }

            List<VisiteDTO> listeVisites = null;

            try
            {
                using (MySqlConnection connection = new MySqlConnection(connectionString))
                {
                    connection.Open();
                    MySqlCommand findByMembrePreparedStatement = new MySqlCommand(VisiteDAO.FIND_BY_MEMBRE_REQUEST, connection);
                    findByMembrePreparedStatement.Parameters.AddWithValue("@idMembre", membreDTO.IdMembre);
                    findByMembrePreparedStatement.Prepare();

                    using (MySqlDataReader dataReader = findByMembrePreparedStatement.ExecuteReader())
                    {
                        if (dataReader.HasRows) // Si la requête n'est pas vide
                        {

                            listeVisites = new List<VisiteDTO>();

                            if (dataReader.Read()) // Lecture de la ligne du dataReader
                            {
                                VisiteDTO uneVisiteDTO = new VisiteDTO();
                                uneVisiteDTO.IdVisite = dataReader.GetInt32(0);

                                MembreDTO unMembreDTO = new MembreDTO();
                                unMembreDTO.IdMembre = dataReader.GetInt32(1);
                                uneVisiteDTO.Membre = unMembreDTO;

                                uneVisiteDTO.DateVisite = dataReader.GetDateTime(2);
                                listeVisites.Add(uneVisiteDTO);
                            }
                        }
                    }
                }
            }
            catch (MySqlException mySqlException)
            {
                throw new DAOException(mySqlException.Message, mySqlException);
            }
            return listeVisites;
        }
Example #21
0
        /// <summary>
        /// Trouve tous les membres de la base de données
        /// </summary>
        /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
        /// <returns>La liste de tous les membres</returns>
        public List<MembreDTO> ReadAll(string connectionString)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new DAOException("Les paramètres de connexion n'ont pas été initialisé.");
            }

            List<MembreDTO> listeDTO = null;

            try
            {
                using (MySqlConnection connection = new MySqlConnection(connectionString))
                {
                    connection.Open();
                    MySqlCommand findPreparedStatement = new MySqlCommand(MembreDAO.READ_ALL_REQUEST, connection);
                    using (MySqlDataReader dataReader = findPreparedStatement.ExecuteReader())
                    {
                        if (dataReader.HasRows) // Si la requête n'est pas vide
                        {
                            listeDTO = new List<MembreDTO>();
                            while (dataReader.Read())
                            {
                                MembreDTO unMembreDTO = new MembreDTO();
                                unMembreDTO.IdMembre = dataReader.GetInt32(0);
                                unMembreDTO.Nom = dataReader.GetString(1);
                                unMembreDTO.Prenom = dataReader.GetString(2);
                                unMembreDTO.Adresse = dataReader.GetString(3);
                                unMembreDTO.Ville = dataReader.GetString(4);
                                unMembreDTO.Telephone = dataReader.GetString(5);
                                unMembreDTO.Email = dataReader.GetString(6);
                                unMembreDTO.Sexe = dataReader.GetString(7);
                                unMembreDTO.DateNaissance = dataReader.GetDateTime(8);

                                listeDTO.Add(unMembreDTO);
                            }
                        }
                    }
                }
            }
            catch (MySqlException mySqlException)
            {
                throw new DAOException(mySqlException.Message, mySqlException);
            }
            return listeDTO;
        }
 public List<MembreDTO> RechercherMembreParNom(string connectionString, MembreDTO membreDTO)
 {
     if(membreDTO == null)
     {
         throw new ServiceException("Le membre ne peut être null");
     }
     List<MembreDTO> listeMembres = null;
     try
     {
         listeMembres = this.membreDAO.FindByNomComplet(connectionString, membreDTO);
         if (listeMembres == null)
         {
             throw new ServiceException("Aucun membres ne possèdent le nom et le prénom donnée.");
         }
         return listeMembres;
     }
     catch (DAOException daoException)
     {
         throw new ServiceException(daoException.Message, daoException);
     }
 }
        public MembreDTO RechercherMembre(string connectionString, MembreDTO membreDTO)
        {
            MembreDTO membreRecherche = null;

            if (membreDTO == null)
            {
                throw new ServiceException("Le membre ne peut pas être null.");
            }

            try
            {
                membreRecherche = Find(connectionString, membreDTO);
                if (membreRecherche == null)
                {
                    throw new ServiceException("Le membre " + membreDTO.IdMembre + " n'existe pas.");
                }
                return membreRecherche;
            }
            catch (DAOException daoException)
            {
                throw new ServiceException(daoException.Message, daoException);
            }
        }
        public void ModifierMembre(string connectionString, MembreDTO membreDTO)
        {
            if (membreDTO == null)
            {
                throw new ServiceException("Le membre ne peut être null");
            }
            try
            {
                MembreDTO unMembreDTO = membreDAO.Find(connectionString, membreDTO);

                if (unMembreDTO == null)
                {
                    throw new ServiceException("Le membre passé en paramètre n'existe pas");
                }
                Update(connectionString, membreDTO);
            }
            catch (DAOException daoException)
            {
                throw new ServiceException(daoException.Message, daoException);
            }
        }
 /// <inheritedoc/>
 public List<InscriptionDTO> FindByMembre(string connectionString, MembreDTO membreDTO)
 {
     List<InscriptionDTO> listeInscription = null;
     try
     {
         listeInscription = inscriptionDAO.FindByMembre(connectionString,membreDTO);
     }
     catch (DAOException daoException)
     {
         throw new ServiceException(daoException.Message, daoException);
     }
     return listeInscription;
 }
        /// <summary>
        /// Recherche un abonnement.
        /// </summary>
        /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
        /// <param name="seanceDTO">Représente l'abonnement à chercher.</param>
        /// <returns>L'abonnement s'il y en a, sinon null.</returns>
        public AbonnementGymDTO Find(string connectionString, AbonnementGymDTO abonnementGymDTO)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new DAOException("Les paramètres de connexion n'ont pas été initialisé.");
            }

            AbonnementGymDTO abonnementRecherche = null;
            try
            {
                using (MySqlConnection connection = new MySqlConnection(connectionString))
                {
                    connection.Open();
                    MySqlCommand findPreparedStatement = new MySqlCommand(AbonnementGymDAO.FIND_REQUEST, connection);
                    findPreparedStatement.Parameters.AddWithValue("@idAbonnement", abonnementGymDTO.IdAbonnement);
                    findPreparedStatement.Prepare();

                    using (MySqlDataReader dataReader = findPreparedStatement.ExecuteReader())
                    {
                        //idMembre, duree, cout, dateAbonnement, flagSupprime
                        if (dataReader.Read())
                        {
                            abonnementRecherche = new AbonnementGymDTO();
                            abonnementRecherche.IdAbonnement = dataReader.GetInt32(0);

                            //Membre
                            MembreDTO membreDTO = new MembreDTO();
                            membreDTO.IdMembre = dataReader.GetInt32(1);
                            abonnementRecherche.Membre = membreDTO;

                            abonnementRecherche.Duree = dataReader.GetInt32(2);
                            abonnementRecherche.Cout = dataReader.GetInt32(3);
                            abonnementRecherche.DateAbonnement = dataReader.GetDateTime(4);
                            abonnementRecherche.FlagSupprime = dataReader.GetBoolean(5);
                        }
                    }
                }
            }
            catch (InvalidCastException invalidCastException)
            {
                throw new DAOException(invalidCastException.Message, invalidCastException);
            }
            catch (SqlException sqlException)
            {
                throw new DAOException(sqlException.Message, sqlException);
            }
            return abonnementRecherche;
        }
        /// <summary>
        /// Recherhe les abonnements par membre.
        /// </summary>
        /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
        /// <param name="membreDTO">Représente le membre à trouver.</param>
        /// <returns>S'il y a des abonnements, une liste de tous les abonnements, sinon null.</returns>
        public List<AbonnementGymDTO> FindByMembre(string connectionString, MembreDTO membreDTO)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new DAOException("Les paramètres de connexion n'ont pas été initialisé.");
            }

            List<AbonnementGymDTO> listeAbonnements = null;
            try
            {
                using (MySqlConnection connection = new MySqlConnection(connectionString))
                {
                    connection.Open();
                    MySqlCommand findByActivitePreparedStatement = new MySqlCommand(AbonnementGymDAO.FIND_BY_MEMBRE_REQUEST, connection);
                    findByActivitePreparedStatement.Parameters.AddWithValue("@idMembre", membreDTO.IdMembre);
                    using (MySqlDataReader dataReader = findByActivitePreparedStatement.ExecuteReader())
                    {
                        if (dataReader.HasRows) // Si la requête n'est pas vide
                        {

                            listeAbonnements = new List<AbonnementGymDTO>();

                            //idMembre, duree, cout, dateAbonnement, flagSupprime
                            while (dataReader.Read())
                            {
                                AbonnementGymDTO abonnementGymDTO = new AbonnementGymDTO();
                                abonnementGymDTO.IdAbonnement = dataReader.GetInt32(0);

                                //Membre
                                MembreDTO membreRecherche = new MembreDTO();
                                membreRecherche.IdMembre = dataReader.GetInt32(1);
                                abonnementGymDTO.Membre = membreRecherche;

                                abonnementGymDTO.Duree = dataReader.GetInt32(2);
                                abonnementGymDTO.Cout = dataReader.GetInt32(3);
                                abonnementGymDTO.DateAbonnement = dataReader.GetDateTime(4);
                                abonnementGymDTO.FlagSupprime = dataReader.GetBoolean(5);

                                listeAbonnements.Add(abonnementGymDTO);
                            }
                        }
                    }
                }
            }
            catch (MySqlException mySqlException)
            {
                throw new DAOException(mySqlException.Message, mySqlException);
            }
            return listeAbonnements;
        }
Example #28
0
 /// <summary>
 /// Supprime un membre de la base de données
 /// </summary>
 /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
 /// <param name="membreDTO">Le membre à supprimer</param>
 public void Delete(string connectionString, MembreDTO membreDTO)
 {
     if (string.IsNullOrEmpty(connectionString))
     {
         throw new DAOException("Les paramètres de connexion n'ont pas été initialisé.");
     }
     try
     {
         using (MySqlConnection connection = new MySqlConnection(connectionString))
         {
             connection.Open();
             MySqlCommand deletePreparedStatement = new MySqlCommand(MembreDAO.DELETE_REQUEST, connection);
             deletePreparedStatement.Parameters.AddWithValue("@idMembre", membreDTO.IdMembre);
             deletePreparedStatement.Prepare();
             deletePreparedStatement.ExecuteNonQuery();
         }
     }
     catch (MySqlException mySqlException)
     {
         throw new DAOException(mySqlException.Message, mySqlException);
     }
 }
Example #29
0
        /// <summary>
        /// Lit toutes les visites.
        /// </summary>
        /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
        /// <returns>Une liste de toutes les visites.</returns>
        public List<VisiteDTO> ReadAll(string connectionString)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new DAOException("Les paramètres de connexion n'ont pas été initialisé.");
            }

            List<VisiteDTO> listeVisites = null;

            try
            {
                using (MySqlConnection connection = new MySqlConnection(connectionString))
                {
                    connection.Open();
                    MySqlCommand findPreparedStatement = new MySqlCommand(VisiteDAO.READ_ALL_REQUEST, connection);
                    using (MySqlDataReader dataReader = findPreparedStatement.ExecuteReader())
                    {
                        if (dataReader.HasRows) // Si la requête n'est pas vide
                        {
                            listeVisites = new List<VisiteDTO>();

                            while (dataReader.Read())
                            {
                                VisiteDTO uneVisiteDTO = new VisiteDTO();
                                uneVisiteDTO.IdVisite = dataReader.GetInt32(0);

                                MembreDTO unMembreDTO = new MembreDTO();
                                unMembreDTO.IdMembre = dataReader.GetInt32(1);
                                uneVisiteDTO.Membre = unMembreDTO;

                                uneVisiteDTO.DateVisite = dataReader.GetDateTime(2);
                                listeVisites.Add(uneVisiteDTO);
                            }
                        }
                    }
                }
            }
            catch (MySqlException mySqlException)
            {
                throw new DAOException(mySqlException.Message, mySqlException);
            }
            return listeVisites;
        }
        public List<MembreDTO> FindByNomComplet(string connectionString, MembreDTO membreDTO)
        {
            List<MembreDTO> listeMembres = null;

            try
            {
                listeMembres = this.membreDAO.FindByNomComplet(connectionString, membreDTO);
            }
            catch (DAOException daoException)
            {
                throw new ServiceException(daoException.Message, daoException);
            }
            return listeMembres;
        }