A Java Swing desktop payroll application for MotorPH. It reads employee data from a CSV file, lets payroll staff manage those records and compute salaries, and lets an individual employee log in to view only their own record and payslip.
The program is written in a procedural style. Records are kept in memory as an ArrayList<String[]> (one
String array per employee), the logic is built from static methods, and the
work is split across three areas, the screen (MotorPHPayroll), file handling
(CsvUtil), and the salary math (SalaryComputationModule).
When the program starts, a login window appears. Everyone uses the password
12345.
- Payroll staff — type
payroll_staffas the username. This unlocks full access to every record and every action. - Employee — type your Employee Number (for example
10001) as the username. The number is checked againstemployee_details.csv; if it exists, you are logged in as that employee. An unknown number or a wrong password shows an error.
After logging in, the main window shows three parts:
- An input form with fields for Employee Number, Employee Name (Last, First), SSS Number, PhilHealth Number, TIN Number, Pag-IBIG Number, Basic Salary, and Pay Coverage.
- A JTable listing Employee #, Last Name, First Name, SSS #, PhilHealth #, TIN #, and Pag-IBIG #.
- An output area where computed salaries and payslips are printed.
Clicking a row in the table fills the form with that employee's details.
- View – loads and refreshes the table from
employee_details.csv. - Add – validates the form, blocks duplicate Employee Numbers, appends the new record to the CSV, and refreshes the table.
- Update – saves the edited form values back to the selected record and rewrites the CSV.
- Delete – asks for confirmation, removes the selected record, and rewrites the CSV.
- Compute Salaries – computes Gross Pay, all deductions, and Net Pay for
every employee, prints the results in the output area, and saves them to
salary_results.csv. - Clear – empties the form and the output area.
- Logout – closes the main window and returns to the login screen.
- View Payslip (employee login only) – shows that employee's payslip,
including hours logged from
attendance_record.csv.
A payroll-staff login can use every button and see all 34 records. An employee login is view-only: the table is filtered to that employee's own row, and the Add, Update, Delete, and Compute Salaries buttons are disabled.
All salary math lives in SalaryComputationModule.java. Each method takes
array parameters and returns an array, so the whole list of employees is
processed at once:
- Gross Pay = the employee's Basic Salary.
- SSS – taken from the standard contribution bracket table.
- PhilHealth –
150up to10,000, otherwise 1.5% of salary, capped at900. - Pag-IBIG – 1% or 2% of salary, capped at
100. - Withholding Tax – BIR tax brackets applied to taxable income (gross minus the three contributions above).
- Total Deductions = SSS + PhilHealth + Pag-IBIG + Tax.
- Net Pay = Gross Pay − Total Deductions.
All user input is checked before anything is saved, and errors are shown with
JOptionPane message dialogs:
- Employee Number must be a whole number and cannot be blank.
- Employee Name, SSS, PhilHealth, TIN, and Pag-IBIG numbers are required.
- Basic Salary must be numeric and not negative.
- Adding a record fails if the Employee Number already exists.
- Delete asks for confirmation and refuses when nothing is selected.
| File | Purpose |
|---|---|
Main.java |
Program entry point; starts the login window on the Swing thread. |
MotorPHPayroll.java |
Login screen, main window, all buttons and event handling, validation, and the Add / Update / Delete / Compute actions. |
CsvUtil.java |
Reusable file-handling helpers: read a CSV, write a CSV, and parse money values. |
SalaryComputationModule.java |
The salary math (gross pay, deductions, and net pay). |
employee_details.csv |
The employee database (19 columns). |
attendance_record.csv |
Log-in / log-out times, used to total hours on the payslip. |
salary_results.csv |
Generated by Compute Salaries (Employee Name, Gross Pay, Deductions, Net Pay). |
Open the project, make sure employee_details.csv and
attendance_record.csv are in the project folder, then run Main.java via terminal or on your respective IDE.
javac -d build src/*.java
java -cp build Main
- Java (Swing for the GUI)
ArrayListfor in-memory storage- CSV files for data storage
- VSCode
[A1101] Computer Programming 2 - Group 25.