Advertisement
tko_pb

EM_OEZ_BpValue

Jul 24th, 2018
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.55 KB | None | 0 0
  1. package org.openbravo.erpCommon.ad_callouts;
  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.utility.Utility;
  11.  
  12. public class GenerateBPSearchKeyCallout extends SimpleCallout {
  13.  
  14.     @Override
  15.     protected void execute(CalloutInfo info) throws ServletException {
  16.        
  17.         //get key from sub Category inpmProductCategoryId
  18.         String strClientId = info.getStringParameter("inpadClientId", null);
  19.        
  20.         //String strBusi = info.getStringParameter(param, filter)
  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 jumlahBpPartner" +
  27.                 " from c_bpartner" +
  28.                 " where ad_client_id = ?";
  29.         java.sql.Connection conn = OBDal.getInstance().getConnection();
  30.         try {
  31.             PreparedStatement ps = conn.prepareStatement(sql);
  32.             ps.setString(1, strClientId);
  33.             ResultSet rs = ps.executeQuery();
  34.             int JumlahBP = 0;
  35.             while (rs.next()) {
  36.                 JumlahBP = rs.getInt("JumlahBP");
  37.             }
  38.             JumlahBP++;
  39.            
  40.             DecimalFormat myFormatter = new DecimalFormat("00000000");
  41.             String strJumlahBPartner = myFormatter.format(JumlahBP);
  42.             String searchKey = bpPrefix+ strJumlahBPartner + bpSuffix;
  43.             info.addResult("inpvalue", searchKey);
  44.         }
  45.         catch (Exception e) {
  46.             e.printStackTrace();
  47.         }      
  48.        
  49.     }
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement