is211 data file & object structure project

30
1 “Zero Gravity Payroll System”. IS211 Data file & Object Structure Presented by: Romel Lacorte, BSIT 3 rd yr. Jayson Laurente, BSIT 2 nd yr. Presented to: PROF. MARTZEL P. ARDENA October 28, 2015

Upload: boom-laurente

Post on 13-Apr-2016

17 views

Category:

Documents


0 download

DESCRIPTION

Zero Gravity Payroll System - A project for our subject in Data Struct last October 28, 2015

TRANSCRIPT

Page 1: IS211 Data file & Object Structure Project

1

“Zero Gravity Payroll System”.

IS211 Data file & Object Structure

Presented by:

Romel Lacorte, BSIT 3 rd yr.

Jayson Laurente, BSIT 2 nd yr.

Presented to:

PROF. MARTZEL P. ARDENA

October 28, 2015

Page 2: IS211 Data file & Object Structure Project

2

TABLE OF CONTENTS

Introduction --------------------------------------------------------------------------------------------------------------- 3

Purpose and Definition ----------------------------------------------------------------------------------------------- 4

Project Features -------------------------------------------------------------------------------------------------------- 5

Scope and Limitations ------------------------------------------------------------------------------------------------ 5

Hardware requirements ---------------------------------------------------------------------------------------------- 5

Manual of Instructions ------------------------------------------------------------------------------------------------ 6

Log In Class (GUI) ----------------------------------------------------------------------------------------------------- 7

Main Class (GUI) ------------------------------------------------------------------------------------------------------- 8

Transaction Class (GUI) ---------------------------------------------------------------------------------------------- 9

Add Deduction Class (GUI) ----------------------------------------------------------------------------------------- 10

Record Class (GUI) --------------------------------------------------------------------------------------------------- 10

Added Deduction Class (GUI) -------------------------------------------------------------------------------------- 11

Source Code ------------------------------------------------------------------------------------------------------------ 12

Log In Class (Source C) ---------------------------------------------------------------------------------------------- 12

Main Class (Source C) ------------------------------------------------------------------------------------------------ 14

Record Class (Source C) -------------------------------------------------------------------------------------------- 16

Transaction Class (Source C) -------------------------------------------------------------------------------------- 18

Page 3: IS211 Data file & Object Structure Project

3

INTRODUCTION

Background of the Study

Nowadays almost all of the companies either small or big are using modernized technologies to make

transaction fast, accurate, easy to use and to avoid mistakes. By using a computerize system it saves more

time and reduce human error.

The proposed payroll system helps the human to computes the complex transactions one of which is

the computation of the salary for the employee.

That’s why we have developed a system for business owners to help them in there every

transaction when it comes to wages of the employee. The title of the project is “Zero Gravity Payroll

System V2.0”, it designed for small business owners like convenience stores or any other small

businesses. Its handles the salary calculations, and also stores data for future information.

A Computerized Payroll System will not only provide accurate calculation and fast process of

Payroll transaction but it will secure data through security implementation and accordingly arrange

files provided by a well-designed database that will produce a paperless environment.

Page 4: IS211 Data file & Object Structure Project

4

Purpose and Definition

Objectives

The objective of the study is:

• Calculate the total salary of the employee• To give an ease to the owners• Store data for future references• To provide miscalculation

Project Definition

This project title as “Zero Gravity Payroll System” comes under the Relational Database

Management System (RDBMS). This project is developed with the use of JAVA as programming

language.

Program Tools:

1. JAVA-JRE 1.7

2. Microsoft Office Access 2007 Database

Page 5: IS211 Data file & Object Structure Project

5

Features

Project Features

Log-in

Transaction

View Record

Add Deduction

Calculate net salary

Scope and Limitations

Scope

The coverage of the study is for calculation of the salary for the employee and preparing for pay slip. It is

designed to develop a computerized payroll system; it overrides the regular wages of the employee derived

from; Hours Worked, Rate per Hour, Overtime Pay, SSS, Pag-Ibig, Phil-Health, Tax, Late/absences. It’s also

stores data for future references.

Limitations

The project limits to small business owners only, it does not have Loans, cash advance, special and Legal

