Esempio n. 1
0
        public void CreerSalle(string connectionString, SalleDTO salleDTO)
        {
            if (salleDTO == null)
            {
                throw new ServiceException("Le DTO passé en paramètre ne peut être null");
            }
            try
            {
                var listeSalle = ListerSalle(connectionString);
                if(listeSalle != null)
                {
                    foreach (var salle in listeSalle)
                    {
                        if (salle.Numero == salleDTO.Numero)
                        {
                            throw new ServiceException("Un salle est déjà assigné à ce numéro");
                        }
                    }
                }

                Add(connectionString, salleDTO);
            }
            catch (ServiceException serviceException)
            {
                throw new ServiceException(serviceException.Message, serviceException);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Ajoute une salle à base de donneés.
        /// </summary>
        /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
        /// <param name="salleDTO">Représente la salle qui sera ajouté.</param>
        public void Add(string connectionString, SalleDTO salleDTO)
        {
            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(SalleDAO.ADD_REQUEST, connection);
                    addPreparedStatement.Parameters.AddWithValue("@numero", salleDTO.Numero);
                    addPreparedStatement.Parameters.AddWithValue("@etage", salleDTO.Etage);
                    addPreparedStatement.Parameters.AddWithValue("@bloc", salleDTO.Bloc);
                    addPreparedStatement.Prepare();
                    addPreparedStatement.ExecuteNonQuery();
                }
            }
            catch (SqlException sqlException)
            {
                throw new DAOException(sqlException.Message, sqlException);
            }
        }
Esempio n. 3
0
 public void Delete(string connectionString, SalleDTO salleDTO)
 {
     try
     {
         salleDAO.Delete(connectionString, salleDTO);
     }
     catch (DAOException daoException)
     {
         throw new ServiceException(daoException.Message, daoException);
     }
 }
Esempio n. 4
0
 public void ModifierSalle(string connectionString, SalleDTO salleDTO)
 {
     try
     {
         salleService.ModifierSalle(connectionString, salleDTO);
     }
     catch (ServiceException serviceException)
     {
         throw new FacadeException(serviceException.Message, serviceException);
     }
 }
Esempio n. 5
0
 public SalleDTO RechercherSalle(string connectionString, SalleDTO salleDTO)
 {
     SalleDTO salleRecherche = null;
     try
     {
         salleRecherche = this.salleService.RechercherSalle(connectionString, salleDTO);
     }
     catch (ServiceException serviceException)
     {
         throw new FacadeException(serviceException.Message, serviceException);
     }
     return salleRecherche;
 }
        public SalleDTO GetSelectedSalle(GestionSport gestionSport)
        {
            SalleDTO salleSelected = null;
            var currentRow = this.CurrentRow;

            if (!currentRow.IsNewRow)   //Si la row clické n'est pas la dernière qui est toujours vide.
            {
                int salleId = Convert.ToInt32(this.Rows[currentRow.Index].Cells["idSalle"].Value);
                SalleDTO salleDTO = new SalleDTO();
                salleDTO.IdSalle = salleId;
                salleSelected = gestionSport.SalleFacade.RechercherSalle(gestionSport.ConnectionString, salleDTO);
            }
            return salleSelected;
        }
 /// <summary>
 /// Ajoute une salle dans la base de données.
 /// </summary>
 private void btnAjouterSalle_Click(object sender, EventArgs e)
 {
     if (SalleIsValid())
     {
         SalleDTO salleDTO = new SalleDTO();
         salleDTO.Bloc = txtBlocSalle.Text;
         salleDTO.Etage = Convert.ToInt32(txtEtageSalle.Text);
         salleDTO.Numero = Convert.ToInt32(txtNumeroSalle.Text);
         try
         {
             GestionSportApp.SalleFacade.CreerSalle(GestionSportApp.ConnectionString, salleDTO);
             RefreshSalle();
         }
         catch (FacadeException facadeException)
         {
             MessageBox.Show(facadeException.Message);
         }
     }
 }
Esempio n. 8
0
 public SalleDTO Find(string connectionString, SalleDTO salleDTO)
 {
     SalleDTO salleRecherche = null;
     try
     {
         salleRecherche = salleDAO.Find(connectionString, salleDTO);
     }
     catch (DAOException daoException)
     {
         throw new ServiceException(daoException.Message, daoException);
     }
     return salleRecherche;
 }
Esempio n. 9
0
        public SalleDTO RechercherSalle(string connectionString, SalleDTO salleDTO)
        {
            SalleDTO salleRecherche = null;

            if (salleDTO == null)
            {
                throw new ServiceException("La salle ne peut pas être null.");
            }

            try
            {
                salleRecherche = Find(connectionString, salleDTO);
                if (salleRecherche == null)
                {
                    throw new ServiceException("La salle " + salleDTO.IdSalle + " n'existe pas.");
                }
                return salleRecherche;
            }
            catch (DAOException daoException)
            {
                throw new ServiceException(daoException.Message, daoException);
            }
        }
 /// <summary>
 /// Remplit le formulaire de salle avec les informations du DTO passé en paramètre.
 /// </summary>
 /// <param name="salleDTO">Représente la salle qui sera affiché.</param>
 private void FillFieldsSalle(SalleDTO salleDTO)
 {
     if (salleDTO != null)
     {
         txtBlocSalle.Text = salleDTO.Bloc;
         txtEtageSalle.Text = salleDTO.Etage.ToString();
         txtNumeroSalle.Text = salleDTO.Numero.ToString();
         lblSalleId.Text = salleDTO.IdSalle.ToString();
     }
 }
