public static Vector consulta(String nomeFantasia){
Vector lista = new Vector();
Statement stmt;
try {
stmt = GerenciadorBD.getConexao().createStatement();
ResultSet rs;
String sql = "Select * from contas_receber ";
if(nomeFantasia != null && nomeFantasia.length() == 0 ){
sql += "order by nome_fantasia";
rs = stmt.executeQuery(sql);
} else {
sql += "where nome_fantasia like '%" + nomeFantasia + "%' order by nome_fantasia";
}
rs = stmt.executeQuery(sql);
}
while (rs.next()){
ContasReceber cr = new ContasReceber();
cr.setDataVenda(rs.getDate("data_venda"));
cr.setIdContasReceber(rs.getInt("id_contas_receber"));
cr.setNomeFantasia(rs.getString("nome_fantasia"));
cr.setNumParcela(rs.getString("num_parcela"));
cr.setNumPedido(rs.getInt("num_pedido"));
cr.setTipoPagamento(rs.getString("tipo_pagamento"));
cr.setValorTotal(rs.getFloat("valor_total"));
lista.add(cr);
//Dados Boleto
Statement stm = GerenciadorBD.getConexao().createStatement();
ResultSet res = stm.executeQuery("select * from item_boleto where contas_receber_id_contas_receber = "+cr.getIdContasReceber());
ArrayList result = new ArrayList();
while(res.next()){
ItemBoleto ib = new ItemBoleto();
ib.setIdItemBoleto(res.getInt("id_item_boleto"));
ib.setNumBoleto(res.getInt("num_boleto"));
ib.setNumParcela(res.getString("num_parcela"));
ib.setObservacao(res.getString("observacao"));
ib.setTipoBoleto(res.getString("tipo_boleto"));
ib.setValorBoleto(res.getFloat("valor"));
ib.setVencimento(res.getDate("vencimento"));
ib.setBancoBoleto(res.getString("banco_boleto"));
result.add(ib);
}
cr.setListaBoleto(result);
//Dados Cheque
res = stm.executeQuery("select * from item_cheque where contas_receber_id_contas_receber = "+cr.getIdContasReceber());
ArrayList resultado = new ArrayList();
while(res.next()){
ItemCheque ic = new ItemCheque();
ic.setAgencia(res.getString("agencia"));
ic.setBanco(res.getString("banco"));
ic.setConta(res.getString("conta"));
ic.setIdItemCheque(res.getInt("id_item_cheque"));
ic.setNumCheque(res.getString("num_cheque"));
ic.setNumParcela(res.getString("num_parcela"));
ic.setObservacao(res.getString("observacao"));
ic.setValorCheque(res.getFloat("valor"));
ic.setVencimento(res.getDate("vencimento"));
resultado.add(ic);
}
cr.setListaCheque(resultado);
}
}
catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return lista;
}
if(e.getClickCount() == 2){
int linha = tabelaConsulta.getSelectedRow();
jTabbedPane.setSelectedIndex(1);
ContasReceber cr = (ContasReceber)registrosConsulta.get(linha);
int idContasReceber = cr.getIdContasReceber();
tfClienteBaixa.setText(cr.getNomeFantasia().toString());
tfNumPedidoBaixa.setText(String.valueOf(cr.getNumPedido()));
if(cr.getTipoPagamento().equalsIgnoreCase("B")){
ItemBoleto ib = (ItemBoleto)cr.getListaBoleto();
tfNumParcelaBaixa.setText(ib.getNumParcela().toString());
tfVencimentoBaixa.setText(new SimpleDateFormat("dd/MM/yyyy").format(ib.getVencimento().toString()));
tfValorPago.setText(String.valueOf(ib.getValorBoleto()));
}else{
ItemCheque ic = (ItemCheque)cr.getListaCheque();
//tfNumParcelaBaixa.setText(ic.getNumParcela().toString());
String aux = ic.getNumParcela();
tfNumParcelaBaixa.setText(aux);
tfVencimentoBaixa.setText(new SimpleDateFormat("dd/MM/yyyy").format(ic.getVencimento().toString()));
tfValorPago.setText(String.valueOf(ic.getValorCheque()));
}
}
ad "AWT-EventQueue-0" java.lang.ClassCastException: java.util.ArrayList
at br.com.sstintas.view.ContasReceberView$5.mouseClicked(ContasReceberView.java:1068)
at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
A linha que dá o erro é a seguinte:
ItemCheque ic = (ItemCheque)cr.getListaCheque();porque o dado selecionado era do tipo cheque.
Se alguém tiver uma sugestão do como posso fazer, agradeço!
Obrigada!