Exemple #1
0
 /** 2015-11-6 段彬彬 首次创建 保存油耗 */
 public int saveOil(Context context, Oil oil) {
   dbw = DBHelper.getDBHelper(context).getWritableDatabase();
   dbw.execSQL(
       "insert into oil(litre,cost,kilo,systime) values(?,?,?,?)",
       new Object[] {oil.getLitre(), oil.getCost(), oil.getKilo(), oil.getSystime()});
   dbw.close();
   return Constants.SUCCESS;
 }
Exemple #2
0
 /** 2015-11-6 段彬彬 首次创建 查询油耗明细 */
 public ArrayList<Oil> queryOil(Context context, String beginTime, String endTime) {
   ArrayList<Oil> list = new ArrayList<Oil>();
   Oil oil = null;
   dbr = DBHelper.getDBHelper(context).getReadableDatabase();
   Cursor cursor =
       dbr.rawQuery(
           "select litre,cost,kilo,systime,id from oil where systime between ? and ? ORDER BY id DESC",
           new String[] {beginTime, endTime});
   while (cursor.moveToNext()) {
     oil = new Oil();
     double litre = cursor.getDouble(0);
     int cost = cursor.getInt(1);
     int kilo = cursor.getInt(2);
     String systime = cursor.getString(3);
     int id = cursor.getInt(4);
     oil.setLitre(litre);
     oil.setKilo(kilo);
     oil.setCost(cost);
     oil.setSystime(systime);
     oil.setId(id);
     list.add(oil);
   }
   cursor.close();
   dbr.close();
   return list;
 }