Exemple #1
0
 private void ajoute_Click(object sender, RoutedEventArgs e)
 {
     if (AllDataBases.name == "Engrais")
     {
         db.engrais.Add(new engrai()
         {
             nom            = nomCombo.Text,
             Taille         = Convert.ToSingle(tailleCombo.Text),
             Prix           = Convert.ToSingle(prixText.Text),
             Quantite       = Convert.ToInt16(quantiteText.Text),
             Tarif          = 0.5,
             descript       = descriptionText.Text,
             Date_D__Ajoute = DateTime.Now
         });
         db.SaveChanges();
         AllDataBases.AlldataGrid.ItemsSource = (from s in db.engrais select s).ToList();
         MessageBox.Show("Ajoute avec Succsess", "Ajoute", MessageBoxButton.OK, MessageBoxImage.Information);
         return;
     }
     if (AllDataBases.name == "Irrigation")
     {
         db.Irrigations.Add(new Irrigation()
         {
             nom            = nomCombo.Text,
             Taille         = Convert.ToSingle(tailleCombo.Text),
             Prix           = Convert.ToSingle(prixText.Text),
             Quantite       = Convert.ToInt16(quantiteText.Text),
             Tarif          = 0.5,
             descript       = descriptionText.Text,
             Date_D__Ajoute = DateTime.Now
         });
         db.SaveChanges();
         AllDataBases.AlldataGrid.ItemsSource = (from s in db.Irrigations select s).ToList();
         MessageBox.Show("Ajoute avec Succsess", "Ajoute", MessageBoxButton.OK, MessageBoxImage.Information);
         return;
     }
     if (AllDataBases.name == "Pesticides")
     {
         db.Pesticides.Add(new Pesticide()
         {
             nom            = nomCombo.Text,
             Taille         = Convert.ToSingle(tailleCombo.Text),
             Prix           = Convert.ToSingle(prixText.Text),
             Quantite       = Convert.ToInt16(quantiteText.Text),
             Tarif          = 0.5,
             descript       = descriptionText.Text,
             Date_D__Ajoute = DateTime.Now
         });
         db.SaveChanges();
         AllDataBases.AlldataGrid.ItemsSource = (from s in db.Pesticides select s).ToList();
         MessageBox.Show("Ajoute avec Succsess", "Ajoute", MessageBoxButton.OK, MessageBoxImage.Information);
         return;
     }
 }
Exemple #2
0
        private void Supprimier_Click(object sender, RoutedEventArgs e)
        {
            if (name == "Engrais")
            {
                foreach (var item in listID)
                {
                    engrai p = new engrai()
                    {
                        id = item
                    };
                    db.engrais.Attach(p);
                    db.engrais.Remove(p);
                }

                db.SaveChanges();
                AllDataBases.AlldataGrid.ItemsSource = (from s in db.engrais select s).ToList();
                return;
            }
            if (name == "Irrigation")
            {
                foreach (var item in listID)
                {
                    Irrigation p = new Irrigation()
                    {
                        id = item
                    };
                    db.Irrigations.Attach(p);
                    db.Irrigations.Remove(p);
                }

                db.SaveChanges();
                AllDataBases.AlldataGrid.ItemsSource = (from s in db.Irrigations select s).ToList();
                return;
            }
            if (name == "Pesticides")
            {
                foreach (var item in listID)
                {
                    Pesticide p = new Pesticide()
                    {
                        id = item
                    };
                    db.Pesticides.Attach(p);
                    db.Pesticides.Remove(p);
                }

                db.SaveChanges();
                AllDataBases.AlldataGrid.ItemsSource = (from s in db.Pesticides select s).ToList();
                return;
            }
        }
        private void Confirm_Click(object sender, RoutedEventArgs e)
        {
            DBagricultureEntities db = new DBagricultureEntities();

            if (AllDataBases.name == "Engrais")
            {
                engrai p = new engrai()
                {
                    id = idGlobal
                };
                db.engrais.Attach(p);
                db.engrais.Remove(p);
                db.SaveChanges();
                AllDataBases.AlldataGrid.ItemsSource = (from s in db.engrais select s).ToList();
                this.Close();
                return;
            }
            if (AllDataBases.name == "Irrigation")
            {
                Irrigation p = new Irrigation()
                {
                    id = idGlobal
                };
                db.Irrigations.Attach(p);
                db.Irrigations.Remove(p);
                db.SaveChanges();
                AllDataBases.AlldataGrid.ItemsSource = (from s in db.Irrigations select s).ToList();
                this.Close();
                return;
            }
            if (AllDataBases.name == "Pesticides")
            {
                Pesticide p = new Pesticide()
                {
                    id = idGlobal
                };
                db.Pesticides.Attach(p);
                db.Pesticides.Remove(p);
                db.SaveChanges();
                AllDataBases.AlldataGrid.ItemsSource = (from s in db.Pesticides select s).ToList();
                this.Close();
                return;
            }
        }