Ejemplo n.º 1
0
 //输出所有订单
 public List <Order> FindAll()
 {
     using (var db = new OrderDB())
     {
         return(db.Order.Include("orderDetails").ToList <Order>());
     }
 }
Ejemplo n.º 2
0
 //通过用户名查找相应订单
 public List <Order> FindByGuestName(string guestname)
 {
     using (var db = new OrderDB())
     {
         return(db.Order.Include("OrderDetail")
                .Where(o => o.guestName.Equals(guestname)).ToList <Order>());
     }
 }
Ejemplo n.º 3
0
 //通过订单号查找相应订单
 public Order FindByOrderNumber(long ordernumber)
 {
     using (var db = new OrderDB())
     {
         return(db.Order.Include("OrderDetail").
                SingleOrDefault(o => o.orderNumber == ordernumber));
     }
 }
Ejemplo n.º 4
0
 //通过货物名查找相应订单
 public List <Order> FindByGoodName(string goodname)
 {
     using (var db = new OrderDB())
     {
         var query = db.Order.Include("OrderDetail")
                     .Where(o => o.orderDetail.Where(
                                item => item.goodName.Equals(goodname)).Count() > 0);
         return(query.ToList <Order>());
     }
 }
Ejemplo n.º 5
0
 public void Update(Order order)
 {
     using (var db = new OrderDB())
     {
         db.Order.Attach(order);
         db.Entry(order).State = EntityState.Modified;
         order.orderDetail.ForEach(
             item => db.Entry(item).State = EntityState.Modified);
         db.SaveChanges();
     }
 }
Ejemplo n.º 6
0
 //删除订单
 public void RemoveOrder(long ordernumber)
 {
     using (var db = new OrderDB())
     {
         var order = db.Order.Include("orderDetails").SingleOrDefault(o => o.orderNumber == ordernumber);
         db.OrderDetail.RemoveRange(order.orderDetail);
         db.Order.Remove(order);
         db.SaveChanges();
     }
     //orderDictionary.Remove(ordernumber);
 }
Ejemplo n.º 7
0
 //添加订单
 public void AddOrder(Order order)
 {
     using (var db = new OrderDB())
     {
         db.Order.Add(order);
         db.SaveChanges();
     }
     //if (orderDictionary.ContainsKey(order.orderNumber))
     //    throw new Exception("Order has existed.");
     //orderDictionary[order.orderNumber] = order;
 }