Dbms Project
Dbms Project
*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
JTable j1;
JButton b1;
int i=0,j=0;
List_Attendence(){
setSize(800,300);
setLocation(450,150);
try{
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");
add(s1);
b1.addActionListener(this);
try{
j1.print();
}catch(Exception e){}
new List_Attendence().setVisible(true);
}
import java.sql.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
JTable j1;
JButton b1;
int i=0,j=0;
List_Employee(){
super("View Employees");
setSize(1000,400);
setLocation(450,200);
try{
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");
add(s1);
b1.addActionListener(this);
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.*;
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);
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");
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);
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();
try{
c1.s.executeUpdate(qry);
JOptionPane.showMessageDialog(null,"Employee Created");
this.setVisible(false);
}catch(Exception ee){
ee.printStackTrace();
new New_Employee().setVisible(true);
}
import java.sql.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
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{
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);
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);
String id = c2.getSelectedItem();
String da = t3.getText();
String pf = t5.getText();
try{
c1.s.executeUpdate(qry);
JOptionPane.showMessageDialog(null,"Salary updated");
this.setVisible(false);
}catch(Exception ee){
ee.printStackTrace();
new Salary();
}
import java.sql.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
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{
while(rs.next()){
c2.add(rs.getString("id"));
}catch(Exception e){ }
add(c2);
l1 = new JLabel("First Half");
fh = new Choice();
fh.add("Present");
fh.add("Absent");
fh.add("Leave");
add(l1);
add(fh);
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);
String f = fh.getSelectedItem();
String s = sh.getSelectedItem();
String id=c2.getSelectedItem();
try{
c1.s.executeUpdate(qry);
JOptionPane.showMessageDialog(null,"Attendence confirmed");
this.setVisible(false);
}catch(Exception ee){
ee.printStackTrace();
new TakeAttendence();
}
import java.sql.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
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{
while(rs.next()){
c2.add(rs.getString("id"));
}
}catch(Exception e){ }
emp.setBounds(40,40,100,20);
add(emp);
add(c2);
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.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);
t4 = new JTextField(15);
l4.setBounds(40,200,100,20);
t4.setBounds(160,200,200,20);
add(l4);
add(t4);
t5 = new JTextField(15);
l5.setBounds(40,240,100,20);
t5.setBounds(160,240,200,20);
add(l5);
add(t5);
t6 = new JTextField(15);
l6.setBounds(40,280,100,20);
t6.setBounds(160,280,200,20);
add(l6);
add(t6);
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);
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();
try{
c1.s.executeUpdate(qry);
JOptionPane.showMessageDialog(null,"Employee Updated");
}catch(Exception ee){
ee.printStackTrace();
if(ae.getSource()==b2){
try{
JOptionPane.showMessageDialog(null,"Employee Deleted");
this.setVisible(false);
}catch(Exception ee){
ee.printStackTrace();
try{
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();
new Update_employee();
}
import java.sql.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
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{
while(rs.next()){
c2.add(rs.getString("id"));
}catch(Exception e){ }
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);
if(ae.getSource()==b1){
String id = c2.getSelectedItem();
String da = t2.getText();
String pf = t4.getText();
c1.s.executeUpdate(qry);
JOptionPane.showMessageDialog(null,"Salary Updated");
this.setVisible(false);
}catch(Exception ee){
ee.printStackTrace();
if(ae.getSource()==b2){
try{
JOptionPane.showMessageDialog(null,"Salary Deleted");
this.setVisible(false);
}catch(Exception ee){
ee.printStackTrace();
try{
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();
new Update_salary();
}
import java.sql.*;
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.*;
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);
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(t1);
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);
String u=t1.getText();
String v=t2.getText();
if(rs.next()){
new project().setVisible(true);
setVisible(false);
}else{
setVisible(false);
}catch(Exception e){
e.printStackTrace();
new login();
}
import java.sql.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
Choice c1;
JTextArea t1;
JButton b1;
pay_slip(){
setSize(800,700);
setLocation(400,150);
c1 = new Choice();
try{
while(rs.next()){
c1.add(rs.getString("id"));
}catch(Exception e) { }
setLayout(new BorderLayout());
p1.add(c1);
add(p1,"North");
// c1.addItemListener(this);
t1 = new JTextArea(30,80);
t1.setFont(f1);
add(b1,"South");
add(jsp,"Center");
b1.addActionListener(this);
try{
rs.next();
double gross=0;
double net=0;
t1.append("\n");
if(rs.next()){
t1.append("\n----------------------------------------------------------------");
t1.append("\n");
double da = rs.getDouble("da");
t1.append("\n DA : "+da);
double pf = rs.getDouble("pf");
t1.append("\n PF : "+pf);
double basic = rs.getDouble("basic_salary");
gross = hra+da+med+pf+basic;
t1.append("\n-------------------------------------------------------");
t1.append("\n");
t1.append("\n -------------------------------------------------");
t1.append("\n");
t1.append("\n");
t1.append("\n");
}catch(Exception ee) {
ee.printStackTrace();
new pay_slip().setVisible(true);
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
project(){
setSize(2000,1100);
getContentPane().setBackground(Color.WHITE);
Image i2 = i1.getImage().getScaledInstance(1200,700,Image.SCALE_DEFAULT);
add(l1);
setJMenuBar(mb);
m1.setForeground(Color.blue);
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")));
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));
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);
edit.setForeground(Color.RED);
mb.add(edit);
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);
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);
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);
rep.setForeground(Color.blue);
mb.add(rep);
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);
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);
util.setForeground(Color.red);
mb.add(util);
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);
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);
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);
m8.setForeground(Color.red);
mb.add(m8);
m8.add(m8i1);
m8i1.setForeground((Color.blue));
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);
if(msg.equals("New Employee"))
new New_Employee().setVisible(true);
new Update_employee().setVisible(true);
else if(msg.equals("Salary"))
new Salary().setVisible(true);
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){ }
try{
}catch(Exception e){ }
new TakeAttendence().setVisible(true);
else if(msg.equals("Exit"))
System.exit(0);
else if(msg.equals("Generate PaySlip"))
new pay_slip().setVisible(true);
new List_Attendence().setVisible(true);
new project().setVisible(true);
}
import java.awt.*;
import javax.swing.*;
class splash{
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) { }
Thread t1;
sframe(String s){
super(s);
setLayout(new FlowLayout());
add(m1);
t1.start();
try{
Thread.sleep(7000);
this.setVisible(false);
}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 :