117 lines
3.1 KiB
Java
117 lines
3.1 KiB
Java
package it.acxent.art;
|
|
|
|
import it.acxent.db.ApplParmFull;
|
|
import it.acxent.db.WcString;
|
|
import it.acxent.util.Vectumerator;
|
|
import java.io.Serializable;
|
|
import java.sql.PreparedStatement;
|
|
import java.sql.SQLException;
|
|
|
|
public class ArticoloComponente extends _ArtAdapter implements Serializable {
|
|
private long id_articoloComponente;
|
|
|
|
private long id_componente;
|
|
|
|
private long id_articolo;
|
|
|
|
private double perc;
|
|
|
|
private Articolo articolo;
|
|
|
|
private Componente componente;
|
|
|
|
public ArticoloComponente(ApplParmFull newApplParmFull) {
|
|
super(newApplParmFull);
|
|
}
|
|
|
|
public ArticoloComponente() {}
|
|
|
|
public long getId_articoloComponente() {
|
|
return this.id_articoloComponente;
|
|
}
|
|
|
|
public void setId_articoloComponente(long id_articoloComponente) {
|
|
this.id_articoloComponente = id_articoloComponente;
|
|
}
|
|
|
|
public long getId_componente() {
|
|
return this.id_componente;
|
|
}
|
|
|
|
public void setId_componente(long id_componente) {
|
|
this.id_componente = id_componente;
|
|
}
|
|
|
|
public long getId_articolo() {
|
|
return this.id_articolo;
|
|
}
|
|
|
|
public void setId_articolo(long id_articolo) {
|
|
this.id_articolo = id_articolo;
|
|
}
|
|
|
|
public double getPerc() {
|
|
return this.perc;
|
|
}
|
|
|
|
public void setPerc(double perc) {
|
|
this.perc = perc;
|
|
}
|
|
|
|
public Articolo getArticolo() {
|
|
this.articolo = (Articolo)getSecondaryObject(this.articolo, Articolo.class,
|
|
getId_articolo());
|
|
return this.articolo;
|
|
}
|
|
|
|
public Componente getComponente() {
|
|
this.componente = (Componente)getSecondaryObject(this.componente, Componente.class,
|
|
getId_componente());
|
|
return this.componente;
|
|
}
|
|
|
|
public Vectumerator findByArticolo(long id_articolo) {
|
|
String s_Sql_Find = "select A.* from ARTICOLO_COMPONENTE AS A";
|
|
String s_Sql_Order = "";
|
|
WcString wc = new WcString();
|
|
wc.addWc("id_articolo = " + id_articolo);
|
|
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 void findByArticoloComponente(long id_articolo, long id_componente) {
|
|
String s_Sql_Find = "select A.* from ARTICOLO_COMPONENTE AS A";
|
|
String s_Sql_Order = "";
|
|
WcString wc = new WcString();
|
|
wc.addWc("id_articolo = " + id_articolo);
|
|
wc.addWc("id_componente = " + id_componente);
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find +
|
|
wc.toString());
|
|
findFirstRecord(stmt);
|
|
} catch (SQLException e) {
|
|
handleDebug(e);
|
|
}
|
|
}
|
|
|
|
public double getPercTotale(long id_articolo) {
|
|
String s_Sql_Find = "select SUM(A.perc) AS _sum from ARTICOLO_COMPONENTE AS A";
|
|
String s_Sql_Order = "";
|
|
WcString wc = new WcString();
|
|
wc.addWc("id_articolo = " + id_articolo);
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find +
|
|
wc.toString());
|
|
return getSum(stmt);
|
|
} catch (SQLException e) {
|
|
handleDebug(e);
|
|
return 0.0D;
|
|
}
|
|
}
|
|
}
|