Example #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();
     }
 }
Example #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();
     }
 }
Example #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();
     }
 }
Example #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();
     }
 }
Example #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);
     }
 }
Example #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);
         }
     }
 }