hasancse1991

Untitled

Jul 2nd, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.65 KB | None | 0 0
  1. protected void populateProductList() {
  2.         if (!products.isEmpty()){
  3.             products.clear();
  4.         }
  5.        
  6.         String query = "SELECT P_CODE,BRAND_NAME,P_GROUP,PACK_S FROM PRODUCT_INFO where 1=1 ";
  7.         if(_searchString.length() > 0 )
  8.             query += " AND BRAND_NAME like '"+ _searchString + "%' ";
  9.         if(_pGroupName.length() > 0 && !_pGroupName.equalsIgnoreCase("All"))
  10.             query +=  " AND P_GROUP = '" + _pGroupName + "' ";
  11.        
  12.         query +=  " ORDER BY BRAND_NAME ";
  13.        
  14.         cur = executeQuery(query);
  15.         _totalProducts = 0;
  16.         if(cur.moveToNext()) {
  17.             _totalProducts = cur.getCount();
  18.         }
  19.         tvTotalProduct.setText("Product("+_totalProducts+")");
  20.        
  21.         if(end >= _totalProducts ){
  22.             end = _totalProducts;
  23.             buttonViewMore.setVisibility(View.GONE);
  24.         }else{
  25.             buttonViewMore.setVisibility(View.VISIBLE);
  26.         }
  27.        
  28.         query += " LIMIT 0, " + end;
  29.  
  30.         cur = executeQuery(query);
  31.  
  32.         while (cur.moveToNext()) {
  33.  
  34.             String p_code = cur.getString(0);
  35.             String brand_name = cur.getString(1) + "-" + p_code + "-"
  36.                     + cur.getString(2) + "-" + cur.getString(3);
  37.  
  38.             String unitPriceQuery = "select T_P,S_P from PRODUCT_INFO_PRICE where P_CODE='"
  39.                     + p_code + "'";
  40.  
  41.             Cursor c = productDb.rawQuery(unitPriceQuery, null);
  42.  
  43.             while (c.moveToNext()) {
  44.                 productData = new ProductData(p_code, brand_name,
  45.                         c.getString(0), c.getString(1));
  46.  
  47.                 products.add(productData);
  48.             }
  49.             if(!c.isClosed()){
  50.                 c.close();
  51.             }
  52.         }              
  53.        
  54.         initProductDataAdapter();              
  55.         productDataAdapter.notifyDataSetChanged();
  56.         lvResults.setAdapter(productDataAdapter);
  57.         if(!cur.isClosed()){
  58.             cur.close();
  59.         }
  60.     }
Advertisement
Add Comment
Please, Sign In to add comment