Repository navigation
Expand file tree
/
Copy pathStudentDetails.java
More file actions
134 lines (113 loc) · 4.22 KB
/
Copy pathStudentDetails.java
File metadata and controls
134 lines (113 loc) · 4.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package university.management.systems;
/**
*
* @author R.SHANMUKH
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
public class StudentDetails extends JFrame implements ActionListener{
JLabel l1,l2,l3;
JTable t1;
JButton b1,b2,b3;
JTextField t2;
String x[] = {"Name","Father's Name","Age","Date of Birth","Address","Phone","Email","Class X(%)", "Class XII(%)", "Aadhar No","Roll No","Course","Branch"};
String y[][] = new String[20][13];
int i=0, j=0;
StudentDetails(){
super("Student Details");
setSize(1260,650);
setLocation(200,200);
setLayout(null);
l1 = new JLabel("Enter roll number to delete Student : ");
l1.setBounds(50,360,400,30);
l1.setFont(new Font("serif",Font.BOLD,20));
add(l1);
t2 = new JTextField();
t2.setBounds(400,360,200,30);
add(t2);
b1 = new JButton("Delete");
b1.setBackground(Color.BLACK);
b1.setForeground(Color.WHITE);
b1.setBounds(620, 360, 100 ,30);
add(b1);
l2 = new JLabel("Add New Student");
l2.setBounds(50,450,400,30);
l2.setFont(new Font("serif",Font.BOLD,20));
add(l2);
b2 = new JButton("Add Student");
b2.setBackground(Color.BLACK);
b2.setForeground(Color.WHITE);
b2.setBounds(300, 450, 150 ,30);
add(b2);
l3 = new JLabel("Update Student Details");
l3.setBounds(50,490,400,30);
l3.setFont(new Font("serif",Font.BOLD,20));
add(l3);
b3 = new JButton("Update Student");
b3.setBackground(Color.BLACK);
b3.setForeground(Color.WHITE);
b3.setBounds(300, 490, 150 ,30);
add(b3);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
try{
connect c1 = new connect();
String s1 = "select * from student";
ResultSet rs = c1.s.executeQuery(s1);
while(rs.next()){
y[i][j++]=rs.getString("name");
y[i][j++]=rs.getString("fathers_name");
y[i][j++]=rs.getString("age");
y[i][j++]=rs.getString("dob");
y[i][j++]=rs.getString("address");
y[i][j++]=rs.getString("phone");
y[i][j++]=rs.getString("email");
y[i][j++]=rs.getString("class_x");
y[i][j++]=rs.getString("class_xii");
y[i][j++]=rs.getString("aadhar");
y[i][j++]=rs.getString("rollno");
y[i][j++]=rs.getString("course");
y[i][j++]=rs.getString("branch");
i++;
j=0;
}
t1 = new JTable(y,x);
}catch(Exception e){
e.printStackTrace();
}
JScrollPane sp = new JScrollPane(t1);
sp.setBounds(20,20,1200,330);
add(sp);
getContentPane().setBackground(Color.WHITE);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent ae){
connect c1 = new connect();
if(ae.getSource() == b1){
try{
String a = t2.getText();
String q = "delete from student where rollno = '"+a+"'";
c1.s.executeUpdate(q);
this.setVisible(false);
new StudentDetails().setVisible(true);
}catch(Exception e){}
}else if(ae.getSource() == b2){
new AddStudent().f.setVisible(true);
this.setVisible(false);
}else if(ae.getSource() == b3){
//new UpdateStudent().setVisible(true);
this.setVisible(false);
}
}
public static void main(String[] args){
new StudentDetails().setVisible(true);
}
}