/// <summary>
 /// Ajoute un entraineur à la base de données.
 /// </summary>
 /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
 /// <param name="entraineurDTO">Représente l'entraineur qui sera ajouté.</param>
 public void Add(string connectionString, EntraineurDTO entraineurDTO)
 {
     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(EntraineurDAO.ADD_REQUEST, connection);
             addPreparedStatement.Parameters.AddWithValue("@nom", entraineurDTO.Nom);
             addPreparedStatement.Parameters.AddWithValue("@prenom", entraineurDTO.Prenom);
             addPreparedStatement.Parameters.AddWithValue("@adresse", entraineurDTO.Adresse);
             addPreparedStatement.Parameters.AddWithValue("@ville", entraineurDTO.Ville);
             addPreparedStatement.Parameters.AddWithValue("@telephone", entraineurDTO.Telephone);
             addPreparedStatement.Parameters.AddWithValue("@email", entraineurDTO.Email);
             addPreparedStatement.Parameters.AddWithValue("@sexe", entraineurDTO.Sexe);
             addPreparedStatement.Parameters.AddWithValue("@dateNaissance", entraineurDTO.DateNaissance);
             addPreparedStatement.Prepare();
             addPreparedStatement.ExecuteNonQuery();
         }
     }
     catch (SqlException sqlException)
     {
         throw new DAOException(sqlException.Message, sqlException);
     }
 }
        /// <inheritDoc/>
        public void EnregistrerEntraineur(string connectionString, EntraineurDTO entraineurDTO)
        {
            if (entraineurDTO == null)
            {
                throw new ServiceException("Le DTO ne peut être null");
            }

            entraineurDAO.Add(connectionString, entraineurDTO);
        }
 public void ModifierEntraineur(string connectionString, EntraineurDTO entraineurDTO)
 {
     try
     {
         entraineurService.ModifierEntraineur(connectionString, entraineurDTO);
     }
     catch (ServiceException serviceException)
     {
         throw new FacadeException(serviceException.Message, serviceException);
     }
 }
 /// <inheritDoc/>
 public void Delete(string connectionString, EntraineurDTO entraineurDTO)
 {
     try
     {
         entraineurDAO.Delete(connectionString, entraineurDTO);
     }
     catch (DAOException daoException)
     {
         throw new ServiceException(daoException.Message, daoException);
     }
 }
 /// <inheritDoc/>
 public EntraineurDTO Find(string connectionString, EntraineurDTO entraineurDTO)
 {
     EntraineurDTO entraineurRecherche = null;
     try
     {
         entraineurRecherche = entraineurDAO.Find(connectionString, entraineurDTO);
     }
     catch (DAOException daoException)
     {
         throw new ServiceException(daoException.Message, daoException);
     }
     return entraineurRecherche;
 }
 public EntraineurDTO RechercherEntraineur(string connectionString, EntraineurDTO entraineurDTO)
 {
     EntraineurDTO entraineurRecherche = null;
     try
     {
         entraineurRecherche = entraineurService.RechercherEntraineur(connectionString, entraineurDTO);
     }
     catch (ServiceException serviceException)
     {
         throw new FacadeException(serviceException.Message, serviceException);
     }
     return entraineurRecherche;
 }
        public EntraineurDTO GetSelectedEntraineur(GestionSport gestionSport)
        {
            EntraineurDTO entraieurSelected = null;
            var currentRow = this.CurrentRow;

            if (!currentRow.IsNewRow)
            {
                int entraineurId = Convert.ToInt32(this.Rows[currentRow.Index].Cells["idEntraineur"].Value);
                EntraineurDTO entraineurDTO = new EntraineurDTO();
                entraineurDTO.IdEntraineur = entraineurId;
                entraieurSelected = gestionSport.EntraineurFacade.RechercherEntraineur(gestionSport.ConnectionString, entraineurDTO);
            }
            return entraieurSelected;
        }
        /// <inheritDoc/>
        public void SupprimerEntraineur(string connectionString, EntraineurDTO entraineurDTO)
        {
            if (entraineurDTO == null)
            {
                throw new ServiceException("Le DTO ne peut être null");
            }

            EntraineurDTO unEntraineurDTO = entraineurDAO.Find(connectionString, entraineurDTO);

            if (unEntraineurDTO == null)
            {
                throw new ServiceException("L'entraineur passé en paramètre n'existe pas");
            }
            if (unEntraineurDTO.FlagSupprime)
            {
                throw new ServiceException("L'utilisateur à déjà été supprimé.");
            }
            unEntraineurDTO.FlagSupprime = true;
            Update(connectionString, unEntraineurDTO);
        }
        public EntraineurDTO RechercherEntraineur(string connectionString, EntraineurDTO entraineurDTO)
        {
            EntraineurDTO entraineurRecherche = null;

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

            try
            {
                entraineurRecherche = Find(connectionString, entraineurDTO);
                if (entraineurRecherche == null)
                {
                    throw new ServiceException("L'entraineur " + entraineurDTO.IdEntraineur + " n'existe pas.");
                }
                return entraineurRecherche;
            }
            catch (DAOException daoException)
            {
                throw new ServiceException(daoException.Message, daoException);
            }
        }
        /// <inheritDoc/>
        public void ModifierEntraineur(string connectionString, EntraineurDTO entraineurDTO)
        {
            if (entraineurDTO == null)
            {
                throw new ServiceException("Le DTO ne peut être null");
            }
            try
            {
                EntraineurDTO unEntraineurDTO = entraineurDAO.Find(connectionString, entraineurDTO);

                if (unEntraineurDTO == null)
                {
                    throw new ServiceException("L'entraineur passé en paramètre n'existe pas");
                }
                entraineurDAO.Update(connectionString, entraineurDTO);
            }
            catch (DAOException daoException)
            {
                throw new ServiceException(daoException.Message, daoException);
            }
        }
        /// <summary>
        /// Efface un entraineur de la base de données.
        /// </summary>
        /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
        /// <param name="entraineurDTO">Représente l'entraineur qui sera effacé.</param>
        public void Delete(string connectionString, EntraineurDTO entraineurDTO)
        {
            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(EntraineurDAO.DELETE_REQUEST, connection);
                    deletePreparedStatement.Parameters.AddWithValue("@idEntraineur", entraineurDTO.IdEntraineur);
                    deletePreparedStatement.Prepare();
                    deletePreparedStatement.ExecuteNonQuery();
                }
            }
            catch (SqlException sqlException)
            {
                throw new DAOException(sqlException.Message, sqlException);
            }
        }
