Example #1
0
        public static PedidoEN pedidoPorId(int id)
        {
            PedidoEN pedido = null;

            SqlConnection c = new SqlConnection(ConnectionString);

            c.Open();
            SqlCommand    com = new SqlCommand("Select * from Pedido WHERE pedidoId ='" + id + "'", c);
            SqlDataReader dr  = com.ExecuteReader();

            while (dr.Read())
            {
                pedido = new PedidoEN(Convert.ToInt32(dr["pedidoId"].ToString()), Convert.ToDateTime(dr["fecha"].ToString()), dr["direccion"].ToString(), Convert.ToInt32(dr["codigoPostal"].ToString()), dr["tipoPago"].ToString(), ClienteCAD.clientePorNif(dr["FK_NIF_idCliente"].ToString()));
            }
            dr.Close();
            c.Close();
            return(pedido);
        }
Example #2
0
        //Obterner un pedido a través del id
        public static PedidoEN pedidoPorId(int id)
        {
            PedidoEN pedido = null;

            SqlConnection c = new SqlConnection(ConnectionString);

            try
            {
                c.Open();
                SqlCommand    com = new SqlCommand("Select * from Pedido WHERE pedidoId like " + id, c);
                SqlDataReader dr  = com.ExecuteReader();
                while (dr.Read())
                {
                    pedido = new PedidoEN(Convert.ToInt32(dr["pedidoId"].ToString()), Convert.ToDateTime(dr["fecha"].ToString()), dr["direccion"].ToString(), Convert.ToInt32(dr["codigoPostal"].ToString()), dr["tipoPago"].ToString(), ClienteCAD.clientePorNif(dr["FK_NIF_idCliente"].ToString()));
                }
                dr.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("No conecta a la base de datos: " + ex);
            }
            c.Close();
            return(pedido);
        }
Example #3
0
        public static PedidoEN[] dameTodosPedidos()
        {
            List <PedidoEN> pedidos = new List <PedidoEN>();

            SqlConnection c = new SqlConnection(ConnectionString);

            c.Open();
            SqlCommand    com = new SqlCommand("Select * from Pedido", c);
            SqlDataReader dr  = com.ExecuteReader();

            while (dr.Read())
            {
                pedidos.Add(new PedidoEN(Convert.ToInt32(dr["pedidoId"].ToString()), Convert.ToDateTime(dr["fecha"].ToString()), dr["direccion"].ToString(), Convert.ToInt32(dr["codigoPostal"].ToString()), "Contra Reembolso", ClienteCAD.clientePorNif(dr["FK_NIF_idCliente"].ToString())));
            }
            dr.Close();
            c.Close();
            return(pedidos.ToArray());
        }
Example #4
0
        public static PedidoEN[] dameTodosPedidos()
        {
            List <PedidoEN> pedidos = new List <PedidoEN>();

            SqlConnection c = new SqlConnection(ConnectionString);

            try
            {
                c.Open();//abre la conexion
                SqlCommand    com = new SqlCommand("Select * from Pedido", c);
                SqlDataReader dr  = com.ExecuteReader();
                while (dr.Read())
                {
                    pedidos.Add(new PedidoEN(Convert.ToInt32(dr["pedidoId"].ToString()), Convert.ToDateTime(dr["fecha"].ToString()), dr["direccion"].ToString(), Convert.ToInt32(dr["codigoPostal"].ToString()), "Contra Reembolso", ClienteCAD.clientePorNif(dr["FK_NIF_idCliente"].ToString())));
                }
                dr.Close();//cerrar conexion
            }
            catch (Exception ex)
            {
                Console.WriteLine("No conecta a la base de datos: " + ex);
            }
            c.Close();//cerrar conexion
            return(pedidos.ToArray());
        }