예제 #1
0
파일: FoodService.java 프로젝트: hjzgg/five
 /** 查询所有商品 */
 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
파일: FoodService.java 프로젝트: hjzgg/five
 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
파일: FoodService.java 프로젝트: hjzgg/five
 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
파일: FoodService.java 프로젝트: hjzgg/five
 /** 商品识别: */
 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
파일: FoodService.java 프로젝트: hjzgg/five
 /** 删除 */
 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();
   }
 }