Search in sources :

Example 31 with KeyNamePair

use of org.compiere.util.KeyNamePair in project adempiere by adempiere.

the class WInOutGen method dynInit.

//	jbInit
/**
	 *	Fill Picks.
	 *		Column_ID from C_Order
	 *  @throws Exception if Lookups cannot be initialized
	 */
public void dynInit() throws Exception {
    //	C_OrderLine.M_Warehouse_ID
    MLookup orgL = MLookupFactory.get(Env.getCtx(), form.getWindowNo(), 0, 2223, DisplayType.TableDir);
    fWarehouse = new WTableDirEditor("M_Warehouse_ID", true, false, true, orgL);
    lWarehouse.setText(Msg.translate(Env.getCtx(), "M_Warehouse_ID"));
    fWarehouse.addValueChangeListener(this);
    fWarehouse.setValue(Env.getContextAsInt(Env.getCtx(), "#M_Warehouse_ID"));
    setM_Warehouse_ID(fWarehouse.getValue());
    //      Document Action Prepared/ Completed
    lDocAction.setText(Msg.translate(Env.getCtx(), "DocAction"));
    MLookup docActionL = MLookupFactory.get(Env.getCtx(), form.getWindowNo(), 4324, /* M_InOut.DocAction */
    DisplayType.List, Env.getLanguage(Env.getCtx()), "DocAction", 135, /* _Document Action */
    false, "AD_Ref_List.Value IN ('CO','PR')");
    docAction = new WTableDirEditor("DocAction", true, false, true, docActionL);
    docAction.setValue(DocAction.ACTION_Complete);
    docAction.addValueChangeListener(this);
    //	C_Order.C_BPartner_ID
    MLookup bpL = MLookupFactory.get(Env.getCtx(), form.getWindowNo(), 0, 2762, DisplayType.Search);
    fBPartner = new WSearchEditor("C_BPartner_ID", false, false, true, bpL);
    lBPartner.setText(Msg.translate(Env.getCtx(), "C_BPartner_ID"));
    fBPartner.addValueChangeListener(this);
    //Document Type Sales Order/Vendor RMA
    lDocType.setText(Msg.translate(Env.getCtx(), "C_DocType_ID"));
    cmbDocType.addItem(new KeyNamePair(MOrder.Table_ID, Msg.translate(Env.getCtx(), "Order")));
    cmbDocType.addItem(new KeyNamePair(MRMA.Table_ID, Msg.translate(Env.getCtx(), "VendorRMA")));
    cmbDocType.addActionListener(this);
    cmbDocType.setSelectedIndex(0);
    //@@
    form.getStatusBar().setStatusLine(Msg.getMsg(Env.getCtx(), "InOutGenerateSel"));
}
Also used : WTableDirEditor(org.adempiere.webui.editor.WTableDirEditor) MLookup(org.compiere.model.MLookup) WSearchEditor(org.adempiere.webui.editor.WSearchEditor) KeyNamePair(org.compiere.util.KeyNamePair)

Example 32 with KeyNamePair

use of org.compiere.util.KeyNamePair in project adempiere by adempiere.

the class MPaySelection method verifyIsPaid.

/**
	 * Verify if is not paid
	 */
private void verifyIsPaid() {
    if (linesPaid != null)
        return;
    //	Get
    linesPaid = new HashMap<Integer, Boolean>();
    //	Get from Validation
    KeyNamePair[] pairs = DB.getKeyNamePairs("SELECT psl.C_PaySelectionLine_ID, " + "(CASE " + "		WHEN COALESCE(" + "					SUM(CASE " + "							WHEN p.DocStatus NOT IN('VO', 'RE') " + "							THEN 1 " + "							ELSE 0 " + "							END" + "					), 0" + "			) > 0 " + "		THEN 'Y' " + "		ELSE 'N' " + "		END" + ") IsPaid " + "FROM C_PaySelectionLine psl " + "LEFT JOIN C_PaySelectionCheck psc ON(psc.C_PaySelectionCheck_ID = psl.C_PaySelectionCheck_ID) " + "LEFT JOIN C_Payment p ON(p.C_Payment_ID = psc.C_Payment_ID) " + "WHERE psl.C_PaySelection_ID = ? " + "GROUP BY psl.C_PaySelectionLine_ID", false, getC_PaySelection_ID());
    //	Get Values
    boolean paidCompletely = true;
    boolean paid = false;
    for (KeyNamePair pair : pairs) {
        linesPaid.put(pair.getKey(), pair.getName().equals("Y"));
        //	Fill Use
        if (!pair.getName().equals("Y") && paidCompletely) {
            paidCompletely = false;
        } else if (pair.getName().equals("Y") && !paid) {
            paid = true;
        }
    }
    //	
    isPaidCompletely = paidCompletely;
    isPaid = paid;
}
Also used : KeyNamePair(org.compiere.util.KeyNamePair)

Example 33 with KeyNamePair

use of org.compiere.util.KeyNamePair in project adempiere by adempiere.

the class MPaySelection method verifyIsUsed.

/**
	 * Verify if is used
	 */
