Esempio n. 1
0
        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;
            }
        }