示例#1
0
        //change le prix réel en fonction de la pièce sélectionnée dans ajoutReprésentation
        private void cbChoixPieceSaisieShow_TextChanged(object sender, EventArgs e)
        {
            //on affiche le prix
            TheaterPiece maPiece = ModulePiecesTheatre.GetOneTheaterPiece(cbChoixPieceSaisieShow.Text);

            if (maPiece != null)
            {
                lblPrixFixeAjoutRep.Text = maPiece.TheaterPiece_seatsPrice.ToString() + " €";
            }
        }
示例#2
0
        //change le prix réel en fonction de la pièce sélectionnée dans ajoutReprésentation
        private void cbModifPiece_TextChanged(object sender, EventArgs e)
        {
            //on affiche le prix
            TheaterPiece maPiece = ModulePiecesTheatre.GetOneTheaterPiece(cbModifPiece.Text);

            if (maPiece != null)
            {
                lblPrixFixeModifRep.Text = maPiece.TheaterPiece_seatsPrice.ToString() + " €";
                //on récupère date saisie et heure à mettre en datetime
                string   mesdates = dateTimePickerModifDate.Text.ToString() + " " + textBoxModifHeure.Text.ToString();
                DateTime parsedDate;
                bool     retConv = DateTime.TryParse(mesdates, out parsedDate);
                if (retConv == true && dateTimePickerModifDate.Text.Trim() != "" && textBoxModifHeure.Text.Trim() != "")
                {
                    //on vérifie l'heure pour voir dans quelle tranche de pricerate on va
                    List <PriceRate> Lestaux = new List <PriceRate>();
                    Lestaux = ModuleRepresentations.GetPriceRate();
                    List <PriceRate> LestauxdansLHeure = new List <PriceRate>();
                    PriceRate        monTaux           = null;
                    foreach (PriceRate unTaux in Lestaux)
                    {
                        TimeSpan debutHeure = unTaux.PriceRate_startTime;
                        TimeSpan finHeure   = unTaux.PriceRate_endTime;
                        TimeSpan monHeure   = TimeSpan.Parse(textBoxModifHeure.Text.ToString());
                        if (debutHeure <= monHeure && monHeure <= finHeure)
                        {
                            LestauxdansLHeure.Add(unTaux);
                        }
                    }
                    //on vérifie le jour et on a le pricerate !!!!
                    string monJour = parsedDate.ToString("dddd");

                    foreach (PriceRate unTaux in LestauxdansLHeure)
                    {
                        foreach (WeekDays unJour in unTaux.PriceRate_weekDays)
                        {
                            if (unJour.WeekDays_name == monJour)
                            {
                                monTaux = unTaux;
                            }
                        }
                    }
                    if (monTaux != null)
                    {
                        float seatPrice = maPiece.TheaterPiece_seatsPrice;
                        float prixReel  = seatPrice + (seatPrice * monTaux.PriceRate_rate);
                        lblPrixReelModifRep.Text = prixReel.ToString() + " €";
                    }
                }
            }
        }
示例#3
0
        //- une méthode qui renvoie le nombre de représentations pour une pièce* GetNbShows(TheaterPiece laPiece) *
        //  Appel de la requête SQL GetShows(), puis tris de la liste pour en construire une avec seulement les shows concernés par la pièce passée en param et renvoie cette nouvelle liste
        public static int GetNbShows(TheaterPiece laPiece)
        {
            List <Show> shows   = RepresentationsDAO.GetShows();
            int         nbShows = 0;

            foreach (Show unshow in shows)
            {
                if (unshow.Show_theaterPiece.TheaterPiece_id == laPiece.TheaterPiece_id)
                {
                    nbShows++;
                }
            }
            return(nbShows);
        }
示例#4
0
        //- une méthode qui renvoie le nombre de représentations SUR UNE PERIODE pour une pièce    *GetNbShows(TheaterPiece laPiece, DateTime dateDebut, DateTime dateFin) *
        //  Appel de la requête SQL GetFilterShowsDate(), puis tris de la liste pour en construire une avec seulement les shows concernés par la pièce passée en param et renvoie cette nouvelle liste
        public static int GetNbShows(TheaterPiece laPiece, DateTime dateDebut, DateTime dateFin)
        {
            List <Show> shows   = RepresentationsDAO.GetFilterShows(laPiece.TheaterPiece_id, dateDebut, dateFin);
            int         nbShows = 0;

            foreach (Show unshow in shows)
            {
                if (unshow.Show_theaterPiece.TheaterPiece_id == laPiece.TheaterPiece_id)
                {
                    nbShows++;
                }
            }
            return(nbShows);
        }
示例#5
0
        //- une méthode qui renvoie le nombre total de spectateur pour une pièce    *GetNbSpectators(TheaterPiece laPiece) *
        //  Appel de la requête SQL GetSpectators(), on compte le nombre de spectateurs (addition de tous les seatsBooked) qui sont concernés par la pièce passée en param(spectator.show.piece.id == laPiece.id) et on renvoie ce nombre.
        public static int GetNbSpectators(TheaterPiece laPiece)
        {
            List <Spectator> spectators = ReservationsDAO.GetSpectators();
            int nbSpectators            = 0;

            foreach (Spectator unSpectateur in spectators)
            {
                if (unSpectateur.Spectator_show.Show_theaterPiece.TheaterPiece_id == laPiece.TheaterPiece_id)
                {
                    nbSpectators = nbSpectators + unSpectateur.Spectator_seatsBooked;
                }
            }
            return(nbSpectators);
        }
示例#6
0
        //- une méthode qui renvoie le CA total réalisé pour une pièce* GetCaTotal(TheaterPiece laPiece)*
        //  Appel de la requête SQL GetSpectators(), pour chaque spectator concerné par la pièce passée en param, on calcule le prix qu'il a payé et on l'ajoute à une variable qui récupère le total.On renvoi ce total.
        public static float GetCaTotal(TheaterPiece laPiece)
        {
            List <Spectator> spectators = ReservationsDAO.GetSpectators();
            float            prixTotal  = 0;

            foreach (Spectator unSpectateur in spectators)
            {
                if (laPiece.TheaterPiece_id == unSpectateur.Spectator_show.Show_theaterPiece.TheaterPiece_id)
                {
                    float prixaPayer = unSpectateur.Spectator_seatsBooked * (laPiece.TheaterPiece_seatsPrice + laPiece.TheaterPiece_seatsPrice * unSpectateur.Spectator_show.Show_priceRate.PriceRate_rate);
                    prixTotal = prixTotal + prixaPayer;
                }
            }
            return(prixTotal);
        }
示例#7
0
        //- une méthode qui renvoie le nombre total de spectateur SUR UNE PERIODE pour une pièce* GetNbSpectators(TheaterPiece laPiece, DateTime dateDebut, DateTime dateFin)*
        //  Appel de la requête SQL GetSpectators() et appel de la requête SQL GetFilterShowsDate(), on compte le nombre de spectateurs(addition de tous les seatsBooked) qui sont concernés par ces show et on renvoie ce nombre.
        public static int GetNbSpectators(TheaterPiece laPiece, DateTime dateDebut, DateTime dateFin)
        {
            List <Spectator> spectators = ReservationsDAO.GetSpectators();                                                //liste spectateurs
            List <Show>      shows      = RepresentationsDAO.GetFilterShows(laPiece.TheaterPiece_id, dateDebut, dateFin); //listes des shows à une date donnée
            int nbSpectators            = 0;

            foreach (Show unShow in shows)
            {
                foreach (Spectator unSpectateur in spectators)
                {
                    if (laPiece.TheaterPiece_id == unSpectateur.Spectator_show.Show_theaterPiece.TheaterPiece_id && laPiece.TheaterPiece_id == unShow.Show_theaterPiece.TheaterPiece_id)
                    {
                        nbSpectators = nbSpectators + unSpectateur.Spectator_seatsBooked;
                    }
                }
            }
            return(nbSpectators);
        }
