Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string id = textBox1.Text;

            using (var db = new OrderModel())
            {
                int k = int.Parse(id);

                var order = db.orders.Include("OrderDetails").FirstOrDefault(p => p.id == k);
                if (order != null)
                {
                    //db.orders.Attach(order);
                    db.orders.Remove(order);
                    db.SaveChanges();
                }
            }

            if (orderService.DeleteOrder(id))
            {
                DeleteSucced deleteSucced = new DeleteSucced();
                deleteSucced.ShowDialog();
                this.Close();
            }
            else
            {
                DeleteError deleteError = new DeleteError();
                deleteError.ShowDialog();
                this.Close();
            }
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string id = textBox1.Text;

            if (orderService.DeleteOrder(id))
            {
                DeleteSucced deleteSucced = new DeleteSucced();
                deleteSucced.ShowDialog();
                this.Close();
            }
            else
            {
                DeleteError deleteError = new DeleteError();
                deleteError.ShowDialog();
                this.Close();
            }
        }