示例#1
0
        private void delBtn_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确认彻底删除所选订单项?", "删除订单", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                this.OrderView.DataSource = null;

                while (queryFliter.Count > 0)
                {
                    Order m = queryFliter.FirstOrDefault();
                    serve.DeleteOrder(m);
                    using (var DB = new OrderServiceDB())
                    {
                        var o = DB.MyOrders.Include("OrderDetails").FirstOrDefault(p => p.Id == m.Id);
                        if (o != null)
                        {
                            DB.MyOrders.Remove(o);
                            DB.SaveChanges();
                        }
                    }
                    queryFliter.Remove(m);
                }

                queryFliter = serve.orders;
                this.OrderView.DataSource = queryFliter;
            }
        }
示例#2
0
        private void ModifyBtn_Click(object sender, EventArgs e)
        {
            Order newOne = new Order(this.Id, new Client(this.Name, this.Address));

            newOne.AddProducts(this.AddProd, this.Count);

            Serve.ModifyOrder(this.QueryId, newOne);
            using (var DB = new OrderServiceDB())
            {
                var o = DB.MyOrders.Include("OrderDetails").FirstOrDefault(p => p.Id == QueryId);
                if (o != null)
                {
                    o.OrderDetails = newOne.OrderDetails;
                    o.User         = newOne.User;
                    DB.SaveChanges();
                }
            }
            this.Close();
        }