Holiday. It is use for presentation and partial fulfilment of: CS211L 2341 Object-Oriented Programming does

not support online transactions.

Hardware and Software Requirements

HARDWARE:

Processor Intel(R) Celeron(R) CPU877@ 1.Processor Speed 1.8 GHZ Hard Disk Space 120 GB (min.)Memory 512 MB (1GB recommended)

SOFTWARE:

Operating System Windows 7 and higher Database Server Microsoft Office Access 2007 Database

Front end JAVA-JRE 1.7

Page 6: IS211 Data file & Object Structure Project

6

MANUAL OF INSTRUCTIONS

System Prototyping

This project includes the following modules for development of the project. These are as follows:

1. LOGIN CLASS

This form shows the Login password when user enter a valid password, when user enter a valid then he/she can operate the application.

2. MAIN CLASS

This form provides the option to Transaction, View Records, Exit.

3. TRANSACTION CLASS

This form provides an Employee Information, below are the following input, Identification Number, Full Name, Age, Position.

Gross Pay, Hours Worked, Rate per-Hour, Overtime Pay,

Deduction, SSS, Pag-Ibig, Phil-Health, Tax, Late/Absences,

4. ADD DEDUCTION CLASS

This form provides the adding of deduction of the employee for example, company T-shirt.

5. RECORD CLASS

This form provides the data of the employee for references, it uses database.

6. ADDED DEDUCTION CLASS

This form will view the added deduction of the employee.

Page 7: IS211 Data file & Object Structure Project

7

LOGIN CLASS

Page 8: IS211 Data file & Object Structure Project

8

MAIN CLASS

Page 9: IS211 Data file & Object Structure Project

9

TRANSACTION CLASS

Page 10: IS211 Data file & Object Structure Project

10

RECORD CLASS

ADD DEDUCTION CLASS

Page 11: IS211 Data file & Object Structure Project

11

SOURCE C

ADDED DEDUCTION CLASS

Page 12: IS211 Data file & Object Structure Project

12

LOGIN CLASS

import java.awt.BorderLayout;import java.awt.Color;import java.awt.GridBagLayout;import java.awt.GridLayout;import java.awt.Window;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;

import javax.swing.AbstractButton;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JTextField;import javax.swing.SpringLayout;import javax.swing.SwingConstants;import javax.swing.plaf.TextUI;import javax.xml.soap.Text;

