-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGUI_DeleteAccount.java
87 lines (73 loc) · 2.1 KB
/
GUI_DeleteAccount.java
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
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.sql.*;
public class GUI_DeleteAccount
{
JFrame jf4 = new JFrame("Delete Your Account");
JButton delete = new JButton("DELETE");
JButton back = new JButton("BACK");
JLabel id = new JLabel("ENTER YOUR ID");
JTextField id_tf = new JTextField(20);
JLabel password = new JLabel("PASSWORD");
JTextField password_tf = new JTextField(20);
JPanel jp1 = new JPanel();
JPanel jp2 = new JPanel();
JPanel jp3 = new JPanel();
public GUI_DeleteAccount()
{
jf4.setSize(350,200);
jf4.setVisible(true);
jf4.setDefaultCloseOperation(jf4.EXIT_ON_CLOSE);
BoxLayout l = new BoxLayout(jf4.getContentPane(),BoxLayout.Y_AXIS);
jf4.setLayout(l);
jf4.setLocation(500,300);
jp1.add(id);
jp1.add(id_tf);
jp2.add(password);
jp2.add(password_tf);
jf4.add(jp1);
jf4.add(jp2);
jp3.add(delete);
jp3.add(back);
jf4.add(jp3);
delete.addActionListener(new Handler());
back.addActionListener(new Handler());
}
void DeleteAccount() throws SQLException
{
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Multiple_Choice_Quiz_System","root","");
Statement stat = con.createStatement();
int id = Integer.parseInt(id_tf.getText());
stat.executeUpdate("delete from Student_Info where id = '"+id+"' ");
}
catch(ClassNotFoundException cnfe)
{
cnfe.printStackTrace();
}
}
class Handler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == delete)
{
try
{DeleteAccount();}
catch (SQLException e1)
{e1.printStackTrace();}
jf4.dispose();
GUI page1 = new GUI();
}
if(e.getSource()==back)
{
jf4.dispose();
GUI page1 = new GUI();
}
}
}
}