Quantcast
Channel: Programação - GUJ
Viewing all articles
Browse latest Browse all 33093

Criar Relatorio em Java no netbeans sem usar BD

$
0
0

@Fernanda2015 escreveu:

Olá Galera!

Alguem poderia me ajudar com um trabalhinho.

Estou tentando montar um relatorio e não consigo puxar os dados que preciso das tabelas de cliente, produto e venda, não estou usando nenhum tipo de banco está tudo em tabelinhas no netbeans. Preciso puxar o relatorio onde o usuario informa um periodo (Data inicio e fim) e ele me traz as vendas daquele periodo.
Veja Imagem abaixo.

Ate o momento estou com o seguinte codigo.
//Botão emitir relatorio
private void ButtonRelatorioActionPerformed(java.awt.event.ActionEvent evt) {

    try {
        SimpleDateFormat sdf= new SimpleDateFormat("dd/MM/yyyy");
        sdf.setLenient(false);            
        Date data = sdf.parse(txtInicio.getText());
        Relatorio.preencherTabela(listVendas, jTableRelatorioVendas, data);
        
    } catch (ParseException ex) {
        Logger.getLogger(FormRelatorioVendas.class.getName()).log(Level.SEVERE, null, ex);
    }
  

}

// FormRelatorioVendas
public class Relatorio {

public static final List<AtributosVendas> listVendas = new ArrayList<AtributosVendas>();

public static void preencherTabela(List<AtributosVendas> listVendas, JTable tabelaDadosVenda, Date dataIncial) {
    DecimalFormat df = new DecimalFormat("0.00"); 
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    sdf.setLenient(false);

    DefaultTableModel model = (DefaultTableModel) tabelaDadosVenda.getModel();
    model.setRowCount(0);
    boolean mensagem = true;
    int size = listVendas.size();
    
    if (listVendas.size() <= 0 || listVendas == null) {
        JOptionPane.showMessageDialog(null, "A lista está vazia.", "LISTA VAZIA", JOptionPane.ERROR_MESSAGE);
    } else {
        for (AtributosVendas venda : listVendas) {

            Object[] row = new Object[8];
            Date dataObjeto = venda.getData();
            String dtOb = sdf.format(dataObjeto);
            String  dtIni = sdf.format(dataIncial);
            System.out.println("DATA OBJETO: "+dtOb);
            System.out.println("DATA QUE VEM PARAMENTRO: "  + dtIni);
            if ( dtIni.equalsIgnoreCase(dtOb)) { 
                
                row[0] = venda.getNome();
                row[1] = venda.getRG();
                row[2] = venda.getCPF();
                row[3] = venda.getCodigo();
                row[4] = venda.getQuantidade();
                row[5] = venda.getDesconto();
                row[6] = df.format(venda.getTotal());
                row[7] = sdf.format(venda.getData());
                model.addRow(row);
                break;

            }

Mensagens: 1

Participantes: 1

Ler tópico completo


Viewing all articles
Browse latest Browse all 33093


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>