/// <summary>
        ///  Fonction Click du bouton Ajouter
        /// </summary>
        public void B_AjServFin_Click(object sender, EventArgs e)
        {
            int  prix         = 0;
            bool isNumberPrix = int.TryParse(TB_Prix_Plat.Text, out prix);                                                                                                                 // Vérifier que le prix saisie et bien écrit avec des chiffre

            if (isNumberPrix == true)                                                                                                                                                      // Si le prix est bien un nombre
            {
                B_Article.Add(Convert.ToString(TB_Nom_Plat.Text), Convert.ToInt32(TB_Prix_Plat.Text), Convert.ToString(TB_Photo_Plat.Text), Convert.ToInt32(CB_Type_Plats.SelectedValue)); // Appel de la fonction Add de B_Article
                this.Close();                                                                                                                                                              // Fermeture du formulaire
            }
            else
            {
                MessageBox.Show("Veuillez saisir des chiffres pour le prix!"); // Affiche un message si erreur
            }
        }
        /// <summary>
        /// Fonction Click du bouton Supprimer
        /// </summary>
        private void Bouton_Supprimer_Click(object sender, EventArgs e)
        {
            try
            {
                B_Article.Delete(Convert.ToInt32(lv_Article.SelectedItems[0].SubItems[0].Text)); // Apple de la fonction Delete de B_Article
                lv_Article.Items.RemoveAt(lv_Article.SelectedItems[0].Index);                    // Suppresion de l'item selectionné dans la ListView
                lv_Article.Refresh();                                                            // refraichisement de la ListView

                //revenir Menu
                // A compléter
            }
            catch (Exception)
            {
                MessageBox.Show("Sélectionner un article!"); // Affichage d'un message si erreur
            }
        }
Ejemplo n.º 3
0
        private void B_ModifFin_Click(object sender, EventArgs e)
        {
            int    unId;
            string unNom;
            string unePhoto;
            int    unPrix;
            int    unIdCat;

            unId     = Convert.ToInt32(TB_Id_Plat.Text);
            unNom    = TB_Nom_Plat.Text;
            unePhoto = TB_Photo_Plat.Text;
            unPrix   = Convert.ToInt32(TB_Prix_Plat.Text);
            unIdCat  = Convert.ToInt32(CB_Type_Plats.SelectedValue);
            B_Article.Update(unId, unNom, unPrix, unePhoto, unIdCat);
            this.Close();
        }