示例#8
0
        // Au changement de sélection d'une pièce
        private void cmbPiece_SelectedIndexChanged(object sender, EventArgs e)
        {
            cmbDates.Items.Clear();
            cmbHeures.Items.Clear();
            if (cmbPiece.SelectedItem != null)
            {
                TheaterPiece laPiece = cmbPiece.SelectedItem as TheaterPiece;

                lblLeTheme.Text     = laPiece.TheaterPiece_theme.Theme_name;
                lblLaDuree.Text     = TimeSpan.FromHours(double.Parse(laPiece.TheaterPiece_duration.ToString())).ToString(@"hh\:mm");
                lblLeType.Text      = laPiece.TheaterPiece_publicType.PublicType_name;
                lblLaCompagnie.Text = laPiece.TheaterPiece_company.Company_name;
                lblLePrixFixe.Text  = laPiece.TheaterPiece_seatsPrice.ToString() + " €";

                lesRepresentations = ModuleRepresentations.GetFilterShows(laPiece.TheaterPiece_id);

                if (lesRepresentations.Count > 0)
                {
                    cmbDates.Enabled = true;
                    foreach (var uneRep in lesRepresentations)
                    {
                        if (!cmbDates.Items.Contains(uneRep.Show_dateTime.ToString("dd/MM/yyyy")))
                        {
                            cmbDates.Items.Add(uneRep.Show_dateTime.ToString("dd/MM/yyyy"));
                        }
                    }
                }
                else
                {
                    cmbDates.Enabled = false;
                    cmbDates.Items.Add("Aucune date disponible");
                }
                cmbDates.SelectedIndex = 0;
            }
            else
            {
                lblLeTheme.Text     = String.Empty;
                lblLaDuree.Text     = String.Empty;
                lblLeType.Text      = String.Empty;
                lblLaCompagnie.Text = String.Empty;
                lblLePrixFixe.Text  = "€";
                lblLePrixTotal.Text = "0 €";
            }
        }
示例#9
0
        //- une méthode qui renvoie le CA total réalisé SUR UNE PERIODE pour une pièce   *GetCaTotal(TheaterPiece laPiece, DateTime dateDebut, DateTime dateFin) *
        //  Appel de la requête SQL GetSpectators() et appel de la requête SQL GetFilterShowsDate(), pour chaque spectator concerné par un des shows de la période, on calcule le prix qu'il a payé et on l'ajoute à une variable qui récupère le total. On renvoi ce total.
        public static float GetCaTotal(TheaterPiece laPiece, DateTime dateDebut, DateTime dateFin)
        {
            List <Spectator> spectators = ReservationsDAO.GetSpectators();                                                //liste spectateurs
            List <Show>      shows      = RepresentationsDAO.GetFilterShows(laPiece.TheaterPiece_id, dateDebut, dateFin); //listes des shows à une date donnée
            float            prixTotal  = 0;

            foreach (Show unShow in shows)
            {
                foreach (Spectator unSpectateur in spectators)
                {
                    if (laPiece.TheaterPiece_id == unSpectateur.Spectator_show.Show_theaterPiece.TheaterPiece_id && laPiece.TheaterPiece_id == unShow.Show_theaterPiece.TheaterPiece_id)
                    {
                        float prixaPayer = unSpectateur.Spectator_seatsBooked * (laPiece.TheaterPiece_seatsPrice + laPiece.TheaterPiece_seatsPrice * unSpectateur.Spectator_show.Show_priceRate.PriceRate_rate);
                        prixTotal = prixTotal + prixaPayer;
                    }
                }
            }
            return(prixTotal);
        }
        // Suppression de toutes les représentations par rapport à une pièce de théâtre
        public static void RemoveShows(TheaterPiece unePiece)
        {
            // Connexion à la BD
            SqlConnection maConnexion = ConnexionBD.GetConnexionBD().GetSqlConnexion();
            SqlCommand    cmd         = new SqlCommand();

            cmd.Connection  = maConnexion;
            cmd.CommandText = "DELETE FROM Show WHERE show_theaterPiece = @idPiece;";

            //param
            SqlParameter idPiece = new SqlParameter("@idPiece", SqlDbType.Int);

            idPiece.Value = unePiece.TheaterPiece_id;
            cmd.Parameters.Add(idPiece);
            //fin param
            cmd.ExecuteNonQuery();

            // Fermeture de la connexion
            maConnexion.Close();
        }
示例#11
0
        // Au changement de sélection de l'heure
        private void cmbHeures_SelectedValueChanged(object sender, EventArgs e)
        {
            TheaterPiece laPiece = cmbPiece.SelectedItem as TheaterPiece;

            foreach (var uneRep in lesRepresentations)
            {
                if (uneRep.Show_dateTime.ToString("dd/MM/yyyy") == cmbDates.SelectedItem.ToString() && uneRep.Show_dateTime.ToString("HH:mm") == cmbHeures.SelectedItem.ToString() && uneRep.Show_theaterPiece.TheaterPiece_id == laPiece.TheaterPiece_id)
                {
                    laRepres  = uneRep;
                    taux      = uneRep.Show_priceRate.PriceRate_rate;
                    prixPlace = uneRep.Show_theaterPiece.TheaterPiece_seatsPrice;

                    lblLePrixReel.Text = (laPiece.TheaterPiece_seatsPrice + (laPiece.TheaterPiece_seatsPrice * laRepres.Show_priceRate.PriceRate_rate)).ToString() + " €";

                    ChangementPlacesRest(laRepresAvEdit);
                }
            }

            ChangementPrixTotal();
        }
