Exemplo n.º 1
0
 //按订单号查询订单
 public OrderDetails SearchOrder1(string num1)
 {
     using (var db = new OrderDB())
     {
         return(db.OrderDetails.SingleOrDefault(o => o.num == num1));
     }
 }
Exemplo n.º 2
0
 //按商品名称查询订单
 public OrderDetails SearchOrder2(string goodName1)
 {
     using (var db = new OrderDB())
     {
         return(db.OrderDetails.SingleOrDefault(o => o.goodName == goodName1));
     }
 }
Exemplo n.º 3
0
 //获得所有订单
 public List <OrderDetails> GetAllOrders()
 {
     using (var db = new OrderDB())
     {
         return(db.OrderDetails.ToList <OrderDetails>());
     }
 }
Exemplo n.º 4
0
 public List <Order> GetAllOrders()
 {
     using (var db = new OrderDB())
     {
         return(db.Order.Include("Items").ToList <Order>());
     }
 }
Exemplo n.º 5
0
 //查询电话号码
 public OrderDetails SearchOrder4(string phoneNum1)
 {
     using (var db = new OrderDB())
     {
         return(db.OrderDetails.SingleOrDefault(o => o.phoneNum == phoneNum1));
     }
 }
Exemplo n.º 6
0
 //按客户查询订单
 public OrderDetails SearchOrder3(string cusName1)
 {
     using (var db = new OrderDB())
     {
         return(db.OrderDetails.SingleOrDefault(o => o.cusName == cusName1));
     }
 }
Exemplo n.º 7
0
 public List <Order> QueryById(String id)
 {
     using (var db = new OrderDB())
     {
         return(db.Order.Include("items")
                .Where(o => o.Id.Equals(id)).ToList <Order>());
     }
 }
Exemplo n.º 8
0
 public void AddOrder(Order order)
 {
     using (var db = new OrderDB())
     {
         db.Order.Add(order);
         db.SaveChanges();
     }
 }
Exemplo n.º 9
0
 public Order GetOrder(String Id)
 {
     using (var db = new OrderDB())
     {
         return(db.Order.Include("Items").
                SingleOrDefault(o => o.Id == Id));
     }
 }
Exemplo n.º 10
0
 public List <Order> QueryByCustormer(String custormer)
 {
     using (var db = new OrderDB())
     {
         return(db.Order.Include("Items")
                .Where(o => o.Customer.Equals(custormer)).ToList <Order>());
     }
 }
Exemplo n.º 11
0
 public List <Order> QueryAllOrders() //查询所有订单
 {
     using (var db = new OrderDB())
     {
         return(db.Order.Include("Details").ToList <Order>());
     }
     return(orderDict.Values.ToList());
 }
Exemplo n.º 12
0
 public int AddOrder(Order order)//添加订单
 {
     using (var db = new OrderDB()) {
         db.Order.Add(order);
         db.SaveChanges();
     }
     orderDict[order.Id] = order;
     return(0);
 }
Exemplo n.º 13
0
 public List <Order> QueryByGoods(String product)
 {
     using (var db = new OrderDB())
     {
         var query = db.Order.Include("Items")
                     .Where(o => o.Items.Where(
                                item => item.Product.Equals(product)).Count() > 0);
         return(query.ToList <Order>());
     }
 }
Exemplo n.º 14
0
 public void Delete(String orderId)
 {
     using (var db = new OrderDB())
     {
         var order = db.Order.Include("Items").SingleOrDefault(o => o.Id == orderId);
         db.OrderItem.RemoveRange(order.Items);
         db.Order.Remove(order);
         db.SaveChanges();
     }
 }
Exemplo n.º 15
0
        //添加订单
        public void AddOrder(string num1, string cusName1, string phoneNum1, string goodName1, double price1)
        {
            OrderDetails A = new OrderDetails(num1, cusName1, phoneNum1, goodName1, price1);

            using (var db = new OrderDB())
            {
                db.OrderDetails.Add(A);
                db.SaveChanges();
            }
        }
Exemplo n.º 16
0
 public void Add(Order order)
 {
     using (var db = new OrderDB())
     {
         db.Order.Add(order);
         //db.Order.Attach(order);
         //db.Entry(order).State = EntityState.Added;
         db.SaveChanges();
     }
 }
Exemplo n.º 17
0
        public List <Order> QueryByGoodsName(string goodsName)//根据商品名字查询订单,使用linq语句
        {
            using (var db = new OrderDB())
            {
                return(db.Order.Include("Details")
                       .Where(order => order.Details.Where(d => d.goodsname == goodsName).Count() > 0).ToList <Order>());
            }

            /* var query = orderDict.Values.Where(order => order.Details.Where(d => d.goodsname == goodsName).Count() > 0);
             * return query.ToList();*/
        }
Exemplo n.º 18
0
 public void Update(Order order)
 {
     using (var db = new OrderDB())
     {
         db.Order.Attach(order);
         db.Entry(order).State = EntityState.Modified;
         order.Items.ForEach(
             item => db.Entry(item).State = EntityState.Modified);
         db.SaveChanges();
     }
 }
Exemplo n.º 19
0
        public List <Order> QueryByCustomerName(string customerName)//根据客户名字查询订单,使用linq语句
        {
            using (var db = new OrderDB())
            {
                return(db.Order.Include("Details")
                       .Where(o => o.customername.Equals(customerName)).ToList <Order>());
            }

            /* var query = orderDict.Values
             *   .Where(order => order.customername == customerName);
             * return query.ToList();*/
        }
Exemplo n.º 20
0
 public int RemoveOrder(int orderId)//删除订单
 {
     using (var db = new OrderDB())
     {
         var order = db.Order.Include("Details").SingleOrDefault(o => o.Id == orderId);
         db.OrderDetails.RemoveRange(order.Details);
         db.Order.Remove(order);
         db.SaveChanges();
     }
     orderDict.Remove(orderId);
     return(0);
 }
Exemplo n.º 21
0
 //删除订单
 public void DeleteOrder(string num1)
 {
     using (var db = new OrderDB())
     {
         var order = db.OrderDetails.SingleOrDefault(o => o.num == num1);
         if (order != null)
         {
             db.OrderDetails.Remove(order);
             db.SaveChanges();
         }
         else
         {
             Console.WriteLine("订单不存在不能删除");
         }
     }
 }
Exemplo n.º 22
0
        //修改订单
        public void ChangeOrder(string num2, string cusName2, string phoneNum2, string goodName2, double price2, string num1, string cusName1, string phoneNum1, string goodName1, double price1)
        {
            OrderDetails B = new OrderDetails(num1, cusName1, phoneNum1, goodName1, price1);

            using (var db = new OrderDB())
            {
                var A = db.OrderDetails.SingleOrDefault(o => o.num == num2 && o.goodName == goodName2 && o.cusName == cusName2 && o.price == price2 && o.phoneNum == phoneNum2);
                if (A != null)
                {
                    db.OrderDetails.Remove(A);
                    db.OrderDetails.Add(B);
                    db.SaveChanges();
                }
                else
                {
                    Console.WriteLine("订单修改失败");
                }
            }
        }