示例#1
0
 public void update(OrderDetails order)
 {
     using (OrderDB db = new OrderDB())
     {
         db.OrderDetails.Attach(order);
         db.Entry(order).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
示例#2
0
 //修改订单
 public void changeCustomerOfOrder(Order ele, String newCustomer)
 {
     ele.Customer = newCustomer;
     using (var db = new OrderDB())
     {
         var target = db.Orders.Find(ele.OrderNum);
         target.Customer = newCustomer;
         db.SaveChanges();
     }
 }
示例#3
0
 //删除订单
 public void deleteOrder(Order ele)
 {
     using (var db = new OrderDB())
     {
         var orderitem = from b in db.OrderDetails where b.OrderNum == ele.OrderNum select b;
         db.OrderDetails.RemoveRange(orderitem);
         var target = db.Orders.Find(ele.OrderNum);
         db.Orders.Remove(target);
         db.SaveChanges();
     }
 }
示例#4
0
 //添加产品
 public void addOrderDetail(OrderDetails pro)
 {
     using (var db = new OrderDB())
     {
         var target = db.Orders.Find(pro.OrderNum);
         var order  = from e in this.ListOfOrder where e.OrderNum == pro.OrderNum select e;
         foreach (Order ele in order)
         {
             ele.ListOfProduct.Add(pro);
         }
         target.ListOfProduct.Add(pro);
         db.OrderDetails.Add(pro);
         db.SaveChanges();
     }
 }
示例#5
0
 //添加订单
 public bool addOrder(Order neworder)
 {
     if ((from b in this.ListOfOrder where b.OrderNum == neworder.OrderNum select b).Count() == 0)
     {
         using (var db = new OrderDB())
         {
             db.Orders.Add(neworder);
             db.SaveChanges();
         }
         this.ListOfOrder.Add(neworder);
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#6
0
 public bool changeOrderNumOfOrder(Order ele, String newNum)
 {
     ele.OrderNum = newNum;
     using (var db = new OrderDB())
     {
         var orderitem = from b in db.OrderDetails where b.OrderNum == ele.OrderNum select b;
         var target    = db.Orders.Find(ele.OrderNum);
         try
         {
             target.Customer = newNum;
             foreach (OrderDetails el in orderitem)
             {
                 el.OrderNum = newNum;
             }
             db.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
示例#7
0
 public void init()
 {
     using (OrderDB db = new OrderDB())
     {
         foreach (Order e in db.Orders)
         {
             ListOfOrder.Add(e);
         }
     }
     using (OrderDB db = new OrderDB())
     {
         var list = db.OrderDetails.ToList();
         foreach (OrderDetails e in db.OrderDetails)
         {
             foreach (Order target in ListOfOrder)
             {
                 if (target.OrderNum == e.OrderNum)
                 {
                     target.ListOfProduct.Add(e);
                 }
             }
         }
     }
 }