Exemplo n.º 1
0
  public void modificar(Object vale) throws Exception {
    if (!(vale instanceof Reclamacion)) {
      throw new Exception("Esta intentando modificar un objeto que no es un Reclamacion");
    }

    Reclamacion med = (Reclamacion) vale;

    // Modificamos el documento
    (new DocumentoDAO()).modificar(med);

    PreparedStatement ps = getConnection().prepareStatement(UPDATE_SQL);
    ps.setString(1, med.getDatosReales());
    ps.setInt(2, med.getId());

    ps.execute();
  }
Exemplo n.º 2
0
  @Override
  public void eliminar(Object object) throws Exception {
    if (!(object instanceof Reclamacion)) {
      throw new Exception("Esta intentando eliminar un objeto que no es un Reclamacion");
    }

    Reclamacion med = (Reclamacion) object;

    PreparedStatement ps = getConnection().prepareStatement(DELETE_SQL);

    ps.setInt(1, med.getId());

    ps.execute();
    // Eliminamos el documento
    (new DocumentoDAO()).eliminar(med);
  }
Exemplo n.º 3
0
  @Override
  public void salvar(Object object) throws Exception {
    if (!(object instanceof Reclamacion)) {
      throw new Exception("Esta intentando almacenar un objeto que no es un Reclamacion");
    }

    Reclamacion med = (Reclamacion) object;
    // Insertamos el documento
    (new DocumentoDAO()).salvar(med);
    // cogemos el id
    int id = (new DocumentoDAO()).obtenerUltimoVale().getId();

    PreparedStatement ps = getConnection().prepareStatement(INSERT_SQL);

    ps.setInt(1, id);
    ps.setString(2, med.getDatosReales());

    ps.execute();
  }
Exemplo n.º 4
0
  @Override
  public Reclamacion obtenerPorID(Object object) throws Exception {
    if (!(object instanceof Reclamacion)) {
      throw new Exception("Esta intentando obtener un Vale con un objeto invalido");
    }

    Reclamacion m = new Reclamacion();
    Documento d = (new DocumentoDAO()).obtenerPorID(m);

    PreparedStatement ps = getConnection().prepareStatement(SELECT_BY_ID_SQL);
    ps.setInt(1, ((Reclamacion) object).getId());

    ResultSet rs = ps.executeQuery();

    while (rs.next()) {
      m.setDatosReales(rs.getString(2));
    }

    m.setDatosFactura(d.getDatosFactura());
    m.setFecha(d.getFecha());
    m.setTrabajadorUsuario(d.getTrabajadorUsuario());
    m.setId(d.getId());

    return m;
  }