Exemple #1
0
        //bouton modifier
        private void button3_Click(object sender, EventArgs e)
        {
            if (dgvListeRepresentations.CurrentRow.Selected == false)
            {
                MessageBox.Show("Vous devez sélectionner une représentation.", "Modification de la représentation", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                int indexRow = dgvListeRepresentations.CurrentRow.Index;
                if (dgvListeRepresentations.Rows[indexRow].Cells[0].Value != DBNull.Value)
                {
                    Show laRepres = (Show)dgvListeRepresentations.Rows[indexRow].Cells[0].Value;


                    //affichage du formulaire
                    //quand on clique sur le bouton affichage des cases de saisie
                    grbModifRepresentation.Visible = true;
                    grbDetails.Visible             = false;

                    grbFiltres.Enabled = false;
                    dgvListeRepresentations.Enabled = false;

                    // affichage des infos de la représentation sélectionnéee
                    cbModifPiece.DataSource    = ModulePiecesTheatre.GetTheaterPieces();
                    cbModifPiece.DisplayMember = "theaterPiece_name";
                    cbModifPiece.Text          = laRepres.Show_theaterPiece.TheaterPiece_name;
                    //affichage nb places
                    textBoxModifPlaces.Text = laRepres.Show_seats.ToString();
                    //affichage heure
                    textBoxModifHeure.Text = laRepres.Show_dateTime.ToString("HH:mm");
                    //affichage date
                    dateTimePickerModifDate.Text = laRepres.Show_dateTime.Date.ToString();
                }
            }
        }
Exemple #2
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() + " €";
            }
        }
Exemple #3
0
        private void btnFiltrer_Click(object sender, EventArgs e)
        {
            List <Show> lesRepresentations = ModuleRepresentations.GetFilterShows(ModulePiecesTheatre.GetOneTheaterPiece(cbChoixPiece.Text).TheaterPiece_id, dtpDateDeb.Value, dtpDateFin.Value);

            DataTable dt = new DataTable();

            dgvListeRepresentations.DataSource = dt;

            dt.Columns.Add(new DataColumn("representation", typeof(Show)));

            dt.Columns.Add(new DataColumn("nom", typeof(string)));
            dgvListeRepresentations.Columns["Nom"].HeaderText = "Nom de la pièce";

            dt.Columns.Add(new DataColumn("date", typeof(string)));
            dgvListeRepresentations.Columns["Date"].HeaderText = "Date";

            dt.Columns.Add(new DataColumn("heure", typeof(string)));
            dgvListeRepresentations.Columns["Heure"].HeaderText = "Heure";

            dt.Columns.Add(new DataColumn("places", typeof(int)));
            dgvListeRepresentations.Columns["Places"].HeaderText = "Places";

            dt.Columns.Add(new DataColumn("durée", typeof(float)));
            dgvListeRepresentations.Columns["Durée"].HeaderText = "Durée";

            dt.Columns.Add(new DataColumn("tarif", typeof(float)));
            dgvListeRepresentations.Columns["Tarif"].HeaderText = "Tarif";

            dgvListeRepresentations.ReadOnly = true;


            //test dgv
            foreach (Show uneRepresentation in lesRepresentations)
            {
                string nomPiece = uneRepresentation.Show_theaterPiece.TheaterPiece_name;

                DateTime dateHeure = uneRepresentation.Show_dateTime;

                string date = dateHeure.ToString("dd/MM/yyyy");

                string heure = dateHeure.ToString("HH:mm");

                int places = uneRepresentation.Show_seats;

                float duree = uneRepresentation.Show_theaterPiece.TheaterPiece_duration;

                float prix = uneRepresentation.Show_theaterPiece.TheaterPiece_seatsPrice;

                dt.Rows.Add(uneRepresentation, nomPiece, date, heure, places, duree, prix);
            }

            // La première colonne contenant l'objet ne sera pas visible
            dgvListeRepresentations.Columns["representation"].Visible = false;
        }
Exemple #4
0
        private void btnAjouter_Click(object sender, EventArgs e)
        {
            //quand on clique sur le bouton affichage des cases de saisie
            grbAjoutRepresentation.Visible = true;

            grbFiltres.Enabled = false;
            dgvListeRepresentations.Enabled = false;

            // Remplissable de la comboBox avec les pièces de théâtre
            cbChoixPieceSaisieShow.DataSource    = ModulePiecesTheatre.GetTheaterPieces();
            cbChoixPieceSaisieShow.DisplayMember = "theaterPiece_name";
        }
Exemple #5
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() + " €";
                    }
                }
            }
        }
Exemple #6
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();
        }
