Exemplo n.º 1
0
        // Bouton Supprimer
        private void BTN_Supprimer_Click(object sender, EventArgs e)
        {
            AfficherMasquerChamps(false);

            if (LB_Livres.SelectedItem != null)
            {
                if (MessageBox.Show("Voulez-vous vraiment supprimer ce livre ?", "Suppression", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Livre itemSelectionne = (Livre)LB_Livres.SelectedItem; // Récupérer l'item sélectionné
                    Livre livre           = new Livre(itemSelectionne.GetCode());
                    livre.Supprimer();

                    ObtenirListeLivres();
                }
            }
        }
Exemplo n.º 2
0
        // Bouton Modifier
        private void BTN_Modifier_Click(object sender, EventArgs e)
        {
            if (LB_Livres.SelectedItem != null)
            {
                action = ActionSelectionnee.Modifier;
                AfficherMasquerChamps(true);

                Livre itemSelectionne = (Livre)LB_Livres.SelectedItem;
                Livre cd = new Livre(itemSelectionne.GetCode());

                TXT_Nom.Text     = cd.GetNom();
                TXT_Auteur.Text  = cd.GetAuteur();
                TXT_NbPages.Text = cd.GetNombrePages().ToString();

                TXT_Nom.Focus();
            }
        }
Exemplo n.º 3
0
        // Index de la Listbox changé
        private void LB_Livres_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (LB_Livres.SelectedItem != null)
            {
                AfficherMasquerChamps(false);

                Livre itemSelectionne = (Livre)LB_Livres.SelectedItem; // Récupérer l'item sélectionné
                codeCDSelectionne = itemSelectionne.GetCode();         // Enregistrer le code de l'item sélectionné

                LBL_Infos_Titre.Text     = "Titre: " + itemSelectionne.GetNom();
                LBL_Infos_Auteur.Text    = "Ecrit par: " + itemSelectionne.GetAuteur();
                LBL_Infos_NbPages.Text   = itemSelectionne.GetNombrePages().ToString() + " pages";
                LBL_Infos_DateAjout.Text = "Livre ajouté le " + itemSelectionne.GetDateAjout();

                BTN_Modifier.Enabled  = true;
                BTN_Supprimer.Enabled = true;
            }
        }