Пример #1
0
 public AtletaCadastro(java.awt.Frame parent, boolean modal) {
   super(parent, modal);
   initComponents();
   this.setLocationRelativeTo(null);
   ac = new AtletaController();
   matriculaTxt.setText(ac.gerarMatricula());
 }
Пример #2
0
 private void imagemBtActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_imagemBtActionPerformed
   ac = new AtletaController();
   ac.escolherImagem("C");
 } // GEN-LAST:event_imagemBtActionPerformed
Пример #3
0
  private void btCadastrarActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btCadastrarActionPerformed
    int matricula;
    String rg,
        nome,
        dataNascimento,
        endereco,
        cidade,
        bairro,
        cep,
        sexo,
        ativo,
        observacao,
        telefone = null,
        foto;

    String msg = "";

    Validador.valida_textField(nomeTxt, 100, true, false, 1, "Nome");
    Validador.valida_textField(matriculaTxt, 7, true, true, 2, "Matricula");
    Validador.valida_textField(rgTxt, 10, true, true, 3, "RG");
    Validador.valida_textField(dataNascTxt, 10, true, false, 4, "Data Nasc.");
    Validador.valida_textField(enderecoTxt, 100, false, false, 5, "Endereço");
    Validador.valida_textField(cidadeTxt, 45, false, false, 6, "Cidade");
    Validador.valida_textField(bairroTxt, 45, false, false, 7, "Bairro");
    Validador.valida_textField(cepTxt, 10, false, false, 8, "cep");
    Validador.valida_textField(telefoneTxt, 10, false, false, 9, "Nome");
    String dataV = Validador.data(dataNascTxt.getText(), 10);

    if (Validador.erros == 0) {
      matricula = Integer.parseInt(matriculaTxt.getText());
      nome = nomeTxt.getText();
      rg = rgTxt.getText();
      dataNascimento = dataV;
      endereco = enderecoTxt.getText();
      cidade = cidadeTxt.getText();
      bairro = bairroTxt.getText();
      cep = cepTxt.getText();
      foto = file;
      telefone = telefoneTxt.getText();
      observacao = observacaoTxt.getText();

      if (sexoCombo.getSelectedIndex() == 0) {
        sexo = "M";
      } else {
        sexo = "F";
      }

      if (ativoCheck.isSelected()) {
        ativo = "S";
      } else {
        ativo = "N";
      }

      ac = new AtletaController();
      Atleta a =
          new Atleta(
              matricula,
              rg,
              nome,
              dataNascimento,
              endereco,
              cidade,
              bairro,
              cep,
              sexo,
              ativo,
              observacao,
              telefone,
              foto);
      if (ac.cadastrar(a) == true) {
        int dialogResultado =
            JOptionPane.showConfirmDialog(null, "Deseja incluir atividade ao atleta?");
        if (dialogResultado == JOptionPane.YES_OPTION) {

          this.setVisible(false);
          this.dispose();
          seDesejaColocarAtividade = "S";
          Atleta a2 = ac.retornaAtleta(a.getMatricula());
          ac.despacharAtvidadeForm(a2);

        } else {
          seDesejaColocarAtividade = "N";
          this.setVisible(false);
          this.dispose();

          nomeTxt.setText("");
          rgTxt.setText("");
          dataNascTxt.setText("");
          enderecoTxt.setText("");
          cidadeTxt.setText("");
          bairroTxt.setText("");
          cepTxt.setText("");
          telefoneTxt.setText("");
          observacaoTxt.setText("");

          AtletaCadastro atletaCadastro = new AtletaCadastro(null, true);
          atletaCadastro.setVisible(true);
        }
      }

    } else {
      for (int i = 0; i < 15; i++) { // Lista os erros
        for (int j = 0; j < 5; j++) {
          if (null != Validador.arrayErros[i][j]) {
            msg = msg + Validador.arrayErros[i][j];
          }
        }
      }

      JOptionPane.showMessageDialog(null, msg, "Erros", JOptionPane.ERROR_MESSAGE);
      Validador.erros = 0;
      for (int i = 0; i < 15; i++) { // Apaga os erros para não se acumular.
        for (int j = 0; j < 5; j++) {
          if (null != Validador.arrayErros[i][j]) {
            Validador.arrayErros[i][j] = "";
          }
        }
      }
    }
  } // GEN-LAST:event_btCadastrarActionPerformed