コード例 #1
0
        private void Delete_Cdr(object sender, RoutedEventArgs e)
        {
            Cooking_BDD.cookingDataSet cookingDataSet = ((Cooking_BDD.cookingDataSet)(this.FindResource("cookingDataSet")));

            DataRow data  = cookingDataSet.clients[clientsDataGrid.SelectedIndex];
            string  items = Convert.ToString(data["createur_recette_id_createur"]);



            MySqlCommand my_recette = mySql_cooking.CreateCommand();

            my_recette.CommandText = "select nom_recette from recette where id_createur=@cdr";
            my_recette.Parameters.AddWithValue("@cdr", items);
            MySqlDataReader dr;

            dr = my_recette.ExecuteReader();
            while (dr.Read())
            {
                string nom_recette = Convert.ToString(dr["nom_recette"]);

                Cooking_BDD.cookingDataSetTableAdapters.contientTableAdapter cookingDataSetingredientTableAdapter = new Cooking_BDD.cookingDataSetTableAdapters.contientTableAdapter();
                cookingDataSetingredientTableAdapter.DeleteRecetteIngredient(nom_recette);

                Cooking_BDD.cookingDataSetTableAdapters.est_composeeTableAdapter cookingDataSetcontientTableAdapter = new Cooking_BDD.cookingDataSetTableAdapters.est_composeeTableAdapter();
                cookingDataSetcontientTableAdapter.DeleteContientRecette(nom_recette);
            }
            dr.Close();


            if (items == "")
            {
                MessageBox.Show("Vous n'avez rien selectionné et/ou le client n'est pas un CDR.");
            }
            else
            {
                Cooking_BDD.cookingDataSetTableAdapters.recetteTableAdapter cookingDataSetrecetteTableAdapter = new Cooking_BDD.cookingDataSetTableAdapters.recetteTableAdapter();
                cookingDataSetrecetteTableAdapter.DeleteRecette(items);

                Cooking_BDD.cookingDataSetTableAdapters.createur_recetteTableAdapter cookingDataSetcdrTableAdapter = new Cooking_BDD.cookingDataSetTableAdapters.createur_recetteTableAdapter();
                cookingDataSetcdrTableAdapter.DeleteQuery(items);

                Cooking_BDD.cookingDataSetTableAdapters.clientsTableAdapter cookingDataSetclientsTableAdapter = new Cooking_BDD.cookingDataSetTableAdapters.clientsTableAdapter();
                cookingDataSetclientsTableAdapter.UpdateCDR_ID(items);

                ActualiseClient();
            }
        }
コード例 #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Cooking_BDD.cookingDataSet cookingDataSet = ((Cooking_BDD.cookingDataSet)(this.FindResource("cookingDataSet")));

            DataRow data  = cookingDataSet.recette[recetteDataGrid.SelectedIndex];
            string  items = Convert.ToString(data["nom_recette"]);

            Cooking_BDD.cookingDataSetTableAdapters.contientTableAdapter cookingDataSetingredientTableAdapter = new Cooking_BDD.cookingDataSetTableAdapters.contientTableAdapter();
            cookingDataSetingredientTableAdapter.DeleteRecetteIngredient(items);

            Cooking_BDD.cookingDataSetTableAdapters.est_composeeTableAdapter cookingDataSetcontientTableAdapter = new Cooking_BDD.cookingDataSetTableAdapters.est_composeeTableAdapter();
            cookingDataSetcontientTableAdapter.DeleteContientRecette(items);

            Cooking_BDD.cookingDataSetTableAdapters.recetteTableAdapter cookingDataSetrecetteTableAdapter = new Cooking_BDD.cookingDataSetTableAdapters.recetteTableAdapter();
            cookingDataSetrecetteTableAdapter.DeleteQuery(items);

            ActualiseRecette();
        }