Esempio n. 1
0
 public MainWindow()
 {
     InitializeComponent();
     ClientStatic.ClientStatic1();
     Panier.PanierVide();
     mot_de_passe.mot_de_passe_changement("4F10e6bff@");
 }
 private void valider_panier(object sender, RoutedEventArgs e)
 {
     if (Panier.FaitTravailCommande(int.Parse(prix_tot.Text)))
     {
         MessageBox.Show("Merci pour votre achat, vous serez livré dans les plus brefs délais");
         this.Close();
     }
     Panier.PanierVide();
 }
        private void ajouter_commande(object sender, RoutedEventArgs e)
        {
            string choix_entree  = entree.Text;
            string choix_plat    = plat.Text;
            string choix_dessert = dessert.Text;
            string choix_boisson = Boissons.Text;
            string choix         = "";

            if (choix_entree != "Choisir une entrée")
            {
                choix = choix_entree;
            }
            else if (choix_plat != "Choisir un plat")
            {
                choix = choix_plat;
            }
            else if (choix_dessert != "Choisir un dessert")
            {
                choix = choix_dessert;
            }
            else if (choix_boisson != "Choisir une boisson")
            {
                choix = choix_boisson;
            }
            else
            {
                Console.WriteLine("erreur rien n'est choisi");
                erreur pb = new erreur();
                pb.Show();
                return;
            }


            MySqlConnection maConnexion = null;

            try
            {
                string connexionString = "SERVER=localhost;PORT=3306;DATABASE=tableprojet;UID=root;PASSWORD="******";";
                maConnexion = new MySqlConnection(connexionString);
                maConnexion.Open();
            }
            catch (MySqlException er)
            {
                Console.WriteLine(" ErreurConnexion : " + er.ToString());
            }
            //MessageBox.Show(choix);
            string       requete_list_ingre = "Select r.idRecette,l.idIngredient1,l.quantite from Liste_ingredient l join recette r on l.idRecette1=r.idRecette  where r.Nom='" + choix + "';";
            MySqlCommand command_list       = maConnexion.CreateCommand();

            command_list.CommandText = requete_list_ingre;

            MySqlDataReader reader_list = command_list.ExecuteReader();

            List <string> list_ingredient = new List <string>();

            while (reader_list.Read())
            {
                list_ingredient.Add(reader_list.GetValue(1).ToString() + "-" + reader_list.GetValue(2).ToString());
            }
            int id_r = int.Parse(reader_list.GetValue(0).ToString());

            reader_list.Close();
            command_list.Dispose();

            bool estStock = true;

            foreach (string id_ingre in list_ingredient)
            {
                if (Estenstock(id_ingre) == false)
                {
                    estStock = false;
                }
            }

            if (estStock == true)
            {
                Panier.listIdRecette.Add(id_r);
            }
            //MessageBox.Show(Panier.listIdRecette.ToString());
            if (Panier.EstCreable())
            {
                Commande new_win = new Commande();
                this.Close();
                new_win.Show();
            }
            else
            {
                Panier.listIdRecette.Remove(id_r);
                MessageBox.Show("Pas assez de quantité");
            }
        }