public List<String> getInfoByGPriceId(int goodsPriceId) { Cursor c = this.query( AllTables.GoodsPrice.CONTENT_URI, null, " _id = ? ", new String[] {goodsPriceId + ""}, null); if (c.getCount() > 0) { gCPer = new GoodsCPer(); unitCPer = new UnitCPer(); c.moveToFirst(); List<String> info = new ArrayList<String>(); info.add(gCPer.getGoodsNameByGoodsId(c.getInt(1))); info.add(gCPer.getKindNameByGoodsId(c.getInt(1))); info.add(unitCPer.getUnitNameById(c.getInt(2))); info.add("" + c.getDouble(4)); info.add("" + c.getDouble(5)); return info; } return null; }
public List<String> getUnitNameByGoodsId( int goodsId) { // 根据商品的ID查找单位的名字(一件商品可能有多种单位,比如红塔山的烟有”包“,”条“ Cursor c = this.query( AllTables.GoodsPrice.CONTENT_URI, null, " goodsId = ? ", new String[] {goodsId + ""}, null); List<String> allUnitByGoodsId = new ArrayList<String>(); unitCPer = new UnitCPer(); if (c.getCount() > 0) { c.moveToFirst(); for (int i = 0; i < c.getCount(); i++) { allUnitByGoodsId.add(unitCPer.getUnitNameById(c.getInt(2))); c.moveToNext(); } return allUnitByGoodsId; } return new ArrayList<String>(); }