Beispiel #1
0
        public List <Compra> ListaCompra()
        {
            List <Compra> Lista = new List <Compra>();

            this.Conect();
            sql = "SELECT id, data, vlrtotal, desconto, qtditens, idfornecedor FROM tbcompra order by id;";
            cmd = new NpgsqlCommand(sql, con);
            rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                Compra            c           = new Compra();
                CItemCompra       i           = new CItemCompra();
                List <ItemCompra> itensCompra = new List <ItemCompra>();
                c.setID(rdr.GetInt32(0));
                c.setData(rdr.GetString(1));
                c.setVlrTotal(rdr.GetDouble(2));
                c.setDesconto(rdr.GetDouble(3));
                c.setQtdItens(rdr.GetInt32(4));
                c.setIdFornecedor(rdr.GetInt32(5));
                itensCompra = i.ListarItemCompra(c.getId());
                c.setItensCompra(itensCompra);
                Lista.Add(c);
            }
            this.Desconect();
            return(Lista);
        }