117 lines
3 KiB
Java
117 lines
3 KiB
Java
package it.acxent.cc;
|
|
|
|
import it.acxent.db.ApplParmFull;
|
|
import it.acxent.db.DBAdapter;
|
|
import it.acxent.db.ResParm;
|
|
import it.acxent.db.WcString;
|
|
import it.acxent.util.StringTokenizer;
|
|
import it.acxent.util.Vectumerator;
|
|
import java.io.Serializable;
|
|
import java.sql.PreparedStatement;
|
|
import java.sql.SQLException;
|
|
|
|
public class Abbonamento extends DBAdapter implements Serializable {
|
|
private static final long serialVersionUID = 1587713684972L;
|
|
|
|
private long id_abbonamento;
|
|
|
|
private long id_attivita;
|
|
|
|
private String dataInizio;
|
|
|
|
private String dataFine;
|
|
|
|
private double costoMensile;
|
|
|
|
private Attivita attivita;
|
|
|
|
public Abbonamento(ApplParmFull newApplParmFull) {
|
|
super(newApplParmFull);
|
|
}
|
|
|
|
public Abbonamento() {}
|
|
|
|
public void setId_abbonamento(long newId_abbonamento) {
|
|
this.id_abbonamento = newId_abbonamento;
|
|
}
|
|
|
|
public void setId_attivita(long newId_attivita) {
|
|
this.id_attivita = newId_attivita;
|
|
setAttivita(null);
|
|
}
|
|
|
|
public void setDataInizio(String newDataInizio) {
|
|
this.dataInizio = newDataInizio;
|
|
}
|
|
|
|
public void setDataFine(String newDataFine) {
|
|
this.dataFine = newDataFine;
|
|
}
|
|
|
|
public void setCostoMensile(double newCostoMensile) {
|
|
this.costoMensile = newCostoMensile;
|
|
}
|
|
|
|
public long getId_abbonamento() {
|
|
return this.id_abbonamento;
|
|
}
|
|
|
|
public long getId_attivita() {
|
|
return this.id_attivita;
|
|
}
|
|
|
|
public String getDataInizio() {
|
|
return (this.dataInizio == null) ? "" : this.dataInizio.trim();
|
|
}
|
|
|
|
public String getDataFine() {
|
|
return (this.dataFine == null) ? "" : this.dataFine.trim();
|
|
}
|
|
|
|
public double getCostoMensile() {
|
|
return this.costoMensile;
|
|
}
|
|
|
|
public void setAttivita(Attivita newAttivita) {
|
|
this.attivita = newAttivita;
|
|
}
|
|
|
|
public Attivita getAttivita() {
|
|
this.attivita = (Attivita)getSecondaryObject(this.attivita, Attivita.class,
|
|
|
|
getId_attivita());
|
|
return this.attivita;
|
|
}
|
|
|
|
protected ResParm checkDeleteCascade() {
|
|
return new ResParm(true);
|
|
}
|
|
|
|
protected void deleteCascade() {}
|
|
|
|
public Vectumerator<Abbonamento> findByCR(AbbonamentoCR CR, int pageNumber, int pageRows) {
|
|
String s_Sql_Find = "select A.* from ABBONAMENTO AS A";
|
|
String s_Sql_Order = "";
|
|
WcString wc = new WcString();
|
|
if (!CR.getSearchTxt().trim().isEmpty()) {
|
|
StringTokenizer st = new StringTokenizer(CR.getSearchTxt().trim(), " ");
|
|
StringBuffer txt = new StringBuffer("(");
|
|
while (st.hasMoreTokens()) {
|
|
String token = st.nextToken();
|
|
txt.append("(A.Cognome like '%" + token + "%' or A.Nome like '%" + token + "%')");
|
|
if (st.hasMoreTokens())
|
|
txt.append(" and ");
|
|
}
|
|
txt.append(")");
|
|
wc.addWc(txt.toString());
|
|
}
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
return findRows(stmt, pageNumber, pageRows);
|
|
} catch (SQLException e) {
|
|
removeCPConnection();
|
|
handleDebug(e);
|
|
return AB_EMPTY_VECTUMERATOR;
|
|
}
|
|
}
|
|
}
|