Search in sources :

Example 21 with ValueNamePair

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

the class HRPayPrint method loadPaymentRule.

//  loadPaySelectInfo
/**
	 *  Bank changed - load PaymentRule
	 */
public ArrayList<ValueNamePair> loadPaymentRule(int C_PaySelection_ID) {
    ArrayList<ValueNamePair> data = new ArrayList<ValueNamePair>();
    // load PaymentRule for Bank
    //  MLookupInfo.getAD_Reference_ID("All_Payment Rule");
    int AD_Reference_ID = 195;
    Language language = Language.getLanguage(Env.getAD_Language(Env.getCtx()));
    MLookupInfo info = MLookupFactory.getLookup_List(language, AD_Reference_ID);
    String sql = info.Query.substring(0, info.Query.indexOf(" ORDER BY")) + " AND " + info.KeyColumn + " IN (SELECT PaymentRule FROM HR_PaySelectionCheck WHERE HR_PaySelection_ID=?) " + info.Query.substring(info.Query.indexOf(" ORDER BY"));
    try {
        PreparedStatement pstmt = DB.prepareStatement(sql, null);
        pstmt.setInt(1, C_PaySelection_ID);
        ResultSet rs = pstmt.executeQuery();
        //
        while (rs.next()) {
            ValueNamePair pp = new ValueNamePair(rs.getString(2), rs.getString(3));
            data.add(pp);
        }
        rs.close();
        pstmt.close();
    } catch (SQLException e) {
        log.log(Level.SEVERE, sql, e);
    }
    if (data.size() == 0)
        log.config("PaySel=" + C_PaySelection_ID + ", BAcct=" + m_C_BankAccount_ID + " - " + sql);
    return data;
}
Also used : MLookupInfo(org.compiere.model.MLookupInfo) Language(org.compiere.util.Language) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) ValueNamePair(org.compiere.util.ValueNamePair)

Example 22 with ValueNamePair

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

the class HRActionNotice method getConcept.

//getEmployeeValid
public ArrayList<ValueNamePair> getConcept(MHRProcess process, boolean isFieldProcessNull) {
    if (process == null)
        return null;
    ArrayList<ValueNamePair> data = new ArrayList<ValueNamePair>();
    String sql = "SELECT DISTINCT hrpc.HR_Concept_ID,hrpc.Name,hrpc.Value " + " FROM HR_Concept hrpc " + " INNER JOIN HR_Attribute hrpa ON (hrpa.HR_Concept_ID=hrpc.HR_Concept_ID)" + " WHERE hrpc.AD_Client_ID = " + Env.getAD_Client_ID(Env.getCtx()) + " AND hrpc.IsActive = 'Y' AND hrpc.IsManual = 'Y' AND hrpc.Type != 'E'" + " AND (hrpa.HR_Payroll_ID = " + m_HR_Payroll_ID + " OR hrpa.HR_Payroll_ID IS NULL)";
    if (!isFieldProcessNull) {
        // Process
        if (// Process & Payroll
        process.getHR_Payroll_ID() != 0)
            sql = sql + " AND (hrpa.HR_Payroll_ID = " + process.getHR_Payroll_ID() + " OR hrpa.HR_Payroll_ID is NULL)";
        // Process & Department
        if (process.getHR_Department_ID() != 0)
            ;
        sql = sql + " AND (hrpa.HR_Department_ID = " + process.getHR_Department_ID() + " OR hrpa.HR_Department_ID is NULL)";
        // Process & Employee
        if (process.getHR_Department_ID() != 0)
            ;
        sql = sql + " AND (hrpa.HR_Employee_ID = " + process.getHR_Employee_ID() + " OR hrpa.HR_Employee_ID is NULL)";
    }
    sql = sql + " ORDER BY hrpc.Name";
    try {
        PreparedStatement pstmt = DB.prepareStatement(sql, null);
        //pstmt.setInt(1, bi.C_BankAccount_ID);
        ResultSet rs = pstmt.executeQuery();
        ValueNamePair vp = null;
        data.add(new ValueNamePair("", ""));
        while (rs.next()) {
            //  returns also not active
            vp = new ValueNamePair(rs.getString(1), rs.getString(2));
            data.add(vp);
        }
        rs.close();
        pstmt.close();
    } catch (SQLException e) {
        log.log(Level.SEVERE, sql, e);
    }
    return data;
}
Also used : SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) ValueNamePair(org.compiere.util.ValueNamePair)

Example 23 with ValueNamePair

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

the class VHRPayPrint method cmd_print.

//  cmd_EFT
/**
	 *  Print Checks and/or Remittance
	 */
private void cmd_print() {
    String PaymentRule = ((ValueNamePair) fPaymentRule.getSelectedItem()).getValue();
    log.info(PaymentRule);
    if (!getChecks(PaymentRule))
        return;
    panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    boolean somethingPrinted = false;
    boolean directPrint = !Ini.isPropertyBool(Ini.P_PRINTPREVIEW);
    //	for all checks
    for (MHRPaySelectionCheck check : m_checks) {
        //	ReportCtrl will check BankAccountDoc for PrintFormat
        boolean ok = ReportCtl.startDocumentPrint(ReportEngine.HR_CHECK, check.get_ID(), null, Env.getWindowNo(panel), directPrint);
        if (!somethingPrinted && ok)
            somethingPrinted = true;
    }
    //	Confirm Print and Update BankAccountDoc
    if (somethingPrinted && ADialog.ask(m_WindowNo, panel, "VPayPrintSuccess?")) {
        int lastDocumentNo = MHRPaySelectionCheck.confirmPrint(m_checks, m_batch);
        if (lastDocumentNo != 0) {
            StringBuffer sb = new StringBuffer();
            sb.append("UPDATE C_BankAccountDoc SET CurrentNext=").append(++lastDocumentNo).append(" WHERE C_BankAccount_ID=").append(m_C_BankAccount_ID).append(" AND PaymentRule='").append(PaymentRule).append("'");
            DB.executeUpdate(sb.toString(), null);
        }
    }
    if (ADialog.ask(m_WindowNo, panel, "VPayPrintPrintRemittance")) {
        for (MHRPaySelectionCheck check : m_checks) {
            ReportCtl.startDocumentPrint(ReportEngine.HR_REMITTANCE, check.get_ID(), null, Env.getWindowNo(panel), directPrint);
        }
    }
    //	remittance
    panel.setCursor(Cursor.getDefaultCursor());
    dispose();
}
Also used : MHRPaySelectionCheck(org.eevolution.model.MHRPaySelectionCheck) ValueNamePair(org.compiere.util.ValueNamePair) HRPayPrint(org.eevolution.service.HRPayPrint)

Example 24 with ValueNamePair

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

the class VHRPayPrint method loadPaymentRuleInfo.

//  loadPaymentRule
/**
	 *  PaymentRule changed - load DocumentNo, NoPayments,
	 *  enable/disable EFT, Print
	 */
private void loadPaymentRuleInfo() {
    ValueNamePair pp = (ValueNamePair) fPaymentRule.getSelectedItem();
    if (pp == null)
        return;
    String PaymentRule = pp.getValue();
    log.info("PaymentRule=" + PaymentRule);
    fNoPayments.setText(" ");
    int C_PaySelection_ID = ((KeyNamePair) fPaySelect.getSelectedItem()).getKey();
    String msg = loadPaymentRuleInfo(C_PaySelection_ID, PaymentRule);
    if (noPayments != null)
        fNoPayments.setText(noPayments);
    bProcess.setEnabled(PaymentRule.equals("T"));
    if (documentNo != null)
        fDocumentNo.setValue(documentNo);
    if (msg != null && msg.length() > 0)
        ADialog.error(m_WindowNo, panel, msg);
}
Also used : ValueNamePair(org.compiere.util.ValueNamePair) KeyNamePair(org.compiere.util.KeyNamePair) HRPayPrint(org.eevolution.service.HRPayPrint)

Example 25 with ValueNamePair

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

the class MRefList method getList.

//	getListDescription
/**
	 * Get Reference List (translated)
	 * @param ctx context
	 * @param AD_Reference_ID reference
	 * @param optional if true add "",""
	 * @return List or null
	 */
public static ValueNamePair[] getList(Properties ctx, int AD_Reference_ID, boolean optional) {
    String ad_language = Env.getAD_Language(ctx);
    boolean isBaseLanguage = Env.isBaseLanguage(ad_language, "AD_Ref_List");
    String sql = isBaseLanguage ? "SELECT Value, Name FROM AD_Ref_List WHERE AD_Reference_ID=? AND IsActive='Y' ORDER BY Name" : "SELECT r.Value, t.Name FROM AD_Ref_List_Trl t" + " INNER JOIN AD_Ref_List r ON (r.AD_Ref_List_ID=t.AD_Ref_List_ID)" + " WHERE r.AD_Reference_ID=? AND t.AD_Language=? AND r.IsActive='Y'" + " ORDER BY t.Name";
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    ArrayList<ValueNamePair> list = new ArrayList<ValueNamePair>();
    if (optional)
        list.add(new ValueNamePair("", ""));
    try {
        pstmt = DB.prepareStatement(sql, null);
        pstmt.setInt(1, AD_Reference_ID);
        if (!isBaseLanguage)
            pstmt.setString(2, ad_language);
        rs = pstmt.executeQuery();
        while (rs.next()) list.add(new ValueNamePair(rs.getString(1), rs.getString(2)));
        rs.close();
        pstmt.close();
        pstmt = null;
    } catch (SQLException e) {
        s_log.log(Level.SEVERE, sql, e);
    } finally {
        DB.close(rs, pstmt);
        rs = null;
        pstmt = null;
    }
    ValueNamePair[] retValue = new ValueNamePair[list.size()];
    list.toArray(retValue);
    return retValue;
}
Also used : SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement) ValueNamePair(org.compiere.util.ValueNamePair)

Aggregations

ValueNamePair (org.compiere.util.ValueNamePair)109 KeyNamePair (org.compiere.util.KeyNamePair)35 SQLException (java.sql.SQLException)22 ArrayList (java.util.ArrayList)22 PreparedStatement (java.sql.PreparedStatement)20 ResultSet (java.sql.ResultSet)19 Timestamp (java.sql.Timestamp)9 GridField (org.compiere.model.GridField)7 BigDecimal (java.math.BigDecimal)5 MetalLookAndFeel (javax.swing.plaf.metal.MetalLookAndFeel)5 MetalTheme (javax.swing.plaf.metal.MetalTheme)5 MInvoice (org.compiere.model.MInvoice)5 MLookup (org.compiere.model.MLookup)5 MLookupInfo (org.compiere.model.MLookupInfo)5 HRPayPrint (org.eevolution.service.HRPayPrint)5 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)4 ListItem (org.adempiere.webui.component.ListItem)4 MCashLine (org.compiere.model.MCashLine)4 AdempiereUserError (org.compiere.util.AdempiereUserError)4 NamePair (org.compiere.util.NamePair)4