Exemple #7
0
        private void ListePiece()
        {
            // Liste qui récupère la liste des pieces de théatre dans le ModulePiecesTheatre
            List <TheaterPiece> lesPiecesTheatre = ModulePiecesTheatre.GetTheaterPieces();

            DataTable dt = new DataTable();

            dgvListePiecesTheatre.DataSource = dt;

            // Ajout des colonnes necéssaires au tableau
            dt.Columns.Add(new DataColumn("piece", typeof(TheaterPiece)));
            dt.Columns.Add(new DataColumn("idPiece", typeof(int)));

            dt.Columns.Add(new DataColumn("nom", typeof(string)));
            dgvListePiecesTheatre.Columns["Nom"].HeaderText = "Nom de la pièce";

            dt.Columns.Add(new DataColumn("auteur", typeof(string)));
            dgvListePiecesTheatre.Columns["Auteur"].HeaderText = "Auteur";

            dt.Columns.Add(new DataColumn("public", typeof(string)));
            dgvListePiecesTheatre.Columns["Public"].HeaderText = "Type de public";

            dt.Columns.Add(new DataColumn("theme", typeof(string)));
            dgvListePiecesTheatre.Columns["Theme"].HeaderText = "Thème";

            dt.Columns.Add(new DataColumn("durée", typeof(TimeSpan)));
            dgvListePiecesTheatre.Columns["Durée"].HeaderText = "Durée";

            dt.Columns.Add(new DataColumn("prix", typeof(float)));
            dgvListePiecesTheatre.Columns["Prix"].HeaderText = "Prix du siège";

            dgvListePiecesTheatre.ReadOnly = true;

            // Pour chaque piece dans la liste lesPiecesTheatres, on affiche les données dans les colonnes
            foreach (TheaterPiece unePiece in lesPiecesTheatre)
            {
                int idPiece = unePiece.TheaterPiece_id;

                string nomPiece = unePiece.TheaterPiece_name;

                string nomAuteur = unePiece.TheaterPiece_author.Author_firstname + " " + unePiece.TheaterPiece_author.Author_lastname;

                string nomTheme = unePiece.TheaterPiece_theme.Theme_name;

                string typePublic = unePiece.TheaterPiece_publicType.PublicType_name;

                double doubleConvertDuree = double.Parse(unePiece.TheaterPiece_duration.ToString());

                TimeSpan convertDuree = TimeSpan.FromHours(doubleConvertDuree);

                string duree = convertDuree.ToString();

                float prix = unePiece.TheaterPiece_seatsPrice;

                dt.Rows.Add(unePiece, idPiece, nomPiece, nomAuteur, typePublic, nomTheme, duree, prix);
            }


            // La première colonne contenant l'objet ne sera pas visible
            dgvListePiecesTheatre.Columns["piece"].Visible   = false;
            dgvListePiecesTheatre.Columns["idPiece"].Visible = false;
            // dgvListePiecesTheatre.Columns["idPiece"].Visible = false;
        }
Exemple #8
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;
                }
            }
        }
Exemple #9
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");
                }
            }
        }
Exemple #10
0
        // Affichage du formulaire d'ajout
        private void btnAjouter_Click(object sender, EventArgs e)
        {
            grbDetails.Text = "Ajouter une réservation";

            isEdit = false;

            #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();

            btnValiderAjout.Visible  = true;
            btnAnnulerAjout.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          = String.Empty;
            lblLaDuree.Text          = String.Empty;
            lblLeType.Text           = String.Empty;
            lblLaCompagnie.Text      = String.Empty;
            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;
            lblLePrixFixe.Text       = "€";
            lblLePrixTotal.Text      = "0 €";

            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";
        }
Exemple #11
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;
                        }
                    }
                }
            }
        }
Exemple #12
0
        public Representations(LoginInfo currentUser)
        {
            InitializeComponent();
            dtpDateDeb.Value = DateTime.Now;
            dtpDateFin.Value = DateTime.Now;
            this.currentUser = currentUser;

            // Remplissable de la comboBox avec les pièces de théâtre
            cbChoixPiece.DataSource    = ModulePiecesTheatre.GetTheaterPieces();
            cbChoixPiece.DisplayMember = "theaterPiece_name";


            List <Show> lesRepresentations = ModuleRepresentations.GetShows();

            // Blocage de la génération automatique des colonnes
            //dgvListePiecesTheatre.AutoGenerateColumns = false;

            DataTable dt = new DataTable();

            dgvListeRepresentations.DataSource = dt;

            dt.Columns.Add(new DataColumn("representation", typeof(Show)));

            dt.Columns.Add(new DataColumn("nom", typeof(string)));
            dgvListeRepresentations.Columns["Nom"].HeaderText = "Nom de la pièce";

            dt.Columns.Add(new DataColumn("date", typeof(string)));
            dgvListeRepresentations.Columns["Date"].HeaderText = "Date";

            dt.Columns.Add(new DataColumn("heure", typeof(string)));
            dgvListeRepresentations.Columns["Heure"].HeaderText = "Heure";

            dt.Columns.Add(new DataColumn("places", typeof(int)));
            dgvListeRepresentations.Columns["Places"].HeaderText = "Places";

            dt.Columns.Add(new DataColumn("durée", typeof(string)));
            dgvListeRepresentations.Columns["Durée"].HeaderText = "Durée";

            dt.Columns.Add(new DataColumn("tarif", typeof(float)));
            dgvListeRepresentations.Columns["Tarif"].HeaderText = "Tarif";

            dgvListeRepresentations.ReadOnly = true;


            //test dgv
            foreach (Show uneRepresentation in lesRepresentations)
            {
                string nomPiece = uneRepresentation.Show_theaterPiece.TheaterPiece_name;

                DateTime dateHeure = uneRepresentation.Show_dateTime;

                string date = dateHeure.ToString("dd/MM/yyyy");

                string heure = dateHeure.ToString("HH:mm");

                int places = uneRepresentation.Show_seats;

                double doubleConvertDuree = double.Parse(uneRepresentation.Show_theaterPiece.TheaterPiece_duration.ToString());

                TimeSpan convertDuree = TimeSpan.FromHours(doubleConvertDuree);

                string duree = convertDuree.ToString();

                float prix = uneRepresentation.Show_theaterPiece.TheaterPiece_seatsPrice;

                dt.Rows.Add(uneRepresentation, nomPiece, date, heure, places, duree, prix);
            }


            // La première colonne contenant l'objet ne sera pas visible
            dgvListeRepresentations.Columns["representation"].Visible = false;
        }