private void button1_Click(object sender, EventArgs e) { OrderDelForm form = new OrderDelForm(); if (form.ShowDialog() == DialogResult.OK) { totalorderService.DeleteOrder(form.delOrder.Order_ID); QueryAll(); } }
private void button1_Click(object sender, EventArgs e) { OrderDelForm form = new OrderDelForm(); if (form.ShowDialog() == DialogResult.OK) { totalorderService.DeleteOrder(form.delOrder.Order_ID); using (var db = new OrdersContext()) { var delOrder = db.Orders.Include("Orderitem_list").FirstOrDefault(o => o.Order_ID == form.delOrder.Order_ID); if (delOrder != null) { db.Orders.Remove(delOrder); db.SaveChanges(); } } QueryAll(); } }