package it.acxent.art; import it.acxent.anag.Nazione; import it.acxent.cart.Cart; 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 ArticoloNazione extends DBAdapter implements Serializable { private static final long serialVersionUID = 1622308001596L; private long id_articoloNazione; private String id_nazione; private long id_articolo; private long flgPreventivoWwwAN; private double costoSpedizioneAN; private Nazione nazione; private Articolo articolo; public ArticoloNazione(ApplParmFull newApplParmFull) { super(newApplParmFull); } public ArticoloNazione() {} public void setId_articoloNazione(long newId_articoloNazione) { this.id_articoloNazione = newId_articoloNazione; } public void setId_nazione(String newId_nazione) { this.id_nazione = newId_nazione; setNazione(null); } public void setId_articolo(long newId_articolo) { this.id_articolo = newId_articolo; setArticolo(null); } public void setFlgPreventivoWwwAN(long newFlgPreventivoWwwAN) { this.flgPreventivoWwwAN = newFlgPreventivoWwwAN; } public void setCostoSpedizioneAN(double newCostoSpedizioneAN) { this.costoSpedizioneAN = newCostoSpedizioneAN; } public long getId_articoloNazione() { return this.id_articoloNazione; } public String getId_nazione() { return (this.id_nazione == null) ? "" : this.id_nazione.trim(); } public long getId_articolo() { return this.id_articolo; } public long getFlgPreventivoWwwAN() { return this.flgPreventivoWwwAN; } public double getCostoSpedizioneAN() { return this.costoSpedizioneAN; } public void setNazione(Nazione newNazione) { this.nazione = newNazione; } public Nazione getNazione() { this.nazione = (Nazione)getSecondaryObject(this.nazione, Nazione.class, getId_nazione()); return this.nazione; } 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 ResParm checkDeleteCascade() { return new ResParm(true); } protected void deleteCascade() {} public Vectumerator findByCR(ArticoloNazioneCR CR, int pageNumber, int pageRows) { String s_Sql_Find = "select A.* from ARTICOLO_NAZIONE 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 Vectumerator findByArticolo(long l_id_articolo) { String s_Sql_Find = "select A.* from ARTICOLO_NAZIONE AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("A.id_articolo=" + l_id_articolo); 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 double getCostoSpedizioneANConIva() { return conIva(getCostoSpedizioneAN(), getParm(Cart.P_DELIVERY_IVA_ALIQUOTA).getNumeroDouble()); } public void findByArticoloNazione(long l_id_articolo, String l_id_nazione) { String s_Sql_Find = "select A.* from ARTICOLO_NAZIONE AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("A.id_articolo=" + l_id_articolo); wc.addWc("A.id_nazione='" + l_id_nazione + "'"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { removeCPConnection(); handleDebug(e); } } }