private void verifyIsUsed() {
    if (linesUsed != null)
        return;
    //	Get
    linesUsed = new HashMap<Integer, Boolean>();
    //	Get from Validation
    KeyNamePair[] pairs = DB.getKeyNamePairs("SELECT psl.C_PaySelectionLine_ID, " + "(CASE " + "		WHEN COALESCE(" + "					SUM(CASE " + "							WHEN cps.DocStatus NOT IN('VO', 'RE') " + "							THEN 1 " + "							ELSE 0 " + "							END" + "					), 0" + "			) > 0 " + "		THEN 'Y' " + "		ELSE 'N' " + "		END" + ") IsUsed " + "FROM C_PaySelectionLine psl " + "LEFT JOIN C_PaySelectionLine cpsl ON(cpsl.C_PaySelectionLine_Parent_ID = psl.C_PaySelectionLine_ID) " + "LEFT JOIN C_PaySelection cps ON(cps.C_PaySelection_ID = cpsl.C_PaySelection_ID) " + "WHERE psl.C_PaySelection_ID = ? " + "GROUP BY psl.C_PaySelectionLine_ID", false, getC_PaySelection_ID());
    //	Get Values
    boolean usedCompletely = true;
    boolean used = false;
    for (KeyNamePair pair : pairs) {
        linesUsed.put(pair.getKey(), pair.getName().equals("Y"));
        //	Fill Use
        if (!pair.getName().equals("Y") && usedCompletely) {
            usedCompletely = false;
        } else if (pair.getName().equals("Y") && !used) {
            used = true;
        }
    }
    //	
    isUsedCompletely = usedCompletely;
    isUsed = used;
}
Also used : KeyNamePair(org.compiere.util.KeyNamePair)

Example 34 with KeyNamePair

use of org.compiere.util.KeyNamePair in project adempiere by adempiere.

the class VAssignmentDialog method setDisplay.

//	jbInit
/**
	 * 	Initialize component & values from m_mAssignment
	 */
private void setDisplay() {
    m_setting = true;
    //	Set Resource
    int S_Resource_ID = m_mAssignment.getS_Resource_ID();
    KeyNamePair[] resources = new KeyNamePair[m_lookup.size()];
    m_lookup.keySet().toArray(resources);
    for (int i = 0; i < resources.length; i++) {
        if (resources[i].getKey() == S_Resource_ID) {
            fResource.setSelectedItem(resources[i]);
            break;
        }
    }
    KeyNamePair check = (KeyNamePair) fResource.getSelectedItem();
    if (check == null || check.getKey() != S_Resource_ID) {
        if (//	new record select first
        m_mAssignment.getS_ResourceAssignment_ID() == 0)
            //	initiates UOM display
            fResource.setSelectedItem(fResource.getSelectedItem());
        else
            log.log(Level.SEVERE, "Resource not found ID=" + S_Resource_ID);
    }
    //	Set Date, Qty
    fDateFrom.setValue(m_mAssignment.getAssignDateFrom());
    fQty.setValue(m_mAssignment.getQty());
    //	Name, Description
    fName.setValue(m_mAssignment.getName());
    fDescription.setValue(m_mAssignment.getDescription());
    //	Set Editor to R/O if confirmed
    boolean readWrite = true;
    if (m_mAssignment.isConfirmed())
        readWrite = false;
    confirmPanel.getCancelButton().setVisible(readWrite);
    fResource.setReadWrite(readWrite);
    fDateFrom.setReadWrite(readWrite);
    fQty.setReadWrite(readWrite);
    m_setting = false;
}
Also used : KeyNamePair(org.compiere.util.KeyNamePair)

Example 35 with KeyNamePair

use of org.compiere.util.KeyNamePair in project adempiere by adempiere.

the class VAssignmentDialog method cmd_save.

//	getMResourceAssignment
/**
	 * 	Check availability and insert record
	 *  @return true if saved/updated
	 */
private boolean cmd_save() {
    log.config("");
    //	Set AssignDateTo
    Timestamp assignDateFrom = fDateFrom.getTimestamp();
    BigDecimal qty = (BigDecimal) fQty.getValue();
    KeyNamePair uom = (KeyNamePair) m_lookup.get(fResource.getSelectedItem());
    int minutes = MUOMConversion.convertToMinutes(Env.getCtx(), uom.getKey(), qty);
    Timestamp assignDateTo = TimeUtil.addMinutess(assignDateFrom, minutes);
    m_mAssignment.setAssignDateTo(assignDateTo);
    //	m_mAssignment.dump();
    return m_mAssignment.save();
}
Also used : KeyNamePair(org.compiere.util.KeyNamePair) Timestamp(java.sql.Timestamp) BigDecimal(java.math.BigDecimal)

Aggregations

KeyNamePair (org.compiere.util.KeyNamePair)286 SQLException (java.sql.SQLException)66 ResultSet (java.sql.ResultSet)65 PreparedStatement (java.sql.PreparedStatement)62 BigDecimal (java.math.BigDecimal)46 ArrayList (java.util.ArrayList)38 ValueNamePair (org.compiere.util.ValueNamePair)36 Timestamp (java.sql.Timestamp)32 Vector (java.util.Vector)22 ListItem (org.adempiere.webui.component.ListItem)22 Login (org.compiere.util.Login)22 MProduct (org.compiere.model.MProduct)17 IDColumn (org.compiere.minigrid.IDColumn)13 ALayoutConstraint (org.compiere.apps.ALayoutConstraint)12 AdempiereException (org.adempiere.exceptions.AdempiereException)10 MLookup (org.compiere.model.MLookup)10 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)9 org.apache.ecs.xhtml.p (org.apache.ecs.xhtml.p)8 org.apache.ecs.xhtml.script (org.apache.ecs.xhtml.script)8 MUOM (org.compiere.model.MUOM)7