Esempio n. 1
0
        private void afficherRepresentations()
        {
            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(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;
        }
Esempio n. 2
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;
        }
Esempio n. 3
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() + " €";
                    }
                }
            }
        }
Esempio n. 4
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 €";
            }
        }
Esempio n. 5
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();
        }
Esempio n. 6
0
        //affichage des détails de la preprésentation
        private void dgvListeRepresentations_CellClick_1(object sender, DataGridViewCellEventArgs e)
        {
            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;

                lblLaPiece.Text = laRepres.Show_theaterPiece.TheaterPiece_name;

                lblLesPlaces.Text = laRepres.Show_seats.ToString();

                lblLesPlacesRest.Text = ModuleRepresentations.GetRemainingSeats(laRepres).ToString();

                lblLaDate.Text = laRepres.Show_dateTime.ToString("dd/MM/yyyy");

                lblLHeure.Text = laRepres.Show_dateTime.ToString("HH:mm");

                lblLePrixFixe.Text = laRepres.Show_theaterPiece.TheaterPiece_seatsPrice.ToString() + " €";
            }
            else
            {
                lblLaPiece.Text = "";

                lblLesPlaces.Text = "";

                lblLesPlacesRest.Text = "";

                lblLaDate.Text = "";

                lblLHeure.Text = "";

                lblLePrixFixe.Text = " €";
            }
        }
Esempio n. 7
0
 private void button4_Click(object sender, EventArgs e)
 {
     if (dgvListeRepresentations.CurrentRow.Selected == false)
     {
         MessageBox.Show("Vous devez sélectionner une représentation.", "Suppression de la représentation", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         DialogResult result = MessageBox.Show("Etes vous sur de vouloir supprimer cette représentation ?", "Suppression de la représentation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (result == DialogResult.Yes)
         {
             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;
                 // Appel de la méthode SupprimerUtilisateur de la couche BLL
                 ModuleRepresentations.DeleteShow(laRepres.Show_id);
                 MessageBox.Show("La représentation a bien été supprimée.", "Suppression de la représentation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 afficherRepresentations();
             }
         }
     }
 }
Esempio n. 8
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");
                }
            }
        }
Esempio n. 9
0
        // Fonction changement places restantes dynamique
        private void ChangementPlacesRest(Show repAvEdit)
        {
            TheaterPiece laPiece;

            if (cmbPiece.SelectedItem != null)
            {
                laPiece = cmbPiece.SelectedItem as TheaterPiece;
            }
            else
            {
                laPiece = editReserv.Spectator_show.Show_theaterPiece;
            }

            lesRepresentations = ModuleRepresentations.GetFilterShows(laPiece.TheaterPiece_id);
            Show uneRep = laRepres;

            if (uneRep == null)
            {
                foreach (var rep in lesRepresentations)
                {
                    if (cmbDates.SelectedItem != null && cmbHeures.SelectedItem != null && cmbPiece.SelectedItem != null)
                    {
                        if (rep.Show_dateTime.ToString("dd/MM/yyyy") == cmbDates.SelectedItem.ToString() && rep.Show_dateTime.ToString("HH:mm") == cmbHeures.SelectedItem.ToString() && rep.Show_theaterPiece.TheaterPiece_id == laPiece.TheaterPiece_id)
                        {
                            uneRep = rep;
                        }
                    }
                    else
                    {
                        if (rep.Show_dateTime.ToString("dd/MM/yyyy") == editReserv.Spectator_show.Show_dateTime.ToString("dd/MM/yyyy") && rep.Show_dateTime.ToString("HH:mm") == editReserv.Spectator_show.Show_dateTime.ToString("HH:mm") && rep.Show_theaterPiece.TheaterPiece_id == editReserv.Spectator_show.Show_theaterPiece.TheaterPiece_id)
                        {
                            uneRep = rep;
                        }
                    }
                }
            }

            int repPlacesRes = ModuleReservations.GetNbPlacesReservees(laRepres);
            int bookedPlaces = 0;

            if (repPlacesRes == -1)
            {
                repPlacesRes = 0;
            }

            if (txtNbPlaces.Text != String.Empty)
            {
                int test;
                if (int.TryParse(txtNbPlaces.Text, out test))
                {
                    bookedPlaces = Int32.Parse(txtNbPlaces.Text);
                }
                else
                {
                    txtNbPlaces.Text = string.Empty;
                    errNbPlaces.SetError(txtNbPlaces, "Veuillez saisir un nombre !");
                }
            }

            if (isEdit && uneRep.Show_id == repAvEdit.Show_id)
            {
                nbPlacesRest = uneRep.Show_seats - (repPlacesRes - nbPlacesAvEdit) - bookedPlaces;
            }
            else
            {
                nbPlacesRest = uneRep.Show_seats - repPlacesRes - bookedPlaces;
            }

            if (nbPlacesRest < 0)
            {
                lblLesPlacesRest.Text = "0";
            }
            else
            {
                lblLesPlacesRest.Text = nbPlacesRest.ToString();
            }
        }
Esempio n. 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";
        }
Esempio n. 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;
                        }
                    }
                }
            }
        }
Esempio n. 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;
        }