Esempio n. 1
0
  public void save() {
    mName = etName.getText().toString();
    mNumber = etNumber.getText().toString();
    relation = etRelation.getText().toString();
    mAge = etAge.getText().toString();
    mBloodGroup = String.valueOf(etBloodGroup.getSelectedItem());
    mWeight = etWeight.getText().toString();
    mHeight = etHeight.getText().toString();
    mDateOfBirth = etDateOfBirth.getText().toString();
    mSpecialNotes = etSpecialNotes.getText().toString();

    // Assign values in the ICareProfile
    FamilyProfileClass profileDataInsert = new FamilyProfileClass();
    profileDataInsert.setFname(mName);
    profileDataInsert.setFNumber(mNumber);
    profileDataInsert.setFrelationship(mName);
    profileDataInsert.setFage(mAge);
    profileDataInsert.setFbloodGroup(mBloodGroup);
    profileDataInsert.setFweight(mWeight);
    profileDataInsert.setFheight(mHeight);
    profileDataInsert.setFdateOfBirth(mDateOfBirth);
    profileDataInsert.setFspecialNotes(mSpecialNotes);

    /*
     * if update is needed then update otherwise submit
     */
    profileDataSource = new FamilyProfileDataSource(this);
    if (profileDataSource.insert(profileDataInsert) == true) {
      toast = Toast.makeText(this, getString(R.string.successfullySaved), Toast.LENGTH_LONG);
      toast.show();
      startActivity(new Intent(FamilyProfile.this, DisplayAllFamilyProfile.class));
    } else {
      toast = Toast.makeText(this, getString(R.string.notSaved), Toast.LENGTH_LONG);
      toast.show();
    }
  }