Search in sources :

Example 6 with X_T_BOMLine

use of org.eevolution.model.X_T_BOMLine in project adempiere by adempiere.

the class PrintBOM method loadBOM.

/**
	 * Action: Fill Tree with all nodes
	 */
private void loadBOM() throws Exception {
    int count = 0;
    if (p_M_Product_ID == 0)
        raiseError("Error: ", "Product ID not found");
    X_T_BOMLine tboml = new X_T_BOMLine(ctx, 0, null);
    tboml.setPP_Product_BOM_ID(0);
    tboml.setPP_Product_BOMLine_ID(0);
    tboml.setM_Product_ID(p_M_Product_ID);
    tboml.setSel_Product_ID(p_M_Product_ID);
    tboml.setImplosion(p_implosion);
    tboml.setLevelNo(0);
    tboml.setLevels("0");
    tboml.setSeqNo(0);
    tboml.setAD_PInstance_ID(AD_PInstance_ID);
    tboml.save();
    if (p_implosion) {
        PreparedStatement stmt = null;
        ResultSet rs = null;
        String sql = "SELECT PP_Product_BOMLine_ID FROM PP_Product_BOMLine " + "WHERE IsActive = 'Y' AND M_Product_ID = ? ";
        try {
            stmt = DB.prepareStatement(sql, get_TrxName());
            stmt.setInt(1, p_M_Product_ID);
            rs = stmt.executeQuery();
            while (rs.next()) {
                parentImplotion(rs.getInt(1));
                ++count;
            }
            if (count == 0)
                raiseError("Error: ", "Product is not a component");
        } catch (SQLException e) {
            log.log(Level.SEVERE, e.getLocalizedMessage() + sql, e);
            throw new Exception("SQLException: " + e.getLocalizedMessage());
        } finally {
            DB.close(rs, stmt);
            rs = null;
            stmt = null;
        }
    } else {
        PreparedStatement stmt = null;
        ResultSet rs = null;
        String sql = "SELECT PP_Product_BOM_ID FROM PP_Product_BOM " + "WHERE IsActive = 'Y' AND M_Product_ID = ? ";
        try {
            stmt = DB.prepareStatement(sql, get_TrxName());
            stmt.setInt(1, p_M_Product_ID);
            rs = stmt.executeQuery();
            while (rs.next()) {
                parentExplotion(rs.getInt(1));
                ++count;
            }
            if (count == 0)
                raiseError("Error: ", "Product is not a BOM");
        } catch (SQLException e) {
            log.log(Level.SEVERE, e.getLocalizedMessage() + sql, e);
            throw new Exception("SQLException: " + e.getLocalizedMessage());
        } finally {
            DB.close(rs, stmt);
            rs = null;
            stmt = null;
        }
    }
}
Also used : SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) SQLException(java.sql.SQLException) X_T_BOMLine(org.eevolution.model.X_T_BOMLine)

Aggregations

X_T_BOMLine (org.eevolution.model.X_T_BOMLine)6 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 SQLException (java.sql.SQLException)3 MProduct (org.compiere.model.MProduct)3 Query (org.compiere.model.Query)3 ArrayList (java.util.ArrayList)2 MQuery (org.compiere.model.MQuery)2 MPPProductBOM (org.eevolution.model.MPPProductBOM)2 MPPProductBOMLine (org.eevolution.model.MPPProductBOMLine)2 BigDecimal (java.math.BigDecimal)1 Arrays (java.util.Arrays)1 List (java.util.List)1 CostEngine (org.adempiere.engine.CostEngine)1 CostEngineFactory (org.adempiere.engine.CostEngineFactory)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1 MAcctSchema (org.compiere.model.MAcctSchema)1 MCost (org.compiere.model.MCost)1 MCostElement (org.compiere.model.MCostElement)1 Env (org.compiere.util.Env)1