예제 #1
0
        private void PrixLostFocus(object sender, RoutedEventArgs e)
        {
            try
            {
                Convert.ToInt32(((TextBox)sender).Text);

                if (Convert.ToInt32(((TextBox)sender).Text) < 10 || Convert.ToInt32(((TextBox)sender).Text) > 40)
                {
                    MessageBox.Show("Le prix doit être entre 10 et 40 cook !", "Erreur !", MessageBoxButton.OK, MessageBoxImage.Error);
                    CookLabel.Text     = string.Empty;
                    prixRec            = 0;
                    EurosLabel.Content = "";
                }
                else
                {
                    prixRec            = Convert.ToInt32(((TextBox)sender).Text);
                    EurosLabel.Content = Recette.ConvertirEnEuros(Convert.ToInt32(((TextBox)sender).Text));
                }
            }
            catch
            {
                MessageBox.Show("Vous devez entrez des chiffres.", "Syntax !", MessageBoxButton.OK, MessageBoxImage.Error);
                CookLabel.Text     = string.Empty;
                prixRec            = 0;
                EurosLabel.Content = "";
            }
        }
예제 #2
0
        public Panier()
        {
            InitializeComponent();

            int prixCook = 0;

            DataTable dataPanier = new DataTable("Liste Recettes");

            dataPanier.Columns.Add("Quantité_Commandée");
            dataPanier.Columns.Add("Type");
            dataPanier.Columns.Add("Nom Recette");
            dataPanier.Columns.Add("Id Recette");
            dataPanier.Columns.Add("Prix (Cook)");
            dataPanier.Columns.Add("Id Createur de Recette");
            dataPanier.Columns.Add("Nom Createur de Recette");
            dataPanier.Columns.Add("Prenom Createur de Recette");

            string connectionString = "SERVER=localhost;PORT=3306;DATABASE=projet;UID=" + MainWindow.Username + ";PASSWORD="******"SELECT R.type,R.nomR AS Nom_Recette,R.idR AS id_Recette,R.prixR,R.idCdR AS id_Createur_de_Recette,UPPER(C.nomC) AS Nom_Createur_de_Recette,C.prenomC AS Prenom_Createur_de_Recette FROM projet.recette AS R, projet.client AS C, projet.cdr AS CdR WHERE R.idCdR = CdR.idCdR AND CdR.idC = C.idC AND idR='" + id + "' ORDER BY R.type,R.nomR;";

                MySqlDataReader readerRemplir;
                readerRemplir = commandRemplir.ExecuteReader();

                while (readerRemplir.Read())
                {
                    prixCook += readerRemplir.GetInt32(3);

                    if (!listeIdRajoutes.Contains(id))
                    {
                        dataPanier.Rows.Add(PasserCommande.listeIdRecettesCommandees.Count(item => item == id), readerRemplir.GetString(0), readerRemplir.GetString(1), readerRemplir.GetString(2), readerRemplir.GetInt32(3), readerRemplir.GetString(4), readerRemplir.GetString(5), readerRemplir.GetString(6));
                        listeIdRajoutes.Add(id);
                    }
                }


                connection.Close();
            }

            dataPanier.DefaultView.Sort = "Quantité_Commandée desc";
            PanierData.ItemsSource      = dataPanier.DefaultView;

            PrixCook.Content  = prixCook;
            PrixEuros.Content = Recette.ConvertirEnEuros(prixCook);
        }
