Skip to content

Commit 533d5c7

Browse files
authored
Add files via upload
1 parent 2a819ea commit 533d5c7

File tree

14 files changed

+1568
-0
lines changed

14 files changed

+1568
-0
lines changed
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
package Library;
2+
3+
import java.awt.event.*;
4+
import java.awt.*;
5+
import javax.swing.*;
6+
import java.sql.*;
7+
8+
public class AddBooks extends JFrame implements ActionListener
9+
{
10+
JLabel l1,l2,l3,l4,l5,l6;
11+
JButton bt1,bt2;
12+
JPanel p1,p2;
13+
JTextField tf1,tf2,tf3,tf4,tf5;
14+
Font f,f1;
15+
16+
AddBooks()
17+
{
18+
super("Add Books");
19+
setLocation(450,400);
20+
setSize(650,400);
21+
22+
f=new Font("Arial",Font.BOLD,25);
23+
f1=new Font("Arial",Font.BOLD,20);
24+
25+
l1=new JLabel("Add Books");
26+
l2=new JLabel("Book No");
27+
l3=new JLabel("Book Name");
28+
l4=new JLabel("Author");
29+
l5=new JLabel("Publisher");
30+
l6=new JLabel("Quantity");
31+
32+
l1.setForeground(Color.WHITE);
33+
l1.setHorizontalAlignment(JLabel.CENTER);
34+
35+
tf1= new JTextField();
36+
tf2= new JTextField();
37+
tf3= new JTextField();
38+
tf4= new JTextField();
39+
tf5= new JTextField();
40+
41+
l1.setFont(f);
42+
l2.setFont(f1);
43+
l3.setFont(f1);
44+
l4.setFont(f1);
45+
l5.setFont(f1);
46+
l6.setFont(f1);
47+
48+
bt1=new JButton("Add Book");
49+
bt2=new JButton("Cancel");
50+
51+
bt1.setFont(f1);
52+
bt2.setFont(f1);
53+
54+
bt1.addActionListener(this);
55+
bt2.addActionListener(this);
56+
57+
tf1.setFont(f1);
58+
tf2.setFont(f1);
59+
tf3.setFont(f1);
60+
tf4.setFont(f1);
61+
tf5.setFont(f1);
62+
63+
p1= new JPanel();
64+
p1.setLayout(new GridLayout(1,1,10,10));
65+
p1.add(l1);
66+
p1.setBackground(Color.BLUE);
67+
68+
p2= new JPanel();
69+
p2.setLayout(new GridLayout(6,2,10,10));
70+
p2.add(l2);
71+
p2.add(tf1);
72+
p2.add(l3);
73+
p2.add(tf2);
74+
p2.add(l4);
75+
p2.add(tf3);
76+
p2.add(l5);
77+
p2.add(tf4);
78+
p2.add(l6);
79+
p2.add(tf5);
80+
p2.add(bt1);
81+
p2.add(bt2);
82+
83+
setLayout(new BorderLayout(10,10));
84+
add(p1,"North");
85+
add(p2,"Center");
86+
}
87+
88+
public void actionPerformed(ActionEvent e)
89+
{
90+
String bookno= tf1.getText();
91+
String bookname= tf2.getText();
92+
String author= tf3.getText();
93+
String publisher= tf4.getText();
94+
String quantity= tf5.getText();
95+
String date=new java.util.Date().toString();
96+
97+
if(e.getSource()==bt1)
98+
{
99+
try
100+
{
101+
ConnectionClass obj=new ConnectionClass();
102+
String q="insert into addbook (Bookno,Bookname,Author,Publisher,Quantity,Date) values('"+bookno+"','"
103+
+bookname+"','"+author+"','"+publisher+"','"+quantity+"','"+date+"')";
104+
int aa= obj.stm.executeUpdate(q);
105+
106+
if(aa==1)
107+
{
108+
JOptionPane.showMessageDialog(null,"Your data successfully inserted");
109+
this.setVisible(false);
110+
}
111+
112+
else
113+
{
114+
JOptionPane.showMessageDialog(null,"Please,fill all the details carefully");
115+
this.setVisible(true);
116+
}
117+
}
118+
119+
catch(Exception ee)
120+
{
121+
ee.printStackTrace();
122+
}
123+
}
124+
125+
if(e.getSource()==bt2)
126+
{
127+
this.setVisible(false);
128+
}
129+
130+
}
131+
132+
public static void main(String[] args)
133+
{
134+
new AddBooks().setVisible(true);
135+
}
136+
}
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
package Library;
2+
3+
import java.awt.event.*;
4+
import java.awt.*;
5+
import javax.swing.*;
6+
import java.sql.*;
7+
8+
public class AddLibrarian extends JFrame implements ActionListener
9+
{
10+
JLabel l1,l2,l3,l4,l5,l6,l7;
11+
JButton bt1,bt2;
12+
JPanel p1,p2;
13+
JTextField tf1,tf2,tf3,tf4,tf5;
14+
JPasswordField pf1;
15+
Font f,f1;
16+
17+
AddLibrarian()
18+
{
19+
super("Add Librarian");
20+
setLocation(450,400);
21+
setSize(650,400);
22+
23+
f=new Font("Arial",Font.BOLD,25);
24+
f1=new Font("Arial",Font.BOLD,20);
25+
26+
l1=new JLabel("Add Librarian");
27+
l2=new JLabel("Name");
28+
l3=new JLabel("Password");
29+
l4=new JLabel("Email");
30+
l5=new JLabel("Contact");
31+
l6=new JLabel("Address");
32+
l7=new JLabel("City");
33+
34+
tf1= new JTextField();
35+
tf2= new JTextField();
36+
tf3= new JTextField();
37+
tf4= new JTextField();
38+
tf5= new JTextField();
39+
40+
pf1= new JPasswordField();
41+
42+
l1.setFont(f);
43+
l2.setFont(f1);
44+
l3.setFont(f1);
45+
l4.setFont(f1);
46+
l5.setFont(f1);
47+
l6.setFont(f1);
48+
l7.setFont(f1);
49+
50+
l1.setForeground(Color.WHITE);
51+
l1.setHorizontalAlignment(JLabel.CENTER);
52+
53+
tf1.setFont(f1);
54+
tf2.setFont(f1);
55+
tf3.setFont(f1);
56+
tf4.setFont(f1);
57+
tf5.setFont(f1);
58+
59+
pf1.setFont(f1);
60+
61+
bt1=new JButton("Add Librarian");
62+
bt2=new JButton("Cancel");
63+
64+
bt1.setFont(f1);
65+
bt2.setFont(f1);
66+
67+
bt1.addActionListener(this);
68+
bt2.addActionListener(this);
69+
70+
p1=new JPanel();
71+
p1.setLayout(new GridLayout(1,1,10,10));
72+
p1.add(l1);
73+
p1.setBackground(Color.BLUE);
74+
75+
p2=new JPanel();
76+
p2.setLayout(new GridLayout(7,7,10,10));
77+
p2.add(l2);
78+
p2.add(tf1);
79+
p2.add(l3);
80+
p2.add(pf1);
81+
p2.add(l4);
82+
p2.add(tf2);
83+
p2.add(l5);
84+
p2.add(tf3);
85+
p2.add(l6);
86+
p2.add(tf4);
87+
p2.add(l7);
88+
p2.add(tf5);
89+
p2.add(bt1);
90+
p2.add(bt2);
91+
92+
setLayout(new BorderLayout(10,10));
93+
add(p1,"North");
94+
add(p2,"Center");
95+
}
96+
97+
public void actionPerformed(ActionEvent e)
98+
{
99+
String name= tf1.getText();
100+
String pass= pf1.getText();
101+
String email=tf2.getText();
102+
String contact=tf3.getText();
103+
String add=tf4.getText();
104+
String city=tf5.getText();
105+
106+
if(e.getSource()==bt1)
107+
{
108+
try
109+
{
110+
ConnectionClass obj=new ConnectionClass();
111+
String q="insert into librarian (name,password,email,contact,address,city) values('"+name+"','"
112+
+pass+"','"+email+"','"+contact+"','"+add+"','"+city+"')";
113+
int aa= obj.stm.executeUpdate(q);
114+
115+
if(aa==1)
116+
{
117+
JOptionPane.showMessageDialog(null,"Your data successfully inserted");
118+
this.setVisible(false);
119+
}
120+
121+
else
122+
{
123+
JOptionPane.showMessageDialog(null,"Please,fill all the details carefully");
124+
this.setVisible(true);
125+
}
126+
}
127+
128+
catch(Exception ee)
129+
{
130+
ee.printStackTrace();
131+
}
132+
}
133+
134+
if(e.getSource()==bt2)
135+
{
136+
this.setVisible(false);
137+
}
138+
}
139+
140+
public static void main(String[] args)
141+
{
142+
new AddLibrarian().setVisible(true);
143+
}
144+
145+
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
package Library;
2+
3+
import java.awt.event.*;
4+
import java.awt.*;
5+
import javax.swing.*;
6+
import java.sql.*;
7+
8+
public class Admin extends JFrame implements ActionListener
9+
{
10+
JLabel l1,l2,l3;
11+
JButton bt1,bt2;
12+
JPanel p1,p2;
13+
Font f,f1;
14+
JTextField tf1;
15+
JPasswordField pf1;
16+
17+
Admin()
18+
{
19+
super("Admin Login Page");
20+
setLocation(500,350);
21+
setSize(500,200);
22+
23+
f=new Font("Arial",Font.BOLD,25);
24+
f1=new Font("Arial",Font.BOLD,20);
25+
26+
l1= new JLabel("Admin Login");
27+
l2= new JLabel("Name");
28+
l3= new JLabel("Password");
29+
30+
31+
bt1=new JButton("Login");
32+
bt2=new JButton("Cancel");
33+
34+
bt1.addActionListener(this);
35+
bt2.addActionListener(this);
36+
37+
tf1=new JTextField();
38+
pf1=new JPasswordField();
39+
40+
l1.setFont(f);
41+
l2.setFont(f1);
42+
l3.setFont(f1);
43+
bt1.setFont(f1);
44+
bt2.setFont(f1);
45+
tf1.setFont(f1);
46+
pf1.setFont(f1);
47+
48+
l1.setHorizontalAlignment(JLabel.CENTER);
49+
l1.setForeground(Color.WHITE);
50+
51+
p1= new JPanel();
52+
p1.setLayout(new GridLayout(1,1,10,10));
53+
p1.add(l1);
54+
p1.setBackground(Color.BLUE);
55+
56+
p2= new JPanel();
57+
p2.setLayout(new GridLayout(3,2,10,10));
58+
p2.add(l2);
59+
p2.add(tf1);
60+
p2.add(l3);
61+
p2.add(pf1);
62+
p2.add(bt1);
63+
p2.add(bt2);
64+
65+
setLayout(new BorderLayout(10,10));
66+
add(p1,"North");
67+
add(p2,"Center");
68+
}
69+
70+
public void actionPerformed(ActionEvent e)
71+
{
72+
String name=tf1.getText();
73+
String pass=pf1.getText();
74+
75+
if(e.getSource()==bt1)
76+
{
77+
try
78+
{
79+
ConnectionClass obj= new ConnectionClass();
80+
String s="select * from admin where username='"+name+"' and password='"+pass+"'";
81+
ResultSet rest= obj.stm.executeQuery(s);
82+
83+
if(rest.next())
84+
{
85+
System.out.println("Admin Section");
86+
new AdminSection().setVisible(true);
87+
this.setVisible(false);
88+
}
89+
90+
else
91+
{
92+
JOptionPane.showMessageDialog(null,"Your name and password is wrong");
93+
this.setVisible(false);
94+
this.setVisible(true);
95+
96+
tf1.setText("");
97+
pf1.setText("");
98+
}
99+
}
100+
catch(Exception ee)
101+
{
102+
ee.printStackTrace();
103+
}
104+
}
105+
106+
if(e.getSource()==bt2)
107+
{
108+
this.setVisible(false);
109+
}
110+
}
111+
112+
public static void main(String[] args)
113+
{
114+
new Admin().setVisible(true);
115+
}
116+
}

0 commit comments

Comments
 (0)