public int createEmployee(Employee employee, List<Skill> selectedSkills) { open(); employee.setId((int) createBasicEmployee(employee)); for (Skill skill : selectedSkills) { addEmployeeSkill(employee, skill); } close(); return employee.getId(); }
public List<Employee> getEmployeeList() { open(); String[] columns = new String[] {EMPLOYEE_NAME, EMPLOYEE_ID}; Cursor c = myDatabase.query(EMPLOYEE_TABLE, columns, null, null, null, null, null); List<Employee> employees = new ArrayList<Employee>(); int iTableID = c.getColumnIndex(EMPLOYEE_ID); int iId = c.getColumnIndex(EMPLOYEE_NAME); if (c != null) { for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) { Employee e = new Employee(); e.setId(c.getInt(iTableID)); e.setName(c.getString(iId)); employees.add(e); } } close(); return employees; }
public Employee getEmployee(int id) { open(); Employee e = new Employee(); Cursor c = myDatabase.rawQuery( "SELECT * FROM " + EMPLOYEE_TABLE + " WHERE " + EMPLOYEE_ID + " = ? ORDER BY " + EMPLOYEE_NAME + " ASC", new String[] {Integer.toString(id)}); int iTableId = c.getColumnIndex(EMPLOYEE_ID); int iId = c.getColumnIndex(EMPLOYEE_NAME); if (c != null) { c.moveToFirst(); e.setId(c.getInt(iTableId)); e.setName(c.getString(iId)); } close(); return e; }