Ejemplo n.º 1
0
 //sort orders by date
 public List <OrderManagement.DAL.OrdersTable> GetOrdersByDate(String date)
 {
     using (OrderManagementDBEntities ct = new OrderManagementDBEntities())
     {
         List <OrderManagement.DAL.OrdersTable> orders = new List <OrderManagement.DAL.OrdersTable>();
         foreach (var c in ct.OrdersTable)
         {
             OrderManagement.DAL.OrdersTable order = new OrderManagement.DAL.OrdersTable()
             {
                 OrderNumber     = c.OrderNumber,
                 OrderDate       = c.OrderDate,
                 DeliveryAddress = c.DeliveryAddress,
                 OrderStatus     = c.OrderStatus,
                 Total           = c.Total
             };
             orders.Add(order);
         }
         if (date == "Ascending")
         {
             orders.Sort((x, y) => DateTime.Compare(x.OrderDate, y.OrderDate));
         }
         else if (date == "Descending")
         {
             orders.Sort((x, y) => DateTime.Compare(y.OrderDate, x.OrderDate));
         }
         return(orders);
     }
 }
Ejemplo n.º 2
0
 //edits order in database
 public void EditOrder(OrderManagement.DAL.OrdersTable order)
 {
     using (OrderManagementDBEntities ct = new OrderManagementDBEntities())
     {
         ct.Entry(order).State = System.Data.EntityState.Modified;
         ct.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 //adds order to teh database
 public void AddOrder(OrderManagement.DAL.OrdersTable order)
 {
     using (OrderManagementDBEntities ct = new OrderManagementDBEntities())
     {
         ct.OrdersTable.Add(order);
         ct.SaveChanges();
     }
 }
Ejemplo n.º 4
0
        //deletes order from database
        public void DeleteOrder(OrderManagement.DAL.OrdersTable order)
        {
            using (OrderManagementDBEntities ct = new OrderManagementDBEntities())
            {
                OrdersTable or = ct.OrdersTable.First(t => t.OrderNumber == order.OrderNumber);

                //OrdersTable ord = new OrdersTable() { OrderNumber = order.OrderNumber };
                ct.Entry(or).State = System.Data.EntityState.Deleted;
                ct.SaveChanges();
            }
        }
Ejemplo n.º 5
0
 //gets processed orders between indicated dates min and max
 public List <OrderManagement.DAL.OrdersTable> GetProcessedOrders(DateTime min, DateTime max)
 {
     using (OrderManagementDBEntities ct = new OrderManagementDBEntities())
     {
         List <OrderManagement.DAL.OrdersTable> orders = new List <OrderManagement.DAL.OrdersTable>();
         foreach (var c in ct.OrdersTable.Where(c => c.OrderDate >= min && c.OrderDate <= max && c.OrderStatus == "Processed"))
         {
             OrderManagement.DAL.OrdersTable order = new OrderManagement.DAL.OrdersTable()
             {
                 OrderNumber     = c.OrderNumber,
                 OrderDate       = c.OrderDate,
                 DeliveryAddress = c.DeliveryAddress,
                 OrderStatus     = c.OrderStatus,
                 Total           = c.Total
             };
             orders.Add(order);
         }
         return(orders);
     }
 }
Ejemplo n.º 6
0
 //get orders from database by order status
 public List <OrderManagement.DAL.OrdersTable> GetOrders(String s)
 {
     using (OrderManagementDBEntities ct = new OrderManagementDBEntities())
     {
         List <OrderManagement.DAL.OrdersTable> orders = new List <OrderManagement.DAL.OrdersTable>();
         foreach (var c in ct.OrdersTable.Where(c => c.OrderStatus == s))
         {
             OrderManagement.DAL.OrdersTable order = new OrderManagement.DAL.OrdersTable()
             {
                 OrderNumber     = c.OrderNumber,
                 OrderDate       = c.OrderDate,
                 DeliveryAddress = c.DeliveryAddress,
                 OrderStatus     = c.OrderStatus,
                 Total           = c.Total
             };
             orders.Add(order);
         }
         return(orders);
     }
 }