Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


Abdullah Al- Mamun
PaySlip
1 Answer(s)      4 years and 5 months ago
Posted in : Java Beginners


package dmm.ui;

import dmm.bean.Employee;
import dmm.bean.Employees;
import dmm.bean.FullTimeEmployee;
import dmm.bean.PartTimeEmployee;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Vector;
import javax.swing.JOptionPane;

/**
*
* @author Administrator
*/
public class PaySlip extends javax.swing.JInternalFrame {

Employees employees;
/** Creates new form PaySlip */
public PaySlip(Employees employees) {
this.employees=employees;
initComponents();
generateSlip();
}

public void generateSlip()
{
String user=JOptionPane.showInputDialog("Enter user name");
String password=JOptionPane.showInputDialog("Enter user password");



/*File file=new File("EmpInfo.ant");
FileInputStream fileInputStream=new FileInputStream(file);
ObjectInputStream objectInputStream=new ObjectInputStream(fileInputStream);

Employees employees=(Employees)objectInputStream.readObject();*/
//logic for password checking
//if wrong show error message
//else

Vector<Employee> allEmployees=employees.getEmployees();
txtPaySlip.setText("Pay slip\n");
txtPaySlip.append("ID\tName\tWorked Hour\tRate\tAnnual Salary\tEarnings\tTax\tAllowance\tPaymenty\n\n");
for(int i=0;i<allEmployees.size();i++)
{
Employee employee=allEmployees.get(i);
if(employee instanceof PartTimeEmployee)
{
PartTimeEmployee pte=(PartTimeEmployee)employee;

txtPaySlip.append(pte.getId()+"\t"+pte.getName()+"\t"+pte.getHoursWorked()+"\t"+pte.getHourlyRate()+"\tn/a"+"\t"+pte.earnings()+"\t"+Math.round(pte.tax())+"\t"+pte.Allowance()+"\t"+pte.payment()+"\n\n");
}
else if(employee instanceof FullTimeEmployee)
{
FullTimeEmployee fte=(FullTimeEmployee)employee;
txtPaySlip.append(fte.getId()+"\t"+fte.getName()+"\t n/a"+"\tn/a"+"\t"+fte.getAnnualSalary()+"\t"+fte.earnings()+"\t"+Math.round(fte.tax())+"\t"+fte.Allowance()+"\t"+fte.payment()+"\n\n");
}
}

}

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jScrollPane1 = new javax.swing.JScrollPane();
txtPaySlip = new javax.swing.JTextArea();
jPanel1 = new javax.swing.JPanel();
btnFundTransfer = new javax.swing.JButton();
btnTaxFile = new javax.swing.JButton();

txtPaySlip.setColumns(20);
txtPaySlip.setRows(5);
jScrollPane1.setViewportView(txtPaySlip);

getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);

btnFundTransfer.setText("Create Fund Transfer File");
btnFundTransfer.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFundTransferActionPerformed(evt);
}
});
jPanel1.add(btnFundTransfer);

btnTaxFile.setText("Create Tax File");
btnTaxFile.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnTaxFileActionPerformed(evt);
}
});
jPanel1.add(btnTaxFile);

getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_END);

pack();
}// </editor-fold>

private void btnTaxFileActionPerformed(java.awt.event.ActionEvent evt) {
String output="";
Vector<Employee> allEmployees=employees.getEmployees();
for(int i=0;i<allEmployees.size();i++) {
Employee employee=allEmployees.get(i);
if(employee instanceof FullTimeEmployee) {
FullTimeEmployee fte=(FullTimeEmployee)employee;
output+=fte.getId()+"\t"+fte.getName()+"\t"+Math.round(fte.tax())+"\n";
} else if(employee instanceof PartTimeEmployee) {
PartTimeEmployee pte=(PartTimeEmployee)employee;
output+=pte.getId()+"\t"+pte.getName()+"\t"+Math.round(pte.tax())+"\n";
}

}

try {
File file=new File("Tax.txt");
FileWriter fw=new FileWriter(file);
BufferedWriter bw=new BufferedWriter(fw);
bw.write(output);
bw.flush();
bw.close();
JOptionPane.showMessageDialog(this,"Tax file created");
} catch(IOException ioe) {
ioe.printStackTrace();
}
}

private void btnFundTransferActionPerformed(java.awt.event.ActionEvent evt) {
String output="";
Vector<Employee> allEmployees=employees.getEmployees();
for(int i=0;i<allEmployees.size();i++) {
Employee employee=allEmployees.get(i);
if(employee instanceof FullTimeEmployee) {
FullTimeEmployee fte=(FullTimeEmployee)employee;
output+=fte.getId()+"\t"+fte.getName()+"\t"+fte.getAccountHolder()+"\t"+fte.getAccountNo()+"\t"+fte.payment()+"\n";
} else if(employee instanceof PartTimeEmployee) {
PartTimeEmployee pte=(PartTimeEmployee)employee;
output+=pte.getId()+"\t"+pte.getName()+"\t"+pte.getAccountHolder()+"\t"+pte.getAccountNo()+"\t"+pte.payment()+"\n";
}

}

try {
File file=new File("Fund Transfer.txt");
FileWriter fw=new FileWriter(file);
BufferedWriter bw=new BufferedWriter(fw);
bw.write(output);
bw.flush();
bw.close();
JOptionPane.showMessageDialog(this,"Fund transfer file created");
} catch(IOException ioe) {
ioe.printStackTrace();
}
}


// Variables declaration - do not modify
private javax.swing.JButton btnFundTransfer;
private javax.swing.JButton btnTaxFile;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea txtPaySlip;
// End of variables declaration

}

Advertisement
View Answers

April 24, 2010 at 10:49 AM


Hi Friend,

Please clarify your problem.

Thanks


Related Tutorials/Questions & Answers:
PaySlip - Java Beginners
javax.swing.JOptionPane; /** * * @author Administrator */ public class PaySlip... new form PaySlip */ public PaySlip(Employees employees
printing in swing
printing in swing  How can i print payslip in swing
Advertisements
Needed jsp codes
Needed jsp codes   jsp code for employee payroll.producing a payslip of every employees monthly calculating the gross pay of a particular employee considering the income tax and producing a report which can be printed out
jsp code for employee payroll - JSP-Servlet
jsp code for employee payroll  jsp code for employee payroll. i need to generate the payslip with tax calucation and deductions,allwoance .how to calculate the employee tax using the jsp code  Hi Friend, Try
Vector object[]
Vector object[]  I want to create payslip in java public Vector createData() { Vector result = new Vector(); Vector rec = new Vector(); Object[] value = new Object[] {"Employee Name",f.ename.getSelectedItem
Advertisements
 

 

 

DMCA.com