コード例 #1
0
 static FastFood()
 {
     random          = new Random();
     listaTerminados = new Stack <Pedido>();
     listaDelivery   = new Queue <Pedido>();
     try
     {
         listaClientes = DB.TraerClientes();
         FastFood.TraerPedidos();
     }
     catch (Exception e)
     {
         throw new Exception("Error al cargar los datos del negocio - " + e.Message, e);
     }
 }
コード例 #2
0
ファイル: DB.cs プロジェクト: MarianoSeif/2doParcialLabo2
        /// <summary>
        /// Arma una lista de pedidos con los datos traidos de la base de datos
        /// </summary>
        /// <returns></returns>
        public static Queue <Pedido> TraerPedidos()
        {
            Queue <Pedido> pedidos = new Queue <Pedido>();

            command.CommandText = "select * from pedidos where estado = @estado";
            command.Parameters.Clear();
            command.Parameters.Add(new SqlParameter("@estado", (int)EEstadoPedido.pendiente));

            try
            {
                if (sqlConn.State != System.Data.ConnectionState.Open)
                {
                    sqlConn.Open();
                }

                SqlDataReader dataReader = command.ExecuteReader();

                while (dataReader.Read())
                {
                    Pedido pedido = new Pedido(
                        int.Parse(dataReader["id"].ToString()),
                        FastFood.BuscarClientePorId(int.Parse(dataReader["idCliente"].ToString())),
                        (bool)dataReader["delivery"]
                        );
                    pedidos.Enqueue(pedido);
                }
                return(pedidos);
            }
            catch (Exception ex)
            {
                throw new DatabaseException(ex);
            }
            finally
            {
                if (sqlConn.State != System.Data.ConnectionState.Closed)
                {
                    sqlConn.Close();
                }
            }
        }