예제 #3
0
        public CreerRecette()
        {
            InitializeComponent();
            ValiderButton.Visibility = Visibility.Hidden;

            try
            {
                TypesCombo.Items.Clear();
                listeSupprimerCombo.Items.Clear();
                listeProduitsCombo.Items.Clear();

                MainWindow.LoadDatabase();

                // Remplir les combobox

                string connectionString = "SERVER=localhost;PORT=3306;DATABASE=projet;UID=" + MainWindow.Username + ";PASSWORD="******"SELECT nomP FROM projet.produit ORDER BY nomP;";

                MySqlDataReader readerRemplir;
                readerRemplir = commandRemplir.ExecuteReader();


                while (readerRemplir.Read())
                {
                    listeProduitsCombo.Items.Add(readerRemplir.GetString(0));
                }

                connection.Close();

                connection.Open();

                MySqlCommand commandRemplir2 = connection.CreateCommand();
                commandRemplir2.CommandText = "SELECT DISTINCT type FROM projet.recette ORDER BY type;";

                MySqlDataReader readerRemplir2;
                readerRemplir2 = commandRemplir2.ExecuteReader();


                while (readerRemplir2.Read())
                {
                    if (readerRemplir2.GetString(0) != "Autre")
                    {
                        TypesCombo.Items.Add(readerRemplir2.GetString(0));
                    }
                }

                TypesCombo.Items.Add("Autre");

                connection.Close();


                foreach (string nomP in listeNomProduitsRecette)
                {
                    listeSupprimerCombo.Items.Add(nomP);
                }

                foreach (Produit p in listeNomNouveauxProduits)
                {
                    listeSupprimerCombo.Items.Add(p.NomP);
                    listeProduitsCombo.Items.Add(p.NomP);
                }

                TypesCombo.SelectedIndex = indiceType;

                NomLabel.Text        = nomRec;
                IdLabel.Text         = idRec;
                CookLabel.Text       = prixRec.ToString();
                EurosLabel.Content   = Recette.ConvertirEnEuros(prixRec);
                textDescription.Text = description;


                // Remplir la table

                DataTable dataProduits = new DataTable("Liste Produits");

                dataProduits.Columns.Add("Nom Produit");
                dataProduits.Columns.Add("Quantité");
                dataProduits.Columns.Add("Unité");

                int compteur = 0;

                foreach (string nom in listeNomProduitsRecette)
                {
                    string connectionStringData = "SERVER=localhost;PORT=3306;DATABASE=projet;UID=" + MainWindow.Username + ";PASSWORD="******"SELECT unite FROM projet.produit WHERE nomP='" + nom + "';";

                    MySqlDataReader readerData;
                    readerData = commandData.ExecuteReader();

                    string unite = "";

                    while (readerData.Read())
                    {
                        unite = readerData.GetString(0);
                    }

                    connectionData.Close();

                    dataProduits.Rows.Add(nom, listeQuantitesRecette[compteur], unite);
                    compteur++;
                }

                if (listeNomNouveauxProduits.Count != 0)
                {
                    int compteur2 = 0;
                    foreach (Produit p in listeNomNouveauxProduits)
                    {
                        dataProduits.Rows.Add(p.NomP, listeQuantiteNouveauxProduits[compteur2], p.Unite);
                        compteur2++;
                    }
                }

                dataProduits.DefaultView.Sort = "Nom Produit asc";
                TableIngred.ItemsSource       = dataProduits.DefaultView;
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message);
            }
        }
예제 #4
0
        public DetailRecette(string idRecette)
        {
            InitializeComponent();

            string connectionString = "SERVER=localhost;PORT=3306;DATABASE=projet;UID=" + MainWindow.Username + ";PASSWORD="******"SELECT nomR,type,prixR,listeIngredients,quantites,descriptionR FROM projet.recette WHERE idR='" + idRecette + "'; ";

            MySqlDataReader readerRemplir;

            readerRemplir = commandRemplir.ExecuteReader();


            string listeIng   = "";
            string listeQuant = "";

            while (readerRemplir.Read())
            {
                NomLabel.Content   = readerRemplir.GetString(0);
                TypeLabel.Content  = readerRemplir.GetString(1);
                IdLabel.Content    = idRecette;
                CookLabel.Content  = readerRemplir.GetInt32(2);
                EurosLabel.Content = Recette.ConvertirEnEuros(readerRemplir.GetInt32(2));

                listeIng   = readerRemplir.GetString(3);
                listeQuant = readerRemplir.GetString(4);

                textDescription.Text = readerRemplir.GetString(5) + ".";
            }

            connection.Close();

            string[] ingred    = listeIng.Split(';');
            string[] quantites = listeQuant.Split(';');

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

            foreach (string nomP in ingred)
            {
                connection.Open();
                MySqlCommand commandU = connection.CreateCommand();
                commandU.CommandText = "SELECT unite FROM projet.produit WHERE nomP='" + nomP + "'; ";

                MySqlDataReader readerU;
                readerU = commandU.ExecuteReader();

                while (readerU.Read())
                {
                    unites.Add(readerU.GetString(0));
                }
                connection.Close();
            }


            for (int j = 0; j < ingred.Length; j++)
            {
                textIngredients.Text += ingred[j] + " : " + quantites[j] + " " + unites[j] + "\n";
            }
        }
예제 #5
0
        public void TestConvertirEnEuros()
        {
            double res = Recette.ConvertirEnEuros(10);

            Assert.AreEqual(5.0, res);
        }