public boolean update(User user) { if (user.getUser_name() != null && user.getUser_name() != "") { dbOperator.update( String.format(UPDATE_USER, "user_name", user.getUser_name(), user.getUser_id())); } if (user.getDepartment_id() > 0) { dbOperator.update( String.format(UPDATE_USER, "department_id", user.getDepartment_id(), user.getUser_id())); } if (user.getStaff_position() != null && user.getStaff_position() != "") { dbOperator.update( String.format( UPDATE_USER, "staff_position", user.getStaff_position(), user.getUser_id())); } if (user.getPwd() != null && user.getPwd() != "") { dbOperator.update(String.format(UPDATE_USER, "pwd", user.getPwd(), user.getUser_id())); } return true; }
public boolean add(User user) { return dbOperator.add( String.format( ADD_USER, user.getUser_id(), user.getUser_name(), user.getPwd(), user.getDepartment_id() > 0 ? user.getDepartment_id() : null, user.getStaff_position() != null ? "'" + user.getStaff_position() + "'" : null, user.getTotal_annual_leave() != 0 ? user.getTotal_annual_leave() : null)); }