Example #12
0
        /// <summary>
        /// Remplit les champs du tab entraineur avec les information de l'entraineur sélectionné
        /// </summary>
        /// <param name="entraineur"></param>
        private void FillFieldsEntraineur(EntraineurDTO entraineur)
        {
            if (entraineur != null)
            {
                txtIdEntraineur.Text = entraineur.IdEntraineur.ToString();
                txtNomEntraineur.Text = entraineur.Nom;
                txtPrenomEntraineur.Text = entraineur.Prenom;
                txtAdresseEntraineur.Text = entraineur.Adresse;
                txtVilleEntraineur.Text = entraineur.Ville;
                txtEmailEntraineur.Text = entraineur.Email;
                txtTelephoneEntraineur.Text = entraineur.Telephone;

                if (entraineur.Sexe.ToUpper() == "HOMME")
                {
                    rbHommeEntraineur.Checked = true;
                }
                else
                {
                    rbFemmeEntraineur.Checked = true;
                }
                dateTimePickerDateNaissanceEntraineur.Value = entraineur.DateNaissance;
                dateTimePickerDateNaissanceEntraineur.Value.ToString(Constantes.DATE_FORMAT);
            }
        }
        /// <summary>
        /// Lit tous les entraineurs de la base de données.
        /// </summary>
        /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
        /// <returns>Une liste de tous les entraineurs, s'il y en a, sinon null</returns>
        public List<EntraineurDTO> ReadAll(string connectionString)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new DAOException("Les paramètres de connexion n'ont pas été initialisé.");
            }

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

                            while (dataReader.Read())
                            {
                                EntraineurDTO entrainneurDTO = new EntraineurDTO();
                                entrainneurDTO.IdEntraineur = dataReader.GetInt32(0);
                                entrainneurDTO.Nom = dataReader.GetString(1);
                                entrainneurDTO.Prenom = dataReader.GetString(2);
                                entrainneurDTO.Adresse = dataReader.GetString(3);
                                entrainneurDTO.Ville = dataReader.GetString(4);
                                entrainneurDTO.Telephone = dataReader.GetString(5);
                                entrainneurDTO.Email = dataReader.GetString(6);
                                entrainneurDTO.Sexe = dataReader.GetString(7);
                                entrainneurDTO.DateNaissance = dataReader.GetDateTime(8);
                                entrainneurDTO.FlagSupprime = dataReader.GetBoolean(9);
                                listeEntraineur.Add(entrainneurDTO);
                            }
                        }
                    }
                }
            }
            catch (SqlException sqlException)
            {
                throw new DAOException(sqlException.Message, sqlException);
            }
            return listeEntraineur;
        }
