示例#1
0
  /**
   * @param exam
   * @return
   */
  public long addExam(Exam exam) {
    long id = this.addExam(exam.getTitle(), exam.getComment(), exam.getLecture_id());
    exam.setId(id);

    if (exam.getDate() != null) {
      this.setExamDate(exam, exam.getDate());
    }

    return id;
  }
示例#2
0
  /**
   * @param exam
   * @return
   */
  public int updateExam(Exam exam) {
    ContentValues values = new ContentValues();

    if (!exam.getTitle().isEmpty()) {
      values.put(HLPExams.COL_TITLE, exam.getTitle());
    }

    if (!exam.getComment().isEmpty()) {
      values.put(HLPExams.COL_COMMENT, exam.getComment());
    }

    if (exam.getLecture_id() > 0) {
      values.put(HLPExams.COL_LECTURE_ID, exam.getLecture_id());
    }

    int ret =
        this.hlpExams.openCon().update(HLPExams.TABLE_NAME, values, "_id = " + exam.getId(), null);

    Log.i(DBsettings.LOG_TAG_EXAMS, "Update res.: " + ret);

    return ret;
  }