Esempio n. 1
0
 public List <Order> SearchPriceMoreThan(double temp)
 {
     using (var db = new OrderDB())
     {
         return(db.tb_Order.Include("Items").Where(m => m.TotalPrice >= temp).ToList <Order>());
     }
 }
Esempio n. 2
0
 public List <Order> SearchOrderbyName(string temp)
 {
     using (var db = new OrderDB())
     {
         return(db.tb_Order.Include("Items").Where(m => m.Name == temp).ToList <Order>());
     }
 }
Esempio n. 3
0
 public List <Order> SearchAllOrders()
 {
     using (var db = new OrderDB())
     {
         return(db.tb_Order.Include("Items").ToList <Order>());
     }
 }
Esempio n. 4
0
 public void AddOrder(Order order)
 {
     using (var db = new OrderDB())
     {
         db.tb_Order.Add(order);
         db.SaveChanges();
     }
 }
Esempio n. 5
0
 public List <Order> SearchOrderbyItem(string temp)
 {
     using (var db = new OrderDB())
     {
         var query = db.tb_Order.Include("Items").Where(m => m.Items.Where
                                                            (n => n.Item == temp).Count() > 0);
         return(query.ToList <Order>());
     }
 }
Esempio n. 6
0
 public void Update(Order order)
 {
     using (var db = new OrderDB())
     {
         db.tb_Order.Attach(order);
         db.Entry(order).State = EntityState.Modified;
         order.Items.ForEach(item => db.Entry(item).State = EntityState.Modified);
         db.SaveChanges();
     }
 }
Esempio n. 7
0
 public void DeleteByID(String id)
 {
     using (var db = new OrderDB())
     {
         var order = db.tb_Order.Include("Items").SingleOrDefault(m => m.ID == id);
         db.tb_OrderDetails.RemoveRange(order.Items);   //还需要删除 items 的内容
         db.tb_Order.Remove(order);
         db.SaveChanges();
     }
 }