Esempio n. 11
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;
        }
Esempio n. 12
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;
        }
Esempio n. 13
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;
        }
Esempio n. 14
0
        /// <summary>
        /// Recherche une salle dans la base de données.
        /// </summary>
        /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
        /// <param name="salleDTO">La salle qui sera recherché.</param>
        /// <returns>Si la salle recherché existe, alors elle sera retourné, sinon null.</returns>
        public SalleDTO Find(string connectionString, SalleDTO salleDTO)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new DAOException("Les paramètres de connexion n'ont pas été initialisé.");
            }

            SalleDTO salleRecherche = null;     //Salle recherché dans la base de données.

            try
            {
                using (MySqlConnection connection = new MySqlConnection(connectionString))
                {
                    connection.Open();
                    MySqlCommand findPreparedStatement = new MySqlCommand(SalleDAO.FIND_REQUEST, connection);
                    findPreparedStatement.Parameters.AddWithValue("@idSalle", salleDTO.IdSalle);
                    findPreparedStatement.Prepare();
                    using (MySqlDataReader dataReader = findPreparedStatement.ExecuteReader())
                    {
                        if (dataReader.Read())
                        {
                            salleRecherche = new SalleDTO();
                            salleRecherche.IdSalle = dataReader.GetInt32(0);
                            salleRecherche.Numero = dataReader.GetInt32(1);
                            salleRecherche.Etage = dataReader.GetInt32(2);
                            salleRecherche.Bloc = dataReader.GetString(3);
                        }
                    }
                }
            }
            catch (SqlException sqlException)
            {
                throw new DAOException(sqlException.Message, sqlException);
            }

            return salleRecherche;
        }
Esempio n. 15
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;
        }
Esempio n. 16
0
        /// <summary>
        /// Liste tous les salles.
        /// </summary>
        /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
        /// <returns>Une liste de tous les salles s'il y en a, sinon null.</returns>
        public List<SalleDTO> ReadAll(string connectionString)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new DAOException("Les paramètres de connexion n'ont pas été initialisé.");
            }

            List<SalleDTO> listeSalle = null;

            try
            {
                using (MySqlConnection connection = new MySqlConnection(connectionString))
                {
                    connection.Open();
                    MySqlCommand readAllPreparedStatement = new MySqlCommand(SalleDAO.READ_ALL_REQUEST, connection);
                    readAllPreparedStatement.Prepare();
                    using (MySqlDataReader dataReader = readAllPreparedStatement.ExecuteReader())
                    {
                        if (dataReader.HasRows)
                        {

                            listeSalle = new List<SalleDTO>();

                            while (dataReader.Read())
                            {
                                SalleDTO salleDTO = new SalleDTO();
                                salleDTO.IdSalle = dataReader.GetInt32(0);
                                salleDTO.Numero = dataReader.GetInt32(1);
                                salleDTO.Etage = dataReader.GetInt32(2);
                                salleDTO.Bloc = dataReader.GetString(3);
                                listeSalle.Add(salleDTO);
                            }
                        }
                    }
                }
            }
            catch (SqlException sqlException)
            {
                throw new DAOException(sqlException.Message, sqlException);
            }

            return listeSalle;
        }
Esempio n. 17
0
        public void ModifierSalle(string connectionString, SalleDTO salleDTO)
        {
            if (salleDTO == null)
            {
                throw new ServiceException("La salle ne peut être null");
            }
            try
            {
                if (Find(connectionString, salleDTO) == null)
                {
                    throw new ServiceException("La salle n'existe pas");
                }

                var listeSalle = ReadAll(connectionString);
                foreach (var item in listeSalle)
                {
                    if (item.Numero == salleDTO.Numero)
                    {
                        throw new ServiceException("Une salle possède déjà ce numéro");
                    }
                }

                Update(connectionString, salleDTO);

            }
            catch (DAOException daoException)
            {
                throw new ServiceException(daoException.Message, daoException);
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Efface une salle dans la base de données.
        /// </summary>
        /// <param name="connectionString">Les paramètres de connexion à la base de données.</param>
        /// <param name="salleDTO">Représente la salle qui sera effacé.</param>
        public void Delete(string connectionString, SalleDTO salleDTO)
        {
            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(SalleDAO.DELETE_REQUEST, connection);
                    deletePreparedStatement.Parameters.AddWithValue("@idSalle", salleDTO.IdSalle);
                    deletePreparedStatement.Prepare();
                    deletePreparedStatement.ExecuteNonQuery();
                }
            }
            catch (SqlException sqlException)
            {
                throw new DAOException(sqlException.Message, sqlException);
            }
        }
Esempio n. 19
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";
            }
        }