示例#12
0
        private void btnSupprimer_Click(object sender, EventArgs e)
        {
            var rep = MessageBox.Show("Êtes vous sûr de vouloir supprimer cette pièce de théatre ?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

            if (rep == DialogResult.Yes)
            {
                TheaterPiece unePiece = new TheaterPiece(int.Parse(lblIdPiece.Text));

                ModulePiecesTheatre.RemoveTheaterPiece(unePiece);
                List <Show> lesShows = ModuleRepresentations.GetShows();

                btnSupprimer.Enabled = false;
                btnModifier.Enabled  = false;
            }
            else
            {
                btnSupprimer.Enabled = false;
                btnModifier.Enabled  = false;
            }

            ListePiece();
        }
        // Suppression des réservations en fonction de la pièce
        public static void RemoveSpectators(TheaterPiece unePiece)
        {
            try
            {
                SqlConnection connexion = ConnexionBD.GetConnexionBD().GetSqlConnexion();

                string reqDelSpec = "DELETE FROM To_book WHERE toBook_show IN (SELECT show_id FROM Show WHERE show_theaterPiece = @idPiece) ; DELETE FROM Spectator WHERE spectator_id IN (SELECT toBook_spectator FROM To_Book, Show WHERE toBook_show = show_id AND show_theaterPiece = @idPiece ); ";

                SqlCommand commDelSpec = new SqlCommand(reqDelSpec, connexion);

                commDelSpec.Parameters.Add(new SqlParameter("@idPiece", System.Data.SqlDbType.Int));
                commDelSpec.Parameters["@idPiece"].Value = unePiece.TheaterPiece_id;

                commDelSpec.ExecuteNonQuery();

                connexion.Close();
            }
            catch (Exception e)
            {
                string error = e.Message;
            }
        }
示例#14
0
        // Modification d'une piece
        public static void EditTheaterPiece(TheaterPiece unePiece)
        {
            try
            {
                SqlConnection connexion = ConnexionBD.GetConnexionBD().GetSqlConnexion();
                string        reqEdit   = "UPDATE Theater_piece SET theaterPiece_name = @name, theaterPiece_description = @description, theaterPiece_duration = @duration, theaterPiece_seatsPrice = @seatsPrice, theaterPiece_company = @company, theaterPiece_author = @author, theaterPiece_publicType = @publicType, theaterPiece_theme = @theme WHERE theaterPiece_id = @id;";

                SqlCommand commEditPiece = new SqlCommand(reqEdit, connexion);

                commEditPiece.Parameters.Add(new SqlParameter("@name", System.Data.SqlDbType.VarChar, 255));
                commEditPiece.Parameters.Add(new SqlParameter("@id", System.Data.SqlDbType.Int));
                commEditPiece.Parameters.Add(new SqlParameter("@description", System.Data.SqlDbType.VarChar, 255));
                commEditPiece.Parameters.Add(new SqlParameter("@duration", System.Data.SqlDbType.Float));
                commEditPiece.Parameters.Add(new SqlParameter("@seatsPrice", System.Data.SqlDbType.Float));
                commEditPiece.Parameters.Add(new SqlParameter("@company", System.Data.SqlDbType.Int));
                commEditPiece.Parameters.Add(new SqlParameter("@author", System.Data.SqlDbType.Int));
                commEditPiece.Parameters.Add(new SqlParameter("@publicType", System.Data.SqlDbType.Int));
                commEditPiece.Parameters.Add(new SqlParameter("@theme", System.Data.SqlDbType.Int));

                commEditPiece.Parameters["@name"].Value        = unePiece.TheaterPiece_name;
                commEditPiece.Parameters["@id"].Value          = unePiece.TheaterPiece_id;
                commEditPiece.Parameters["@description"].Value = unePiece.TheaterPiece_description;
                commEditPiece.Parameters["@duration"].Value    = unePiece.TheaterPiece_duration;
                commEditPiece.Parameters["@seatsPrice"].Value  = unePiece.TheaterPiece_seatsPrice;
                commEditPiece.Parameters["@company"].Value     = unePiece.TheaterPiece_company.Company_id;
                commEditPiece.Parameters["@author"].Value      = unePiece.TheaterPiece_author.Author_id;
                commEditPiece.Parameters["@publicType"].Value  = unePiece.TheaterPiece_publicType.PublicType_id;
                commEditPiece.Parameters["@theme"].Value       = unePiece.TheaterPiece_theme.Theme_id;

                commEditPiece.ExecuteNonQuery();

                connexion.Close();
            }
            catch (Exception e)
            {
                //Message box erreur
                string test = e.ToString();
            }
        }
示例#15
0
        // suppression d'une piece
        public static void RemoveTheaterPiece(TheaterPiece unePiece)
        {
            try
            {
                SqlConnection connexion = ConnexionBD.GetConnexionBD().GetSqlConnexion();
                string        reqRemove = "DELETE FROM Theater_piece WHERE theaterPiece_id = @id;";

                SqlCommand commRemovePiece = new SqlCommand(reqRemove, connexion);

                commRemovePiece.Parameters.Add(new SqlParameter("@id", System.Data.SqlDbType.Int));

                commRemovePiece.Parameters["@id"].Value = unePiece.TheaterPiece_id;

                commRemovePiece.ExecuteNonQuery();

                connexion.Close();
            }
            catch (Exception e)
            {
                //Message box erreur
                string test = e.ToString();
            }
        }
示例#16
0
        // Ajout d'une nouvelle piece
        public static void AddTheaterPiece(TheaterPiece unePiece)
        {
            try
            {
                SqlConnection connexion = ConnexionBD.GetConnexionBD().GetSqlConnexion();
                string        reqAdd    = "INSERT INTO Theater_piece (theaterPiece_name, theaterPiece_description, theaterPiece_duration, theaterPiece_seatsPrice, theaterPiece_company, theaterPiece_author, theaterPiece_publicType, theaterPiece_theme) VALUES (@name, @description, @duration, @seatsPrice, @company, @author, @publicType, @theme);";

                SqlCommand commAddPiece = new SqlCommand(reqAdd, connexion);

                commAddPiece.Parameters.Add(new SqlParameter("@name", System.Data.SqlDbType.VarChar, 255));
                commAddPiece.Parameters.Add(new SqlParameter("@description", System.Data.SqlDbType.VarChar, 255));
                commAddPiece.Parameters.Add(new SqlParameter("@duration", System.Data.SqlDbType.Float));
                commAddPiece.Parameters.Add(new SqlParameter("@seatsPrice", System.Data.SqlDbType.Float));
                commAddPiece.Parameters.Add(new SqlParameter("@company", System.Data.SqlDbType.Int));
                commAddPiece.Parameters.Add(new SqlParameter("@author", System.Data.SqlDbType.Int));
                commAddPiece.Parameters.Add(new SqlParameter("@publicType", System.Data.SqlDbType.Int));
                commAddPiece.Parameters.Add(new SqlParameter("@theme", System.Data.SqlDbType.Int));

                commAddPiece.Parameters["@name"].Value        = unePiece.TheaterPiece_name;
                commAddPiece.Parameters["@description"].Value = unePiece.TheaterPiece_description;
                commAddPiece.Parameters["@duration"].Value    = unePiece.TheaterPiece_duration;
                commAddPiece.Parameters["@seatsPrice"].Value  = unePiece.TheaterPiece_seatsPrice;
                commAddPiece.Parameters["@company"].Value     = unePiece.TheaterPiece_company.Company_id;
                commAddPiece.Parameters["@author"].Value      = unePiece.TheaterPiece_author.Author_id;
                commAddPiece.Parameters["@publicType"].Value  = unePiece.TheaterPiece_publicType.PublicType_id;
                commAddPiece.Parameters["@theme"].Value       = unePiece.TheaterPiece_theme.Theme_id;

                commAddPiece.ExecuteNonQuery();

                connexion.Close();
            }
            catch (Exception e)
            {
                //Message box erreur
                string test = e.ToString();
            }
        }
 // Ajoute une piece de theatre dans la DB
 public static void AddTheaterPiece(TheaterPiece unePiece)
 {
     PiecesTheatreDAO.AddTheaterPiece(unePiece);
 }
示例#18
0
        private void dgvListePiecesTheatre_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            btnModifier.Enabled  = true;
            btnSupprimer.Enabled = true;

            grbDetails.Text          = "Détails de la pièce de théatre";
            lblLaPiece.Visible       = true;
            lblLeTheme.Visible       = true;
            lblLaDuree.Visible       = true;
            lblLeAuteur.Visible      = true;
            lblLeType.Visible        = true;
            lblLaDescription.Visible = true;
            lblLaCompagnie.Visible   = true;
            lblLePrixFixe.Visible    = true;
            lblLaNationalite.Text    = string.Empty;
            lblLaNationalite.Visible = true;
            lblIdPiece.Visible       = false;

            textBoxNomPiece.Visible    = false;
            textBoxPrixFixe.Visible    = false;
            textBoxDuree.Visible       = false;
            textBoxCommentaire.Visible = false;
            comboBoxAuteur.Visible     = false;
            comboBoxCompagnie.Visible  = false;
            comboBoxTheme.Visible      = false;
            comboBoxPublic.Visible     = false;

            btnModifier.Visible  = true;
            btnSupprimer.Visible = true;
            btnValider.Visible   = false;
            btnAnnuler.Visible   = false;

            dgvListePiecesTheatre.CurrentRow.Selected = true;

            // Récupération du numéro de la ligne (index)
            int indexRow = dgvListePiecesTheatre.CurrentRow.Index;

            // Si la ligne contient bien une valeur, on valorise les labels avec les valeurs correspondantes
            if (dgvListePiecesTheatre.Rows[indexRow].Cells[0].Value != DBNull.Value)
            {
                // Récupération de l'objet TheaterPiece
                TheaterPiece laPiece = (TheaterPiece)dgvListePiecesTheatre.Rows[indexRow].Cells[0].Value;

                // Ajout du nom de la pièce
                lblLaPiece.Text = laPiece.TheaterPiece_name;

                // Ajout id de la piece
                lblIdPiece.Text = laPiece.TheaterPiece_id.ToString();



                // Ajout du nom du theme
                lblLeTheme.Text = laPiece.TheaterPiece_theme.Theme_name;

                // Ajout de la durée

                //TimeSpan dureeTS = TimeSpan.FromMinutes(double.Parse(textBoxDuree.Text));
                //float dureeFl = (float)dureeTS.TotalHours;
                //TheaterPiece unePiece = new TheaterPiece(textBoxNomPiece.Text, textBoxCommentaire.Text, dureeFl, float.Parse(textBoxPrixFixe.Text), laCompagnie, leAuteur, leTypePublic, leTheme);
                //ModulePiecesTheatre.AddTheaterPiece(unePiece);

                TimeSpan dureeTS = TimeSpan.FromHours(double.Parse(laPiece.TheaterPiece_duration.ToString()));

                float convertDuree = (float)dureeTS.TotalMinutes;

                lblLaDuree.Text = convertDuree.ToString();

                // Ajout du type
                lblLeType.Text = laPiece.TheaterPiece_publicType.PublicType_name;

                // Ajout de l'auteur
                lblLeAuteur.Text = laPiece.TheaterPiece_author.Author_firstname + " " + laPiece.TheaterPiece_author.Author_lastname;

                // Ajout de la nationnalité
                lblLaNationalite.Text = "";
                int indNat = 1;

                // on affiche la(es) nationalité(s) que possède l'auteur
                foreach (Nationality laNationalite in laPiece.TheaterPiece_author.Author_nationalities)
                {
                    lblLaNationalite.Text += laNationalite.Nationality_name;

                    if (indNat < laPiece.TheaterPiece_author.Author_nationalities.Count)
                    {
                        indNat++;
                        // si plusieurs nationalité, les deux nationalités sont séparés d'un ","
                        lblLaNationalite.Text += ", ";
                    }
                }

                // Ajout du nom de la compagnie
                lblLaCompagnie.Text = laPiece.TheaterPiece_company.Company_name;

                // Ajout du prix fixe
                lblLePrixFixe.Text = laPiece.TheaterPiece_seatsPrice.ToString() + " €";

                // Ajout de la description
                lblLaDescription.Text = laPiece.TheaterPiece_description;
            }
            else // Si pas de valeur dans la cellule
            {
                // On valorise chaque label avec une valeur vide
                lblLaPiece.Text = "";

                lblLeTheme.Text = "";

                lblLaDuree.Text = "";

                lblLeAuteur.Text = "";

                lblLeType.Text = "";

                lblLaDescription.Text = "";

                lblLaCompagnie.Text = "";

                lblLePrixFixe.Text = "€";

                lblLaNationalite.Text = "";
            }
        }
