Exemplo n.º 1
0
 public static LinkedList<P6004> getList(Date date) {
   byte dayOfWeek = Common.getDayOfWeek(date);
   int WeekOfTerm = Common.getWeekOfTerm(date);
   int mono = WeekOfTerm % 2 == 0 ? 2 : 1;
   LinkedList<P6004> clist = new LinkedList<P6004>();
   SQLiteDatabase db = DALHelper.getInstance().getReadableDatabase();
   Cursor cursor =
       db.rawQuery(
           "select * from "
               + TABLE_NAME
               + " where "
               + COLUMN_WEEKTIME
               + "=? and "
               + COLUMN_DAYTIME
               + "=? and "
               + COLUMN_STARTTIME
               + "<=? "
               + "and "
               + COLUMN_ENDTIME
               + ">=? ",
           new String[] {
             String.valueOf(mono),
             String.valueOf(dayOfWeek),
             String.valueOf(WeekOfTerm),
             String.valueOf(WeekOfTerm)
           });
   LinkedList<P6004> list = modelToLinkedList(cursor, clist);
   db.close();
   return list;
 }
Exemplo n.º 2
0
 public static int count() {
   SQLiteDatabase db = DALHelper.getInstance().getReadableDatabase();
   Cursor cursor = db.rawQuery("select count(*) from " + TABLE_NAME, null);
   int count = 0;
   if (cursor.moveToLast()) {
     count = cursor.getInt(0);
   }
   db.close();
   return count;
 }
Exemplo n.º 3
0
 public static P6004 getModel(int id) {
   SQLiteDatabase db = DALHelper.getInstance().getReadableDatabase();
   Cursor cursor =
       db.rawQuery(
           "select * from " + TABLE_NAME + " where " + COLUMN_ID + "=?",
           new String[] {String.valueOf(id)});
   P6004 model;
   if (cursor.moveToFirst()) {
     model = cursorToModel(cursor);
   } else {
     model = null;
   }
   db.close();
   return model;
 }
Exemplo n.º 4
0
 public static LinkedList<P6004> getLinkedList() {
   LinkedList<P6004> clist = new LinkedList<P6004>();
   SQLiteDatabase db = DALHelper.getInstance().getReadableDatabase();
   Cursor cursor =
       db.rawQuery(
           "select * from "
               + TABLE_NAME
               + " order by "
               + COLUMN_DAYTIME
               + ","
               + COLUMN_COURSETIME1,
           null);
   LinkedList<P6004> list = modelToLinkedList(cursor, clist);
   db.close();
   return list;
 }
Exemplo n.º 5
0
 public static void update(P6004 course) {
   SQLiteDatabase db = DALHelper.getInstance().getWritableDatabase();
   db.execSQL(
       "update "
           + TABLE_NAME
           + " set "
           + COLUMN_WEEKTIME
           + "=?,"
           + COLUMN_DAYTIME
           + "=?,"
           + COLUMN_COURSETIME1
           + "=?,"
           + COLUMN_COURSETIME2
           + "=?,"
           + COLUMN_STARTTIME
           + "=?,"
           + COLUMN_ENDTIME
           + "=?,"
           + COLUMN_NAME
           + "=?,"
           + COLUMN_TEACHER
           + "=?,"
           + COLUMN_SITE
           + "=?,"
           + COLUMN_STATU
           + "=?,"
           + COLUMN_SERVERID
           + "=? where "
           + COLUMN_ID
           + "=?",
       new Object[] {
         course.getWeektime(),
         course.getDaytime(),
         course.getCoursetime1(),
         course.getCoursetime2(),
         course.getStarttime(),
         course.getEndtime(),
         course.getName(),
         course.getTeacher(),
         course.getSite(),
         course.getStatu(),
         course.getServerid(),
         course.getId()
       });
   db.close();
 }
Exemplo n.º 6
0
 public static void save(P6004 course) {
   SQLiteDatabase db = DALHelper.getInstance().getWritableDatabase();
   db.execSQL(
       "insert into "
           + TABLE_NAME
           + " ("
           + COLUMN_WEEKTIME
           + ","
           + COLUMN_DAYTIME
           + ","
           + COLUMN_COURSETIME1
           + ","
           + COLUMN_COURSETIME2
           + ","
           + COLUMN_STARTTIME
           + ","
           + COLUMN_ENDTIME
           + ","
           + COLUMN_NAME
           + ","
           + COLUMN_TEACHER
           + ","
           + COLUMN_SITE
           + ","
           + COLUMN_STATU
           + ","
           + COLUMN_SERVERID
           + ")"
           + "  values (?,?,?,?,?,?,?,?,?,?,?)",
       new Object[] {
         course.getWeektime(),
         course.getDaytime(),
         course.getCoursetime1(),
         course.getCoursetime2(),
         course.getStarttime(),
         course.getEndtime(),
         course.getName(),
         course.getTeacher(),
         course.getSite(),
         course.getStatu(),
         course.getServerid()
       });
   db.close();
 }
Exemplo n.º 7
0
 public static void delete() {
   SQLiteDatabase db = DALHelper.getInstance().getWritableDatabase();
   db.execSQL("delete from " + TABLE_NAME);
   db.close();
 }
Exemplo n.º 8
0
 public static void delete(int id) {
   SQLiteDatabase db = DALHelper.getInstance().getWritableDatabase();
   db.execSQL("delete from " + TABLE_NAME + " where " + COLUMN_ID + "=?", new Object[] {id});
   db.close();
 }