Example #14
0
        /// <summary>
        /// Bouton qui permet d'ajouter un entraineur
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAjouterEntraineur_Click(object sender, EventArgs e)
        {
            txtErreurEntraineur.Text = string.Empty;
            EntraineurDTO nouvelEntraineur = new EntraineurDTO();
            string nom = txtNomEntraineur.Text;
            string prenom = txtPrenomEntraineur.Text;
            string adresse = txtAdresseEntraineur.Text;
            string ville = txtVilleEntraineur.Text;
            string telephone = txtTelephoneEntraineur.Text;
            string email = txtEmailEntraineur.Text;
            string sexe = rbHommeEntraineur.Checked ? rbHommeEntraineur.Text
                        : rbFemmeEntraineur.Checked ? rbFemmeEntraineur.Text
                        : string.Empty;
            DateTime dateNaissance = dateTimePickerDateNaissanceEntraineur.Value;

            nouvelEntraineur.Nom = nom;
            nouvelEntraineur.Prenom = prenom;
            nouvelEntraineur.Adresse = adresse;
            nouvelEntraineur.Ville = ville;
            nouvelEntraineur.Telephone = telephone;
            nouvelEntraineur.Email = email;
            nouvelEntraineur.Sexe = sexe;
            nouvelEntraineur.DateNaissance = dateNaissance;

            if (entraineurIsValid(nouvelEntraineur))
            {
                gestionSportApp.EntraineurFacade.EnregistrerEntraineur(gestionSportApp.ConnectionString, nouvelEntraineur);
                dataGridViewEntraineur.Refresh();
                ResetFieldsEntraineur();
                this.dataGridViewEntraineur.Clear();
                LoadEntraineur();
            }
        }
Example #15
0
        /// <summary>
        /// Bouton qui permet la modification d'un entraineur
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnModifierEntraineur_Click(object sender, EventArgs e)
        {
            txtErreurEntraineur.Text = string.Empty;
            try
            {
                EntraineurDTO entraineurSelected = new EntraineurDTO();
                entraineurSelected.IdEntraineur = Convert.ToInt32(txtIdEntraineur.Text);
                entraineurSelected.Nom = txtNomEntraineur.Text;
                entraineurSelected.Prenom = txtPrenomEntraineur.Text;
                entraineurSelected.Email = txtEmailEntraineur.Text;
                entraineurSelected.Adresse = txtAdresseEntraineur.Text;
                entraineurSelected.DateNaissance = dateTimePickerDateNaissanceEntraineur.Value;
                entraineurSelected.Sexe = rbHommeEntraineur.Checked ? rbHommeEntraineur.Text
                        : rbFemmeEntraineur.Checked ? rbFemmeEntraineur.Text
                        : string.Empty;
                entraineurSelected.Ville = txtVilleEntraineur.Text;
                entraineurSelected.Telephone = txtTelephoneEntraineur.Text;
                if (entraineurIsValid(entraineurSelected))
                {
                    this.GestionSportApp.EntraineurFacade.ModifierEntraineur(GestionSportApp.ConnectionString, entraineurSelected);
                    this.dataGridViewEntraineur.Clear();
                    ResetFieldsEntraineur();
                    LoadEntraineur();

                }
            }
            catch (FormatException)
            {
                txtErreurEntraineur.Text = "Vous n'avez pas sélectionné un entraineur";
            }
            catch (FacadeException facadeException)
            {
                MessageBox.Show(facadeException.Message);
            }
        }