示例#19
0
        private void btnModifier_Click(object sender, EventArgs e)
        {
            // Récupération du numéro de la ligne (index)
            int indexRow = dgvListePiecesTheatre.CurrentRow.Index;

            // Si la ligne contient bien une valeur, on valorise les labels avec les valeurs correspondantes
            if (dgvListePiecesTheatre.Rows[indexRow].Cells[0].Value != DBNull.Value)
            {
                TheaterPiece maPieceEditee = (TheaterPiece)dgvListePiecesTheatre.Rows[indexRow].Cells[0].Value;


                grbDetails.Text = "Modifier cette pièce de théatre";


                textBoxNomPiece.Text    = maPieceEditee.TheaterPiece_name.ToString();
                textBoxPrixFixe.Text    = maPieceEditee.TheaterPiece_seatsPrice.ToString();
                textBoxDuree.Text       = lblLaDuree.Text;
                textBoxCommentaire.Text = maPieceEditee.TheaterPiece_description.ToString();



                lblLaPiece.Visible       = false;
                lblLeTheme.Visible       = false;
                lblLaDuree.Visible       = false;
                lblLeAuteur.Visible      = false;
                lblLeType.Visible        = false;
                lblLaDescription.Visible = false;
                lblLaCompagnie.Visible   = false;
                lblLePrixFixe.Visible    = false;
                lblLaNationalite.Text    = string.Empty;
                //lblLaNationalite.Visible = false;

                dgvListePiecesTheatre.Enabled = false;

                btnModifier.Visible  = false;
                btnSupprimer.Visible = false;
                btnValider.Visible   = true;
                btnAnnuler.Visible   = true;

                btnAjouter.Enabled = false;

                textBoxNomPiece.Visible    = true;
                textBoxPrixFixe.Visible    = true;
                textBoxDuree.Visible       = true;
                textBoxCommentaire.Visible = true;
                comboBoxAuteur.Visible     = true;
                comboBoxCompagnie.Visible  = true;
                comboBoxTheme.Visible      = true;
                comboBoxPublic.Visible     = true;


                List <Author> lesAuteurs = PiecesTheatreDAO.GetAuthors();
                comboBoxAuteur.DataSource    = lesAuteurs;
                comboBoxAuteur.DisplayMember = "author_lastname";

                int  indAuteur    = 0;
                bool trouveAuteur = false;
                while (trouveAuteur == false && indAuteur < comboBoxAuteur.Items.Count)
                {
                    Author monAuteur = comboBoxAuteur.Items[indAuteur] as Author;
                    if (monAuteur.Author_id == maPieceEditee.TheaterPiece_author.Author_id)
                    {
                        comboBoxAuteur.SelectedIndex = indAuteur;
                        trouveAuteur = true;
                    }
                    else
                    {
                        indAuteur++;
                    }
                }


                List <Theme> lesThemes = PiecesTheatreDAO.GetThemes();
                comboBoxTheme.DataSource    = lesThemes;
                comboBoxTheme.DisplayMember = "theme_name";

                int  indTheme    = 0;
                bool trouveTheme = false;
                while (trouveTheme == false && indTheme < comboBoxTheme.Items.Count)
                {
                    Theme monTheme = comboBoxTheme.Items[indTheme] as Theme;
                    if (monTheme.Theme_id == maPieceEditee.TheaterPiece_theme.Theme_id)
                    {
                        comboBoxTheme.SelectedIndex = indTheme;
                        trouveTheme = true;
                    }
                    else
                    {
                        indTheme++;
                    }
                }

                List <PublicType> lesTypes = PiecesTheatreDAO.GetTypesPublic();
                comboBoxPublic.DataSource    = lesTypes;
                comboBoxPublic.DisplayMember = "publicType_name";

                int  indType    = 0;
                bool trouveType = false;
                while (trouveType == false && indType < comboBoxPublic.Items.Count)
                {
                    PublicType monType = comboBoxPublic.Items[indType] as PublicType;
                    if (monType.PublicType_id == maPieceEditee.TheaterPiece_publicType.PublicType_id)
                    {
                        comboBoxPublic.SelectedIndex = indType;
                        trouveType = true;
                    }
                    else
                    {
                        indType++;
                    }
                }

                List <Company> lesCompagnies = PiecesTheatreDAO.GetCompagnies();
                comboBoxCompagnie.DataSource    = lesCompagnies;
                comboBoxCompagnie.DisplayMember = "company_name";

                int  indCompagnie    = 0;
                bool trouveCompagnie = false;
                while (trouveCompagnie == false && indCompagnie < comboBoxCompagnie.Items.Count)
                {
                    Company maCompagnie = comboBoxCompagnie.Items[indCompagnie] as Company;
                    if (maCompagnie.Company_id == maPieceEditee.TheaterPiece_company.Company_id)
                    {
                        comboBoxCompagnie.SelectedIndex = indCompagnie;
                        trouveCompagnie = true;
                    }
                    else
                    {
                        indCompagnie++;
                    }
                }
            }
        }
