Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.openbravo.erpCommon.ad_callouts;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.text.DecimalFormat;
- import javax.servlet.ServletException;
- import org.openbravo.dal.service.OBDal;
- import org.openbravo.erpCommon.utility.Utility;
- public class GenerateBPSearchKeyCallout extends SimpleCallout {
- @Override
- protected void execute(CalloutInfo info) throws ServletException {
- //get key from sub Category inpmProductCategoryId
- String strClientId = info.getStringParameter("inpadClientId", null);
- //String strBusi = info.getStringParameter(param, filter)
- // get preference
- String bpPrefix = Utility.getPreference(info.vars, "BusinessPartnerPrefix", null);
- String bpSuffix = Utility.getPreference(info.vars, "BusinessPartnerSuffix", null);
- //get increment number
- String sql = "select count(*) as jumlahBpPartner" +
- " from c_bpartner" +
- " where ad_client_id = ?";
- java.sql.Connection conn = OBDal.getInstance().getConnection();
- try {
- PreparedStatement ps = conn.prepareStatement(sql);
- ps.setString(1, strClientId);
- ResultSet rs = ps.executeQuery();
- int JumlahBP = 0;
- while (rs.next()) {
- JumlahBP = rs.getInt("JumlahBP");
- }
- JumlahBP++;
- DecimalFormat myFormatter = new DecimalFormat("00000000");
- String strJumlahBPartner = myFormatter.format(JumlahBP);
- String searchKey = bpPrefix+ strJumlahBPartner + bpSuffix;
- info.addResult("inpvalue", searchKey);
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement