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

460 lines
12 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 Banca extends DBAdapter implements Serializable {
private static final long serialVersionUID = 1423651664351L;
private long id_banca;
private long id_comune;
private String descrizione;
private String iban;
private String indirizzo;
private String telefono;
private String email;
private String abi;
private String capZona;
private double importoRiba;
private Comune comune;
private String codiceAlt;
private String agenzia;
private String cab;
private String bic;
private String numeroConto;
private long ordine;
private long flgDefaultBonifico;
private long flgVisualizzaPresentazione;
public Banca(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public Banca() {}
public void setId_banca(long newId_banca) {
this.id_banca = newId_banca;
}
public void setId_comune(long newId_comune) {
this.id_comune = newId_comune;
setComune(null);
}
public void setDescrizione(String newDescrizione) {
this.descrizione = newDescrizione;
}
public void setIban(String newIban) {
this.iban = newIban;
}
public void setIndirizzo(String newIndirizzo) {
this.indirizzo = newIndirizzo;
}
public void setTelefono(String newTelefono) {
this.telefono = newTelefono;
}
public void setEmail(String newEmail) {
this.email = newEmail;
}
public void setBic(String newBic) {
this.bic = newBic;
}
public void setCapZona(String newCapZona) {
this.capZona = newCapZona;
}
public long getId_banca() {
return this.id_banca;
}
public long getId_comune() {
return this.id_comune;
}
public String getDescrizione() {
return (this.descrizione == null) ? "" : this.descrizione.trim();
}
public String getIban() {
return (this.iban == null) ? "" : this.iban.trim();
}
public String getIndirizzo() {
return (this.indirizzo == null) ? "" : this.indirizzo.trim();
}
public String getTelefono() {
return (this.telefono == null) ? "" : this.telefono.trim();
}
public String getEmail() {
return (this.email == null) ? "" : this.email.trim();
}
public String getBic() {
return (this.bic == null) ? "" : this.bic.trim();
}
public String getCapZona() {
return (this.capZona == null) ? "" : this.capZona.trim();
}
public void setComune(Comune newComune) {
this.comune = newComune;
}
public Comune getComune() {
this.comune = (Comune)getSecondaryObject(this.comune, Comune.class, getId_comune());
return this.comune;
}
protected ResParm checkDeleteCascade() {
return new ResParm(true);
}
protected void deleteCascade() {}
public Vectumerator<Banca> findByCR(BancaCR CR, int pageNumber, int pageRows) {
String s_Sql_Find = "select A.* from BANCA 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 String getCodiceAlt() {
return (this.codiceAlt == null) ? "" : this.codiceAlt.trim();
}
public void setCodiceAlt(String codieAlt) {
this.codiceAlt = codieAlt;
}
public String getAgenzia() {
return (this.agenzia == null) ? "" : this.agenzia.trim();
}
public void setAgenzia(String agenzia) {
this.agenzia = agenzia;
}
public String getAbi() {
if (this.abi == null &&
getIban().length() >= 11)
this.abi = getIban().substring(6, 11);
return (this.abi == null) ? "" : this.abi.trim();
}
public void setAbi(String abi) {
this.abi = abi;
}
public String getCab() {
if (this.cab == null &&
getIban().length() >= 15)
this.cab = getIban().substring(11, 15);
return (this.cab == null) ? "" : this.cab.trim();
}
public void setCab(String cab) {
this.cab = cab;
}
public String getNumeroConto() {
return (this.numeroConto == null) ? "" : this.numeroConto.trim();
}
public void setNumeroConto(String numeroConto) {
this.numeroConto = numeroConto;
}
public void findByCodiceAlt(String codiceAlt) {
String s_Sql_Find = "select A.* from BANCA AS A";
String s_Sql_Order = "";
WcString wc = new WcString();
wc.addWc("A.codiceAlt='" + codiceAlt + "'");
try {
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
findFirstRecord(stmt);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
}
}
public String getConto() {
if (getIban().length() > 16)
return getIban().substring(16, getIban().length());
return "";
}
public long getOrdine() {
return this.ordine;
}
public void setOrdine(long ordine) {
this.ordine = ordine;
}
public Vectumerator<Banca> findByOrdine() {
String s_Sql_Find = "select A.* from BANCA AS A";
String s_Sql_Order = " ORDER BY ordine";
WcString wc = new WcString();
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;
}
}
public ResParm settaOrdineMeno() {
ResParm rp = new ResParm(true);
Banca banca = new Banca(getApFull());
banca.findPrecedenteByOrdine(getOrdine());
if (banca.getDBState() == 1) {
long l_ordine = banca.getOrdine();
banca.setOrdine(getOrdine());
rp = banca.save();
setOrdine(l_ordine);
rp.append(save());
}
return rp;
}
public ResParm settaOrdinePiu() {
ResParm rp = new ResParm(true);
Banca banca = new Banca(getApFull());
banca.findSuccessivoByOrdine(getOrdine());
if (banca.getDBState() == 1) {
long l_ordine = banca.getOrdine();
banca.setOrdine(getOrdine());
rp = banca.save();
setOrdine(l_ordine);
rp.append(save());
}
return rp;
}
public double getImportoRiba() {
return this.importoRiba;
}
public void setImportoRiba(double importoRiba) {
this.importoRiba = importoRiba;
}
public void findPrecedenteByOrdine(long l_ordine) {
String s_Sql_Find = "select A.* from BANCA AS A";
String s_Sql_Order = " ORDER BY ordine desc";
WcString wc = new WcString();
wc.addWc("A.ordine<" + l_ordine);
try {
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
findFirstRecord(stmt);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
}
}
public void findSuccessivoByOrdine(long l_ordine) {
String s_Sql_Find = "select A.* from BANCA AS A";
String s_Sql_Order = " ORDER BY ordine asc";
WcString wc = new WcString();
wc.addWc("A.ordine>" + l_ordine);
try {
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
findFirstRecord(stmt);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
}
}
public long getFlgDefaultBonifico() {
return this.flgDefaultBonifico;
}
public void setFlgDefaultBonifico(long flgDefaultBonifico) {
this.flgDefaultBonifico = flgDefaultBonifico;
}
public ResParm save() {
if (getFlgDefaultBonifico() == 1L);
return super.save();
}
public void findBancaDefault() {
String s_Sql_Find = "select A.* from BANCA AS A";
String s_Sql_Order = " ORDER BY ordine";
WcString wc = new WcString();
wc.addWc("A.flgDefaultBonifico=1");
try {
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
findFirstRecord(stmt);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
}
}
protected ResParm resetDefaultBancaBonifico() {
String sql = "update BANCA set flgDefaultBonifico = null";
return update(sql);
}
public long getFlgVisualizzaPresentazione() {
return this.flgVisualizzaPresentazione;
}
public void setFlgVisualizzaPresentazione(long flgVisualizzaPresentazione) {
this.flgVisualizzaPresentazione = flgVisualizzaPresentazione;
}
public ResParm resetPresentazioneRibaAuto() {
String sql = "update BANCA set flgVisualizzaPresentazione = 0,ordine = 0";
return update(sql);
}
public Vectumerator<Banca> findByOrdineVisibili() {
String s_Sql_Find = "select A.* from BANCA AS A";
String s_Sql_Order = " ORDER BY ordine";
WcString wc = new WcString();
wc.addWc("A.flgVisualizzaPresentazione=1");
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;
}
}
public Vectumerator<Banca> findNonVisibili() {
String s_Sql_Find = "select A.* from BANCA AS A";
String s_Sql_Order = " ORDER BY A.descrizione";
WcString wc = new WcString();
wc.addWc("(A.flgVisualizzaPresentazione is null or A.flgVisualizzaPresentazione =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;
}
}
public ResParm addBancaAPresentazioneRibaAuto() {
if (getId_banca() > 0L) {
setFlgVisualizzaPresentazione(1L);
setOrdine(getMaxOrdine() + 1L);
return save();
}
return new ResParm(false, "ERRORE! Non puoi aggiungere una banca nulla alla presentazione riba!");
}
public ResParm rimuoviBancaAPresentazioneRibaAuto() {
if (getId_banca() > 0L) {
setFlgVisualizzaPresentazione(0L);
setOrdine(0L);
return save();
}
return new ResParm(false, "ERRORE! Non puoi togliere una banca nulla alla presentazione riba!");
}
public long getMaxOrdine() {
String s_Sql_Find = "select max(A.ordine) as _max from BANCA AS A";
String s_Sql_Order = " ORDER BY ordine asc";
WcString wc = new WcString();
try {
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
return (long)getMax(stmt);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
return -1L;
}
}
public String getDescrizioneScript() {
return DBAdapter.prepareScriptString(getDescrizione());
}
public String getBancheDefaultBonificoDesc() {
StringBuilder sb = new StringBuilder();
String s_Sql_Find = "select A.* from BANCA AS A";
String s_Sql_Order = " ORDER BY ordine";
WcString wc = new WcString();
wc.addWc("A.flgDefaultBonifico=1");
try {
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
Vectumerator<Banca> vec = findRows(stmt);
while (vec.hasMoreElements()) {
Banca row = (Banca)vec.nextElement();
sb.append(row.getDescrizione());
sb.append(" ");
sb.append(row.getIban());
if (vec.hasMoreElements())
sb.append(" - ");
}
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
}
return sb.toString();
}
}