199 lines
6.7 KiB
Java
199 lines
6.7 KiB
Java
|
|
package it.acxent.contab;
|
||
|
|
|
||
|
|
import it.acxent.db.ApplParmFull;
|
||
|
|
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 DocPrel extends _ContabAdapter implements Serializable {
|
||
|
|
public static final long TIPO_GENERAZIONE_RIGA_0 = 0L;
|
||
|
|
|
||
|
|
public static final long TIPO_GENERAZIONE_DOC_1 = 1L;
|
||
|
|
|
||
|
|
public static final long TIPO_GENERAZIONE_TIPO_ART_2 = 2L;
|
||
|
|
|
||
|
|
private long id_docPrel;
|
||
|
|
|
||
|
|
private long id_tipoDocumentoPrel;
|
||
|
|
|
||
|
|
private long id_tipoDocumento;
|
||
|
|
|
||
|
|
private TipoDocumento tipoDocumentoPrel;
|
||
|
|
|
||
|
|
private TipoDocumento tipoDocumento;
|
||
|
|
|
||
|
|
private long flgTipoGenerazione;
|
||
|
|
|
||
|
|
public DocPrel(ApplParmFull newApplParmFull) {
|
||
|
|
super(newApplParmFull);
|
||
|
|
}
|
||
|
|
|
||
|
|
public DocPrel() {}
|
||
|
|
|
||
|
|
public static final String getTipoGenerazione(long l_flgTipoGenerazione) {
|
||
|
|
if (l_flgTipoGenerazione == 0L)
|
||
|
|
return "Riga Riga";
|
||
|
|
if (l_flgTipoGenerazione == 1L)
|
||
|
|
return "Per documento";
|
||
|
|
if (l_flgTipoGenerazione == 2L)
|
||
|
|
return "Per tipo articolo/riga";
|
||
|
|
return "";
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getTipoGenerazione() {
|
||
|
|
return getTipoGenerazione(getFlgTipoGenerazione());
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setId_docPrel(long newId_docPrel) {
|
||
|
|
this.id_docPrel = newId_docPrel;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setId_tipoDocumentoPrel(long newId_tipoDocumentoPrel) {
|
||
|
|
this.id_tipoDocumentoPrel = newId_tipoDocumentoPrel;
|
||
|
|
setTipoDocumentoPrel(null);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setId_tipoDocumento(long newId_tipoDocumento) {
|
||
|
|
this.id_tipoDocumento = newId_tipoDocumento;
|
||
|
|
setTipoDocumento(null);
|
||
|
|
}
|
||
|
|
|
||
|
|
public long getId_docPrel() {
|
||
|
|
return this.id_docPrel;
|
||
|
|
}
|
||
|
|
|
||
|
|
public long getId_tipoDocumentoPrel() {
|
||
|
|
return this.id_tipoDocumentoPrel;
|
||
|
|
}
|
||
|
|
|
||
|
|
public long getId_tipoDocumento() {
|
||
|
|
return this.id_tipoDocumento;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setTipoDocumentoPrel(TipoDocumento newTipoDocumentoPrel) {
|
||
|
|
this.tipoDocumentoPrel = newTipoDocumentoPrel;
|
||
|
|
}
|
||
|
|
|
||
|
|
public TipoDocumento getTipoDocumentoPrel() {
|
||
|
|
this.tipoDocumentoPrel = (TipoDocumento)getSecondaryObject(this.tipoDocumentoPrel, TipoDocumento.class, getId_tipoDocumentoPrel());
|
||
|
|
return this.tipoDocumentoPrel;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setTipoDocumento(TipoDocumento newTipoDocumento) {
|
||
|
|
this.tipoDocumento = newTipoDocumento;
|
||
|
|
}
|
||
|
|
|
||
|
|
public TipoDocumento getTipoDocumento() {
|
||
|
|
this.tipoDocumento = (TipoDocumento)getSecondaryObject(this.tipoDocumento, TipoDocumento.class, getId_tipoDocumento());
|
||
|
|
return this.tipoDocumento;
|
||
|
|
}
|
||
|
|
|
||
|
|
protected void deleteCascade() {}
|
||
|
|
|
||
|
|
public Vectumerator findByCR(DocPrelCR CR, int pageNumber, int pageRows) {
|
||
|
|
String s_Sql_Find = "select A.* from DOC_PREL 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 void findByTipoDocumentoTipoDocumentoPrel(long l_id_tipoDocumento, long l_id_tipoDocumentoPrel) {
|
||
|
|
String s_Sql_Find = "select A.* from DOC_PREL AS A";
|
||
|
|
String s_Sql_order = "";
|
||
|
|
WcString wc = new WcString();
|
||
|
|
wc.addWc("A.id_tipoDocumento=" + l_id_tipoDocumento);
|
||
|
|
wc.addWc("A.id_tipoDocumentoPrel=" + l_id_tipoDocumentoPrel);
|
||
|
|
try {
|
||
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + String.valueOf(wc));
|
||
|
|
findFirstRecord(stmt);
|
||
|
|
} catch (Exception e) {
|
||
|
|
handleDebug(e, 0);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public Vectumerator<DocPrel> findPrelevabiliByTipoDocumentoGen(long l_id_tipoDocumento, long l_tipoRicerca, int pageNumber, int pageRows) {
|
||
|
|
String s_Sql_Find = "select A.* from DOC_PREL AS A,TIPO_DOCUMENTO AS B";
|
||
|
|
String s_Sql_order = " order by B.descrizione";
|
||
|
|
WcString wc = new WcString();
|
||
|
|
wc.addWc("A.id_tipoDocumentoPrel=B.id_tipoDocumento");
|
||
|
|
wc.addWc("A.id_tipoDocumento=" + l_id_tipoDocumento);
|
||
|
|
if (l_tipoRicerca == 1L) {
|
||
|
|
wc.addWc("(B.flgUsato is null or B.flgUsato=0)");
|
||
|
|
} else if (l_tipoRicerca == 2L) {
|
||
|
|
wc.addWc("B.flgUsato=1");
|
||
|
|
}
|
||
|
|
try {
|
||
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + String.valueOf(wc));
|
||
|
|
return findRows(stmt, pageNumber, pageRows);
|
||
|
|
} catch (Exception e) {
|
||
|
|
handleDebug(e, 0);
|
||
|
|
return AB_EMPTY_VECTUMERATOR;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public Vectumerator<DocPrel> findGenerabiliByTipoDocumentoPrel(long l_id_tipoDocumentoPrel, long l_flgUsato, long l_id_tipologiaDocumento, int pageNumber, int pageRows) {
|
||
|
|
String s_Sql_Find = "select A.* from DOC_PREL AS A,TIPO_DOCUMENTO AS B";
|
||
|
|
String s_Sql_order = " order by B.ordineNuovoDocumento, B.descrizione";
|
||
|
|
WcString wc = new WcString();
|
||
|
|
wc.addWc("A.id_tipoDocumento=B.id_tipoDocumento");
|
||
|
|
wc.addWc("A.id_tipoDocumentoPrel=" + l_id_tipoDocumentoPrel);
|
||
|
|
if (l_flgUsato == 1L) {
|
||
|
|
wc.addWc("(B.flgUsato is null or B.flgUsato=0)");
|
||
|
|
} else if (l_flgUsato == 2L) {
|
||
|
|
wc.addWc("B.flgUsato=1");
|
||
|
|
}
|
||
|
|
if (l_id_tipologiaDocumento > 0L)
|
||
|
|
wc.addWc("B.id_tipologiaDocumento=" + l_id_tipologiaDocumento);
|
||
|
|
try {
|
||
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + String.valueOf(wc));
|
||
|
|
return findRows(stmt, pageNumber, pageRows);
|
||
|
|
} catch (Exception e) {
|
||
|
|
handleDebug(e, 0);
|
||
|
|
return AB_EMPTY_VECTUMERATOR;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void findByTipoDocumentoGenPrel(long l_id_tipoDocumentoGen, long l_id_tipoDocumentoPrel) {
|
||
|
|
String s_Sql_Find = "select A.* from DOC_PREL AS A,TIPO_DOCUMENTO AS B";
|
||
|
|
String s_Sql_order = " order by B.descrizione";
|
||
|
|
WcString wc = new WcString();
|
||
|
|
wc.addWc("A.id_tipoDocumentoPrel=B.id_tipoDocumento");
|
||
|
|
wc.addWc("A.id_tipoDocumentoPrel=" + l_id_tipoDocumentoPrel);
|
||
|
|
wc.addWc("A.id_tipoDocumento=" + l_id_tipoDocumentoGen);
|
||
|
|
try {
|
||
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + String.valueOf(wc));
|
||
|
|
findFirstRecord(stmt);
|
||
|
|
} catch (Exception e) {
|
||
|
|
handleDebug(e, 0);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public long getFlgTipoGenerazione() {
|
||
|
|
return this.flgTipoGenerazione;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setFlgTipoGenerazione(long flgTipoGenerazione) {
|
||
|
|
this.flgTipoGenerazione = flgTipoGenerazione;
|
||
|
|
}
|
||
|
|
}
|