Example #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();
                }
            }
        }
Example #2
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";
        }
Example #3
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;
        }
Example #4
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");
                }
            }
        }
Example #5
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";
        }
Example #6
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;
        }