Android Open Source - philippine-income-tax-android Phil Health Model






From Project

Back to project page philippine-income-tax-android.

License

The source code is released under:

GNU General Public License

If you think the Android project philippine-income-tax-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.chrisbjr.android.philippineincometax.models;
//  w  w  w .  j  a va 2  s.c o  m
import java.sql.SQLException;
import java.util.List;

import com.chrisbjr.android.philippineincometax.db.DatabaseHelper;
import com.chrisbjr.android.philippineincometax.db.DatabaseManager;
import com.chrisbjr.android.philippineincometax.objects.Philhealth;
import android.content.Context;

import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.stmt.PreparedQuery;
import com.j256.ormlite.stmt.QueryBuilder;

public class PhilHealthModel {
  private DatabaseHelper db;
  Dao<Philhealth, Integer> philhealthDao;

  public PhilHealthModel(Context ctx) {
    try {
      DatabaseManager dbManager = new DatabaseManager();
      db = dbManager.getHelper(ctx);
      philhealthDao = db.getPhilhealthDao();
    } catch (SQLException e) {
      // TODO: Exception Handling
      e.printStackTrace();
    }

  }

  public int create(Philhealth philhealth) {
    try {
      return philhealthDao.create(philhealth);
    } catch (SQLException e) {
      // TODO: Exception Handling
      e.printStackTrace();
    }
    return 0;
  }

  public int update(Philhealth philhealth) {
    try {
      return philhealthDao.update(philhealth);
    } catch (SQLException e) {
      // TODO: Exception Handling
      e.printStackTrace();
    }
    return 0;
  }

  public int delete(Philhealth philhealth) {
    try {
      return philhealthDao.delete(philhealth);
    } catch (SQLException e) {
      // TODO: Exception Handling
      e.printStackTrace();
    }
    return 0;
  }

  public List<Philhealth> getAll() {
    try {
      return philhealthDao.queryForAll();
    } catch (SQLException e) {
      // TODO: Exception Handling
      e.printStackTrace();
    }
    return null;
  }

  public Philhealth getPhilhealth(double salaryRate, int monthlyFrequency) {
    salaryRate = salaryRate * monthlyFrequency;
    QueryBuilder<Philhealth, Integer> qb = philhealthDao.queryBuilder();
    try {
      PreparedQuery<Philhealth> preparedQuery = qb.where()
          .le("salaryRateFrom", salaryRate).and()
          .ge("salaryRateTo", salaryRate).prepare();
      return philhealthDao.queryForFirst(preparedQuery);
    } catch (SQLException e) {
      e.printStackTrace();
    }

    return null;
  }
}




Java Source Code List

com.chrisbjr.android.philippineincometax.MainActivity.java
com.chrisbjr.android.philippineincometax.adapters.IncomeAdapter.java
com.chrisbjr.android.philippineincometax.calculator.CalculatorBrain.java
com.chrisbjr.android.philippineincometax.db.DatabaseConfigUtil.java
com.chrisbjr.android.philippineincometax.db.DatabaseHelper.java
com.chrisbjr.android.philippineincometax.db.DatabaseManager.java
com.chrisbjr.android.philippineincometax.models.IncomeTaxCalculationModel.java
com.chrisbjr.android.philippineincometax.models.NonTaxableIncomeModel.java
com.chrisbjr.android.philippineincometax.models.PagibigModel.java
com.chrisbjr.android.philippineincometax.models.PhilHealthModel.java
com.chrisbjr.android.philippineincometax.models.SssModel.java
com.chrisbjr.android.philippineincometax.models.TaxableIncomeModel.java
com.chrisbjr.android.philippineincometax.models.WithholdingTaxModel.java
com.chrisbjr.android.philippineincometax.objects.IncomeTaxCalculation.java
com.chrisbjr.android.philippineincometax.objects.NonTaxableIncome.java
com.chrisbjr.android.philippineincometax.objects.Pagibig.java
com.chrisbjr.android.philippineincometax.objects.Philhealth.java
com.chrisbjr.android.philippineincometax.objects.Sss.java
com.chrisbjr.android.philippineincometax.objects.TaxableIncome.java
com.chrisbjr.android.philippineincometax.objects.WithholdingTaxType.java
com.chrisbjr.android.philippineincometax.objects.WithholdingTax.java