public class login extends JFrame implements ActionListener{JTextField txtPassword;JButton btnEnter;JPanel panel;

public login() {txtPassword=new JPasswordField(20);txtPassword.setToolTipText("ProjectX Zero Gravity Upgraded v2.0");btnEnter=new JButton("LOG-IN");btnEnter.setToolTipText("ProjectX Zero Gravity Upgraded v2.0");btnEnter.addActionListener(this);Color color = new Color(0, 0, 0, 150); //r,g,b,alpha

panel=new JPanel();panel.setLayout(new GridBagLayout());panel.setBackground(color);

``````````````````````` panel.setToolTipText("ProjectX Zero Gravity Upgraded v2.0");

panel.add(txtPassword);panel.add(btnEnter);

add(panel);

getRootPane().setDefaultButton(btnEnter);setFocusTraversalKeysEnabled(false);setSize(java.awt.Toolkit.getDefaultToolkit().getScreenSize());setUndecorated(true);setVisible(true);

}

Page 13: IS211 Data file & Object Structure Project

13

public static void main(String[] args) {new login();

}

public void actionPerformed(ActionEvent arg0) {String password="adminzero";if(arg0.getSource().equals(btnEnter)){

if(password.equals(txtPassword.getText())){JOptionPane.showMessageDialog(txtPassword, "ACCESS GRANTED !\

nWELCOME TO ZERO GRAVITY UPGRADE PAYROLL SYSTEM","VALID",JOptionPane.INFORMATION_MESSAGE);

Main main = new Main();main.setVisible(true);dispose();//setVisible(false);

}else{

JOptionPane.showMessageDialog(txtPassword, "ACCESS DENIED!","INVALID",JOptionPane.ERROR_MESSAGE);

}}

}

}

MAIN CLASS

Page 14: IS211 Data file & Object Structure Project

14

importjava.awt.BorderLayout;importjava.awt.EventQueue;

importjavax.swing.JFrame;importjavax.swing.JOptionPane;importjavax.swing.JPanel;importjavax.swing.border.EmptyBorder;importjavax.swing.JLabel;importjava.awt.Font;importjava.awt.Color;importjavax.swing.JButton;importjava.awt.event.ActionListener;importjava.awt.event.ActionEvent;importjavax.swing.ImageIcon;importjava.awt.Toolkit;

public class Main extends JFrame {

privateJPanelcontentPane;

/** * Launch the application. */public static void main(String[] args) {

EventQueue.invokeLater(new Runnable() {public void run() {

try {Main frame = new Main();frame.setVisible(true);

} catch (Exception e) {e.printStackTrace();

}}

});}

/** * Create the frame. */public Main() {

setIconImage(Toolkit.getDefaultToolkit().getImage("C:\\pics\\accentServices.jpg"));setTitle("Zero Gravity Payroll System");setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setBounds(100, 100, 338, 258);contentPane = new JPanel();contentPane.setBackground(new Color(204, 204, 255));contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));setContentPane(contentPane);contentPane.setLayout(null);

JLabellblPayrollSystem = new JLabel("PAYROLL SYSTEM");lblPayrollSystem.setForeground(new Color(255, 51, 51));lblPayrollSystem.setFont(new Font("Algerian", Font.BOLD, 19));lblPayrollSystem.setBounds(83, 11, 177, 73);contentPane.add(lblPayrollSystem);

Page 15: IS211 Data file & Object Structure Project

15

JButtonbtnTransactions = new JButton("Transactions");btnTransactions.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

PayrollData payroll = new PayrollData();payroll.setVisible(true);dispose();

}});btnTransactions.setBackground(Color.CYAN);btnTransactions.setBounds(103, 95, 118, 23);contentPane.add(btnTransactions);

JButtonbtnViewRecords = new JButton("View Records");btnViewRecords.setBackground(Color.CYAN);btnViewRecords.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {Records record = new Records();record.setVisible(true);dispose();}

});btnViewRecords.setBounds(103, 127, 118, 23);contentPane.add(btnViewRecords);

JButtonbtnExit = new JButton("Exit");btnExit.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {JOptionPane.showMessageDialog(null, "ZERO GRAVITY PAYROLL

SYSTEM IS NOW TERMINATING!! ","POWERED BY-ROMEL",JOptionPane.INFORMATION_MESSAGE);

System.exit(0);

}});btnExit.setBackground(Color.CYAN);btnExit.setBounds(103, 161, 118, 23);contentPane.add(btnExit);

JLabellblNewLabel = new JLabel("");lblNewLabel.setIcon(new ImageIcon("D:\\Storage\\it's IT\\ProjectX\\

accentServices.jpg"));lblNewLabel.setBounds(0, 0, 322, 224);contentPane.add(lblNewLabel);

}}

RECORD CLASS

Page 16: IS211 Data file & Object Structure Project

16

importjava.awt.*;importjava.awt.event.KeyEvent;importjava.awt.event.KeyListener;importjava.awt.event.TextEvent;importjava.awt.event.TextListener;import java.io.*;importjava.sql.*;importjava.util.*;importjavax.swing.*;importjavax.swing.table.*;importjava.awt.event.ActionListener;importjava.awt.event.ActionEvent;

public class Records extends JFrame implements KeyListener{

//JLabellblSearch=new JLabel("Search(by id): ",SwingConstants.RIGHT);//JTextFieldtxtSearch=new JTextField(20);

JTable table;JScrollPanescrollPane;

Vector columnNames = new Vector();Vector data = new Vector();

public Records() {String sql= "Select * from payroll";viewRecords(sql);setDefaultCloseOperation(DISPOSE_ON_CLOSE);pack();setTitle("Employees Information Table");setVisible(true);

}

public void viewRecords(String SQLStatement){

try {

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");Connection connect =DriverManager.getConnection("jdbc:odbc:PAYROLL");

Statement stmt = connect.createStatement();ResultSetrs = stmt.executeQuery(SQLStatement );ResultSetMetaData md = rs.getMetaData();

int columns = md.getColumnCount();

for (inti = 1; i<= columns; i++) {columnNames.addElement(md.getColumnName(i) );

}while (rs.next()) {

Vector row = new Vector(columns);for (inti = 1; i<= columns; i++) {

row.addElement(rs.getObject(i) );}data.addElement( row );

Page 17: IS211 Data file & Object Structure Project

17

}rs.close();stmt.close();

}catch(Exception e) {

System.out.println( e );}

JPanelsearchPanel = new JPanel();//searchPanel.add(lblSearch);//searchPanel.add(txtSearch);getContentPane().add( searchPanel,BorderLayout.NORTH);

// txtSearch.addKeyListener(this);

table = new JTable(data, columnNames);scrollPane = new JScrollPane( table );getContentPane().add( scrollPane );JPanelbuttonPanel = new JPanel();getContentPane().add( buttonPanel, BorderLayout.SOUTH );setSize(1000, 1000);JButton button = new JButton("<<<Back");button.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) { Main main = new Main();main.setVisible(true);dispose();}

});button.setBackground(Color.CYAN);buttonPanel.add(button);

}public static void main(String[] args){

new Records();

}

@Overridepublic void keyPressed(KeyEvent arg0) {// int id=Integer.parseInt(txtSearch.getText());

//if(arg0.getSource().equals(txtSearch)){//String sql="select *from payroll where ID = " + id +"";//viewRecords(sql);

}

@Overridepublic void keyReleased(KeyEvent arg0) {

}

public void keyTyped(KeyEvent arg0) {

Page 18: IS211 Data file & Object Structure Project

18

}}

TRANSACTION CLASS

importjava.awt.BorderLayout;importjava.awt.EventQueue;

importjavax.swing.JFrame;importjavax.swing.JPanel;importjavax.swing.border.EmptyBorder;importjavax.swing.JLabel;importjavax.swing.JOptionPane;importjavax.swing.JTextField;importjavax.swing.JComboBox;importjava.awt.Font;importjavax.swing.ImageIcon;importjavax.swing.JButton;importjava.awt.Color;importjava.awt.event.ActionListener;importjava.awt.event.ActionEvent;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.PreparedStatement;importjava.sql.ResultSet;importjava.sql.Statement;

public class PayrollData extends JFrame {

int a;privateJPanelcontentPane;privateJTextFieldtxtId;privateJTextFieldtxtName;privateJTextFieldtxtAge;privateJTextFieldtxtHrwrk;privateJTextFieldtxtRph;privateJTextFieldtxtOp;privateJTextFieldtxtGp;privateJTextFieldtxtSSS;privateJTextFieldtxtPIB;privateJTextFieldtxtPh;privateJTextFieldtxtTax;privateJTextFieldtxtNp;privateJTextFieldtxtLate;privateJTextFieldtxtTotal;Connection conn;ResultSetrs;Statement st;staticint id=1;/** * Launch the application. */public static void main(String[] args) {

EventQueue.invokeLater(new Runnable() {public void run() {

Page 19: IS211 Data file & Object Structure Project

19

try {PayrollData frame = new PayrollData();frame.setVisible(true);

} catch (Exception e) {e.printStackTrace();

}}

});}public void DBConnect(){

String driver="sun.jdbc.odbc.JdbcOdbcDriver";String url="jdbc:odbc:PAYROLL";try {

Class.forName(driver);conn=DriverManager.getConnection(url);

st=conn.createStatement();

String sql="select *from payroll";

rs=st.executeQuery(sql);//JOptionPane.showMessageDialog(null, "");

} catch (Exception e) {JOptionPane.showMessageDialog(null, e.toString());e.printStackTrace();

}

}public void insertRecord(String SQLStatement){

try {inti=st.executeUpdate(SQLStatement);

JOptionPane.showMessageDialog(null, i+ " record stored successfully!!! ");/*String str="You got it!\n Congratulation! \nYou earned points :

"+textField.getText();String name= JOptionPane.showInputDialog(str+"\nEnter your Name : ");

String sql="insert into score (NAME,SCORE) values('"+ name +"','"+ textField.getText() +"')";

insertRecord(sql);

*/

} catch (Exception e) {JOptionPane.showMessageDialog(null, e.toString());

}}/** * Create the frame. */publicPayrollData() {

DBConnect();setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setBounds(100, 100, 573, 510);

Page 20: IS211 Data file & Object Structure Project

20

contentPane = new JPanel();contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));setContentPane(contentPane);contentPane.setLayout(null);

JLabellblName = new JLabel("Identification Number :");lblName.setForeground(new Color(102, 255, 0));lblName.setFont(new Font("Tahoma", Font.BOLD, 11));lblName.setBounds(10, 63, 131, 28);contentPane.add(lblName);

JLabellblFullName = new JLabel("Full Name :");lblFullName.setForeground(new Color(102, 255, 0));lblFullName.setFont(new Font("Tahoma", Font.BOLD, 11));lblFullName.setBounds(10, 102, 119, 28);contentPane.add(lblFullName);

JLabellblAge = new JLabel("Age :");lblAge.setForeground(new Color(102, 255, 0));lblAge.setFont(new Font("Tahoma", Font.BOLD, 11));lblAge.setBounds(293, 63, 119, 28);contentPane.add(lblAge);

JLabellblPosition = new JLabel("Position :");lblPosition.setForeground(new Color(102, 255, 0));lblPosition.setFont(new Font("Tahoma", Font.BOLD, 11));lblPosition.setBounds(293, 102, 119, 28);contentPane.add(lblPosition);

txtId = new JTextField();txtId.setEditable(true);txtId.setBackground(new Color(245, 222, 179));txtId.setBounds(153, 67, 119, 20);contentPane.add(txtId);txtId.setColumns(10);//txtId.setText(""+a);//id++;

txtName = new JTextField();txtName.setBackground(new Color(245, 222, 179));txtName.setColumns(10);txtName.setBounds(153, 106, 119, 20);contentPane.add(txtName);

txtAge = new JTextField();txtAge.setBackground(new Color(245, 222, 179));txtAge.setColumns(10);txtAge.setBounds(404, 71, 119, 20);contentPane.add(txtAge);

finalJComboBoxcomboBox = new JComboBox();comboBox.setBackground(new Color(245, 222, 179));

comboBox.addItem("Manager");comboBox.addItem("Supervisor");comboBox.addItem("FullTime");comboBox.addItem("Regular");

Page 21: IS211 Data file & Object Structure Project

21

comboBox.addItem("PartTime");

comboBox.setBounds(404, 110, 119, 20);contentPane.add(comboBox);

JLabellblEmployeeInofrmation = new JLabel("Employee Information ---------------------------------------------------");

lblEmployeeInofrmation.setForeground(new Color(102, 255, 0));lblEmployeeInofrmation.setFont(new Font("Algerian", Font.BOLD, 16));lblEmployeeInofrmation.setBounds(10, 11, 523, 41);contentPane.add(lblEmployeeInofrmation);

JLabellblGrossPay = new JLabel("Gross Pay-------------------------------Deduction------------------------");

lblGrossPay.setForeground(new Color(102, 255, 0));lblGrossPay.setFont(new Font("Algerian", Font.BOLD, 16));lblGrossPay.setBounds(10, 153, 523, 41);contentPane.add(lblGrossPay);

JLabellblHoursWorked = new JLabel("Hours Worked : ");lblHoursWorked.setForeground(new Color(102, 255, 0));lblHoursWorked.setFont(new Font("Tahoma", Font.BOLD, 11));lblHoursWorked.setBounds(10, 205, 131, 28);contentPane.add(lblHoursWorked);

txtHrwrk = new JTextField("0.00");txtHrwrk.setBackground(new Color(245, 222, 179));txtHrwrk.setColumns(10);txtHrwrk.setBounds(153, 209, 119, 20);contentPane.add(txtHrwrk);

JLabellblRatePerhour = new JLabel("Rate per-Hour :");lblRatePerhour.setForeground(new Color(102, 255, 0));lblRatePerhour.setFont(new Font("Tahoma", Font.BOLD, 11));lblRatePerhour.setBounds(10, 244, 119, 28);contentPane.add(lblRatePerhour);

txtRph = new JTextField("0.00");txtRph.setBackground(new Color(245, 222, 179));txtRph.setColumns(10);txtRph.setBounds(153, 248, 119, 20);contentPane.add(txtRph);

JLabellblOvertimePay = new JLabel("Overtime Pay :");lblOvertimePay.setForeground(new Color(102, 255, 0));lblOvertimePay.setFont(new Font("Tahoma", Font.BOLD, 11));lblOvertimePay.setBounds(10, 283, 131, 28);contentPane.add(lblOvertimePay);

txtOp = new JTextField("0.00");txtOp.setBackground(new Color(245, 222, 179));txtOp.setColumns(10);txtOp.setBounds(153, 287, 119, 20);contentPane.add(txtOp);

JLabel lblGrossPay_1 = new JLabel("Gross Pay :");lblGrossPay_1.setForeground(new Color(102, 255, 0));

Page 22: IS211 Data file & Object Structure Project

22

lblGrossPay_1.setFont(new Font("Tahoma", Font.BOLD, 11));lblGrossPay_1.setBounds(10, 322, 119, 28);contentPane.add(lblGrossPay_1);

txtGp = new JTextField("0.00");txtGp.setBackground(new Color(245, 222, 179));txtGp.setEditable(false);txtGp.setColumns(10);txtGp.setBounds(153, 326, 119, 20);contentPane.add(txtGp);

JLabellblSss = new JLabel("SSS :");lblSss.setForeground(new Color(102, 255, 0));lblSss.setFont(new Font("Tahoma", Font.BOLD, 11));lblSss.setBounds(293, 205, 131, 28);contentPane.add(lblSss);

txtSSS = new JTextField("0.00");txtSSS.setBackground(new Color(245, 222, 179));

txtSSS.setColumns(10);txtSSS.setBounds(404, 213, 119, 20);contentPane.add(txtSSS);

JLabellblPagibig = new JLabel("PAG-IBIG :");lblPagibig.setForeground(new Color(102, 255, 0));lblPagibig.setFont(new Font("Tahoma", Font.BOLD, 11));lblPagibig.setBounds(293, 244, 119, 28);contentPane.add(lblPagibig);

txtPIB = new JTextField("0.00");txtPIB.setBackground(new Color(245, 222, 179));txtPIB.setColumns(10);txtPIB.setBounds(404, 252, 119, 20);contentPane.add(txtPIB);

JLabellblPhilhealth = new JLabel("PHIL-HEALTH :");lblPhilhealth.setForeground(new Color(102, 255, 0));lblPhilhealth.setFont(new Font("Tahoma", Font.BOLD, 11));lblPhilhealth.setBounds(293, 283, 131, 28);contentPane.add(lblPhilhealth);

txtPh = new JTextField("0.00");txtPh.setBackground(new Color(245, 222, 179));txtPh.setColumns(10);txtPh.setBounds(404, 291, 119, 20);contentPane.add(txtPh);

JLabellblTax = new JLabel("TAX :");lblTax.setForeground(new Color(102, 255, 0));lblTax.setFont(new Font("Tahoma", Font.BOLD, 11));lblTax.setBounds(293, 322, 119, 28);contentPane.add(lblTax);

txtTax = new JTextField("0.00");txtTax.setBackground(new Color(245, 222, 179));txtTax.setColumns(10);

Page 23: IS211 Data file & Object Structure Project

23

txtTax.setBounds(404, 330, 119, 20);contentPane.add(txtTax);

JLabellblNetPay = new JLabel("Net Pay :");lblNetPay.setForeground(new Color(102, 255, 0));lblNetPay.setFont(new Font("Tahoma", Font.BOLD, 11));lblNetPay.setBounds(10, 366, 119, 28);contentPane.add(lblNetPay);

txtNp = new JTextField("0.00");txtNp.setBackground(new Color(245, 222, 179));txtNp.setEditable(false);txtNp.setColumns(10);txtNp.setBounds(153, 370, 119, 20);contentPane.add(txtNp);

JLabellblLateabsences = new JLabel("Late/Absences :");lblLateabsences.setForeground(new Color(102, 255, 0));lblLateabsences.setFont(new Font("Tahoma", Font.BOLD, 11));lblLateabsences.setBounds(293, 366, 119, 28);contentPane.add(lblLateabsences);

txtLate = new JTextField("0.00");txtLate.setBackground(new Color(245, 222, 179));txtLate.setColumns(10);txtLate.setBounds(404, 374, 119, 20);contentPane.add(txtLate);

JLabellblTotal = new JLabel("TOTAL :");lblTotal.setForeground(new Color(102, 255, 0));lblTotal.setFont(new Font("Tahoma", Font.BOLD, 11));lblTotal.setBounds(293, 404, 119, 28);contentPane.add(lblTotal);

txtTotal = new JTextField("0.00");txtTotal.setBackground(new Color(245, 222, 179));txtTotal.setEditable(false);txtTotal.setColumns(10);txtTotal.setBounds(404, 412, 119, 20);contentPane.add(txtTotal);

finalJButtonbtnNewButton = new JButton("Calculate");btnNewButton.setBackground(Color.CYAN);btnNewButton.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {double gross;double net;double deduction;

Integer.parseInt(txtId.getText());id++;

gross=Double.parseDouble(txtRph.getText())*Double.parseDouble(txtHrwrk.getText())+Double.parseDouble(txtOp.getText());

txtGp.setText(gross+"");

Page 24: IS211 Data file & Object Structure Project

24

deduction=Double.parseDouble(txtSSS.getText())+Double.parseDouble(txtPIB.getText())+Double.parseDouble(txtPh.getText())+Double.parseDouble(txtTax.getText())+Double.parseDouble(txtLate.getText());

txtTotal.setText(deduction+"");

net=gross-deduction;txtNp.setText(net+"");try{

rs.last();a = rs.getInt("ID");//txtId.setText(""+a);

a = a+1;}catch (Exception e1) {

// TODO: handle exception}

String sql="insert into payroll (ID,NAME,POSITION,AGE,HOURSWORKED,RATEPERHOUR,OVERTIME,GROSSPAY,NETPAY,SSS,PAGIBIG,PHILHEALTH,TAX,LATE,TOTAL) values('"+ txtId.getText() +"'" +

",'"+ txtName.getText() +"','"+ comboBox.getSelectedItem() +"','"+ txtAge.getText() +"','"+ txtHrwrk.getText() +"','"+ txtRph.getText() +"','"+ txtOp.getText() +"'," +

"'"+ txtGp.getText() +"','"+ txtNp.getText() +"','"+ txtSSS.getText() +"','"+ txtPIB.getText() +"','"+ txtPh.getText() +"','"+ txtTax.getText() +"','"+ txtLate.getText() +"','"+ txtTotal.getText() +"')";

insertRecord(sql);txtAge.setEditable(false);txtHrwrk.setEditable(false);txtId.setEditable(false);txtLate.setEditable(false);txtName.setEditable(false);txtNp.setEditable(false);txtOp.setEditable(false);txtPh.setEditable(false);txtPIB.setEditable(false);txtRph.setEditable(false);txtSSS.setEditable(false);txtTax.setEditable(false);comboBox.setEditable(false);btnNewButton.setEnabled(false);

//JOptionPane.showMessageDialog(null, comboBox.getSelectedItem());

}});btnNewButton.setForeground(Color.BLACK);btnNewButton.setBounds(153, 407, 119, 23);contentPane.add(btnNewButton);

JButton button = new JButton("<< Back");button.setBackground(Color.CYAN);button.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

Main main = new Main();main.setVisible(true);

Page 25: IS211 Data file & Object Structure Project

25

dispose();}

});button.setForeground(Color.BLACK);button.setBounds(10, 407, 102, 23);contentPane.add(button);

JLabellblNewLabel = new JLabel("");lblNewLabel.setIcon(new ImageIcon("D:\\Storage\\it's IT\\ProjectX\\1366x768-abstract-

black-shapes-wallpapers.jpg"));lblNewLabel.setBounds(0, 0, 557, 472);contentPane.add(lblNewLabel);

}public static void isParTime(){

}}