Example #16
0
        /// <summary>
        /// Validation à appeler lors de la création et la modificatoin d'un entraineur
        /// </summary>
        /// <param name="entraineur"></param>
        /// <returns></returns>
        private bool entraineurIsValid(EntraineurDTO entraineur)
        {
            bool isValid = true;

            if (string.IsNullOrEmpty(entraineur.Nom))
            {
                isValid = false;
                txtErreurEntraineur.Text = "Erreur, vous devez spécifié le nom";
            }
            else if (string.IsNullOrEmpty(entraineur.Prenom))
            {
                isValid = false;
                txtErreurEntraineur.Text = "Erreur, vous devez spécifié le prénom";
            }
            else if (string.IsNullOrEmpty(entraineur.Adresse))
            {
                isValid = false;
                txtErreurEntraineur.Text = "Erreur, vous devez spécifié l'adresse";
            }
            else if (string.IsNullOrEmpty(entraineur.Ville))
            {
                isValid = false;
                txtErreurEntraineur.Text = "Erreur, vous devez spécifié le nom de la ville";
            }
            else if (string.IsNullOrEmpty(entraineur.Telephone))
            {
                isValid = false;
                txtErreurEntraineur.Text = "Erreur, vous devez spécifié le numéro de téléphone du membre";
            }
            else if (string.IsNullOrEmpty(entraineur.Email))
            {
                isValid = false;
                txtErreurEntraineur.Text = "Erreur, vous devez spécifié l'email du membre";
            }
            else if (!Validateur.EmailIsOK(entraineur.Email))
            {
                isValid = false;
                txtErreurEntraineur.Text = "Attention! Il y a une erreur dans la saisie\ndu email de l'entraineur";
            }
            else if (string.IsNullOrEmpty(entraineur.Sexe))
            {
                isValid = false;
                txtErreurEntraineur.Text = "Erreur, vous devez spécifié le sexe";
            }
            else if (entraineur.DateNaissance == null)
            {
                isValid = false;
                txtErreurEntraineur.Text = "Erreur, vous devez spécifié la date de naissance de l'entraineur";
            }
            return isValid;
        }
Example #17
0
        /// <summary>
        /// Lit tous les séances.
        /// </summary>
        /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
        /// <returns>Une liste de tous les seances, s'il y en a, sinon null.</returns>
        public List<SeanceDTO> ReadAll(string connectionString)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new DAOException("Les paramètres de connexion n'ont pas été initialisé.");
            }

            List<SeanceDTO> listeSeance = null;
            try
            {
                using (MySqlConnection connection = new MySqlConnection(connectionString))
                {
                    connection.Open();
                    MySqlCommand readAllPreparedStatement = new MySqlCommand(SeanceDAO.READ_ALL_REQUEST, connection);
                    readAllPreparedStatement.Prepare();
                    using (MySqlDataReader dataReader = readAllPreparedStatement.ExecuteReader())
                    {
                        if (dataReader.HasRows)     //S'il y a des rows.
                        {
                            listeSeance = new List<SeanceDTO>();    //On initialise la liste.
                            //idActivite, idEntraineur, idSalle, limitePlace, nbPlace, dateSeance, heureDebut, heureFin, flagSupprime
                            while (dataReader.Read())
                            {
                                SeanceDTO seanceDTO = new SeanceDTO();
                                seanceDTO.IdSeance = dataReader.GetInt32(0);

                                //Activite
                                ActiviteDTO activiteDTO = new ActiviteDTO();
                                activiteDTO.IdActivite = dataReader.GetInt32(1);
                                seanceDTO.Activite = activiteDTO;

                                //Entraineur.
                                EntraineurDTO entraineurDTO = new EntraineurDTO();
                                entraineurDTO.IdEntraineur = dataReader.GetInt32(2);
                                seanceDTO.Entraineur = entraineurDTO;

                                //Salle.
                                SalleDTO salleDTO = new SalleDTO();
                                salleDTO.IdSalle = dataReader.GetInt32(3);
                                seanceDTO.Salle = salleDTO;

                                seanceDTO.LimitePlace = dataReader.GetInt32(4);
                                seanceDTO.NbPlaces = dataReader.GetInt32(5);
                                seanceDTO.DateSeance = dataReader.GetDateTime(6);
                                seanceDTO.HeureDebut = dataReader.GetFloat(7);
                                seanceDTO.HeureFin = dataReader.GetFloat(8);
                                seanceDTO.FlagSupprime = dataReader.GetBoolean(9);

                                listeSeance.Add(seanceDTO);
                            }
                        }
                    }
                }
            }
            catch (InvalidCastException invalidCastException)
            {
                throw new DAOException(invalidCastException.Message, invalidCastException);
            }
            catch (SqlException sqlException)
            {
                throw new DAOException(sqlException.Message, sqlException);
            }
            return listeSeance;
        }
