示例#1
0
        private void btnAjouter_Click(object sender, EventArgs e)
        {
            grbDetails.Text          = "Ajout d'une pièce de théatre";
            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;

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

            textBoxNomPiece.Text    = "";
            textBoxPrixFixe.Text    = "";
            textBoxDuree.Text       = "";
            textBoxCommentaire.Text = "";

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


            List <Author> lesAuteurs = PiecesTheatreDAO.GetAuthors();

            comboBoxAuteur.DataSource    = lesAuteurs;
            comboBoxAuteur.DisplayMember = "author_lastname";

            List <Theme> lesThemes = PiecesTheatreDAO.GetThemes();

            comboBoxTheme.DataSource    = lesThemes;
            comboBoxTheme.DisplayMember = "theme_name";

            List <PublicType> lesTypes = PiecesTheatreDAO.GetTypesPublic();

            comboBoxPublic.DataSource    = lesTypes;
            comboBoxPublic.DisplayMember = "publicType_name";

            List <Company> lesCompagnies = PiecesTheatreDAO.GetCompagnies();

            comboBoxCompagnie.DataSource    = lesCompagnies;
            comboBoxCompagnie.DisplayMember = "company_name";
        }
示例#2
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++;
                    }
                }
            }
        }
        public static List <Author> GetAuthors()
        {
            List <Author> lesAuteurs = PiecesTheatreDAO.GetAuthors();

            return(lesAuteurs);
        }