private void delete_item(int currentID) { menuItem itemtoDelete = db.menuItems.Where(a => a.id == currentID).FirstOrDefault(); db.menuItems.Remove(itemtoDelete); db.SaveChanges(); }
/* Submit form to database (not complete yet)*/ private void addWindowSubmit_Click(object sender, RoutedEventArgs e) { menuItem newItem = new menuItem() { name = nametextBox.Text, catagory = categorycomboBox.Text, price = Decimal.Parse(priceBox.Text), salesDay = salesdayBox.Text, salesPrice = Decimal.Parse(salespriceBox.Text) }; db.menuItems.Add(newItem); db.SaveChanges(); this.Hide(); DataBaseChanged(true); }
/* Submit form to database (not complete yet)*/ private void updateWindowSubmit_Click(object sender, RoutedEventArgs e) { menuItem updateItem = (from m in db.menuItems where m.id == Id select m).Single(); { updateItem.name = nametextBox.Text; updateItem.catagory = categorycomboBox.Text; updateItem.price = Decimal.Parse(priceBox.Text); updateItem.salesDay = salesdayBox.Text; updateItem.salesPrice = Decimal.Parse(salespriceBox.Text); }; db.SaveChanges(); this.Hide(); DataBaseChanged(true); }