示例#20
0
        private void btnValider_Click(object sender, EventArgs e)
        {
            if (textBoxNomPiece.Text == String.Empty || textBoxDuree.Text == String.Empty || textBoxPrixFixe.Text == String.Empty)
            {
                errorProviderDuree.SetError(textBoxDuree, "Ce champ est requis !");
                errorProviderNomPiece.SetError(textBoxNomPiece, "Ce champ est requis !");
                errorProviderPrixFixe.SetError(textBoxPrixFixe, "Ce champ est requis !");
            }
            else
            {
                var rep = MessageBox.Show("Êtes vous sûr de vouloir valider ?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                if (rep == DialogResult.Yes)
                {
                    leAuteur     = comboBoxAuteur.SelectedItem as Author;
                    laCompagnie  = comboBoxCompagnie.SelectedItem as Company;
                    leTypePublic = comboBoxPublic.SelectedItem as PublicType;
                    leTheme      = comboBoxTheme.SelectedItem as Theme;


                    if (grbDetails.Text == "Modifier cette pièce de théatre")
                    {
                        TimeSpan     dureeTS  = TimeSpan.FromMinutes(double.Parse(textBoxDuree.Text));
                        float        dureeFl  = (float)dureeTS.TotalHours;
                        TheaterPiece unePiece = new TheaterPiece(int.Parse(lblIdPiece.Text), textBoxNomPiece.Text, textBoxCommentaire.Text, dureeFl, float.Parse(textBoxPrixFixe.Text), laCompagnie, leAuteur, leTypePublic, leTheme);
                        ModulePiecesTheatre.EditTheaterPiece(unePiece);
                    }
                    else if (grbDetails.Text == "Ajout d'une pièce de théatre")
                    {
                        TimeSpan     dureeTS  = TimeSpan.FromMinutes(double.Parse(textBoxDuree.Text));
                        float        dureeFl  = (float)dureeTS.TotalHours;
                        TheaterPiece unePiece = new TheaterPiece(textBoxNomPiece.Text, textBoxCommentaire.Text, dureeFl, float.Parse(textBoxPrixFixe.Text), laCompagnie, leAuteur, leTypePublic, leTheme);
                        ModulePiecesTheatre.AddTheaterPiece(unePiece);
                    }


                    grbDetails.Text          = "Détails de la pièce de théatre";
                    lblLaPiece.Visible       = true;
                    lblLeTheme.Visible       = true;
                    lblLaDuree.Visible       = true;
                    lblLeAuteur.Visible      = true;
                    lblLeType.Visible        = true;
                    lblLaDescription.Visible = true;
                    lblLaCompagnie.Visible   = true;
                    lblLePrixFixe.Visible    = true;
                    lblLaNationalite.Text    = string.Empty;
                    lblLaNationalite.Visible = true;

                    dgvListePiecesTheatre.Enabled = true;

                    textBoxNomPiece.Visible    = false;
                    textBoxPrixFixe.Visible    = false;
                    textBoxDuree.Visible       = false;
                    textBoxCommentaire.Visible = false;
                    comboBoxAuteur.Visible     = false;
                    comboBoxCompagnie.Visible  = false;
                    comboBoxTheme.Visible      = false;
                    comboBoxPublic.Visible     = false;

                    btnModifier.Visible  = true;
                    btnSupprimer.Visible = true;
                    btnValider.Visible   = false;
                    btnAnnuler.Visible   = false;

                    dgvListePiecesTheatre.CurrentRow.Selected = true;

                    // On valorise chaque label avec une valeur vide
                    lblLaPiece.Text = "";

                    lblLeTheme.Text = "";

                    lblLaDuree.Text = "";

                    lblLeAuteur.Text = "";

                    lblLeType.Text = "";

                    lblLaDescription.Text = "";

                    lblLaCompagnie.Text = "";

                    lblLePrixFixe.Text = "€";

                    lblLaNationalite.Text = "";

                    ListePiece();

                    btnAjouter.Enabled = true;
                }
            }
        }
示例#21
0
        // clique sur le bouton Edition
        private void btnModifier_Click(object sender, EventArgs e)
        {
            if (dgvListeReservations.SelectedRows.Count <= 0)
            {
                MessageBox.Show("Veuillez sélectionner une réservation");
            }
            else
            {
                int indexRow = dgvListeReservations.CurrentRow.Index;

                // Si la ligne contient bien une valeur, on valorise les labels avec les valeurs correspondantes
                if (dgvListeReservations.Rows[indexRow].Cells[0].Value != DBNull.Value)
                {
                    editReserv     = (Spectator)dgvListeReservations.Rows[indexRow].Cells[0].Value;
                    laRepresAvEdit = editReserv.Spectator_show;

                    grbDetails.Text = "Modifier une réservation";

                    isEdit         = true;
                    nbPlacesAvEdit = editReserv.Spectator_seatsBooked;

                    #region Affiche et cache les champs concernés
                    btnModifier.Visible          = false;
                    btnSupprimer.Visible         = false;
                    lblLaPiece.Visible           = false;
                    lblLaRepresentation.Visible  = false;
                    lblLeNom.Visible             = false;
                    lblLePrenom.Visible          = false;
                    lblLeNbPlaces.Visible        = false;
                    lblLeEmail.Visible           = false;
                    lblLeTelephone.Visible       = false;
                    dgvListeReservations.Enabled = false;
                    dgvListeReservations.ClearSelection();
                    btnAjouter.Enabled = false;

                    btnValiderEdition.Visible = true;
                    btnAnnulerEdition.Visible = true;
                    cmbPiece.Visible          = true;
                    cmbDates.Visible          = true;
                    cmbHeures.Visible         = true;
                    txtNom.Visible            = true;
                    txtPrenom.Visible         = true;
                    txtNbPlaces.Visible       = true;
                    txtEmail.Visible          = true;
                    txtTelephone.Visible      = true;
                    lblHeure.Visible          = true;
                    lblPlacesRest.Visible     = true;
                    lblLesPlacesRest.Visible  = true;
                    lblLesPlacesRest.Text     = "";
                    lblLePrixReel.Visible     = true;
                    lblPrixReel.Visible       = true;
                    #endregion Affiche et cache les champs concernés

                    lblReprésentation.Text = "Dates : ";

                    lblLeTheme.Text = editReserv.Spectator_show.Show_theaterPiece.TheaterPiece_theme.Theme_name;

                    double   doubleConvertDuree = double.Parse(editReserv.Spectator_show.Show_theaterPiece.TheaterPiece_duration.ToString());
                    TimeSpan convertDuree       = TimeSpan.FromHours(doubleConvertDuree);
                    lblLaDuree.Text = convertDuree.ToString();

                    lblLeType.Text      = editReserv.Spectator_show.Show_theaterPiece.TheaterPiece_publicType.PublicType_name;
                    lblLaCompagnie.Text = editReserv.Spectator_show.Show_theaterPiece.TheaterPiece_company.Company_name;

                    lblLaPiece.Text          = String.Empty;
                    lblLaRepresentation.Text = String.Empty;

                    lblLeNom.Text       = String.Empty;
                    lblLePrenom.Text    = String.Empty;
                    lblLeNbPlaces.Text  = String.Empty;
                    lblLeEmail.Text     = String.Empty;
                    lblLeTelephone.Text = String.Empty;

                    txtEmail.Text     = editReserv.Spectator_email;
                    txtNbPlaces.Text  = editReserv.Spectator_seatsBooked.ToString();
                    txtNom.Text       = editReserv.Spectator_lastname;
                    txtPrenom.Text    = editReserv.Spectator_firstname;
                    txtTelephone.Text = editReserv.Spectator_phone;


                    List <TheaterPiece> lesPieces = ModulePiecesTheatre.GetTheaterPieces();

                    List <Show>         lesReps         = ModuleRepresentations.GetShows();
                    List <int>          idPieces        = new List <int>();
                    List <TheaterPiece> lesPiecesTriees = new List <TheaterPiece>();
                    foreach (var uneRep in lesReps)
                    {
                        if (!idPieces.Contains(uneRep.Show_theaterPiece.TheaterPiece_id))
                        {
                            idPieces.Add(uneRep.Show_theaterPiece.TheaterPiece_id);
                        }
                    }

                    foreach (var unePiece in lesPieces)
                    {
                        if (idPieces.Contains(unePiece.TheaterPiece_id))
                        {
                            lesPiecesTriees.Add(unePiece);
                        }
                    }

                    cmbPiece.DataSource    = lesPiecesTriees;
                    cmbPiece.DisplayMember = "theaterPiece_name";

                    int  ind    = 0;
                    bool trouve = false;
                    while (trouve == false && ind <= cmbPiece.Items.Count)
                    {
                        TheaterPiece itemPiece = cmbPiece.Items[ind] as TheaterPiece;
                        if (itemPiece.TheaterPiece_id == editReserv.Spectator_show.Show_theaterPiece.TheaterPiece_id)
                        {
                            cmbPiece.SelectedIndex = ind;
                            trouve = true;
                        }
                        else
                        {
                            ind++;
                        }
                    }

                    string date = editReserv.Spectator_show.Show_dateTime.ToString("dd/MM/yyyy");
                    ind    = 0;
                    trouve = false;
                    while (trouve == false && ind <= cmbDates.Items.Count)
                    {
                        if (date == cmbDates.Items[ind].ToString())
                        {
                            cmbDates.SelectedIndex = ind;
                            trouve = true;
                        }
                        else
                        {
                            ind++;
                        }
                    }


                    string heure = editReserv.Spectator_show.Show_dateTime.ToString("HH:mm");
                    ind    = 0;
                    trouve = false;
                    while (trouve == false && ind <= cmbHeures.Items.Count)
                    {
                        if (heure == cmbHeures.Items[ind].ToString())
                        {
                            cmbHeures.SelectedIndex = ind;
                            trouve = true;
                        }
                        else
                        {
                            ind++;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Veuillez sélectionner une réservation");
                }
            }
        }
 // Suppression d'une pièce de théatre
 public static void RemoveTheaterPiece(TheaterPiece unePiece)
 {
     ReservationsDAO.RemoveSpectators(unePiece);
     RepresentationsDAO.RemoveShows(unePiece);
     PiecesTheatreDAO.RemoveTheaterPiece(unePiece);
 }
 // Edition d'une pièce de théatre
 public static void EditTheaterPiece(TheaterPiece unePiece)
 {
     PiecesTheatreDAO.EditTheaterPiece(unePiece);
 }
        // Renvoie la liste des représentations
        // Utilise la DAO PiecesTheatres pour avoir la liste des pièces
        // besoin du taux (et donc des jours)
        public static List <Show> GetShows()
        {
            //variables
            int          idShow            = 0;
            DateTime     uneDateHeure      = new DateTime(2018, 01, 01, 00, 00, 00); //besoin de date et heure
            int          nbPlaces          = 0;
            TheaterPiece laPiece           = null;                                   //besoin de nomPiece, durée
            PriceRate    letaux            = null;                                   //calcul du prix pour date, heure, semaine
            Show         uneRepresentation = null;


            // Création d'une liste vide d'objets lesRepresentations
            List <Show> lesRepresentations = new List <Show>();

            // Récupération de la liste des pièces de théâtre
            List <TheaterPiece> lesPiecesDeTheatre = PiecesTheatreDAO.GetTheaterPieces();

            // Récupération de la liste des taux
            List <PriceRate> lesTaux = GetPriceRateWeeksDays();

            // Connexion à la BD
            SqlConnection maConnexion = ConnexionBD.GetConnexionBD().GetSqlConnexion();

            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = maConnexion;
            cmd.CommandText = "SELECT * FROM Show";


            SqlDataReader monReader = cmd.ExecuteReader();

            // Remplissage de la liste
            while (monReader.Read())
            {
                idShow       = Int32.Parse(monReader["show_id"].ToString());
                uneDateHeure = (DateTime)monReader["show_dateTime"];
                nbPlaces     = Int32.Parse(monReader["show_seats"].ToString());
                int idDutaux = Convert.ToInt32(monReader["show_priceRate"].ToString());
                int idPiece  = Convert.ToInt32(monReader["show_theaterPiece"].ToString());

                // On trouve dans la liste des pièces de théâtres celle correspondant à l'id
                bool trouve = false;
                int  i      = 0;
                while (trouve == false && i < lesPiecesDeTheatre.Count)
                {
                    if (lesPiecesDeTheatre[i].TheaterPiece_id == idPiece)
                    {
                        // Si on l'a, on l'ajoute
                        laPiece = lesPiecesDeTheatre[i];
                        trouve  = true;
                    }
                    else
                    {
                        i++;
                    }
                }
                bool trouve2 = false;
                int  i2      = 0;
                while (trouve2 == false && i2 < lesTaux.Count)
                {
                    if (lesTaux[i2].PriceRate_id == idDutaux)
                    {
                        // Si on l'a, on l'ajoute
                        letaux  = lesTaux[i2];
                        trouve2 = true;
                    }
                    else
                    {
                        i2++;
                    }
                }
                uneRepresentation = new Show(idShow, uneDateHeure, nbPlaces, letaux, laPiece);
                lesRepresentations.Add(uneRepresentation);
            }

            monReader.Close();

            // Fermeture de la connexion
            maConnexion.Close();
            return(lesRepresentations);
        }
示例#25
0
        //bouton valider
        private void button5_Click(object sender, EventArgs e)
        {
            if (dateTimePickerModifDate.Text.Trim() != "" && textBoxModifHeure.Text.Trim() != "" && textBoxModifPlaces.Text.Trim() != "" && cbModifPiece.Text.Trim() != "")
            {
                //on récupère date saisie et heure à mettre en datetime
                string   mesdates   = dateTimePickerModifDate.Text.ToString() + " " + textBoxModifHeure.Text.ToString();
                DateTime parsedDate = DateTime.Parse(mesdates);
                //on vérifie l'heure pour voir dans quelle tranche de pricerate on va
                List <PriceRate> Lestaux = new List <PriceRate>();
                Lestaux = ModuleRepresentations.GetPriceRate();
                List <PriceRate> LestauxdansLHeure = new List <PriceRate>();
                PriceRate        monTaux           = null;
                foreach (PriceRate unTaux in Lestaux)
                {
                    TimeSpan debutHeure = unTaux.PriceRate_startTime;
                    TimeSpan finHeure   = unTaux.PriceRate_endTime;
                    TimeSpan monHeure   = TimeSpan.Parse(textBoxModifHeure.Text.ToString());
                    if (debutHeure <= monHeure && monHeure <= finHeure)
                    {
                        LestauxdansLHeure.Add(unTaux);
                    }
                }
                //on vérifie le jour et on a le pricerate !!!!
                int monJour = (int)parsedDate.DayOfWeek;
                if (monJour == 0)
                {
                    monJour = 7;
                }
                foreach (PriceRate unTaux in LestauxdansLHeure)
                {
                    foreach (WeekDays unJour in unTaux.PriceRate_weekDays)
                    {
                        if (unJour.WeekDays_id == monJour)
                        {
                            monTaux = unTaux;
                        }
                    }
                }
                //on récupère nb places
                int mesPlaces = int.Parse(textBoxModifPlaces.Text.ToString());
                //on récupère la pièce de théâtre
                TheaterPiece maPiece = ModulePiecesTheatre.GetOneTheaterPiece(cbModifPiece.Text);
                float        duree   = maPiece.TheaterPiece_duration;
                //on récupère l'id
                dgvListeRepresentations.CurrentRow.Selected = true;
                int indexRow = dgvListeRepresentations.CurrentRow.Index;
                if (dgvListeRepresentations.Rows[indexRow].Cells[0].Value != DBNull.Value)
                {
                    Show laRepres = (Show)dgvListeRepresentations.Rows[indexRow].Cells[0].Value;
                    int  idShow   = laRepres.Show_id;

                    // Création de l'objet Show
                    Show show = new Show(idShow, parsedDate, mesPlaces, monTaux, maPiece);

                    //TimeSpan madureeShowFin = TimeSpan.FromHours((double)duree) + show.Show_dateTime.TimeOfDay;
                    //récupérer les datetime de toutes représentations
                    bool        trouve             = false;
                    List <Show> lesRepresentations = ModuleRepresentations.GetShows();
                    //s'il existe déjà une représentation à la date afficher message d'erreur
                    foreach (Show uneRepresentation in lesRepresentations)
                    {
                        TimeSpan madureeFin = TimeSpan.FromHours((double)duree) + uneRepresentation.Show_dateTime.TimeOfDay;


                        if (uneRepresentation.Show_dateTime.Date == show.Show_dateTime.Date && uneRepresentation.Show_id != idShow)
                        {
                            if (uneRepresentation.Show_dateTime.TimeOfDay <= show.Show_dateTime.TimeOfDay && show.Show_dateTime.TimeOfDay < madureeFin)
                            {
                                trouve = true;
                            }
                        }
                    }
                    if (trouve == true)
                    {
                        MessageBox.Show("Vous ne pouvez pas ajouter 2 représentations au même moment.", "Modification de la représentation", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        DialogResult result1 = MessageBox.Show("Etes vous sur de vouloir modifier cette représentation ?", "Modification de la représentation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (result1 == DialogResult.Yes)
                        {
                            // Appel de la méthode ModifierUtilisateur de la couche BLL
                            ModuleRepresentations.EditShow(show);
                            MessageBox.Show("La représentation a bien été modifiée.", "Modification de la représentation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            grbModifRepresentation.Visible = false;
                            grbDetails.Visible             = true;
                            textBoxModifHeure.Text         = "";
                            textBoxModifPlaces.Text        = "";
                            DateTime today = DateTime.Today;
                            dateTimePickerModifDate.Text = today.ToString();
                            afficherRepresentations();


                            grbFiltres.Enabled = true;
                            dgvListeRepresentations.Enabled = true;
                        }
                    }
                }
            }
        }
        // Renvoie la liste des représentations correspondant à la pièce de théatres ayant lieu durant une période passée en paramètres
        public static List <Show> GetFilterShows(int idTheaterPiece, DateTime dateDebutChoisie, DateTime dateFinChoisie)
        {
            //variables
            int          idShow;
            DateTime     uneDateHeure; //besoin de date et heure
            int          nbPlaces;
            int          idTaux;
            int          idPiece;
            TheaterPiece laPiece = null; //besoin de nomPiece, durée
            PriceRate    letaux  = null; //calcul du prix pour date, heure, semaine
            Show         uneRepresentation;
            // Récupération de la liste des pièces de théâtre
            List <TheaterPiece> lesPiecesDeTheatre = PiecesTheatreDAO.GetTheaterPieces();
            // Récupération de la liste des taux
            List <PriceRate> lesTaux = GetPriceRateWeeksDays();
            // Connexion à la BD
            SqlConnection maConnexion = ConnexionBD.GetConnexionBD().GetSqlConnexion();
            // Création d'une liste vide d'objets lesRepresentations
            List <Show> lesRepresentations = new List <Show>();

            SqlCommand cmd = new SqlCommand();

            cmd.Connection = maConnexion;
            //paramètres

            SqlParameter paramIdPiece = new SqlParameter("@idPiece", SqlDbType.Int);

            paramIdPiece.Value = idTheaterPiece;
            SqlParameter paramDateDeb = new SqlParameter("@dateDeb", SqlDbType.VarChar);
            string       date1;

            date1 = dateDebutChoisie.ToString("yyyy/MM/dd");
            paramDateDeb.Value = date1;
            SqlParameter paramDateFin = new SqlParameter("@dateFin", SqlDbType.VarChar);
            string       date2;

            date2 = dateFinChoisie.ToString("yyyy/MM/dd");
            paramDateFin.Value = date2;
            //requête
            cmd.CommandText = "SELECT show_id,show_dateTime, show_seats, show_priceRate, show_theaterPiece FROM Show, Theater_piece WHERE show_theaterPiece = theaterPiece_id AND theaterPiece_id = @idPiece AND CAST(show_dateTime as DATE) BETWEEN @dateDeb AND @dateFin";
            //ajout params
            cmd.Parameters.Add(paramIdPiece);
            cmd.Parameters.Add(paramDateDeb);
            cmd.Parameters.Add(paramDateFin);


            SqlDataReader monReader = cmd.ExecuteReader();

            // Remplissage de la liste
            while (monReader.Read())
            {
                idShow       = Int32.Parse(monReader["show_id"].ToString());
                uneDateHeure = (DateTime)monReader["show_dateTime"];
                nbPlaces     = Int32.Parse(monReader["show_seats"].ToString());
                idTaux       = Int32.Parse(monReader["show_priceRate"].ToString());
                idPiece      = Int32.Parse(monReader["show_theaterPiece"].ToString());
                bool trouve = false;
                int  i      = 0;
                while (trouve == false && i < lesPiecesDeTheatre.Count)
                {
                    if (lesPiecesDeTheatre[i].TheaterPiece_id == idPiece)
                    {
                        // Si on l'a, on l'ajoute
                        laPiece = lesPiecesDeTheatre[i];
                        trouve  = true;
                    }
                    else
                    {
                        i++;
                    }
                }
                // On trouve dans la liste des pièces de théâtres celle correspondant à l'id
                bool trouve2 = false;
                int  i2      = 0;
                while (trouve2 == false && i2 < lesTaux.Count)
                {
                    if (lesTaux[i2].PriceRate_id == idTaux)
                    {
                        // Si on l'a, on l'ajoute
                        letaux  = lesTaux[i2];
                        trouve2 = true;
                    }
                    else
                    {
                        i2++;
                    }
                }
                uneRepresentation = new Show(idShow, uneDateHeure, nbPlaces, letaux, laPiece);
                lesRepresentations.Add(uneRepresentation);
            }
            monReader.Close();
            // Fermeture de la connexion
            maConnexion.Close();
            return(lesRepresentations);
        }
示例#27
0
        public static TheaterPiece GetOneTheaterPiece(string nomPiece)
        {
            int        id          = 0;
            string     nom         = "";
            string     description = "";
            float      duree       = 0;
            float      prix        = 0;
            Company    laCompagnie = null;
            Author     leAuteur    = null;
            PublicType leType      = null;
            Theme      leTheme     = null;

            TheaterPiece unePieceTheatre = null;

            // Connexion à la BD
            SqlConnection maConnexion = ConnexionBD.GetConnexionBD().GetSqlConnexion();


            // Commande sql qui récupère les informations de la table Theatre_piece
            SqlCommand cmdPiecesTheatre = new SqlCommand();

            cmdPiecesTheatre.Connection  = maConnexion;
            cmdPiecesTheatre.CommandText = "SELECT * FROM Theater_piece";

            // Commande sql qui récupère les informations de la table Author
            SqlCommand cmdAuteur = new SqlCommand();

            cmdAuteur.Connection  = maConnexion;
            cmdAuteur.CommandText = "SELECT * FROM Author";

            // Commande sql qui récupère les informations de la table Nationality
            SqlCommand cmdNationalites = new SqlCommand();

            cmdNationalites.Connection  = maConnexion;
            cmdNationalites.CommandText = "SELECT * FROM Nationality";

            // Commande sql qui récupère les informations de la table To_be_of
            SqlCommand cmdAuteurNationalite = new SqlCommand();

            cmdAuteurNationalite.Connection  = maConnexion;
            cmdAuteurNationalite.CommandText = "SELECT * FROM To_be_of";

            // Commande sql qui récupère les informations de la table Theme
            SqlCommand cmdTheme = new SqlCommand();

            cmdTheme.Connection  = maConnexion;
            cmdTheme.CommandText = "SELECT * FROM Theme";

            // Commande sql qui récupère les informations de la table Public_Type
            SqlCommand cmdTypePublic = new SqlCommand();

            cmdTypePublic.Connection  = maConnexion;
            cmdTypePublic.CommandText = "SELECT * FROM Public_Type";

            // Commande sql qui récupère les informations de la table Company
            SqlCommand cmdCompagnie = new SqlCommand();

            cmdCompagnie.Connection  = maConnexion;
            cmdCompagnie.CommandText = "SELECT * FROM Company";


            // Execution des requetes
            SqlDataReader readerPiecesTheatre     = cmdPiecesTheatre.ExecuteReader();
            SqlDataReader readerAuteur            = cmdAuteur.ExecuteReader();
            SqlDataReader readerNationalites      = cmdNationalites.ExecuteReader();
            SqlDataReader readerTheme             = cmdTheme.ExecuteReader();
            SqlDataReader readerTypePublic        = cmdTypePublic.ExecuteReader();
            SqlDataReader readerAuteurNationalite = cmdAuteurNationalite.ExecuteReader();
            SqlDataReader readerCompagnie         = cmdCompagnie.ExecuteReader();

            // Remplissage de la liste
            // Pieces de theatre
            while (readerPiecesTheatre.Read())
            {
                nom = readerPiecesTheatre["theaterPiece_name"].ToString();

                if (nom == nomPiece)
                {
                    id          = Int32.Parse(readerPiecesTheatre["theaterPiece_id"].ToString());
                    description = readerPiecesTheatre["theaterPiece_description"].ToString();
                    duree       = float.Parse(readerPiecesTheatre["theaterPiece_duration"].ToString());
                    prix        = float.Parse(readerPiecesTheatre["theaterPiece_seatsPrice"].ToString());
                    int idDeLAuteur     = Int32.Parse(readerPiecesTheatre["theaterPiece_author"].ToString());
                    int idDeLaCompagnie = Int32.Parse(readerPiecesTheatre["theaterPiece_company"].ToString());
                    int idDuTypePublic  = Int32.Parse(readerPiecesTheatre["theaterPiece_publicType"].ToString());
                    int idDuTheme       = Int32.Parse(readerPiecesTheatre["theaterPiece_theme"].ToString());

                    // Company
                    while (readerCompagnie.Read())
                    {
                        int idCompagnie = Int32.Parse(readerCompagnie["company_id"].ToString());

                        if (idDeLaCompagnie == idCompagnie)
                        {
                            string nomCompagnie        = readerCompagnie["company_name"].ToString();
                            string villeCompagnie      = readerCompagnie["company_city"].ToString();
                            string regionCompagnie     = readerCompagnie["company_region"].ToString();
                            string directeurArtistique = readerCompagnie["company_artisticDirector"].ToString();

                            laCompagnie = new Company(idCompagnie, nomCompagnie, villeCompagnie, regionCompagnie, directeurArtistique);
                        }
                    }
                    // Fermeture reader
                    readerCompagnie.Close();
                    readerCompagnie = cmdCompagnie.ExecuteReader();

                    // Author
                    while (readerAuteur.Read())
                    {
                        int idAuteur = Int32.Parse(readerAuteur["author_id"].ToString());

                        if (idDeLAuteur == idAuteur)
                        {
                            string nomAuteur    = readerAuteur["author_lastname"].ToString();
                            string prenomAuteur = readerAuteur["author_firstname"].ToString();

                            List <int> lesIdsNationalites = new List <int>();

                            while (readerAuteurNationalite.Read())
                            {
                                int idComparerAuteur = Int32.Parse(readerAuteurNationalite["toBeOf_author"].ToString());
                                if (idAuteur == idComparerAuteur)
                                {
                                    int idNatio = Int32.Parse(readerAuteurNationalite["toBeOf_nationality"].ToString());
                                    lesIdsNationalites.Add(idNatio);
                                }
                            }
                            // Fermeture reader
                            readerAuteurNationalite.Close();
                            readerAuteurNationalite = cmdAuteurNationalite.ExecuteReader();

                            List <Nationality> lesNationalites = new List <Nationality>();
                            foreach (int unIdNatio in lesIdsNationalites)
                            {
                                while (readerNationalites.Read())
                                {
                                    int idNationalite = Int32.Parse(readerNationalites["nationality_id"].ToString());
                                    if (unIdNatio == idNationalite)
                                    {
                                        Nationality laNationalite;
                                        string      nomNationalite = readerNationalites["nationality_name"].ToString();

                                        laNationalite = new Nationality(idNationalite, nomNationalite);
                                        lesNationalites.Add(laNationalite);
                                    }
                                }
                                // Fermeture reader
                                readerNationalites.Close();
                                readerNationalites = cmdNationalites.ExecuteReader();
                            }

                            leAuteur = new Author(idAuteur, nomAuteur, prenomAuteur, lesNationalites);
                        }
                    }
                    // Fermeture reader
                    readerAuteur.Close();
                    readerAuteur = cmdAuteur.ExecuteReader();

                    // Public type
                    while (readerTypePublic.Read())
                    {
                        int idType = Int32.Parse(readerTypePublic["publicType_id"].ToString());

                        if (idType == idDuTypePublic)
                        {
                            string nomType = readerTypePublic["publicType_name"].ToString();

                            leType = new PublicType(idType, nomType);
                        }
                    }
                    // Fermeture reader
                    readerTypePublic.Close();
                    readerTypePublic = cmdTypePublic.ExecuteReader();

                    // Theme
                    while (readerTheme.Read())
                    {
                        int idTheme = Int32.Parse(readerTheme["theme_id"].ToString());

                        if (idTheme == idDuTheme)
                        {
                            string nomTheme = readerTheme["theme_name"].ToString();

                            leTheme = new Theme(idTheme, nomTheme);
                        }
                    }
                    // Fermeture reader
                    readerTheme.Close();
                    readerTheme = cmdTheme.ExecuteReader();

                    unePieceTheatre = new TheaterPiece(id, nom, description, duree, prix, laCompagnie, leAuteur, leType, leTheme);
                }
            }
            // Fermeture reader
            readerCompagnie.Close();
            readerAuteurNationalite.Close();
            readerNationalites.Close();
            readerAuteur.Close();
            readerTypePublic.Close();
            readerTheme.Close();
            readerPiecesTheatre.Close();

            // Fermeture de la connexion
            maConnexion.Close();

            return(unePieceTheatre);
        }