Exemple #1
0
        private void btnAddItem_Click(object sender, EventArgs e)
        {
            OrderItem   orderItem   = new OrderItem();
            ItemAddForm itemAddForm = new ItemAddForm(orderItem);

            itemAddForm.ShowDialog();
            //订单每增加一个就应该存到currentorder的items列表中,方便到时候存进数据库
            if (CurrentOrder.Add_Item(itemAddForm.currentItem))
            {
                if (editmode == true)
                {
                    using (var db = new OrdersContext())
                    {
                        var neworderitem = itemAddForm.currentItem;
                        neworderitem.Order_ID        = CurrentOrder.Order_ID;
                        db.Entry(neworderitem).State = EntityState.Added;
                        db.SaveChanges();
                    }
                }
                orderbindingSource.DataSource = CurrentOrder;//更新绑定信息,使界面立即显示信息
                orderbindingSource.ResetBindings(false);
            }
            else
            {
                MessageBox.Show("添加商品明细失败");
            }
        }
Exemple #2
0
        private void btnAddItem_Click(object sender, EventArgs e)
        {
            OrderItem   orderItem   = new OrderItem();
            ItemAddForm itemAddForm = new ItemAddForm(orderItem);

            itemAddForm.ShowDialog();
            CurrentOrder.Add_Item(itemAddForm.currentItem);
            orderbindingSource.DataSource = CurrentOrder;//更新绑定信息,使界面立即显示信息
            orderbindingSource.ResetBindings(false);
        }