Example #18
0
        /// <summary>
        /// Recherhe les seances à l'aide d'une salle.
        /// </summary>
        /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
        /// <param name="seanceDTO">Représente la séance à trouver.</param>
        /// <returns>S'il y a des séances, une liste de celles-ci, sinon null.</returns>
        public List<SeanceDTO> FindBySalle(string connectionString, SalleDTO salleDTO)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new DAOException("Les paramètres de connexion n'ont pas été initialisé.");
            }

            List<SeanceDTO> listeSeance = null;
            try
            {
                using (MySqlConnection connection = new MySqlConnection(connectionString))
                {
                    connection.Open();
                    MySqlCommand findByEntraineurPreparedStatement = new MySqlCommand(SeanceDAO.FIND_BY_SALLE, connection);
                    findByEntraineurPreparedStatement.Parameters.AddWithValue("@idSalle", salleDTO.IdSalle);
                    using (MySqlDataReader dataReader = findByEntraineurPreparedStatement.ExecuteReader())
                    {
                        if (dataReader.HasRows) // Si la requête n'est pas vide
                        {

                            listeSeance = new List<SeanceDTO>();

                            while (dataReader.Read())
                            {
                                SeanceDTO seanceRecherche = new SeanceDTO();
                                seanceRecherche.IdSeance = dataReader.GetInt32(0);

                                //Activite
                                ActiviteDTO activiteRecherche = new ActiviteDTO();
                                activiteRecherche.IdActivite = dataReader.GetInt32(1);
                                seanceRecherche.Activite = activiteRecherche;

                                //Entraineur.
                                EntraineurDTO entraineurRecherche = new EntraineurDTO();
                                entraineurRecherche.IdEntraineur = dataReader.GetInt32(2);
                                seanceRecherche.Entraineur = entraineurRecherche;

                                //Salle.
                                SalleDTO salleRecherche = new SalleDTO();
                                salleRecherche.IdSalle = dataReader.GetInt32(3);
                                seanceRecherche.Salle = salleRecherche;

                                seanceRecherche.LimitePlace = dataReader.GetInt32(4);
                                seanceRecherche.NbPlaces = dataReader.GetInt32(5);
                                seanceRecherche.DateSeance = dataReader.GetDateTime(6);
                                seanceRecherche.HeureDebut = dataReader.GetFloat(7);
                                seanceRecherche.HeureFin = dataReader.GetFloat(8);
                                seanceRecherche.FlagSupprime = dataReader.GetBoolean(9);
                                listeSeance.Add(seanceRecherche);
                            }
                        }
                    }
                }
            }
            catch (MySqlException mySqlException)
            {
                throw new DAOException(mySqlException.Message, mySqlException);
            }
            return listeSeance;
        }
