package it.acxent.contab; 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.PreparedStatement; import java.sql.SQLException; public class RigaDocumentoPM extends _ContabAdapter implements Serializable { private long id_rigaDocumento; private long id_rigaDocumentoPrelevata; private double quantitaPrelevata; private RigaDocumento rigaDocumento; private RigaDocumento rigaDocumentoPrelevata; public RigaDocumentoPM(ApplParmFull newApplParmFull) { super(newApplParmFull); } public RigaDocumentoPM() {} public void setId_rigaDocumento(long newId_rigaDocumento) { this.id_rigaDocumento = newId_rigaDocumento; setRigaDocumento(null); } public void setId_rigaDocumentoPrelevata(long newId_rigaDocumentoPrelevata) { this.id_rigaDocumentoPrelevata = newId_rigaDocumentoPrelevata; setRigaDocumentoPrelevata(null); } public void setQuantitaPrelevata(double newQuantitaPrelevata) { this.quantitaPrelevata = newQuantitaPrelevata; } public long getId_rigaDocumento() { return this.id_rigaDocumento; } public long getId_rigaDocumentoPrelevata() { return this.id_rigaDocumentoPrelevata; } public double getQuantitaPrelevata() { return this.quantitaPrelevata; } public void setRigaDocumento(RigaDocumento newRigaDocumento) { this.rigaDocumento = newRigaDocumento; } public RigaDocumento getRigaDocumento() { this.rigaDocumento = (RigaDocumento)getSecondaryObject(this.rigaDocumento, RigaDocumento.class, getId_rigaDocumento()); return this.rigaDocumento; } public void setRigaDocumentoPrelevata(RigaDocumento newRigaDocumentoPrelevata) { this.rigaDocumentoPrelevata = newRigaDocumentoPrelevata; } public RigaDocumento getRigaDocumentoPrelevata() { this.rigaDocumentoPrelevata = (RigaDocumento)getSecondaryObject(this.rigaDocumentoPrelevata, RigaDocumento.class, getId_rigaDocumentoPrelevata()); return this.rigaDocumentoPrelevata; } protected void deleteCascade() {} public Vectumerator findByCR(RigaDocumentoPCR CR, int pageNumber, int pageRows) { String s_Sql_Find = "select A.* from RIGA_DOCUMENTO_P_M 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 ResParm delete() { RigaDocumento rd = getRigaDocumento(); RigaDocumento rdP = getRigaDocumentoPrelevata(); ResParm rp = super.delete(); return rp; } public ResParm save() { ResParm rp = super.save(); return rp; } public Vectumerator findByDocumento(long l_id_documento, int pageNumber, int pageRows) { String s_Sql_Find = "select A.* from RIGA_DOCUMENTO_P_M AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("A.id_documento=" + l_id_documento); 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 void findByRigaDocumento(long l_id_rigaDocumento) { String s_Sql_Find = "select A.* from RIGA_DOCUMENTO_P_M AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("A.id_rigaDocumento=" + l_id_rigaDocumento); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public Vectumerator findByRigaDocumentoPrelevata(long l_id_rigaDocumentoPrelevata) { String s_Sql_Find = "select A.* from RIGA_DOCUMENTO_P_M AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("A.id_rigaDocumentoPrelevata=" + l_id_rigaDocumentoPrelevata); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); return findRows(stmt, 0, 0); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public static boolean isRigaPrenotazionePrelevata(RigaDocumento rd) { RigaDocumentoPM rdpm = new RigaDocumentoPM(rd.getApFull()); rdpm.findByRigaDocumentoPrelevata(rd.getId_rigaDocumento()); if (rdpm.getDBState() == 1) return true; return false; } }