コード例 #1
0
  /*
  GET PASSED EXAMS
   */
  public Cursor getPassedExams() {

    database = course_dbHelper.getWritableDatabase();

    String where = DB_ABSTRACTS.DBCourse.PASSED_COLUMN + " = " + 1;

    Cursor cursor =
        database.query(
            DB_ABSTRACTS.DBCourse.DATABASE_TABLE,
            examColumns,
            where,
            null,
            null,
            null,
            DB_ABSTRACTS.DBCourse.PASS_MARK_COLUMN + " ASC");

    if (cursor.moveToFirst()) {
      do {
        Course course = new Course();
        course.setId(cursor.getInt(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.KEY_ID)));
        course.setName(cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.NAME_COLUMN)));
        course.setPassed(cursor.getInt(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.PASSED_COLUMN)));
        course.setPass_mark(
            cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.PASS_MARK_COLUMN)));
      } while (cursor.moveToNext());
    }
    return cursor;
  }
コード例 #2
0
  /*
  GET A SINGLE COURSE
   */
  public Course getCourse(long course_id) {

    try {
      this.open();
    } catch (SQLException e) {
      e.printStackTrace();
    }

    String where = DB_ABSTRACTS.DBCourse.KEY_ID + " = " + course_id;
    // SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm");
    Professor prof = new Professor();

    Cursor cursor =
        database.query(
            DB_ABSTRACTS.DBTasks.DATABASE_TABLE, allColumns, where, null, null, null, null);
    Course course = new Course();
    course.setId(cursor.getInt(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.KEY_ID)));
    course.setName(cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.NAME_COLUMN)));
    prof.setProfessor_name(
        cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.PROFESSOR_COLUMN)));
    course.setProfessor(prof);
    course.setSemester(
        cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.SEMESTER_COLUMN)));
    course.setRoom(cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.ROOM_COLUMN)));
    course.setPassed(cursor.getInt(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.PASSED_COLUMN)));

    return course;
  }
コード例 #3
0
  /*
     GET COURSE WITH SPECIFIC COURSE COLUMNS
     RETURNS A TABLE CONTAINING COURSE RELATED INFORMATION
  */
  public Cursor getAllCourses() {

    database = course_dbHelper.getWritableDatabase();

    Cursor cursor =
        database.query(
            DB_ABSTRACTS.DBCourse.DATABASE_TABLE,
            courseColumns,
            null,
            null,
            null,
            null,
            DB_ABSTRACTS.DBCourse.NAME_COLUMN + " ASC");
    Professor prof = new Professor();

    if (cursor.moveToFirst()) {
      do {
        Course course = new Course();
        course.setId(cursor.getInt(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.KEY_ID)));
        course.setName(cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.NAME_COLUMN)));
        prof.setProfessor_name(
            cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.PROFESSOR_COLUMN)));
        course.setProfessor(prof);
        course.setRoom(cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.ROOM_COLUMN)));
        course.setSemester(
            cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.SEMESTER_COLUMN)));
      } while (cursor.moveToNext());
    }

    return cursor;
  }