Example #19
0
        /// <summary>
        /// Recherche une séance selon une date, une heure de debut et de fin et une salle.
        /// </summary>
        /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
        /// <param name="seanceDTO">Représente la séance à chercher.</param>
        /// <returns>La séance s'il y en a, sinon null.</returns>
        public SeanceDTO FindByMoment(string connectionString, SeanceDTO seanceDTO)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new DAOException("Les paramètres de connexion n'ont pas été initialisé.");
            }

            SeanceDTO seanceRecherche = null;
            try
            {
                using (MySqlConnection connection = new MySqlConnection(connectionString))
                {
                    connection.Open();
                    MySqlCommand findByMomentPreparedStatement = new MySqlCommand(SeanceDAO.FIND_BY_MOMENT, connection);
                    findByMomentPreparedStatement.Parameters.AddWithValue("@dateSeance", seanceDTO.DateSeance);
                    findByMomentPreparedStatement.Parameters.AddWithValue("@heureDebut", seanceDTO.HeureDebut);
                    findByMomentPreparedStatement.Parameters.AddWithValue("@heureFin", seanceDTO.HeureFin);
                    findByMomentPreparedStatement.Parameters.AddWithValue("@idSalle", seanceDTO.Salle.IdSalle);
                    findByMomentPreparedStatement.Prepare();

                    using (MySqlDataReader dataReader = findByMomentPreparedStatement.ExecuteReader())
                    {
                        if (dataReader.Read())
                        {
                            seanceRecherche = new SeanceDTO();
                            seanceRecherche.IdSeance = dataReader.GetInt32(0);

                            //Activite
                            ActiviteDTO activiteDTO = new ActiviteDTO();
                            activiteDTO.IdActivite = dataReader.GetInt32(1);
                            seanceRecherche.Activite = activiteDTO;

                            //Entraineur.
                            EntraineurDTO entraineurDTO = new EntraineurDTO();
                            entraineurDTO.IdEntraineur = dataReader.GetInt32(2);
                            seanceRecherche.Entraineur = entraineurDTO;

                            //Salle.
                            SalleDTO salleDTO = new SalleDTO();
                            salleDTO.IdSalle = dataReader.GetInt32(3);
                            seanceRecherche.Salle = salleDTO;

                            seanceRecherche.LimitePlace = dataReader.GetInt32(4);
                            seanceRecherche.NbPlaces = dataReader.GetInt32(5);
                            seanceRecherche.DateSeance = dataReader.GetDateTime(6);
                            seanceRecherche.HeureDebut = dataReader.GetFloat(7);
                            seanceRecherche.HeureFin = dataReader.GetFloat(8);
                            seanceRecherche.FlagSupprime = dataReader.GetBoolean(9);
                        }
                    }
                }
            }
            catch (InvalidCastException invalidCastException)
            {
                throw new DAOException(invalidCastException.Message, invalidCastException);
            }
            catch (SqlException sqlException)
            {
                throw new DAOException(sqlException.Message, sqlException);
            }
            return seanceRecherche;
        }
Example #20
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;
        }
