Regalamiunsorriso/decompiled-libs/www/acxent-common-1.0.1/it/acxent/art/StatoUsato.java

206 lines
5.3 KiB
Java

package it.acxent.art;
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 StatoUsato extends DBAdapter implements Serializable {
private static final String GARANZIA = "garanzia";
private static final String DESCRIZIONE_WWW = "descrizioneWww";
private static final long serialVersionUID = 1620541224365L;
public static final long LIVELLO_USATO_NUOVO = 0L;
public static final long LIVELLO_USATO_NUOVO_APERTO = 1L;
public static final long LIVELLO_USATO_DEMO = 2L;
public static final long LIVELLO_USATO_RICONDIZIONATO_VENDOR = 3L;
public static final long LIVELLO_USATO_RICONDIZIONATO_OTTIMO = 4L;
public static final long LIVELLO_USATO_RICONDIZIONATO_BUONO = 5L;
public static final long LIVELLO_USATO_RICONDIZIONATO_TESTATO = 6L;
private long flgLivello;
private String sigla;
private long id_statoUsato;
public StatoUsato(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public StatoUsato() {}
public static final String getLivello(long l_livello) {
switch ((int)l_livello) {
case 0:
return "Nuovo";
case 1:
return "Nuovo Aperto";
case 2:
return "Demo";
case 3:
return "Ricondizionato dal vendor";
case 4:
return "Ricondizionato Ottimo";
case 5:
return "Ricondizionato Buono";
case 6:
return "Ricondizionato Testato";
}
return "??";
}
public static final String getEbayCondition(long l_livello) {
switch ((int)l_livello) {
case 0:
return "NEW";
case 1:
return "NEW_OTHER";
case 2:
return "SELLER_REFURBISHED";
case 3:
return "CERTIFIED_REFURBISHED";
case 4:
return "SELLER_REFURBISHED";
case 5:
return "SELLER_REFURBISHED";
case 6:
return "SELLER_REFURBISHED";
}
return "??";
}
public String getLivello() {
return getLivello(getFlgLivello());
}
public String getEbayCondition() {
return getEbayCondition(getFlgLivello());
}
public void setId_statoUsato(long newId_statoUsato) {
this.id_statoUsato = newId_statoUsato;
}
public void setSigla(String newSigla) {
this.sigla = newSigla;
}
public long getId_statoUsato() {
return this.id_statoUsato;
}
public String getSigla() {
return (this.sigla == null) ? "" : this.sigla.trim();
}
protected ResParm checkDeleteCascade() {
return new ResParm(true);
}
protected void deleteCascade() {}
public Vectumerator<StatoUsato> findByCR(StatoUsatoCR CR, int pageNumber, int pageRows) {
String s_Sql_Find = "select A.* from STATO_USATO AS A";
String s_Sql_Order = " order by A.sigla";
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;
}
}
public String getGaranzia(String lang) {
if (lang.isEmpty())
lang = "it";
return getDescTxtLang("garanzia", lang);
}
public String getDescrizioneWww(String lang) {
if (lang.isEmpty())
lang = "it";
return getDescTxtLang("descrizioneWww", lang);
}
public boolean useDescLangTables() {
return true;
}
public String getDescrizioneCompleta() {
return getSigla() + " " + getSigla();
}
public void findBySigla(String l_sigla) {
String s_Sql_Find = "select A.* from STATO_USATO AS A";
String s_Sql_Order = "";
WcString wc = new WcString();
wc.addWc("A.sigla='" + l_sigla + "'");
try {
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
findFirstRecord(stmt);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
}
}
public long getFlgLivello() {
return this.flgLivello;
}
public boolean isNuovo() {
return (getFlgLivello() == 0L);
}
public boolean isUsato() {
return !isNuovo();
}
public void setFlgLivello(long flgNuovo) {
this.flgLivello = flgNuovo;
}
public Vectumerator<StatoUsato> findSoloUsato() {
String s_Sql_Find = "select A.* from STATO_USATO AS A";
String s_Sql_Order = " order by A.sigla";
WcString wc = new WcString();
wc.addWc("A.flgLivello>0");
try {
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
return findRows(stmt);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
return AB_EMPTY_VECTUMERATOR;
}
}
}