Exemplo n.º 1
0
 //按照订单号查询订单
 public List <Order> FindByID(string id)
 {
     using (var db = new OrderDB())
     {
         return(db.Orders.Include("OrderDetails").Where(o => o.OrderId.Equals(id)).ToList <Order>());
     }
 }
Exemplo n.º 2
0
 //按照客户查询订单
 public List <Order> FindByName(string client)
 {
     using (var db = new OrderDB())
     {
         return(db.Orders.Include("OrderDetails").Where(o => o.CustomerName.Equals(client)).ToList <Order>());
     }
 }
Exemplo n.º 3
0
 //显示所有订单
 public List <Order> ShowForUser()
 {
     using (var db = new OrderDB())
     {
         db.OrderDetails.Include("Goods").ToList <OrderDetails>();
         return(db.Orders.Include("OrderDetails").ToList <Order>());
     }
 }
Exemplo n.º 4
0
 public void AddOrder(Order order)
 {
     using (var db = new OrderDB())
     {
         db.Orders.Add(order);
         db.SaveChanges();
     }
 }
Exemplo n.º 5
0
 //按客户删除订单
 public void DeleteByCliend(string client)
 {
     using (var db = new OrderDB())
     {
         var order = db.Orders.Include("OrderDetails").SingleOrDefault(o => o.CustomerName == client);
         db.OrderDetails.RemoveRange(order.OrderDetails);
         db.Orders.Remove(order);
         db.SaveChanges();
     }
 }
Exemplo n.º 6
0
 //按订单号删除订单
 public void RemoveOrder(string orderId)
 {
     using (var db = new OrderDB())
     {
         db.OrderDetails.Include("Goods").ToList <OrderDetails>();
         db.OrderDetails.Include("Customers").ToList <OrderDetails>();
         var order = db.Orders.Include("OrderDetails").SingleOrDefault(o => o.OrderId == orderId);
         db.OrderDetails.RemoveRange(order.OrderDetails);
         db.Orders.Remove(order);
         db.SaveChanges();
     }
 }