Example #1
0
  private boolean verificarCampos() {

    Validacao.voltarCampoAoNormal(this.txtNome);
    Validacao.voltarCampoAoNormal(this.txtEmail);
    Validacao.voltarCampoAoNormal(this.txtTelefone);
    Validacao.voltarCampoAoNormal(this.txtCelular);
    Validacao.voltarCampoAoNormal(this.txtCep);

    if (Validacao.valorVazio(this.txtNome.getText())) {
      Alerta.mostrarMensagemDeEsquecimentoDePreenchimentoDeCampo();
      Validacao.realcarCampo(this.txtNome);
      return false;
    } else if (Validacao.validarEmail(this.txtEmail.getText()) == false) {
      Alerta.mostrarMensagemErro("O e-mail digitado é inválido!", "E-mail Inválido");
      Validacao.realcarCampo(this.txtEmail);
      return false;
    } else if (this.txtTelefone.getText().length() != 10
        && Validacao.valorVazio(this.txtTelefone.getText()) == false) {
      Alerta.mostrarMensagemErro(
          "O Telefone não foi preenchido completamente!", "Telefone Incompleto");
      Validacao.realcarCampo(this.txtTelefone);
      return false;
    } else if (this.txtCelular.getText().length() != 11
        && Validacao.valorVazio(this.txtTelefone.getText()) == false) {
      Alerta.mostrarMensagemErro(
          "O Celular não foi preenchido completamente!", "Celular Incompleto");
      Validacao.realcarCampo(this.txtCelular);
      return false;
    } else if (this.txtCep.getText().length() != 8
        && Validacao.valorVazio(this.txtCep.getText()) == false) {
      Alerta.mostrarMensagemErro("O CEP não foi preenchido completamente", "CEP Incompleto");
      Validacao.realcarCampo(this.txtCep);
      return false;
    }

    boolean dataPreenchidaPelaMetade = false;

    try {
      this.getDataNascimentoPreenchida();
    } catch (Exception e) {
      dataPreenchidaPelaMetade = true;
    }

    if (dataPreenchidaPelaMetade) {
      Alerta.mostrarMensagemErro(
          "A data de nascimento não foi preenchida completamente!",
          "Data de Nascimento Incompleta");
      if (this.cmbDia.getSelectionModel().isEmpty()) {
        cmbDia.setStyle("-fx-border-color:red; -fx-border-width: 2px;");
      } else if (this.cmbMes.getSelectionModel().isEmpty()) {
        cmbMes.setStyle("-fx-border-color:red; -fx-border-width: 2px;");
      } else if (this.cmbAno.getSelectionModel().isEmpty()) {
        cmbAno.setStyle("-fx-border-color:red; -fx-border-width: 2px;");
      }
      return false;
    } else {
      return true;
    }
  }