Пример #1
0
 /** 查询所有商品 */
 public List<Goods> getAllGoods() {
   Dao dao = DaoCreater.createDao();
   List<Goods> goodslist = null;
   try {
     dao.beginTransaction();
     goodslist = dao.queryBeanList(Goods.class, "select * from goods");
     dao.commitTransaction();
   } catch (Exception e) {
     e.printStackTrace();
     dao.rollbackTransaction();
   } finally {
     dao.close();
   }
   return goodslist;
 }
Пример #2
0
 public Goods getGood(int gid) {
   Dao dao = DaoCreater.createDao();
   Goods good = null;
   try {
     dao.beginTransaction();
     good = dao.queryUniqueBean(Goods.class, "select * from goods where gid=?", gid);
     dao.commitTransaction();
   } catch (Exception e) {
     e.printStackTrace();
     dao.rollbackTransaction();
   } finally {
     dao.close();
   }
   return good;
 }
Пример #3
0
 public List<Goods> getDiscountGoods(String type) {
   Dao dao = DaoCreater.createDao();
   List<Goods> goodslist = null;
   try {
     dao.beginTransaction();
     goodslist =
         dao.queryBeanList(
             Goods.class, "select * from goods where gtype=" + type + " order by gcount desc");
     dao.commitTransaction();
   } catch (Exception e) {
     e.printStackTrace();
     dao.rollbackTransaction();
   } finally {
     dao.close();
   }
   return goodslist;
 }
Пример #4
0
 /** 商品识别: */
 public List<Goods> supply(String typeid, String foodid) {
   Dao dao = DaoCreater.createDao();
   List<Goods> goods = null;
   try {
     dao.beginTransaction();
     goods =
         dao.queryBeanList(
             Goods.class, "select * from goods where gtype=? and gkindcode=?", typeid, foodid);
     dao.commitTransaction();
   } catch (Exception e) {
     e.printStackTrace();
     dao.rollbackTransaction();
   } finally {
     dao.close();
   }
   return goods;
 }
Пример #5
0
 /** 删除 */
 public void delete(int[] gid) {
   Dao dao = DaoCreater.createDao();
   try {
     dao.beginTransaction();
     PreSQL predql = dao.preSQL("delete from goods where gid=?");
     if (gid.length > 0) {
       for (int i = 0; i < gid.length; i++) {
         predql.update(gid[i]);
       }
     }
     dao.commitTransaction();
   } catch (Exception e) {
     e.printStackTrace();
     dao.rollbackTransaction();
   } finally {
     dao.close();
   }
 }