Beispiel #1
0
 private void CdR(object sender, RoutedEventArgs e)
 {
     if (ConnexionCompte.UnBlockCdR == false)
     {
         MessageBox.Show("Attention ! Vous n'etes pas un créateur de recette ! Vous n'avez pas accès à ces fonctions", "Erreur !", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     else
     {
         ModuleCdR window = new ModuleCdR();
         window.Show();
         this.Close();
     }
 }
Beispiel #2
0
        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            var result = MessageBox.Show("Attention ! êtes-vous sûr de vouloir abandonner la création ?", "Warning !", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (result == MessageBoxResult.Yes)
            {
                listeNomNouveauxProduits.Clear();
                listeNomProduitsRecette.Clear();
                listeQuantiteNouveauxProduits.Clear();
                listeQuantitesRecette.Clear();


                nomRec             = "";
                idRec              = "";
                prixRec            = 0;
                EurosLabel.Content = "";
                description        = "";
                indiceType         = -1;

                ModuleCdR window = new ModuleCdR();
                window.Show();
                this.Close();
            }
        }
Beispiel #3
0
        private void ValiderButton_Click(object sender, RoutedEventArgs e)
        {
            string listeIngred = "";
            string quantites   = "";

            if (listeNomProduitsRecette.Count != 0)
            {
                for (int i = 0; i < listeNomProduitsRecette.Count - 1; i++)
                {
                    listeIngred += listeNomProduitsRecette[i] + ";";
                    quantites   += listeQuantitesRecette[i] + ";";
                }

                listeIngred += listeNomProduitsRecette[listeNomProduitsRecette.Count - 1];
                quantites   += listeQuantitesRecette[listeNomProduitsRecette.Count - 1];
            }

            if (listeNomNouveauxProduits.Count != 0)
            {
                if (listeNomProduitsRecette.Count != 0)
                {
                    listeIngred += ";";
                    quantites   += ";";
                }

                for (int j = 0; j < listeNomNouveauxProduits.Count - 1; j++)
                {
                    listeIngred += listeNomNouveauxProduits[j].NomP + ";";
                    quantites   += listeQuantiteNouveauxProduits[j] + ";";

                    // Inserer les nouveaux produits dans la database

                    string connectionString1 = "SERVER=localhost;PORT=3306;DATABASE=projet;UID=" + MainWindow.Username + ";PASSWORD="******" INSERT INTO `projet`.`produit` (`nomP`,`categorieP`,`unite`,`stockActuel`,`stockMin`,`stockMax`,`idF`) VALUES ('" + nomP + "','" + categorieP + "','" + unite + "'," + stockAct + "," + stockMini + "," + stockMax + ",'" + idF + "');";

                    MySqlDataReader reader1;
                    reader1 = command1.ExecuteReader();

                    while (reader1.Read())
                    {
                    }

                    connection1.Close();
                }

                int dernierInd = listeNomNouveauxProduits.Count - 1;

                listeIngred += listeNomNouveauxProduits[dernierInd].NomP;
                quantites   += listeQuantiteNouveauxProduits[dernierInd];

                // Inserer les nouveaux produits dans la database

                string connectionString = "SERVER=localhost;PORT=3306;DATABASE=projet;UID=" + MainWindow.Username + ";PASSWORD="******"INSERT INTO `projet`.`produit` (`nomP`,`categorieP`,`unite`,`stockActuel`,`stockMin`,`stockMax`,`idF`) VALUES ('" + nomP2 + "','" + categorieP2 + "','" + unite2 + "'," + stockAct2 + "," + stockMini2 + "," + stockMax2 + ",'" + idF2 + "');";


                MySqlDataReader reader;
                reader = command.ExecuteReader();

                while (reader.Read())
                {
                }

                connection.Close();
            }

            // Inserer la recette dans la database

            string connectionStringR = "SERVER=localhost;PORT=3306;DATABASE=projet;UID=" + MainWindow.Username + ";PASSWORD="******"R" + IdLabel.Text;
            string nomR = NomLabel.Text;
            string type = TypesCombo.SelectedItem.ToString();

            string descriptionR = textDescription.Text;
            int    priXR        = Convert.ToInt32(CookLabel.Text);
            string idGrat       = "GratR" + IdLabel.Text;
            int    nbCook       = 2;
            string idCdR        = ConnexionCompte.IdCdRConnecte;

            commandR.CommandText = "INSERT INTO `projet`.`recette` (`idR`,`nomR`,`type`,`listeIngredients`,`quantites`,`descriptionR`,`prixR`,`remunerationCuisinier`,`nbCommandes`,`idGratification`,`nbCook`,`idCdR`) VALUES ('" + idR + "','" + nomR + "','" + type + "','" + listeIngred + "','" + quantites + "','" + descriptionR + "'," + priXR + "," + 2 + "," + 0 + ",'" + idGrat + "'," + nbCook + ",'" + idCdR + "');";


            MySqlDataReader readerR;

            readerR = commandR.ExecuteReader();

            while (readerR.Read())
            {
            }

            connectionR.Close();

            MainWindow.LoadDatabase();
            listeNomNouveauxProduits.Clear();
            listeNomProduitsRecette.Clear();
            listeQuantiteNouveauxProduits.Clear();
            listeQuantitesRecette.Clear();


            nomRec             = "";
            idRec              = "";
            prixRec            = 0;
            EurosLabel.Content = "";
            description        = "";
            indiceType         = -1;

            // Gratifier le createur de la recette de nbCook points

            connectionR.Open();

            MySqlCommand commandUpdate = connectionR.CreateCommand();

            commandUpdate.CommandText = "UPDATE projet.cdr SET cook=cook+" + nbCook + " WHERE idCdR='" + ConnexionCompte.IdCdRConnecte + "';";

            MySqlDataReader readerUpdate;

            readerUpdate = commandUpdate.ExecuteReader();

            while (readerUpdate.Read())
            {
            }

            connectionR.Close();

            MessageBox.Show("La recette a bien été créée et rajouté à la database ! ", "Success!", MessageBoxButton.OK, MessageBoxImage.Information);

            MainWindow.LoadDatabase();

            ModuleCdR window = new ModuleCdR();

            window.Show();
            this.Close();
        }
        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            ModuleCdR window = new ModuleCdR();

            window.Show();
        }