Example #1
0
  public boolean update(Vaccine vaccine, int id, int pID) {
    int reminder = 0;
    if (vaccine.isRemind()) reminder = 1;

    EventManagement eventManagement = new EventManagement(this.context);
    int eventId = this.getVaccine(id).getEventID();
    vaccine.setProfileID(pID);

    ContentValues values = new ContentValues();
    values.put(DBConstants.VACCINE, vaccine.getVaccine());
    values.put(DBConstants.DATE, vaccine.getDateTime().getTime().getTime() + "");
    values.put(DBConstants.REMINDER, reminder);
    values.put(DBConstants.PROFILE_ID, pID);
    if (vaccine.isRemind()) {
      if (getVaccine(id).isRemind()) {
        eventManagement.updateVaccineEvent(eventId, vaccine);
        values.put(DBConstants.EVENT_ID, eventId);
      } else {
        values.put(DBConstants.EVENT_ID, eventManagement.insertVaccineEvent(vaccine));
      }

    } else {
      eventManagement.delete(eventId);
    }

    openDB();
    int updated = db.update(DBConstants.VACCINE_TABLE, values, DBConstants.ID + "=" + id, null);
    clodeDB();
    if (updated > 0) return true;
    return false;
  }
Example #2
0
 public boolean delete(int id) {
   EventManagement management = new EventManagement(this.context);
   int eventId = this.getVaccine(id).getEventID();
   openDB();
   if (management.delete(eventId)) {
     int deleted = db.delete(DBConstants.VACCINE_TABLE, DBConstants.ID + "=" + id, null);
     clodeDB();
     if (deleted > 0) return true;
   }
   return false;
 }
Example #3
0
  public boolean insert(Vaccine vaccine, int pID) {
    int reminder = 0;
    if (vaccine.isRemind()) reminder = 1;
    vaccine.setProfileID(pID);

    ContentValues values = new ContentValues();
    values.put(DBConstants.VACCINE, vaccine.getVaccine());
    values.put(DBConstants.DATE, vaccine.getDateTime().getTime().getTime() + "");
    values.put(DBConstants.REMINDER, reminder);
    values.put(DBConstants.PROFILE_ID, pID);

    if (vaccine.isRemind()) {
      EventManagement eventManagement = new EventManagement(this.context);
      values.put(DBConstants.EVENT_ID, eventManagement.insertVaccineEvent(vaccine));
    }

    openDB();
    long inserted = db.insert(DBConstants.VACCINE_TABLE, null, values);
    clodeDB();
    if (inserted > 0) return true;
    return false;
  }