Exemple #1
0
  public ArrayList<itemDTO> selectByGroup(String partnerid, String itemgrop) {
    ArrayList<itemDTO> list = new ArrayList<itemDTO>();
    Cursor cursor =
        this.db.query(
            TABLE_NAME,
            new String[] {
              "user_id, date,iccid,mdn,item_name,item_code,item_group,price,maping_id,partner_id,sold"
            },
            "partner_id=? AND item_group=?  AND sold='0'",
            new String[] {String.valueOf(partnerid), String.valueOf(itemgrop)},
            null,
            null,
            "item_name asc");

    if (cursor.moveToFirst()) {
      do {
        itemDTO itm = new itemDTO();
        itm.setUser_id(cursor.getString(0));
        itm.setIccid(cursor.getString(2));
        itm.setMdn(cursor.getString(3));
        itm.setItem_name(cursor.getString(4));
        itm.setItem_code(cursor.getString(5));
        itm.setItem_group(cursor.getString(6));
        itm.setPrice(cursor.getString(7));
        itm.setItem_maping_id(cursor.getString(8));
        itm.setPartner_id(cursor.getString(9));

        list.add(itm);
      } while (cursor.moveToNext());
    }
    if (cursor != null && !cursor.isClosed()) {
      cursor.close();
    }
    return list;
  }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View v = convertView;
      if (v == null) {
        LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = vi.inflate(R.layout.item_row, parent, false);
      }
      itemDTO o = items.get(position);
      if (o != null) {

        TextView tt = (TextView) v.findViewById(R.id.itemname);
        TextView bt = (TextView) v.findViewById(R.id.itemprices);
        TextView it = (TextView) v.findViewById(R.id.itemiccid);
        if (tt != null) {
          tt.setText("Name: " + o.getItem_name());
        }
        if (bt != null) {
          bt.setText("Prices: Rp. " + StringUtil.formatToCurrency(o.getPrice()));
        }
        if (it != null) {
          it.setText("ICCID:" + o.getIccid());
        }
      }
      return v;
    }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    itemDTO _group = (itemDTO) getIntent().getSerializableExtra("group");

    setContentView(R.layout.prodcatalog);
    dbi = new DBItem(this, Contents.getDBHelper().getDB());

    m_orders =
        dbi.selectByGroup(
            Contents.getLogInfo().getPartnerid(),
            _group.getItem_group().substring(0, _group.getItem_group().indexOf("  ")));
    this.m_adapter = new OrderAdapter(this, R.layout.item_row, m_orders);
    setListAdapter(this.m_adapter);
  }
Exemple #4
0
  public int setSold(itemDTO _item) {
    ContentValues val = new ContentValues();
    val.put("sold", "1");

    return this.db.update(TABLE_NAME, val, "iccid=?", new String[] {_item.getIccid()});

    // this.db.rawQuery("update "+TABLE_NAME+" set uploaded='1' where id=?",new
    // String[]{String.valueOf(id)});
  }
Exemple #5
0
  public long insert(itemDTO itm) {
    final Calendar dd = Calendar.getInstance();
    SimpleDateFormat da = new SimpleDateFormat("yyyy-MM-dd");
    this.insertStmt.bindString(1, itm.getUser_id());
    this.insertStmt.bindString(2, String.valueOf(da.format(dd.getTime())));
    this.insertStmt.bindString(3, itm.getIccid());
    this.insertStmt.bindString(4, itm.getMdn());
    this.insertStmt.bindString(5, itm.getItem_name());
    this.insertStmt.bindString(6, itm.getItem_code());
    this.insertStmt.bindString(7, itm.getItem_group());
    this.insertStmt.bindString(8, itm.getPrice());
    this.insertStmt.bindString(9, itm.getItem_maping_id());
    this.insertStmt.bindString(10, itm.getPartner_id());
    this.insertStmt.bindString(11, "0");

    return this.insertStmt.executeInsert();
  }
Exemple #6
0
  public itemDTO getitem(String userid) {
    final Calendar dd = Calendar.getInstance();
    SimpleDateFormat da = new SimpleDateFormat("yyyy-MM-dd");
    boolean mustchange = false;
    boolean use_top = false;
    itemDTO itm = new itemDTO();
    Cursor cursor =
        this.db.query(
            TABLE_NAME,
            new String[] {
              "user_id, date,iccid,mdn,item_name,item_code,item_group,price,maping_id,partner_id"
            },
            "user_id=?",
            new String[] {String.valueOf(userid)},
            null,
            null,
            "user_id desc");
    if (cursor.moveToFirst()) {
      do {

        itm.setUser_id(cursor.getString(0));
        itm.setIccid(cursor.getString(2));
        itm.setMdn(cursor.getString(3));
        itm.setItem_name(cursor.getString(4));
        itm.setItem_code(cursor.getString(5));
        itm.setItem_group(cursor.getString(6));
        itm.setPrice(cursor.getString(7));
        itm.setItem_maping_id(cursor.getString(8));
        itm.setPartner_id(cursor.getString(9));

      } while (cursor.moveToNext());
    }
    if (cursor != null && !cursor.isClosed()) {
      cursor.close();
    }
    return itm;
  }
Exemple #7
0
  public int setUnSold(itemDTO _item) {
    ContentValues val = new ContentValues();
    val.put("sold", "0");

    return this.db.update(TABLE_NAME, val, "iccid=?", new String[] {_item.getIccid()});
  }
Exemple #8
0
  public itemDTO selectByIccid(String iccid) {
    itemDTO itm = null;
    Cursor cursor =
        this.db.query(
            TABLE_NAME,
            new String[] {
              "user_id, date,iccid,mdn,item_name,item_code,item_group,price,maping_id,partner_id,sold"
            },
            "iccid=? AND sold=?",
            new String[] {String.valueOf(iccid), "0"},
            null,
            null,
            "item_name asc");

    if (cursor.moveToFirst()) {
      do {
        itm = new itemDTO();
        itm.setUser_id(cursor.getString(0));
        itm.setIccid(cursor.getString(2));
        itm.setMdn(cursor.getString(3));
        itm.setItem_name(cursor.getString(4));
        itm.setItem_code(cursor.getString(5));
        itm.setItem_group(cursor.getString(6));
        itm.setPrice(cursor.getString(7));
        itm.setItem_maping_id(cursor.getString(8));
        itm.setPartner_id(cursor.getString(9));
        if (cursor.getString(10).equalsIgnoreCase("1")) itm.setSold();
      } while (cursor.moveToNext());
    }
    if (cursor != null && !cursor.isClosed()) {
      cursor.close();
    }
    return itm;
  }