/// <summary>
 /// Ajoute une abonnement.
 /// </summary>
 /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
 /// <param name="abonnementGymDTO">Représente l'abonnement qui sera ajoutée.</param>
 public void Add(string connectionString, AbonnementGymDTO abonnementGymDTO)
 {
     if (string.IsNullOrEmpty(connectionString))
     {
         throw new DAOException("Les paramètres de connexion n'ont pas été initialisé.");
     }
     try
     {
         using (MySqlConnection connection = new MySqlConnection(connectionString))
         {
             //idMembre, duree, cout, dateAbonnement
             connection.Open();
             MySqlCommand addPreparedStatement = new MySqlCommand(AbonnementGymDAO.ADD_REQUEST, connection);
             addPreparedStatement.Parameters.AddWithValue("@idMembre", abonnementGymDTO.Membre.IdMembre);
             addPreparedStatement.Parameters.AddWithValue("@duree", abonnementGymDTO.Duree);
             addPreparedStatement.Parameters.AddWithValue("@cout", abonnementGymDTO.Cout);
             addPreparedStatement.Parameters.AddWithValue("@dateAbonnement", DateTime.Now);
             addPreparedStatement.Prepare();
             addPreparedStatement.ExecuteNonQuery();
         }
     }
     catch (SqlException sqlException)
     {
         throw new DAOException(sqlException.Message, sqlException);
     }
 }
 public void TerminerUnAbonnement(string connectionString, AbonnementGymDTO abonnementGymDTO)
 {
     try
     {
         this.abonnementGymService.TerminerUnAbonnement(connectionString, abonnementGymDTO);
     }
     catch (ServiceException serviceException)
     {
         throw new FacadeException(serviceException.Message, serviceException);
     }
 }
 public AbonnementGymDTO RechercherAbonnement(string connectionString, AbonnementGymDTO abonnementGymDTO)
 {
     AbonnementGymDTO abonnementRecherche = null;
     try
     {
         abonnementRecherche = abonnementGymService.RechercherAbonnement(connectionString, abonnementGymDTO);
     }
     catch (ServiceException serviceException)
     {
         throw new FacadeException(serviceException.Message, serviceException);
     }
     return abonnementRecherche;
 }
        public void AbonnerUnMembre(string connectionString, AbonnementGymDTO abonnementGymDTO)
        {
            if (abonnementGymDTO == null)
            {
                throw new ServiceException("Aucune informations a été donnés lors de l'abonnement");
            }

            if (abonnementGymDTO.Membre == null)
            {
                throw new ServiceException("Aucun membre a été indiqué lors de l'abonnement");
            }

            try
            {
                MembreDTO membreDTO = this.membreDAO.Find(connectionString, abonnementGymDTO.Membre);
                if (membreDTO == null)
                {
                    throw new ServiceException("Le membre spécifié n'existe pas");
                }
                var listeAbonnement = FindByMembre(connectionString, membreDTO);
                if (listeAbonnement != null && listeAbonnement.Any())
                {
                    AbonnementGymDTO dernierAbonnement = null;
                    foreach (AbonnementGymDTO abonnement in listeAbonnement)
                    {
                        if (!abonnement.FlagSupprime)
                        {
                            dernierAbonnement = abonnement;
                            break;
                        }
                    }
                    if (dernierAbonnement == null)
                    {
                        throw new ServiceException("Le membre possède déjà un abonnement en cours.");
                    }

                    DateTime dateAbonnementTermine = dernierAbonnement.DateAbonnement.AddMonths(dernierAbonnement.Duree);

                    //Si la date de l'échance de l'abonnement est plus petit qu'aujourd'hui et que l'abonnement n'a pas été annulé.
                    if (dateAbonnementTermine > DateTime.Now && !dernierAbonnement.FlagSupprime)
                    {
                        throw new ServiceException("Le membre possède déjà un abonnement en cours.");
                    }
                }
                Add(connectionString, abonnementGymDTO);
            }
            catch (DAOException daoException)
            {
                throw new ServiceException(daoException.Message, daoException);
            }
        }
        public AbonnementGymDTO GetSelectedAbonnement(GestionSport gestionSport)
        {
            AbonnementGymDTO abonnementSelected = null;
            var currentRow = this.CurrentRow;

            if (!currentRow.IsNewRow)
            {
                int abonnementId = Convert.ToInt32(this.Rows[currentRow.Index].Cells["idAbonnement"].Value);
                AbonnementGymDTO abonnementGymDTO = new AbonnementGymDTO();
                abonnementGymDTO.IdAbonnement = abonnementId;
                abonnementSelected = gestionSport.AbonnementGymFacade.RechercherAbonnement(gestionSport.ConnectionString, abonnementGymDTO);
            }
            return abonnementSelected;
        }
        /// <summary>
        /// Efface un abonnement.
        /// </summary>
        /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
        /// <param name="abonnementGymDTO">Représente l'abonnement qui sera supprimée.</param>
        public void Delete(string connectionString, AbonnementGymDTO abonnementGymDTO)
        {
            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(AbonnementGymDAO.DELETE_REQUEST, connection);
                    deletePreparedStatement.Parameters.AddWithValue("@idAbonnement", abonnementGymDTO.IdAbonnement);
                    deletePreparedStatement.Prepare();
                    deletePreparedStatement.ExecuteNonQuery();
                }
            }
            catch (SqlException sqlException)
            {
                throw new DAOException(sqlException.Message, sqlException);
            }
        }
Beispiel #7
0
 /// <summary>
 /// Remplit tous les champs qui sont dédiés à visualier les informations d'un abonnement.
 /// </summary>
 /// <param name="abonnementGym">Représente les informations sur l'abonnement qui sera affiché.</param>
 private void FillFieldsAbonnement(AbonnementGymDTO abonnementGym)
 {
     if (abonnementGym != null)
     {
         txtAbonnementIdMembre.Text = abonnementGym.Membre.IdMembre.ToString();
         txtAbonnementDuree.Text = abonnementGym.Duree.ToString();
         txtAbonnementCout.Text = abonnementGym.Cout.ToString();
         dateTimePickerRechercheDateAbonnement.Value = abonnementGym.DateAbonnement;
     }
 }
 /// <summary>
 /// Met à jour un abonnement.
 /// </summary>
 /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
 /// <param name="abonnementGymDTO">Représente l'abonnement qui sera mise à jour.</param>
 public void Update(string connectionString, AbonnementGymDTO abonnementGymDTO)
 {
     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 updatePreparedStatement = new MySqlCommand(AbonnementGymDAO.UPDATE_REQUEST, connection);
             updatePreparedStatement.Parameters.AddWithValue("@idMembre", abonnementGymDTO.Membre.IdMembre);
             updatePreparedStatement.Parameters.AddWithValue("@duree", abonnementGymDTO.Duree);
             updatePreparedStatement.Parameters.AddWithValue("@cout", abonnementGymDTO.Cout);
             updatePreparedStatement.Parameters.AddWithValue("@dateAbonnement", abonnementGymDTO.DateAbonnement);
             updatePreparedStatement.Parameters.AddWithValue("@flagSupprime", abonnementGymDTO.FlagSupprime);
             updatePreparedStatement.Parameters.AddWithValue("@idAbonnement", abonnementGymDTO.IdAbonnement);
             updatePreparedStatement.Prepare();
             updatePreparedStatement.ExecuteNonQuery();
         }
     }
     catch (SqlException sqlException)
     {
         throw new DAOException(sqlException.Message, sqlException);
     }
 }
Beispiel #9
0
        /// <summary>
        /// Bouton pour ajouter un abonnement dans la base de données
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAjouterAbonnement_Click(object sender, EventArgs e)
        {
            AbonnementGymDTO nouvelAbonnement = new AbonnementGymDTO();
            string duree = txtAbonnementDuree.Text;
            string cout = txtAbonnementCout.Text;
            string idMembre = txtAbonnementIdMembre.Text;

            if (string.IsNullOrEmpty(duree))
            {
                lblErrorTabAbonnement.Text = "Vous devez obligatoirement entrer une durée\n afin d'ajouter un abonnement.";
            }
            else if (string.IsNullOrEmpty(cout))
            {
                lblErrorTabAbonnement.Text = "Vous devez obligatoirement entrer un coût\n afin d'ajouter un abonnement.";
            }
            else if (string.IsNullOrEmpty(idMembre))
            {
                lblErrorTabAbonnement.Text = "Vous devez obligatoirement entrer un coût\n afin d'ajouter un abonnement.";
            }
            else
            {
                MembreDTO membreAbonnement = new MembreDTO();
                membreAbonnement.IdMembre = Int32.Parse(idMembre);
                nouvelAbonnement.Membre = gestionSportApp.MembreFacade.RechercherMembre(gestionSportApp.ConnectionString, membreAbonnement);

                nouvelAbonnement.Duree = Int32.Parse(duree);
                nouvelAbonnement.Cout = Int32.Parse(cout);
                nouvelAbonnement.FlagSupprime = false;

                if (AbonnementIsValid(nouvelAbonnement))
                {
                    gestionSportApp.AbonnementGymFacade.AbonnerUnMembre(gestionSportApp.ConnectionString, nouvelAbonnement);
                    dataGridViewAbonnementGym.Refresh();
                    ResetFieldsAbonnement();
                    this.dataGridViewAbonnementGym.Clear();
                    LoadAbonnement();
                }
            }
        }
        /// <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;
        }
        /// <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 AbonnementGymDTO Find(string connectionString, AbonnementGymDTO abonnementGymDTO)
 {
     AbonnementGymDTO abonnementGymRecherche = null;
     try
     {
         abonnementGymRecherche = abonnementGymDAO.Find(connectionString, abonnementGymDTO);
     }
     catch (DAOException daoException)
     {
         throw new ServiceException(daoException.Message, daoException);
     }
     return abonnementGymRecherche;
 }
        /// <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;
        }
Beispiel #14
0
 /// <summary>
 /// Vérifie si les données saisie par l'utilisateur sont suffisantes et respectent les règles.
 /// </summary>
 /// <param name="seance">La séance dont les données doivent être validées.</param>
 /// <returns>Vrai si les champs de la séance sont valides, sinon false.</returns>
 private bool AbonnementIsValid(AbonnementGymDTO abonnementGym)
 {
     bool isValid = true;
     if (abonnementGym.Membre == null)
     {
         isValid = false;
         lblErrorSeance.Text = "Erreur, il n'y a pas de membre";
     }
     else if (string.IsNullOrEmpty(abonnementGym.Duree.ToString()))
     {
         isValid = false;
         lblErrorSeance.Text = "Erreur, vous devez spécifié la durée de l'abonnement";
     }
     else if (string.IsNullOrEmpty(abonnementGym.Cout.ToString()))
     {
         isValid = false;
         lblErrorSeance.Text = "Erreur, vous devez spécifié le coût de l'abonnement";
     }
     else if (abonnementGym.FlagSupprime)
     {
         isValid = false;
         lblErrorSeance.Text = "Erreur, vous ne pouvez ajouter un abonnement et le supprimer à la fois";
     }
     return isValid;
 }
Beispiel #15
0
        public void ExecuteCommand(string line)
        {
            string message = "";
            try
            {
                var argumentList = line.Split(' ');
                if (line.StartsWith("-"))
                {
                    message = "-\n";
                }
                else if (line.StartsWith("*"))
                {
                    message = line + "\n";
                }
                else if (line.StartsWith("creerMembre"))
                {
                    MembreDTO membre = new MembreDTO();
                    membre.Nom = argumentList[1];
                    membre.Prenom = argumentList[2];
                    membre.Adresse = argumentList[3];
                    membre.Ville = argumentList[4];
                    membre.Telephone = argumentList[5];
                    membre.Email = argumentList[6];
                    membre.Sexe = argumentList[7];
                    membre.DateNaissance = Convert.ToDateTime(argumentList[8]);
                    message = "création d'un membre.\n";
                    gestionSport.MembreFacade.EnregistrerMembre(gestionSport.ConnectionString, membre);
                }
                else if (line.StartsWith("abonnerMembre"))
                {
                    var abonnement = new AbonnementGymDTO();
                    var membre = new MembreDTO();
                    membre.IdMembre = Convert.ToInt32(argumentList[1]);
                    abonnement.Membre = membre;
                    abonnement.Duree = Convert.ToInt32(argumentList[2]);
                    abonnement.Cout = float.Parse(argumentList[3]);
                    message = "abonnement d'un membre.\n";
                    gestionSport.AbonnementGymFacade.AbonnerUnMembre(gestionSport.ConnectionString, abonnement);
                }
                else if (line.StartsWith("desabonnerMembre"))
                {
                    var abonnement = new AbonnementGymDTO();
                    abonnement.IdAbonnement = Convert.ToInt32(argumentList[1]);
                    message = "désabonnement de l'abonnement " + abonnement.IdAbonnement + "\n";
                    gestionSport.AbonnementGymFacade.TerminerUnAbonnement(gestionSport.ConnectionString, abonnement);
                }
                else if (line.StartsWith("creerEntraineur"))
                {
                    var entraineur = new EntraineurDTO();
                    entraineur.Nom = argumentList[1];
                    entraineur.Prenom = argumentList[2];
                    entraineur.Adresse = argumentList[3];
                    entraineur.Ville = argumentList[4];
                    entraineur.Telephone = argumentList[5];
                    entraineur.Email = argumentList[6];
                    entraineur.Sexe = argumentList[7];
                    entraineur.DateNaissance = Convert.ToDateTime(argumentList[8]);
                    message = "création d'un entraineur.\n";
                    gestionSport.EntraineurFacade.EnregistrerEntraineur(gestionSport.ConnectionString, entraineur);
                }
                else if (line.StartsWith("creerActivite"))
                {
                    var activite = new ActiviteDTO();
                    activite.Nom = argumentList[1];
                    activite.Cout = float.Parse(argumentList[2]);
                    activite.Duree = Convert.ToInt32(argumentList[3]);
                    activite.Description = argumentList[4];
                    message = "création d'une activité\n";
                    gestionSport.ActiviteFacade.CreerActivite(gestionSport.ConnectionString, activite);
                }
                else if (line.StartsWith("creerSalle"))
                {
                    var salle = new SalleDTO();
                    salle.Numero = Convert.ToInt32(argumentList[1]);
                    salle.Etage = Convert.ToInt32(argumentList[2]);
                    salle.Bloc = argumentList[3];
                    message = "création d'une salle\n";
                    gestionSport.SalleFacade.CreerSalle(gestionSport.ConnectionString, salle);
                }
                else if (line.StartsWith("creerSeance"))
                {
                    var seance = new SeanceDTO();
                    var activite = new ActiviteDTO();
                    activite.IdActivite = Convert.ToInt32(argumentList[1]);
                    seance.Activite = activite;
                    var entraineur = new EntraineurDTO();
                    entraineur.IdEntraineur = Convert.ToInt32(argumentList[2]);
                    seance.Entraineur = entraineur;
                    var salle = new SalleDTO();
                    salle.IdSalle = Convert.ToInt32(argumentList[3]);
                    seance.Salle = salle;
                    seance.NbPlaces = 0;
                    seance.LimitePlace = Convert.ToInt32(argumentList[4]);
                    seance.DateSeance = Convert.ToDateTime(argumentList[5]);
                    var heureDebut = float.Parse(argumentList[6].Replace(':', '.'), CultureInfo.InvariantCulture);
                    var heureFin = float.Parse(argumentList[7].Replace(':', '.'), CultureInfo.InvariantCulture);
                    seance.HeureDebut = heureDebut;
                    seance.HeureFin = heureFin;
                    message = "création d'une séance\n";
                    gestionSport.SeanceFacade.CreerSeance(gestionSport.ConnectionString, seance);
                }
                else if (line.StartsWith("inscrire"))
                {
                    var membre = new MembreDTO();
                    membre.IdMembre = Convert.ToInt32(argumentList[1]);
                    var seance = new SeanceDTO();
                    seance.IdSeance = Convert.ToInt32(argumentList[2]);
                    message = "Inscription du membre: " + membre.IdMembre + " à la séance: " + seance.IdSeance + "\n";
                    gestionSport.InscriptionFacade.Inscrire(gestionSport.ConnectionString, membre, seance);
                }
                else if (line.StartsWith("enregistrerUtilisateur"))
                {
                    var utilisateur = new UtilisateurDTO();
                    utilisateur.NomUtilisateur = argumentList[1];
                    utilisateur.Nom = argumentList[2];
                    utilisateur.Prenom = argumentList[3];
                    utilisateur.MotDePasse = argumentList[4];
                    utilisateur.Statut = argumentList[5];

                    message = "Enregistrement d'un utilisateur\n";
                    gestionSport.UtilisateurFacade.EnregistrerUtilisateur(gestionSport.ConnectionString, utilisateur);

                }
                else if (line.StartsWith("effacerUtilisateur"))
                {
                    var utilisateur = new UtilisateurDTO();
                    utilisateur.IdUtilisateur = Convert.ToInt32(argumentList[1]);
                    message = "effacement de l'utilisateur : " + utilisateur.IdUtilisateur + "\n";
                    gestionSport.UtilisateurFacade.EffacerUtilisateur(gestionSport.ConnectionString, utilisateur);

                }
                else if (line.StartsWith("enregistrerVisite"))
                {
                    var visite = new VisiteDTO();
                    var membre = new MembreDTO();
                    membre.IdMembre = Convert.ToInt32(argumentList[1]);
                    visite.Membre = membre;

                    message = "Enregistrement d'une visite\n";
                    gestionSport.VisiteFacade.EnregistrerVisite(gestionSport.ConnectionString, visite);
                }
                else if (line.StartsWith("desinscrire"))
                {
                    var inscription = new InscriptionDTO();
                    inscription.IdInscription = Convert.ToInt32(argumentList[1]);
                    message = "désinscription de l'inscription : " + inscription.IdInscription +  "\n";
                    gestionSport.InscriptionFacade.Desinscrire(gestionSport.ConnectionString, inscription);
                }
                else if (line.StartsWith("listerActivite"))
                {
                    List<ActiviteDTO> listeActivite = gestionSport.ActiviteFacade.ListerActivite(gestionSport.ConnectionString);
                    message = "Liste des activités : \nIdActivite\tNom\tCout\tDescription\tDuree\tFlagSupprime\n";
                    if (listeActivite != null && listeActivite.Any())
                    {
                        foreach(ActiviteDTO activite in listeActivite)
                        {
                            message += activite.ToString();
                        }
                    }
                }
                else if (line.StartsWith("listerMembre"))
                {
                    List<MembreDTO> listeMembre = gestionSport.MembreFacade.ListerMembre(gestionSport.ConnectionString);
                    message = "Liste des membres : \nIdMembre\tPrenom\tNom\tAdresse\tVille\tTelephone\tEmail\tSexe\tDateNaissance\n";
                    if (listeMembre != null && listeMembre.Any())
                    {
                        foreach(MembreDTO membre in listeMembre)
                        {
                            message += membre.ToString();
                        }
                    }
                }
                else if (line.StartsWith("listerSeance"))
                {
                    List<SeanceDTO> listeSeance = gestionSport.SeanceFacade.ListerSeance(gestionSport.ConnectionString);
                    message = "Liste des seances : \nIdSeance\tIdActivite\tIdEntraineur\tIdSalle\tLimitePlace\tNbPlace\tDateSeance\tHeureDebut\tHeureFin\tFlagSupprime\n";
                    if (listeSeance != null && listeSeance.Any())
                    {
                        foreach (SeanceDTO seance in listeSeance)
                        {
                            message += seance.ToString();
                        }
                    }
                }
                else if (line.StartsWith("listerSalle"))
                {
                    List<SalleDTO> listeSalle = gestionSport.SalleFacade.ListerSalle(gestionSport.ConnectionString);
                    message = "Liste des salles : \nIdSalle\tNumero\tEtage\tBloc\n";
                    if (listeSalle != null && listeSalle.Any())
                    {
                        foreach (SalleDTO salle in listeSalle)
                        {
                            message += salle.ToString();
                        }
                    }
                }
                else if (line.StartsWith("listerEntraineur"))
                {
                    List<EntraineurDTO> listeEntraineur = gestionSport.EntraineurFacade.ListerEntraineur(gestionSport.ConnectionString);
                    message = "Liste des entraineurs : \nIdMembre\tPrenom\tNom\tAdresse\tVille\tTelephone\tEmail\tSexe\tDateNaissance\n";
                    if (listeEntraineur != null && listeEntraineur.Any())
                    {
                        foreach (EntraineurDTO entraineur in listeEntraineur)
                        {
                            message += entraineur.ToString();
                        }
                    }
                }
                else if (line.StartsWith("listerAbonnements"))
                {
                    List<AbonnementGymDTO> listeAbonnements = gestionSport.AbonnementGymFacade.ListerAbonnements(gestionSport.ConnectionString);
                    message = "Liste des abonnements : \nIdAbonnement\tidMemebre\tDuree\tCout\tDateAbonnement\tFlagSupprime\n";
                    if (listeAbonnements != null && listeAbonnements.Any())
                    {
                        foreach (AbonnementGymDTO abonnement in listeAbonnements)
                        {
                            message += abonnement.ToString();
                        }
                    }
                }
                else if (line.StartsWith("listerInscriptions"))
                {
                    List<InscriptionDTO> listeInscriptions = gestionSport.InscriptionFacade.ListerInscriptions(gestionSport.ConnectionString);
                    message = "Liste des inscriptions : \nIdInscription\tidMemebre\tidSeance\tDateInscription\tFlagPaiement\tFlagSupprime\n";
                    if (listeInscriptions != null && listeInscriptions.Any())
                    {
                        foreach (InscriptionDTO inscription in listeInscriptions)
                        {
                            message += inscription.ToString();
                        }
                    }
                }
                else if (line.StartsWith("listerUtilisateurs"))
                {
                    List<UtilisateurDTO> listeUtilisateurs = gestionSport.UtilisateurFacade.ListerUtilisateurs(gestionSport.ConnectionString);
                    message = "Liste des utilisateurs : \nIdUtilisateur\tNomUtilisateur\tNom\tPrenom\tEmail\tMotdePasse\tStatut\tFlagSupprime\n";
                    if (listeUtilisateurs != null && listeUtilisateurs.Any())
                    {
                        foreach (UtilisateurDTO utilisateur in listeUtilisateurs)
                        {
                            message += utilisateur.ToString();
                        }
                    }
                }
                else if (line.StartsWith("listerVisites"))
                {
                    List<VisiteDTO> listeVisites = gestionSport.VisiteFacade.ListerVisites(gestionSport.ConnectionString);
                    message = "Liste des visites : \nIdVisite\tIdMembre\tDateVisite\n";
                    if (listeVisites != null && listeVisites.Any())
                    {
                        foreach (VisiteDTO visite in listeVisites)
                        {
                            message += visite.ToString();
                        }
                    }
                }
                else if (line.StartsWith("rechercherMembreParNom"))
                {
                    message = "recherche du membre possèdant le nom: " + argumentList[1] + "\n";
                    var membre = new MembreDTO();
                    membre.Nom = argumentList[1];
                    var listeMembre = gestionSport.MembreFacade.RechercherMembreParNom(gestionSport.ConnectionString, membre);
                }
                else if (line.StartsWith("rechercherMembre"))
                {
                    var membre = new MembreDTO();
                    membre.IdMembre = Convert.ToInt32(argumentList[1]);
                    var membreRecherche = gestionSport.MembreFacade.RechercherMembre(gestionSport.ConnectionString, membre);
                    message = "Recherche d'un membre : " + membreRecherche.ToString();
                }
                else if (line.StartsWith("rechercherSeance"))
                {
                    var seance = new SeanceDTO();
                    seance.IdSeance = Convert.ToInt32(argumentList[1]);
                    var seanceRecherche = gestionSport.SeanceFacade.RechercherSeance(gestionSport.ConnectionString, seance);
                    message = "Recherche d'une séance : " + seanceRecherche.ToString();
                }
                else if (line.StartsWith("rechercherInscription"))
                {
                    var inscription = new InscriptionDTO();
                    inscription.IdInscription = Convert.ToInt32(argumentList[1]);
                    var inscriptionRecherche = gestionSport.InscriptionFacade.RechercherInscription(gestionSport.ConnectionString, inscription);
                    message = "Recherche d'une inscription : " + inscriptionRecherche.ToString();
                }
                else if (line.StartsWith("rechercherActivite"))
                {
                    var activite = new ActiviteDTO();
                    activite.IdActivite = Convert.ToInt32(argumentList[1]);
                    var activiteRecherche = gestionSport.ActiviteFacade.RechercherActivite(gestionSport.ConnectionString, activite);
                    message = "Recherche d'une activite : " + activiteRecherche.ToString();
                }
                else if (line.StartsWith("rechercherEntraineur"))
                {
                    var entraineur = new EntraineurDTO();
                    entraineur.IdEntraineur = Convert.ToInt32(argumentList[1]);
                    var entraineurRecherche = gestionSport.EntraineurFacade.RechercherEntraineur(gestionSport.ConnectionString, entraineur);
                    message = "Recherche d'un entraineur : " + entraineurRecherche.ToString();
                }
                else if (line.StartsWith("rechercherAbonnement"))
                {
                    var abonnement = new AbonnementGymDTO();
                    abonnement.IdAbonnement = Convert.ToInt32(argumentList[1]);
                    var abonnementRecherche = gestionSport.AbonnementGymFacade.RechercherAbonnement(gestionSport.ConnectionString, abonnement);
                    message = "Recherche de l'abonnement: " + abonnementRecherche.ToString();
                }
                else
                {
                    message = "commande inconnue\n";
                }

            }
            catch (Exception exception)
            {
                message += exception.Message + "\n";
            }
            richTextBox1.Text += message;
        }
        public AbonnementGymDTO RechercherAbonnement(string connectionString, AbonnementGymDTO abonnementGymDTO)
        {
            AbonnementGymDTO abonnementRecherche = null;

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

            try
            {
                abonnementRecherche = Find(connectionString, abonnementGymDTO);
                if (abonnementRecherche == null)
                {
                    throw new ServiceException("La seance " + abonnementGymDTO.IdAbonnement + " n'existe pas.");
                }
                return abonnementRecherche;
            }
            catch (DAOException daoException)
            {
                throw new ServiceException(daoException.Message, daoException);
            }
        }
 public void Update(string connectionString, AbonnementGymDTO abonnementGymDTO)
 {
     try
     {
         abonnementGymDAO.Update(connectionString, abonnementGymDTO);
     }
     catch (DAOException daoException)
     {
         throw new ServiceException(daoException.Message, daoException);
     }
 }
        public void TerminerUnAbonnement(string connectionString, AbonnementGymDTO abonnementGymDTO)
        {
            if (abonnementGymDTO == null)
            {
                throw new ServiceException("L'abonnement que vous voulez terminer ne peut être null.");
            }
            try
            {
                AbonnementGymDTO abonnementTerminer = this.abonnementGymDAO.Find(connectionString, abonnementGymDTO);
                if (abonnementTerminer == null)
                {
                    throw new ServiceException("L'abonnement que vous désirez terminer n'existe pas.");
                }
                if (abonnementTerminer.FlagSupprime)
                {
                    throw new ServiceException("L'abonnement que vous désirez terminer à déjà été terminé.");
                }

                abonnementTerminer.FlagSupprime = true;

                Update(connectionString, abonnementTerminer);
            }
            catch (DAOException daoException)
            {
                throw new ServiceException(daoException.Message, daoException);
            }
        }