Example #21
0
        /// <summary>
        /// Bouton qui permet de modifier les informations d'une séance dans la base de données
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnModifierSeance_Click(object sender, EventArgs e)
        {
            if (lblIdSeance.Text != "")
            {
                SeanceDTO nouvelleSeance = new SeanceDTO();
                string idSeance = lblIdSeance.Text;
                string activite = cbActiviteSeance.Text;
                string entraineur = cbEntraineurSeance.Text;
                string salle = cbSalleSeance.Text;
                string limitePlace = txtLimitePlacesSeance.Text;
                string nbPlaces = txtNombrePlacesSeance.Text;
                DateTime dateSeance = dateTimePickerDateSeance.Value;
                string heureDebut = txtHeureDebutSeance.Text;
                string heureFin = txtHeureFinSeance.Text;

                nouvelleSeance.IdSeance = Int32.Parse(idSeance);
                ActiviteDTO activiteSeance = new ActiviteDTO();
                activiteSeance.IdActivite = (cbActiviteSeance.SelectedItem as ComboboxItem).Value;
                nouvelleSeance.Activite = activiteSeance;

                EntraineurDTO entraineurSeance = new EntraineurDTO();
                entraineurSeance.IdEntraineur = (cbEntraineurSeance.SelectedItem as ComboboxItem).Value;
                nouvelleSeance.Entraineur = entraineurSeance;

                SalleDTO salleSeance = new SalleDTO();
                salleSeance.IdSalle = (cbSalleSeance.SelectedItem as ComboboxItem).Value;
                nouvelleSeance.Salle = salleSeance;

                nouvelleSeance.LimitePlace = Int32.Parse(limitePlace);
                nouvelleSeance.NbPlaces = Int32.Parse(nbPlaces);
                nouvelleSeance.DateSeance = dateSeance;
                nouvelleSeance.HeureDebut = float.Parse(heureDebut);
                nouvelleSeance.HeureFin = float.Parse(heureFin);
                nouvelleSeance.FlagSupprime = false;

                if (SeanceIsValid(nouvelleSeance))
                {
                    try
                    {
                        if (activite == "musculation")
                        {
                            gestionSportApp.SeanceFacade.ModifierSeanceMusculation(gestionSportApp.ConnectionString, nouvelleSeance);
                        }
                        else
                        {
                            gestionSportApp.SeanceFacade.ModifierSeance(gestionSportApp.ConnectionString, nouvelleSeance);
                        }
                        dataGridViewSeance.Refresh();
                        ResetFieldsSeance();
                        this.dataGridViewSeance.Clear();
                        LoadSeance();
                    }
                    catch (FacadeException facadeException)
                    {
                        MessageBox.Show(facadeException.Message);
                    }
                }
            }
            else
            {
                lblErrorSeance.Text = "Veuillez sélectionner une séance";
            }
        }
        /// <summary>
        /// Recherche un entraineur.
        /// </summary>
        /// <param name="connexion">La connexion au serveur</param>
        /// <param name="entraineurDTO">Représente l'entraineur qui sera recherché</param>
        /// <returns>Un entraineur s'il existe, sinon null.</returns>
        public EntraineurDTO Find(string connectionString, EntraineurDTO entraineurDTO)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new DAOException("Les paramètres de connexion n'ont pas été initialisé.");
            }

            EntraineurDTO entraineurRecherche = null;   //Représente l'entraineur qui est recherché.

            try
            {
                using (MySqlConnection connection = new MySqlConnection(connectionString))
                {
                    connection.Open();
                    MySqlCommand findPreparedStatement = new MySqlCommand(EntraineurDAO.FIND_REQUEST, connection);
                    findPreparedStatement.Parameters.AddWithValue("@idEntraineur", entraineurDTO.IdEntraineur);
                    findPreparedStatement.Prepare();
                    MySqlDataReader dataReader = findPreparedStatement.ExecuteReader();
                    if (dataReader.Read())
                    {
                        entraineurRecherche = new EntraineurDTO();
                        entraineurRecherche.IdEntraineur = dataReader.GetInt32(0);
                        entraineurRecherche.Nom = dataReader.GetString(1);
                        entraineurRecherche.Prenom = dataReader.GetString(2);
                        entraineurRecherche.Adresse = dataReader.GetString(3);
                        entraineurRecherche.Ville = dataReader.GetString(4);
                        entraineurRecherche.Telephone = dataReader.GetString(5);
                        entraineurRecherche.Email = dataReader.GetString(6);
                        entraineurRecherche.Sexe = dataReader.GetString(7);
                        entraineurRecherche.DateNaissance = dataReader.GetDateTime(8);
                        entraineurRecherche.FlagSupprime = dataReader.GetBoolean(9);

                    }
                }
            }
            catch (SqlException sqlException)
            {
                throw new DAOException(sqlException.Message, sqlException);
            }

            return entraineurRecherche;
        }
Example #23
0
 /// <summary>
 /// bouton qui permet la suppression d'un entraineur
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSupprimerEntraineur_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtIdEntraineur.Text != "")
         {
             EntraineurDTO entraineurDTO = new EntraineurDTO();
             entraineurDTO.IdEntraineur = Int32.Parse(txtIdEntraineur.Text);
             GestionSportApp.EntraineurFacade.SupprimerEntraineur(GestionSportApp.ConnectionString, entraineurDTO);
             dataGridViewEntraineur.Clear();
             ResetFieldsEntraineur();
             LoadEntraineur();
         }
         else
         {
             lblErrorSeance.Text = "Veuillez sélectionner un entraineur";
         }
     }
     catch (FacadeException facadeException)
     {
         MessageBox.Show(facadeException.Message);
     }
 }