139 lines
4.1 KiB
Java
139 lines
4.1 KiB
Java
package it.acxent.art;
|
|
|
|
import it.acxent.db.ApplParmFull;
|
|
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.Date;
|
|
import java.sql.PreparedStatement;
|
|
import java.sql.SQLException;
|
|
|
|
public class Rivalutazione extends _ArtAdapter implements Serializable {
|
|
private long id_rivalutazione;
|
|
|
|
private Date dataRivalutazione;
|
|
|
|
private double imponibileRivalutazione;
|
|
|
|
private long id_articolo;
|
|
|
|
private Articolo articolo;
|
|
|
|
public Rivalutazione(ApplParmFull newApplParmFull) {
|
|
super(newApplParmFull);
|
|
}
|
|
|
|
public Rivalutazione() {}
|
|
|
|
public void setId_rivalutazione(long newId_rivalutazione) {
|
|
this.id_rivalutazione = newId_rivalutazione;
|
|
}
|
|
|
|
public void setDataRivalutazione(Date newDataRivalutazione) {
|
|
this.dataRivalutazione = newDataRivalutazione;
|
|
}
|
|
|
|
public void setImponibileRivalutazione(double newImponibile) {
|
|
this.imponibileRivalutazione = newImponibile;
|
|
}
|
|
|
|
public void setId_articolo(long newId_articolo) {
|
|
this.id_articolo = newId_articolo;
|
|
setArticolo(null);
|
|
}
|
|
|
|
public long getId_rivalutazione() {
|
|
return this.id_rivalutazione;
|
|
}
|
|
|
|
public Date getDataRivalutazione() {
|
|
return this.dataRivalutazione;
|
|
}
|
|
|
|
public double getImponibileRivalutazione() {
|
|
return this.imponibileRivalutazione;
|
|
}
|
|
|
|
public long getId_articolo() {
|
|
return this.id_articolo;
|
|
}
|
|
|
|
public void setArticolo(Articolo newArticolo) {
|
|
this.articolo = newArticolo;
|
|
}
|
|
|
|
public Articolo getArticolo() {
|
|
this.articolo = (Articolo)getSecondaryObject(this.articolo, Articolo.class,
|
|
getId_articolo());
|
|
return this.articolo;
|
|
}
|
|
|
|
protected void deleteCascade() {}
|
|
|
|
public Vectumerator findByCR(RivalutazioneCR CR, int pageNumber, int pageRows) {
|
|
String s_Sql_Find = "select A.* from RIVALUTAZIONE 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) {
|
|
handleDebug(e);
|
|
return AB_EMPTY_VECTUMERATOR;
|
|
}
|
|
}
|
|
|
|
public Vectumerator findById_articolo(long l_id_articolo, int pageNumber, int pageRows) {
|
|
String s_Sql_Find = "select A.* from RIVALUTAZIONE AS A";
|
|
String s_Sql_Order = " order by A.dataRivalutazione desc";
|
|
WcString wc = new WcString();
|
|
wc.addWc("id_articolo=" + l_id_articolo);
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find +
|
|
wc.toString());
|
|
return findRows(stmt, pageNumber, pageRows);
|
|
} catch (SQLException e) {
|
|
handleDebug(e);
|
|
return AB_EMPTY_VECTUMERATOR;
|
|
}
|
|
}
|
|
|
|
public ResParm save() {
|
|
ResParm rp = super.save();
|
|
if (rp.getStatus())
|
|
rp.append(getArticolo().aggiornaCostoRivalutazione(
|
|
getRivalutazioneUltimoById_articolo(getId_articolo())
|
|
.getImponibileRivalutazione()));
|
|
return rp;
|
|
}
|
|
|
|
public Rivalutazione getRivalutazioneUltimoById_articolo(long l_id_articolo) {
|
|
String s_Sql_Find = "select A.* from RIVALUTAZIONE AS A";
|
|
String s_Sql_Order = " order by A.dataRivalutazione desc";
|
|
WcString wc = new WcString();
|
|
wc.addWc("id_articolo=" + l_id_articolo);
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find +
|
|
wc.toString());
|
|
return (Rivalutazione)getFirstRecord(stmt);
|
|
} catch (SQLException e) {
|
|
handleDebug(e);
|
|
return new Rivalutazione(getApFull());
|
|
}
|
|
}
|
|
}
|