0% found this document useful (0 votes)
78 views

Dbms Project

The document contains Java code for several classes that implement a basic employee management system with functionality for: 1. Viewing and printing employee attendance records and employee details stored in database tables using JTables. 2. Adding, updating, and setting salary for employees with GUI forms and inserting/updating SQL queries. 3. Taking employee attendance and adding records to the attendance table. The classes connect to a database, retrieve and manipulate data to populate JTables and forms, and allow insertion/updating of records via action listeners on buttons.

Uploaded by

Ruheena S
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views

Dbms Project

The document contains Java code for several classes that implement a basic employee management system with functionality for: 1. Viewing and printing employee attendance records and employee details stored in database tables using JTables. 2. Adding, updating, and setting salary for employees with GUI forms and inserting/updating SQL queries. 3. Taking employee attendance and adding records to the attendance table. The classes connect to a database, retrieve and manipulate data to populate JTables and forms, and allow insertion/updating of records via action listeners on buttons.

Uploaded by

Ruheena S
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 63

import java.sql.

*;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class List_Attendence extends JFrame implements ActionListener{

JTable j1;

JButton b1;

String h[]={"Emp id","Date Time","First Half","Second Half"};

String d[][]=new String[20][4];

int i=0,j=0;

List_Attendence(){

super("View Employees Attendence");

setSize(800,300);

setLocation(450,150);

try{

String q="select * from attendence";

conn c1=new conn();

ResultSet rs=c1.s.executeQuery(q);

while(rs.next()){

d[i][j++]=rs.getString("id");

d[i][j++]=rs.getString("date_tm");

d[i][j++]=rs.getString("f_half");

d[i][j++]=rs.getString("s_half");
i++;

j=0;

j1=new JTable(d,h);

}catch(Exception e){}

b1=new JButton("Print");

add(b1,"South");

JScrollPane s1=new JScrollPane(j1);

add(s1);

b1.addActionListener(this);

public void actionPerformed(ActionEvent ae){

try{

j1.print();

}catch(Exception e){}

public static void main(String[] args){

new List_Attendence().setVisible(true);

}
import java.sql.*;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class List_Employee extends JFrame implements ActionListener{

JTable j1;

JButton b1;

String h[]={"Emp id","Name","Gender","Address","State","City","Email id","Phone"};

String d[][]=new String[20][8];

int i=0,j=0;

List_Employee(){

super("View Employees");

setSize(1000,400);

setLocation(450,200);

try{

String q="select * from employee";

conn c1=new conn();

ResultSet rs=c1.s.executeQuery(q);

while(rs.next()){

// i = 0 j = 0

d[i][j++]=rs.getString("id");

d[i][j++]=rs.getString("name");
d[i][j++]=rs.getString("gender");

d[i][j++]=rs.getString("address");

d[i][j++]=rs.getString("state");

d[i][j++]=rs.getString("city");

d[i][j++]=rs.getString("email");

d[i][j++]=rs.getString("phone");

i++;

j=0;

j1=new JTable(d,h);

catch(Exception e){}

b1=new JButton("Print");

add(b1,"South");

JScrollPane s1=new JScrollPane(j1);

add(s1);

b1.addActionListener(this);

public void actionPerformed(ActionEvent ae){

try{

j1.print();

}catch(Exception e){}

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

new List_Employee().setVisible(true);

}
import java.sql.*;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class New_Employee extends JFrame implements ActionListener{

JLabel l1,l2,l3,l4,l5,l6,l7;

JTextField t1,t2,t3,t4,t5,t6,t7;

JButton b1,b2;

Choice c1;

New_Employee(){

super("New Employee");

setSize(600,650);

setLocation(600,200);

getContentPane().setBackground(Color.WHITE);

JPanel p1= new JPanel();

p1.setBackground(Color.WHITE);

p1.setLayout(new GridLayout(8,2,10,40));

l1 = new JLabel("Name");

t1 = new JTextField(15);

p1.add(l1);

p1.add(t1);
c1 = new Choice();

c1.add("Male");

c1.add("Female");

l2 = new JLabel("Gender");

p1.add(l2);

p1.add(c1);

l3 = new JLabel("Address");

t3 = new JTextField(15);

p1.add(l3);

p1.add(t3);

l4 = new JLabel("State");

t4 = new JTextField(15);

p1.add(l4);

p1.add(t4);

l5 = new JLabel("City");

t5 = new JTextField(15);

p1.add(l5);

p1.add(t5);

l6 = new JLabel("Email");

t6 = new JTextField(15);

p1.add(l6);

p1.add(t6);

l7 = new JLabel("Phone");

t7= new JTextField(15);

p1.add(l7);
p1.add(t7);

b1 =new JButton("Submit");

b2 = new JButton("Cancel");

p1.add(b1);

p1.add(b2);

setLayout(new BorderLayout());

add(new JLabel(new
ImageIcon(ClassLoader.getSystemResource("icons/new_employee.png"))),"West");

add(p1,"Center");

b1.addActionListener(this);

b1.setBackground(Color.BLACK);

b1.setForeground(Color.WHITE);

b2.addActionListener(this);

b2.setBackground(Color.BLACK);

b2.setForeground(Color.WHITE);

public void actionPerformed(ActionEvent ae){

String n = t1.getText();

String g = c1.getSelectedItem();

String a = t3.getText();

String s = t4.getText();

String c = t5.getText();
String e = t6.getText();

String p = t7.getText();

String qry = "insert into employee


values(null,'"+n+"','"+g+"','"+a+"','"+s+"','"+c+"','"+e+"','"+p+"')";

try{

conn c1 = new conn();

c1.s.executeUpdate(qry);

JOptionPane.showMessageDialog(null,"Employee Created");

this.setVisible(false);

}catch(Exception ee){

ee.printStackTrace();

public static void main(String s[]){

new New_Employee().setVisible(true);

}
import java.sql.*;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class Salary extends JFrame implements ActionListener{

JLabel l1,l2,l3,l4,l5,l6,l7;

JTextField t1,t2,t3,t4,t5,t6,t7;

JButton b1,b2;

Choice c2;

Salary(){

super("Set Salary");

setLayout(new GridLayout(8,2,20,20));

c2 = new Choice();

try{

conn c = new conn();

ResultSet rs = c.s.executeQuery("select * from employee");

while(rs.next()){

c2.add(rs.getString("id"));

}catch(Exception e){ }
add(new JLabel("Select Empno"));

add(c2);

l1 = new JLabel("HRA");

t1 = new JTextField(15);

add(l1);

add(t1);

l3 = new JLabel("DA");

t3 = new JTextField(15);

add(l3);

add(t3);

l4 = new JLabel("MED");

t4 = new JTextField(15);

add(l4);

add(t4);

l5 = new JLabel("PF");

t5 = new JTextField(15);

add(l5);

add(t5);

l6 = new JLabel("Basic Salary");

t6 = new JTextField(15);

add(l6);

add(t6);
b1 =new JButton("Submit");

b1.setBackground(Color.BLACK);

b1.setForeground(Color.WHITE);

b2 = new JButton("Cancel");

b2.setBackground(Color.BLACK);

b2.setForeground(Color.WHITE);

add(b1);

add(b2);

b1.addActionListener(this);

b2.addActionListener(this);

setSize(450,550);

setLocation(500,200);

setVisible(true);

getContentPane().setBackground(Color.WHITE);

public void actionPerformed(ActionEvent ae){


String hra = t1.getText();

String id = c2.getSelectedItem();

String da = t3.getText();

String med = t4.getText();

String pf = t5.getText();

String basic = t6.getText();

String qry = "insert into salary values("+ id +","+hra+","+da+","+med+","+pf+","+basic+")";

try{

conn c1 = new conn();

c1.s.executeUpdate(qry);

JOptionPane.showMessageDialog(null,"Salary updated");

this.setVisible(false);

}catch(Exception ee){

ee.printStackTrace();

public static void main(String[] args){

new Salary();

}
import java.sql.*;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class TakeAttendence extends JFrame implements ActionListener{

JLabel l1,l2,l3,l4,l5,l6,l7;

JTextField t1,t2,t3,t4,t5,t6,t7;

JButton b1,b2;

Choice c2,fh,sh;

TakeAttendence(){

setLayout(new GridLayout(4,2,50,50));

c2 = new Choice();

try{

conn c = new conn();

ResultSet rs = c.s.executeQuery("select * from employee");

while(rs.next()){

c2.add(rs.getString("id"));

}catch(Exception e){ }

add(new JLabel("Select Empno"));

add(c2);
l1 = new JLabel("First Half");

fh = new Choice();

fh.add("Present");

fh.add("Absent");

fh.add("Leave");

add(l1);

add(fh);

l2 = new JLabel("Second Half");

sh = new Choice();

sh.add("Present");

sh.add("Absent");

sh.add("Leave");

add(l2);

add(sh);

b1 =new JButton("Submit");

b1.setBackground(Color.BLACK);

b1.setForeground(Color.WHITE);

b2 = new JButton("Cancel");

b2.setBackground(Color.BLACK);

b2.setForeground(Color.WHITE);
add(b1);

add(b2);

b1.addActionListener(this);

b2.addActionListener(this);

getContentPane().setBackground(Color.WHITE);

setVisible(true);

setSize(400,450);

setLocation(600,200);

public void actionPerformed(ActionEvent ae){

String f = fh.getSelectedItem();

String s = sh.getSelectedItem();

String dt = new java.util.Date().toString();

String id=c2.getSelectedItem();

String qry = "insert into attendence values("+ id +",'"+dt+"','"+f+"','"+s+"')";

try{

conn c1 = new conn();

c1.s.executeUpdate(qry);

JOptionPane.showMessageDialog(null,"Attendence confirmed");

this.setVisible(false);
}catch(Exception ee){

ee.printStackTrace();

public static void main(String s[]){

new TakeAttendence();

}
import java.sql.*;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class Update_employee extends JFrame implements ActionListener,ItemListener{

JLabel l1,l2,l3,l4,l5,l6,l7,emp;

JTextField t1,t2,t3,t4,t5,t6,t7;

JButton b1,b2;

Choice c1,c2;

Update_employee(){

super("Update Employee");

setLayout(null);

getContentPane().setBackground(Color.WHITE);

c2 = new Choice();

c2.setBounds(160,40,200,20);

try{

conn c = new conn();

ResultSet rs = c.s.executeQuery("select * from employee");

while(rs.next()){

c2.add(rs.getString("id"));
}

}catch(Exception e){ }

emp = new JLabel("Select Empno");

emp.setBounds(40,40,100,20);

add(emp);

add(c2);

l1 = new JLabel("Name : ");

t1 = new JTextField(15);

l1.setBounds(40,80,100,20);

t1.setBounds(160,80,200,20);

add(l1);

add(t1);

c1 = new Choice();

c1.add("Male");

c1.add("Female");

l2 = new JLabel("Gender : ");

l2.setBounds(40,120,100,20);

c1.setBounds(160,120,200,20);

add(l2);

add(c1);
l3 = new JLabel("Address : ");

t3 = new JTextField(15);

l3.setBounds(40,160,100,20);

t3.setBounds(160,160,200,20);

add(l3);

add(t3);

l4 = new JLabel("State : ");

t4 = new JTextField(15);

l4.setBounds(40,200,100,20);

t4.setBounds(160,200,200,20);

add(l4);

add(t4);

l5 = new JLabel("City : ");

t5 = new JTextField(15);

l5.setBounds(40,240,100,20);

t5.setBounds(160,240,200,20);

add(l5);

add(t5);

l6 = new JLabel("Email : ");

t6 = new JTextField(15);
l6.setBounds(40,280,100,20);

t6.setBounds(160,280,200,20);

add(l6);

add(t6);

l7 = new JLabel("Phone : ");

t7= new JTextField(15);

l7.setBounds(40,320,100,20);

t7.setBounds(160,320,200,20);

add(l7);

add(t7);

b1 =new JButton("Update");

b2 = new JButton("Delete");

b1.setBounds(40,400,150,30);

b2.setBounds(200,400,150,30);

add(b1);

add(b2);

b1.setBackground(Color.BLACK);

b1.setForeground(Color.WHITE);

b2.setBackground(Color.BLACK);

b2.setForeground(Color.WHITE);
b1.addActionListener(this);

b2.addActionListener(this);

c2.addItemListener(this);

setVisible(true);

setSize(400,550);

setLocation(600,200);

public void actionPerformed(ActionEvent ae){

if(ae.getSource()==b1){

String n = t1.getText();

String g = c1.getSelectedItem();

String a = t3.getText();

String s = t4.getText();

String c = t5.getText();

String e = t6.getText();

String p = t7.getText();

String qry = "update employee set


name='"+n+"',gender='"+g+"',address='"+a+"',state='"+s+"',city='"+c+"',email='"+e+"',phone='"+p+"'
where id="+c2.getSelectedItem();

try{

conn c1 = new conn();

c1.s.executeUpdate(qry);

JOptionPane.showMessageDialog(null,"Employee Updated");
}catch(Exception ee){

ee.printStackTrace();

if(ae.getSource()==b2){

try{

conn c1 = new conn();

c1.s.executeUpdate("delete from employee where id="+c2.getSelectedItem());

JOptionPane.showMessageDialog(null,"Employee Deleted");

this.setVisible(false);

}catch(Exception ee){

ee.printStackTrace();

public void itemStateChanged(ItemEvent ie){

try{

conn c1 = new conn();

ResultSet rs = c1.s.executeQuery("select * from employee where id="+c2.getSelectedItem());

if(rs.next()){

t1.setText(rs.getString("name"));

t3.setText(rs.getString("address"));

t4.setText(rs.getString("state"));

t5.setText(rs.getString("city"));
t6.setText(rs.getString("email"));

t7.setText(rs.getString("phone"));

}catch(Exception ee){

ee.printStackTrace();

public static void main(String[] args){

new Update_employee();

}
import java.sql.*;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class Update_salary extends JFrame implements ActionListener,ItemListener{

JLabel l1,l2,l3,l4,l5,l6;

JTextField t1,t2,t3,t4,t5,t6;

JButton b1,b2;

Choice c2;

Update_salary(){

setLayout(null);

c2 = new Choice();

try{

conn c = new conn();

ResultSet rs = c.s.executeQuery("select * from salary");

while(rs.next()){

c2.add(rs.getString("id"));

}catch(Exception e){ }

JLabel emp = new JLabel("Select Empno");

emp.setBounds(20,20,100,20);

add(emp);
c2.setBounds(120,20,200,20);

add(c2);

l1 = new JLabel("Hra");

t1 = new JTextField(15);

l1.setBounds(20,60,100,20);

t1.setBounds(120,60,200,20);

add(l1);

add(t1);

l2 = new JLabel("Da");

t2 = new JTextField(15);

l2.setBounds(20,100,100,20);

t2.setBounds(120,100,200,20);

add(l2);

add(t2);

l3 = new JLabel("Med");

t3 = new JTextField(15);

l3.setBounds(20,140,100,20);

t3.setBounds(120,140,200,20);

add(l3);

add(t3);
l4 = new JLabel("Pf");

t4 = new JTextField(15);

l4.setBounds(20,180,100,20);

t4.setBounds(120,180,200,20);

add(l4);

add(t4);

l5 = new JLabel("basic_salary");

t5 = new JTextField(15);

l5.setBounds(20,220,100,20);

t5.setBounds(120,220,200,20);

add(l5);

add(t5);

b1 =new JButton("Update");

b1.setBackground(Color.BLACK);

b1.setForeground(Color.WHITE);

b2 = new JButton("Delete");

b2.setBackground(Color.BLACK);

b2.setForeground(Color.WHITE);

b1.setBounds(40,280,100,20);

b2.setBounds(200,280,100,20);
add(b1);

add(b2);

b1.addActionListener(this);

b2.addActionListener(this);

c2.addItemListener(this);

getContentPane().setBackground(Color.WHITE);

setVisible(true);

setSize(400,450);

setLocation(600,200);

public void actionPerformed(ActionEvent ae){

if(ae.getSource()==b1){

String hra = t1.getText();

String id = c2.getSelectedItem();

String da = t2.getText();

String med = t3.getText();

String pf = t4.getText();

String basic = t5.getText();

String qry = "update salary set


hra="+hra+",da="+da+",med="+med+",pf="+pf+",basic_salary="+basic+" where
id="+c2.getSelectedItem();
try{

conn c1 = new conn();

c1.s.executeUpdate(qry);

JOptionPane.showMessageDialog(null,"Salary Updated");

this.setVisible(false);

}catch(Exception ee){

ee.printStackTrace();

if(ae.getSource()==b2){

try{

conn c1 = new conn();

c1.s.executeUpdate("delete from salary where id="+c2.getSelectedItem());

JOptionPane.showMessageDialog(null,"Salary Deleted");

this.setVisible(false);

}catch(Exception ee){

ee.printStackTrace();

public void itemStateChanged(ItemEvent ie)

try{

conn c1 = new conn();


ResultSet rs = c1.s.executeQuery("select * from salary where id="+c2.getSelectedItem());

if(rs.next()){

t1.setText(rs.getString("hra"));

t2.setText(rs.getString("da"));

t3.setText(rs.getString("med"));

t4.setText(rs.getString("pf"));

t5.setText(rs.getString("basic_salary"));

}catch(Exception ee){

ee.printStackTrace();

public static void main(String[] args){

new Update_salary();

}
import java.sql.*;

public class conn {

public Connection c;

public Statement s;

public conn(){

try{

Class.forName("com.mysql.jdbc.Driver");

c=DriverManager.getConnection("jdbc:mysql:///project2","root","");

s = c.createStatement();

}catch(Exception e) {

e.printStackTrace();

}
import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import java.sql.*;

public class login extends JFrame implements ActionListener{

JLabel l1,l2;

JTextField t1;

JPasswordField t2;

JButton b1,b2;

login(){

super("Login Page");

setLayout(new BorderLayout());

t2 = new JPasswordField(10);

t1 = new JTextField(10);

JLabel l = new JLabel(new ImageIcon(ClassLoader.getSystemResource("icon\\defaultpic.png")));

b1 = new JButton("Submit", new


ImageIcon(ClassLoader.getSystemResource("icon\\login.png")));

b2 = new JButton("Cancel", new


ImageIcon(ClassLoader.getSystemResource("icon\\Cancel.png")));

b1.addActionListener(this);

b2.addActionListener(this);

JPanel p1,p2,p3,p4;

p1=new JPanel();
p2=new JPanel();

p3=new JPanel();

p4=new JPanel();

add(l,BorderLayout.WEST);

p2.add(new JLabel("User Name "));

p2.add(t1);

p2.add(new JLabel("Password "));

p2.add(t2);

add(p2,BorderLayout.CENTER);

p4.add(b1);

p4.add(b2);

add(p4,BorderLayout.SOUTH);

setSize(400,250);

setLocation(600,400);

setVisible(true);

public void actionPerformed(ActionEvent ae){


try

conn c1=new conn();

String u=t1.getText();

String v=t2.getText();

String q="select * from login where username='"+u+"' and password='"+v+"'";

ResultSet rs=c1.s.executeQuery(q); // query execute

if(rs.next()){

new project().setVisible(true);

setVisible(false);

}else{

JOptionPane.showMessageDialog(null, "Invalid login");

setVisible(false);

}catch(Exception e){

e.printStackTrace();

public static void main(String[] args){

new login();

}
import java.sql.*;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class pay_slip extends JFrame implements ActionListener{

Choice c1;

JTextArea t1;

JButton b1;

pay_slip(){

setSize(800,700);

setLocation(400,150);

c1 = new Choice();

try{

conn c = new conn();

ResultSet rs = c.s.executeQuery("select * from salary");

while(rs.next()){

c1.add(rs.getString("id"));

}catch(Exception e) { }

setLayout(new BorderLayout());

JPanel p1 = new JPanel();


p1.add(new JLabel("Select Id"));

p1.add(c1);

add(p1,"North");

// c1.addItemListener(this);

t1 = new JTextArea(30,80);

JScrollPane jsp = new JScrollPane(t1);

Font f1 = new Font("arial",Font.BOLD,20);

t1.setFont(f1);

b1 = new JButton("Generate Pay Slip");

add(b1,"South");

add(jsp,"Center");

b1.addActionListener(this);

public void actionPerformed(ActionEvent e) {

try{

conn c = new conn();

ResultSet rs = c.s.executeQuery("select * from employee where id="+c1.getSelectedItem());

rs.next();

String name = rs.getString("name");


rs.close();

rs = c.s.executeQuery("select * from salary where id="+c1.getSelectedItem());

double gross=0;

double net=0;

java.util.Date d1 = new java.util.Date();

int month = d1.getMonth();

t1.setText(" ---------------- PAY SLIP FOR THE MONTH OF "+month+" ,2019


------------------------");

t1.append("\n");

if(rs.next()){

t1.append("\n Employee ID "+rs.getString("id"));

t1.append("\n Employee Name "+name);

t1.append("\n----------------------------------------------------------------");

t1.append("\n");

double hra = rs.getDouble("hra");

t1.append("\n HRA : "+hra);

double da = rs.getDouble("da");

t1.append("\n DA : "+da);

double med = rs.getDouble("med");

t1.append("\n MED : "+med);

double pf = rs.getDouble("pf");

t1.append("\n PF : "+pf);
double basic = rs.getDouble("basic_salary");

gross = hra+da+med+pf+basic;

net = gross - pf;

t1.append("\n BASIC SALARY : "+basic);

t1.append("\n-------------------------------------------------------");

t1.append("\n");

t1.append("\n GROSS SALARY :"+gross+" \n NET SALARY : "+net);

t1.append("\n Tax : 2.1% of gross "+ (gross*2.1/100));

t1.append("\n -------------------------------------------------");

t1.append("\n");

t1.append("\n");

t1.append("\n");

t1.append(" ( Signature ) ");

}catch(Exception ee) {

ee.printStackTrace();

public static void main(String[] args){

new pay_slip().setVisible(true);

}
import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class project extends JFrame implements ActionListener {

project(){

setSize(2000,1100);

getContentPane().setBackground(Color.WHITE);

ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icon/payroll.jpg"));

Image i2 = i1.getImage().getScaledInstance(1200,700,Image.SCALE_DEFAULT);

ImageIcon i3 = new ImageIcon(i2);

JLabel l1 = new JLabel(i3);

add(l1);

JMenuBar mb = new JMenuBar();

setJMenuBar(mb);

JMenu m1 = new JMenu("Master");

m1.setForeground(Color.blue);

JMenuItem t1 = new JMenuItem("New Employee");

t1.setForeground(Color.blue);

t1.setFont(new Font("monospaced",Font.PLAIN,12));

t1.setMnemonic('N');

t1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
t1.setIcon(new ImageIcon(ClassLoader.getSystemResource("Icons/New.png")));

JMenuItem t3 = new JMenuItem("Salary");

t3.setForeground(Color.blue);

t3.setFont(new Font("monospaced",Font.PLAIN,12));

t3.setMnemonic('S');

t3.setIcon(new ImageIcon(ClassLoader.getSystemResource("icon/schedreport.png")));

t3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));

JMenuItem t4 = new JMenuItem("List Employee");

t4.setForeground(Color.blue);

t4.setFont(new Font("monospaced",Font.PLAIN,12));

t4.setMnemonic('L');

t4.setIcon(new ImageIcon(ClassLoader.getSystemResource("icon/newinvoice.png")));

t4.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, ActionEvent.CTRL_MASK));

m1.add(t1);

//m1.add(t2);

m1.add(t3);
m1.add(t4);

mb.add(m1);

t1.addActionListener(this);

//t2.addActionListener(this);

t3.addActionListener(this);

t4.addActionListener(this);

JMenu edit =new JMenu("Update");

edit.setForeground(Color.RED);

mb.add(edit);

JMenuItem s1 = new JMenuItem("Update Salary");

s1.setForeground(Color.blue);

s1.setFont(new Font("monospaced",Font.PLAIN,12));

s1.setMnemonic('U');

s1.setIcon(new ImageIcon(ClassLoader.getSystemResource("Icons/EditOpen.png")));

s1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.CTRL_MASK));

edit.add(s1);

JMenuItem s2 = new JMenuItem("Update Employee");

s2.setForeground(Color.blue);

s2.setFont(new Font("monospaced",Font.PLAIN,12));

s2.setMnemonic('p');

s2.setIcon(new ImageIcon(ClassLoader.getSystemResource("icon/empreport.png")));
s2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK));

edit.add(s2);

JMenuItem s3 = new JMenuItem("Take Attendence");

s3.setForeground(Color.blue);

s3.setFont(new Font("monospaced",Font.PLAIN,12));

s3.setMnemonic('T');

s3.setIcon(new ImageIcon(ClassLoader.getSystemResource("icon/EXPENSE.PNG")));

s3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK));

edit.add(s3);

s1.addActionListener(this);

s2.addActionListener(this);

s3.addActionListener(this);

JMenu rep =new JMenu("Reports");

rep.setForeground(Color.blue);

mb.add(rep);

JMenuItem p1 = new JMenuItem("Generate PaySlip");

p1.setForeground(Color.blue);

p1.setFont(new Font("monospaced",Font.PLAIN,12));
p1.setMnemonic('P');

p1.setIcon(new ImageIcon(ClassLoader.getSystemResource("icon/payments.png")));

p1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK));

rep.add(p1);

JMenuItem p2 = new JMenuItem("List Attendence");

p2.setForeground(Color.blue);

p2.setFont(new Font("monospaced",Font.PLAIN,12));

p2.setMnemonic('L');

p2.setIcon(new ImageIcon(ClassLoader.getSystemResource("icon/empreport.png")));

p2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, ActionEvent.CTRL_MASK));

rep.add(p2);

p1.addActionListener(this);

p2.addActionListener(this);

JMenu util =new JMenu("Utilities");

util.setForeground(Color.red);

mb.add(util);

JMenuItem u1 = new JMenuItem("Notepad");

u1.setIcon(new ImageIcon(ClassLoader.getSystemResource("Icons/New.png")));

u1.setForeground(Color.blue);
u1.setFont(new Font("monospaced",Font.PLAIN,12));

u1.setMnemonic('o');

u1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));

util.add(u1);

JMenuItem u2 = new JMenuItem("Calculator");

u2.setIcon(new ImageIcon(ClassLoader.getSystemResource("icon/calc.png")));

u2.setForeground(Color.blue);

u2.setFont(new Font("monospaced",Font.PLAIN,12));

u2.setMnemonic('C');

u2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK));

util.add(u2);

JMenuItem u3 = new JMenuItem("Web Browser");

u3.setIcon(new ImageIcon(ClassLoader.getSystemResource("icon/explorer.jpg")));

u3.setForeground(Color.blue);

u3.setFont(new Font("monospaced",Font.PLAIN,12));

u3.setMnemonic('E');

u3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK));

util.add(u3);
u1.addActionListener(this);

u2.addActionListener(this);

u3.addActionListener(this);

JMenu m8=new JMenu("Exit");

m8.setForeground(Color.red);

mb.add(m8);

JMenuItem m8i1=new JMenuItem("Exit");

m8.add(m8i1);

m8i1.setForeground((Color.blue));

m8i1.setFont(new Font("monospaced", Font.PLAIN, 14));

m8i1.setMnemonic('X');

m8i1.setIcon(new ImageIcon(ClassLoader.getSystemResource("icon/exit.PNG")));

m8i1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));

m8i1.addActionListener(this);

public void actionPerformed(ActionEvent ae){

String msg= ae.getActionCommand();

if(msg.equals("New Employee"))

new New_Employee().setVisible(true);

else if(msg.equals("List Employee"))


new List_Employee().setVisible(true);

else if(msg.equals("Update Employee"))

new Update_employee().setVisible(true);

else if(msg.equals("Salary"))

new Salary().setVisible(true);

else if(msg.equals("Update Salary"))

new Update_salary().setVisible(true);

else if(msg.equals("Notepad")){

try{

Runtime.getRuntime().exec("notepad.exe");

}catch(Exception e){ }

else if(msg.equals("Calculator")){

try{

Runtime.getRuntime().exec("calc.exe");

}catch(Exception e){ }

else if(msg.equals("Web Browser")){

try{

Runtime.getRuntime().exec("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");

}catch(Exception e){ }

else if(msg.equals("Take Attendence")){

new TakeAttendence().setVisible(true);

else if(msg.equals("Exit"))

System.exit(0);
else if(msg.equals("Generate PaySlip"))

new pay_slip().setVisible(true);

else if(msg.equals("List Attendence"))

new List_Attendence().setVisible(true);

public static void main(String[] args){

new project().setVisible(true);

}
import java.awt.*;

import javax.swing.*;

class splash{

public static void main(String s[]){

sframe f1 = new sframe("Employee payment management system");

f1.setVisible(true); //show

int i;

int x=1;

for(i=2;i<=600;i+=4,x+=1){

f1.setLocation((800-((i+x)/2) ),500-(i/2));

f1.setSize(i+x,i);

try{

Thread.sleep(10);

}catch(Exception e) { }

class sframe extends JFrame implements Runnable{

Thread t1;

sframe(String s){

super(s);

setLayout(new FlowLayout());

ImageIcon c1 = new ImageIcon(ClassLoader.getSystemResource("icon/payroll_system.jpg"));

Image i1 = c1.getImage().getScaledInstance(730, 550,Image.SCALE_DEFAULT);

ImageIcon i2 = new ImageIcon(i1);


JLabel m1 = new JLabel(i2);

add(m1);

t1= new Thread(this);

t1.start();

public void run(){

try{

Thread.sleep(7000);

this.setVisible(false);

login f1 = new login();

}catch(Exception e){

e.printStackTrace();

}
Output:
Data flow Diagram:
New employee

Salary
Master
List employee

Update employee

Update
Update salary

Take attendence

Login Report
Genrate pay list

List attendence

Utilities
Notepad

Calculator

Exit
Web browser
\
E-R Diagrm :

You might also like