Package my.edu.tarc.dco.bookrentalpos
Class StaffManager
public class StaffManager extends Manager<Staff>
Class to load Staff data for the POS system
- Version:
- 1.0
- Author:
- Looz
-
Constructor Summary
Constructors Constructor Description StaffManager(DBManager db) -
Method Summary
Modifier and Type Method Description booleanadd(Staff stf)Register a new staff into databaseStaffgetById(int staffID)Get staff object reference by idStaffgetByName(String name)Get staff object reference by nameStaff[]getCache()This function return a copy of the staff list loaded from the databaseStaffgetLogOnStaff()intgetStaffCount()intlogin(String usrName, String pw)Used to check if the provided username and password matches databasevoidlogOut()Set logOnStaff to nullvoidreload()Reload the staff databasebooleanremove(Staff staff)Remove staff from the database
NOTE: The removed staff will not appear in other table as wellbooleanupdate(Staff stf)Update staff information to database
-
Constructor Details
-
Method Details
-
reload
public void reload()Reload the staff database -
login
Used to check if the provided username and password matches database- Parameters:
usrName- username of the Staffpw- password of the staff in plain text- Returns:
- staff ID if it matches, returns -1 if nothing matches
-
getById
Get staff object reference by id -
getByName
Get staff object reference by name -
getCache
This function return a copy of the staff list loaded from the database- Specified by:
getCachein classManager<Staff>- Returns:
- an array of Staff, use StaffManager.getStaffCount() to get the number of entry
- See Also:
getStaffCount()
-
getLogOnStaff
- Returns:
- staff that is log on using login() function
-
add
Register a new staff into database- Specified by:
addin classManager<Staff>- Parameters:
stf- Staff object without ID- Returns:
- true if registration was successful, false if same staff name existed
- See Also:
Staff(java.lang.String, java.lang.String)
-
update
Update staff information to database -
remove
Remove staff from the database
NOTE: The removed staff will not appear in other table as well -
logOut
public void logOut()Set logOnStaff to null- See Also:
logOnStaff
-
getStaffCount
public int getStaffCount()- Returns:
- amount of staff loaded from database
-