Exemplo n.º 1
0
        //修改故障状态:有待商议
        public int UptOrdersDisAgree(Orders o)
        {
            string str = $"Update Orders set Hitch=4 where OrdersID={o.OrdersID}";

            return(DBHelper.ExecuteNonQuery(str));
        }
Exemplo n.º 2
0
 public void EditOrders(Orders orders)
 {
     db.Entry(orders).State = EntityState.Modified;
     db.SaveChanges();
 }
Exemplo n.º 3
0
 public void RemoveOrders(Orders orders)
 {
     db.Orders.Remove(orders);
     db.SaveChanges();
 }
Exemplo n.º 4
0
        public Orders GetOrdersById(int?id)
        {
            Orders orders = db.Orders.Find(id);

            return(orders);
        }
Exemplo n.º 5
0
        //预定车辆
        public int AddOrders(Orders o)
        {
            string str = $"insert into Orders values('{o.Oid}',{o.uid},{o.CarInfoid},'{o.Useing}','{o.StartTime}','{o.EndTime}',{o.Driver},{o.Price},ZT,'Hitch') ";

            return(DBHelper.ExecuteNonQuery(str));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Вывод таблицы заказов
        /// </summary>
        /// <param name=""></param>
        public IEnumerable <Orders> ShowOrders()
        {
            var order = new List <Orders>();

            using (var connection = new SqlConnection(ConnectionString))
            {
                var command = new SqlCommand(
                    "SELECT TOP(30) total.OrderID, o.CustomerID, c.ContactName, o.OrderDate," +
                    " o.RequiredDate, o.ShippedDate, total.Total" +
                    " FROM Northwind.Customers as c INNER JOIN Northwind.Orders as o" +
                    " ON c.CustomerID = o.CustomerID INNER JOIN " +
                    "(SELECT o.OrderID, SUM((UnitPrice * (1 - Discount)) * Quantity) as Total" +
                    " FROM Northwind.Orders as o FULL OUTER JOIN Northwind.[Order Details] as od" +
                    " ON o.OrderID = od.OrderID GROUP BY o.OrderID) as total" +
                    " ON total.OrderID = o.OrderID ORDER BY o.OrderDate DESC", connection);

                connection.Open();
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    var o = new Orders();
                    o.OrderID = Convert.ToInt32(reader.GetValue(0));
                    if (reader.GetValue(1).ToString() != "")
                    {
                        o.CustomerID = Convert.ToString(reader.GetValue(1));
                    }
                    if (reader.GetValue(2).ToString() != "")
                    {
                        o.ContactName = Convert.ToString(reader.GetValue(2));
                    }
                    if (reader.GetValue(3).ToString() != "")
                    {
                        o.OrderDate = Convert.ToDateTime(reader.GetValue(3));
                    }

                    if ((reader.GetValue(5).ToString() == DateTime.MinValue.ToString()) ||
                        (reader.GetValue(5).ToString() == ""))
                    {
                        o.OrderStatus = OrderTypes.Underway;
                    }
                    else
                    {
                        o.OrderStatus = OrderTypes.Done;
                    }
                    if ((o.OrderDate == DateTime.MinValue) || (o.OrderDate.ToString() == ""))
                    {
                        o.OrderStatus = OrderTypes.NotShipped;
                    }
                    if (reader.GetValue(6).ToString() != "")
                    {
                        o.Total = Convert.ToDouble(reader.GetValue(6));
                    }

                    Console.WriteLine();
                    order.Add(o);
                }

                return(order);
            }
        }