Campeonato

8 respostas
M

Olá amigos, gostaria de uma ajuda para resolver um projeto, pois ainda sou iniciante.
Criei todos as interfaces que desejaria, mas estou com problema para faze-las funcionar, ou seja, o botão.
Gostaria que olhassem e me ajudassem para encontrar o erro, não sei se é problema de conexão ou se tem um erro no código.
Obrigada.

8 Respostas

rodriguesabner

Sua pergunta foi muito genérica, tente explicar melhor o problema

M

Meus botões de Inserir, Atualizar e Excluir, não funciona. Não sei mais o que fazer. Não sei se é problema de conexão com o meu bd.

rodriguesabner

Dá erro? O que acontece?

M

Ele só carrega. Mas, fala “BUILD SUCCESSFUL (total time: 12 seconds)”
Só que não insere nada na tabela.

rodriguesabner

Mostra o código referente ao botão de inserir

M
  • Perdão, é botão inserir.
    Código:
private void btIncluirActionPerformed(java.awt.event.ActionEvent evt) {                                          
       if(tfTime.getText().equals("")|| tfPosicao.getText().equals("")){
            Times t = new Times();
            //time novo quando inserir
            //inclui novo, jogar para dentro do obj e passamos para o DAO que assim será incluido
            t.setCod_time(Integer.parseInt(tfTime.getText()));
            t.setPosicao(Integer.parseInt(tfPosicao.getText()));
            t.setNome (tfNome.getText());
            t.setPontos(Integer.parseInt(tfPontos.getText()));
            t.setVitorias(Integer.parseInt(tfVitorias.getText()));
            t.setEmpates(Integer.parseInt(tfEmpates.getText()));
            t.setDerrotas(Integer.parseInt(tfDerrotas.getText()));
            t.setCartoesVermelhos(Integer.parseInt(tfCartoesVermelhos.getText()));
            t.setCartoesAmarelos(Integer.parseInt(tfCartoesAmarelos.getText()));
            t.setGolsFeitos(Integer.parseInt(tfGolsFeitos.getText()));
            t.setGolsTomados(Integer.parseInt(tfGolsTomados.getText()));
            t.setSaldoGols(Integer.parseInt(tfSaldoGols.getText()));
            t.setNumPartida(Integer.parseInt(tfPartidas.getText()));
            try {
                tm.inserir(t);
            } catch (SQLException ex) {
                Logger.getLogger(BrasileiraoView.class.getName()).log(Level.SEVERE, null, ex);
            }
            //JOptionPane.showMessagerDialog(null, "HÁ CAMPOS EM BRANCO" , "AVISO",JOptionPane.WARNING_MESSAGE);
        }else{
            Times t = new Times(); //ler o time correto do banco
            // altera
            t.setCod_time(Integer.parseInt(tfTime.getText()));
            t.setPosicao(Integer.parseInt(tfPosicao.getText()));
            t.setNome (tfNome.getText());
            t.setPontos(Integer.parseInt(tfPontos.getText()));
            t.setVitorias(Integer.parseInt(tfVitorias.getText()));
            t.setEmpates(Integer.parseInt(tfEmpates.getText()));
            t.setDerrotas(Integer.parseInt(tfDerrotas.getText()));
            t.setCartoesVermelhos(Integer.parseInt(tfCartoesVermelhos.getText()));
            t.setCartoesAmarelos(Integer.parseInt(tfCartoesAmarelos.getText()));
            t.setGolsFeitos(Integer.parseInt(tfGolsFeitos.getText()));
            t.setGolsTomados(Integer.parseInt(tfGolsTomados.getText()));
            t.setSaldoGols(Integer.parseInt(tfSaldoGols.getText()));
            t.setNumPartida(Integer.parseInt(tfPartidas.getText()));
            try {
                tm.alterar(t);
                //tm.incluir(t);
            } catch (SQLException ex) {
                Logger.getLogger(BrasileiraoView.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        try {
            tbClassificacao.setModel(new TableModelProjeto(new TimesDAO().posicaoTodos()));
        } catch (SQLException ex) {
            Logger.getLogger(BrasileiraoView.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            tbClassificacao.setModel( new TableModelProjeto(new TimesDAO().posicaoTodos()));
        } catch (SQLException ex) {
            Logger.getLogger(BrasileiraoView.class.getName()).log(Level.SEVERE, null, ex);
        }
        tfTime.setText("");
        tfPosicao.setText("");
        tfNome.setText("");
        tfPontos.setText("");
        tfVitorias.setText("");
        tfEmpates.setText("");
        tfDerrotas.setText("");
        tfCartoesVermelhos.setText("");
        tfCartoesAmarelos.setText("");
        tfGolsFeitos.setText("");
        tfGolsTomados.setText("");
        tfSaldoGols.setText("");
        tfPartidas.setText("");
        tfPesquisarTime.setText("");
        tfPesquisarPartida.setText("");
        
     btExcluir.setEnabled(false);  
    }
M

Botão Incluir**** estou com inserir na cabeça.

rodriguesabner

mostra esse código

Criado 24 de junho de 2020
Ultima resposta 24 de jun. de 2020
Respostas 8
Participantes 2