Boa tarde.
Estou tentando fechar a primeira JFrame aberta em outra JFrame ao confirma em um JButton
Primeira tela de venda
private void jbPagamentoActionPerformed(java.awt.event.ActionEvent evt) {
// abrir a tela de pagamento
frmPagamentos telap = new frmPagamentos();
telap.jftDataVenda.setText(jftDataVendaPdv.getText());
telap.jtfCodVendedor.setText(jtfCodVendedor.getText());
telap.jtfVendedor.setText(jcbVendedor.getSelectedItem().toString());
telap.jtfCaixa.setText(jtfCaixaPdv.getText());
telap.jtfTotal.setText(jtfTotalGeral.getText());
telap.jtfTotalGeral.setText(jtfTotalGeral.getText());
telap.jtfVlFalta.setText(jtfTotalGeral.getText());
telap.jtfNumNota.setText(jtfNumNotaPdv.getText());
telap.jtfSerie.setText(jtfSeriePdv.getText());
telap.cliente = obj;
telap.funcionario = obju;
telap.carrinho = carrinho;
telap.setVisible(true);
}
segunda tela de pagamento
private void jbFinalizarVendaActionPerformed(java.awt.event.ActionEvent evt) {
// Envento de finalizar venda e pagamento
//criando objeto e pegando objeto forma de pagamento
FormasPagamentos f = new FormasPagamentos();
f = (FormasPagamentos) jcbFormaPagamento.getSelectedItem();
String forma = f.getFormaPagamento();
if (forma.equals("Dinheiro")) {
//criando o objeto vendas
Vendas objv = new Vendas();
//declarando variaveis
double pgDinheiro, totalPago, totalVenda, troco, desconto, totalGeral, vlFalta;
pgDinheiro = Double.parseDouble(jtfDinheiro.getText());
desconto = Double.parseDouble(jtfDesconto.getText());
totalVenda = Double.parseDouble(jtfTotal.getText());
totalGeral = Double.parseDouble(jtfTotalGeral.getText());
vlFalta = Double.parseDouble(jtfTotalGeral.getText());
//calcular pagamento
totalPago = pgDinheiro;
troco = totalGeral - pgDinheiro;
vlFalta = totalGeral - (totalPago + troco);
jtfVlFalta.setText(String.valueOf(vlFalta).format("%.2f", vlFalta).replace(",", "."));
jtfTroco.setText(String.valueOf(troco).format("%.2f", troco).replace(",", "."));
//pegar data da venda
try {
SimpleDateFormat dataBr = new SimpleDateFormat("dd/MM/yyyy");
String strFormatoBr = jftDataVenda.getText();
Date dt = dataBr.parse(strFormatoBr);
SimpleDateFormat dataEua = new SimpleDateFormat("yyyy-MM-dd");
String strFormatoEua = dataEua.format(dt);
objv.setDataVenda(dt);
} catch (ParseException ex) {
JOptionPane.showMessageDialog(null, "Erro ao Converter Um Texto Para Date " + ex);
}
objv.setCliente(cliente);
objv.setUsuario(funcionario);
objv.setNumNota(Integer.parseInt(jtfNumNota.getText()));
objv.setSerie(Integer.parseInt(jtfSerie.getText()));
objv.setUsuarioCaixa(jtfCaixa.getText());
objv.setFormaPagamento(f);
Maquinetas m = new Maquinetas();
m = (Maquinetas) jcbMaquineta.getSelectedItem();
objv.setMaquineta(m);
objv.setTotalVenda(Double.parseDouble(jtfTotalGeral.getText()));
VendasDao dao_v = new VendasDao();
switch(JOptionPane.showConfirmDialog(null, "Deseja Finalizar a Venda e o Pagamento?\n Nota:"
+objv.getNumNota(), "Confirmação", JOptionPane.YES_NO_OPTION , JOptionPane.QUESTION_MESSAGE )){
case 0:
dao_v.cadastrarVendas(objv);
dispose();
frmVendas telaV = new frmVendas();
telaV.dispose();
break;
case 1:
JOptionPane.showMessageDialog(null, "Nenhuma Venda Foi Feita.", "AVISO", JOptionPane.INFORMATION_MESSAGE);
break;
}
}
}