public void plusorMinusElecart( ArrayList<HashMap<String, Object>> list, int position, String flag, Context context) { if (!list.isEmpty()) { String goodsid = list.get(position).get("goodsid").toString(); DBHelper dbhelper = new DBHelper(context); dbhelper.updateByElecartNeedquantity(DBHelper.ELE_CART_TM_NAME, goodsid, flag); } }
/** 将商品加入我的菜单 */ public void setGoodsToElecartSQLite( String goodsid, String goodsname, String memberprice, String pictureurl, String needquantity, Context context) { DBHelper dbhelper = new DBHelper(context); ContentValues values = new ContentValues(); values.put("goodsid", goodsid); values.put("goodsname", goodsname); values.put("memberprice", memberprice); values.put("pictureurl", pictureurl); values.put("needquantity", needquantity); Cursor c = dbhelper.queryByParamgoodsid(DBHelper.ELE_CART_TM_NAME, goodsid); int querycount = c.getCount(); if (querycount > 0) { dbhelper.updateByElecartNeedquantity(DBHelper.ELE_CART_TM_NAME, goodsid, "plus"); } else { dbhelper.insert(DBHelper.ELE_CART_TM_NAME, values); } dbhelper.close(); }