Regalamiunsorriso/decompiled-libs/www/acxent-common-1.0.1/it/acxent/anag/Contatto.java

155 lines
4 KiB
Java

package it.acxent.anag;
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 Contatto extends DBAdapter implements Serializable {
private static final long serialVersionUID = 1489591448348L;
private long id_contatto;
private String descrizioneC;
private String nomeC;
private String telefonoC;
private String emailC;
private long id_clifor;
private Clifor clifor;
private long flgContattoDefault;
public Contatto(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public Contatto() {}
public void setId_contatto(long newId_contatto) {
this.id_contatto = newId_contatto;
}
public void setDescrizioneC(String newDescrizione) {
this.descrizioneC = newDescrizione;
}
public void setNomeC(String newNome) {
this.nomeC = newNome;
}
public void setTelefonoC(String newTelefono) {
this.telefonoC = newTelefono;
}
public void setEmailC(String newEmail) {
this.emailC = newEmail;
}
public void setId_clifor(long newId_clifor) {
this.id_clifor = newId_clifor;
setClifor(null);
}
public long getId_contatto() {
return this.id_contatto;
}
public String getDescrizioneC() {
return (this.descrizioneC == null) ? "" : this.descrizioneC.trim();
}
public String getNomeC() {
return (this.nomeC == null) ? "" : this.nomeC.trim();
}
public String getTelefonoC() {
return (this.telefonoC == null) ? "" : this.telefonoC.trim();
}
public String getEmailC() {
return (this.emailC == null) ? "" : this.emailC.trim();
}
public long getId_clifor() {
return this.id_clifor;
}
public void setClifor(Clifor newClifor) {
this.clifor = newClifor;
}
public Clifor getClifor() {
this.clifor = (Clifor)getSecondaryObject(this.clifor, Clifor.class, getId_clifor());
return this.clifor;
}
protected ResParm checkDeleteCascade() {
return new ResParm(true);
}
protected void deleteCascade() {}
public Vectumerator<Contatto> findByCR(ContattoCR CR, int pageNumber, int pageRows) {
String s_Sql_Find = "select A.* from CONTATTO 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;
}
}
public long getFlgContattoDefault() {
return this.flgContattoDefault;
}
public void setFlgContattoDefault(long flgContattoDefault) {
this.flgContattoDefault = flgContattoDefault;
}
public Vectumerator<Contatto> findByClifor(long l_id_clifor) {
String s_Sql_Find = "select A.* from CONTATTO AS A";
String s_Sql_Order = " order by A.descrizioneC\t";
WcString wc = new WcString();
wc.addWc("A.id_clifor=" + l_id_clifor);
try {
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
return findRows(stmt);
} catch (SQLException e) {
handleDebug(e);
return AB_EMPTY_VECTUMERATOR;
}
}
public ResParm save() {
if (getFlgContattoDefault() == 1L)
update("update CONTATTO SET flgContattoDefault=0 where id_clifor=" + getId_clifor());
return super.save();
}
}