Exemple #1
0
  public void cambiaPeriodo() {
    if (this.periodo == null) {
      this.periodo = "1";
    }
    if (this.periodo.equals("1")) { // Si me estoy cambiando al periodo 1
      if (this.detalles == null || this.detalles.isEmpty()) { // y el periodo 2 esta vacío
        this.fechaTope = null;
        this.soloLectura = false; // puedo editar la fecha final
      } else { // Si no esta vacío el periodo 2
        // Date hoy = Utilerias.hoy();
        this.fechaTope = this.detalles.get(0).getFechaInicial(); // Fecha inicial periodo 2

        // if (Utilerias.addDays(hoy, 1).equals(this.fechaTope)) {
        //    this.soloLectura = true;    // No puedo editar la fecha final
        // } else {
        //    this.soloLectura = false;    // puedo editar fecha final. Tengo tope la fecha inicial
        // del periodo 2
        // }
        this.soloLectura = true; // No se puede editar ningun campo
      }
    } else if (this.detalles == null || this.detalles.isEmpty()) { // Si el periodo uno esta vacio
      this.soloLectura = false; // Se pueden editar todos los campos
      try {
        this.fechaTope = Utilerias.hoy(); // Como tope para fecha inicial es HOY
      } catch (Exception ex) {
        Logger.getLogger(FrmImpuestos.class.getName()).log(Level.SEVERE, null, ex);
      }
    } else {
      this.soloLectura = true; // No se puede editar la fecha inicial
      this.fechaTope = null;
      // this.setFechaTope(this.detalles.get(0).getFechaFinal());
    }
  }
Exemple #2
0
  public void crearPeriodo() {
    FacesMessage fMsg = new FacesMessage(FacesMessage.SEVERITY_WARN, "Aviso:", "");
    if (this.zona == null || this.zona.getIdZona() == 0) {
      fMsg.setDetail("Seleccione una zona !!");
    } else if (this.grupo == null || this.grupo.getIdGrupo() == 0) {
      fMsg.setDetail("Seleccione un grupo !!");
    } else if (this.periodo.equals("1")) {
      fMsg.setDetail("No se puede crear un período actual, debe ser uno siguiente !!");
    } else if (this.detalles.isEmpty()) {
      try {
        Date fechaInicial = Utilerias.addDays(fechaTope, 1);

        this.dao = new DAOImpuestosDetalle();
        this.detalles =
            this.dao.crearPeriodo(
                this.zona.getIdZona(),
                this.grupo.getIdGrupo(),
                this.periodo,
                new java.sql.Date(fechaInicial.getTime()));
        this.detalle = null;

        fMsg.setSeverity(FacesMessage.SEVERITY_INFO);
        fMsg.setDetail("La operación se realizó con éxito !!");
      } catch (SQLException ex) {
        fMsg.setSeverity(FacesMessage.SEVERITY_ERROR);
        fMsg.setDetail(ex.getErrorCode() + " " + ex.getMessage());
      } catch (NamingException ex) {
        fMsg.setSeverity(FacesMessage.SEVERITY_ERROR);
        fMsg.setDetail(ex.getMessage());
      }
    } else {
      fMsg.setDetail("Ya existe un período siguiente, modifique o elimine y velva a crear !!");
    }
    FacesContext.getCurrentInstance().addMessage(null, fMsg);
  }