Search in sources :

Example 1 with PAttributeInstance

use of org.compiere.apps.search.PAttributeInstance in project adempiere by adempiere.

the class VPAttributeDialog method cmd_select.

//	actionPerformed
/**
	 * 	Instance Selection Button
	 * 	@return true if selected
	 */
private boolean cmd_select() {
    log.config("");
    int M_Warehouse_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, "M_Warehouse_ID");
    int C_DocType_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, "C_DocType_ID");
    if (C_DocType_ID > 0) {
        MDocType doctype = new MDocType(Env.getCtx(), C_DocType_ID, null);
        String docbase = doctype.getDocBaseType();
        // consider also old lot numbers at inventory
        if (docbase.equals(MDocType.DOCBASETYPE_MaterialReceipt) || docbase.equals(MDocType.DOCBASETYPE_MaterialPhysicalInventory))
            M_Warehouse_ID = 0;
    }
    // teo_sarca [ 1564520 ] Inventory Move: can't select existing attributes
    // Trifon - Always read Locator from Context. There are too many windows to read explicitly one by one.
    int M_Locator_ID = 0;
    // only window
    M_Locator_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, X_M_MovementLine.COLUMNNAME_M_Locator_ID, true);
    String title = "";
    //	Get Text
    String sql = "SELECT p.Name, w.Name, w.M_Warehouse_ID FROM M_Product p, M_Warehouse w " + "WHERE p.M_Product_ID=? AND w.M_Warehouse_ID" + // teo_sarca [ 1564520 ]
    (M_Locator_ID <= 0 ? "=?" : " IN (SELECT M_Warehouse_ID FROM M_Locator where M_Locator_ID=?)");
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
        pstmt = DB.prepareStatement(sql, null);
        pstmt.setInt(1, m_M_Product_ID);
        pstmt.setInt(2, M_Locator_ID <= 0 ? M_Warehouse_ID : M_Locator_ID);
        rs = pstmt.executeQuery();
        if (rs.next()) {
            title = ": " + rs.getString(1) + " - " + rs.getString(2);
            // fetch the actual warehouse - teo_sarca [ 1564520 ]
            M_Warehouse_ID = rs.getInt(3);
        }
    } catch (Exception e) {
        log.log(Level.SEVERE, sql, e);
    } finally {
        DB.close(rs, pstmt);
        rs = null;
        pstmt = null;
    }
    //		
    PAttributeInstance pai = new PAttributeInstance(this, title, M_Warehouse_ID, M_Locator_ID, m_M_Product_ID, m_C_BPartner_ID);
    //
    if (m_M_AttributeSetInstance_ID != pai.getM_AttributeSetInstance_ID() || !(m_M_AttributeSetInstance_ID == 0 && pai.getM_AttributeSetInstance_ID() == -1)) {
        m_changed = true;
        //
        if (pai.getM_AttributeSetInstance_ID() != -1) {
            m_M_AttributeSetInstance_ID = pai.getM_AttributeSetInstance_ID();
            m_M_AttributeSetInstanceName = pai.getM_AttributeSetInstanceName();
            m_M_Locator_ID = pai.getM_Locator_ID();
        } else {
            m_M_AttributeSetInstance_ID = 0;
            m_M_AttributeSetInstanceName = "";
        // Leave the locator alone
        }
    }
    return m_changed;
}
Also used : MDocType(org.compiere.model.MDocType) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) PAttributeInstance(org.compiere.apps.search.PAttributeInstance) ALayoutConstraint(org.compiere.apps.ALayoutConstraint)

Example 2 with PAttributeInstance

use of org.compiere.apps.search.PAttributeInstance in project adempiere by adempiere.

the class VMRPDetailed method selectAttributeSetInstance.

// prepareTable
/**
	 * filter by Attribute Set Instance
	 */
private void selectAttributeSetInstance() {
    int m_warehouse_id = getM_Warehouse_ID();
    int m_product_id = getM_Product_ID();
    if (m_product_id <= 0)
        return;
    MProduct product = MProduct.get(getCtx(), m_product_id);
    MWarehouse wh = MWarehouse.get(getCtx(), m_warehouse_id);
    String title = product.get_Translation(MProduct.COLUMNNAME_Name) + " - " + wh.get_Translation(MWarehouse.COLUMNNAME_Name);
    //	Yamel Senih FR [ 114 ] 2015-11-23
    PAttributeInstance pai = new PAttributeInstance(m_frame.getCFrame(), title, m_warehouse_id, 0, m_product_id, 0);
    if (pai.getM_AttributeSetInstance_ID() != -1) {
        fAttrSetInstance_ID.setText(pai.getM_AttributeSetInstanceName());
        fAttrSetInstance_ID.setValue(new Integer(pai.getM_AttributeSetInstance_ID()));
    } else {
        fAttrSetInstance_ID.setValue(Integer.valueOf(0));
    }
}
Also used : MProduct(org.compiere.model.MProduct) PAttributeInstance(org.compiere.apps.search.PAttributeInstance) ALayoutConstraint(org.compiere.apps.ALayoutConstraint) MWarehouse(org.compiere.model.MWarehouse)

Example 3 with PAttributeInstance

use of org.compiere.apps.search.PAttributeInstance in project adempiere by adempiere.

the class ChangeASIAction method selectASIID.

private int selectASIID(BOMLineWrapper line) {
    if (line.getM_Product_ID() <= 0)
        return -1;
    MProduct p = new MProduct(Env.getCtx(), line.getM_Product_ID(), null);
    PAttributeInstance pai = new PAttributeInstance((JFrame) null, p.getName(), getParameterValueAsInt("M_Warehouse_ID"), 0, line.getM_Product_ID(), 0);
    return pai.getM_AttributeSetInstance_ID();
}
Also used : MProduct(org.compiere.model.MProduct) PAttributeInstance(org.compiere.apps.search.PAttributeInstance)

Aggregations

PAttributeInstance (org.compiere.apps.search.PAttributeInstance)3 ALayoutConstraint (org.compiere.apps.ALayoutConstraint)2 MProduct (org.compiere.model.MProduct)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 MDocType (org.compiere.model.MDocType)1 MWarehouse (org.compiere.model.MWarehouse)1