Advertisement
tko_pb

GenerateBPSearchKeyCallout 23 agustus

Aug 23rd, 2018
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.58 KB | None | 0 0
  1. package org.wirabumi.gen.oez.callout;
  2.  
  3. import java.sql.PreparedStatement;
  4. import java.sql.ResultSet;
  5. import java.text.DecimalFormat;
  6.  
  7. import javax.servlet.ServletException;
  8.  
  9. import org.openbravo.dal.service.OBDal;
  10. import org.openbravo.erpCommon.ad_callouts.SimpleCallout;
  11. import org.openbravo.erpCommon.utility.Utility;
  12.  
  13. public class GenerateBPSearchKeyCallout extends SimpleCallout {
  14.  
  15.     @Override
  16.     protected void execute(CalloutInfo info) throws ServletException {
  17.        
  18.         //get key from sub Category inpmProductCategoryId
  19.         String strClientId = info.getStringParameter("inpadClientId", null);
  20.        
  21.         // get preference
  22.         String bpPrefix = Utility.getPreference(info.vars, "BusinessPartnerPrefix", null);
  23.         String bpSuffix = Utility.getPreference(info.vars, "BusinessPartnerSuffix", null);
  24.        
  25.         //get increment number
  26.         String sql = "select count(*) as JumlahBP" +
  27.                      " from c_bpartner" +
  28.                      " where ad_client_id=?" +
  29.                      " and lower(name) like '%supplier%' ";
  30.         java.sql.Connection conn = OBDal.getInstance().getConnection();
  31.         try {
  32.             PreparedStatement ps = conn.prepareStatement(sql);
  33.             ps.setString(1, strClientId);
  34.             ResultSet rs = ps.executeQuery();
  35.             int JumlahBP = 0;
  36.             while (rs.next()) {
  37.                 JumlahBP = rs.getInt("JumlahBP");
  38.             }
  39.             JumlahBP++;
  40.            
  41.             DecimalFormat myFormatter = new DecimalFormat("00000000");
  42.             String strJumlahBPartner = myFormatter.format(JumlahBP);
  43.             String searchKey = bpPrefix+ strJumlahBPartner + bpSuffix;
  44.             info.addResult("inpvalue", searchKey);
  45.         }
  46.         catch (Exception e) {
  47.             e.printStackTrace();
  48.         }      
  49.        
  50.     }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement