-
Notifications
You must be signed in to change notification settings - Fork 0
/
DeleteDetails.java
151 lines (122 loc) · 4.22 KB
/
DeleteDetails.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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package managementSystem;
import javax.swing.*;
import java.awt.*;
import java.sql.*;
import java.awt.event.*;
public class DeleteDetails extends JFrame implements ActionListener{
JButton back;
String username;
DeleteDetails(String username){
this.username=username;
setBounds(365,160,870,625);
getContentPane().setBackground(Color.WHITE);
setLayout(null);
JLabel lblusername = new JLabel("Username");
lblusername.setBounds(30, 50, 150, 25);
add(lblusername);
JLabel labelusername = new JLabel();
labelusername.setBounds(220, 50, 150, 25);
add(labelusername);
JLabel lblid = new JLabel("Id");
lblid.setBounds(30, 110, 150, 25);
add(lblid);
JLabel labelid = new JLabel();
labelid.setBounds(220, 110, 150, 25);
add(labelid);
JLabel lblnumber = new JLabel("Number");
lblnumber.setBounds(30, 170, 150, 25);
add(lblnumber);
JLabel labelnumber = new JLabel();
labelnumber.setBounds(220, 170, 150, 25);
add(labelnumber);
JLabel lblname = new JLabel("Name");
lblname.setBounds(30, 230, 150, 25);
add(lblname);
JLabel labelname = new JLabel();
labelname.setBounds(220, 230, 150, 25);
add(labelname);
JLabel lblgender = new JLabel("Gender");
lblgender.setBounds(30, 290, 150, 25);
add(lblgender);
JLabel labelgender = new JLabel();
labelgender.setBounds(220, 290, 150, 25);
add(labelgender);
JLabel lblcountry = new JLabel("Country");
lblcountry.setBounds(500, 50, 150, 25);
add(lblcountry);
JLabel labelcountry = new JLabel();
labelcountry.setBounds(690, 50, 150, 25);
add(labelcountry);
JLabel lbladdress = new JLabel("Address");
lbladdress.setBounds(500, 110, 150, 25);
add(lbladdress);
JLabel labeladdress = new JLabel();
labeladdress.setBounds(690, 110, 150, 25);
add(labeladdress);
JLabel lblphone = new JLabel("Phone");
lblphone.setBounds(500, 170, 150, 25);
add(lblphone);
JLabel labelphone = new JLabel();
labelphone.setBounds(690, 170, 150, 25);
add(labelphone);
JLabel lblemail = new JLabel("Email");
lblemail.setBounds(500, 230, 150, 25);
add(lblemail);
JLabel labelemail = new JLabel();
labelemail.setBounds(690, 230, 150, 25);
add(labelemail);
back= new JButton("Delete");
back.setBackground(Color.BLACK);
back.setForeground(Color.WHITE);
back.setBounds(350,350,100,25);
back.addActionListener(this);
add(back);
ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icons/viewall.jpg"));
Image i2= i1.getImage().getScaledInstance(600, 200, Image.SCALE_DEFAULT);
ImageIcon i3 = new ImageIcon(i2);
JLabel image = new JLabel(i3);
image.setBounds(5, 0, 70, 70);
add(image);
ImageIcon i4 = new ImageIcon(ClassLoader.getSystemResource("icons/viewall.jpg"));
Image i5= i4.getImage().getScaledInstance(600, 200, Image.SCALE_DEFAULT);
ImageIcon i6 = new ImageIcon(i5);
JLabel image2 = new JLabel(i3);
image2.setBounds(600,400,600,200);
add(image2);
try {
Conn conn= new Conn();
String query ="select * from customer where username= '"+username+"' ";
ResultSet rs = conn.s.executeQuery(query);
while(rs.next()) {
labelusername.setText(rs.getString("username"));
labelid.setText(rs.getString("id"));
labelnumber.setText(rs.getString("number"));
labelname.setText(rs.getString("name"));
labelgender.setText(rs.getString("gender"));
labelcountry.setText(rs.getString("country"));
labeladdress.setText(rs.getString("address"));
labelphone.setText(rs.getString("phone"));
labelemail.setText(rs.getString("email"));
}
}catch(Exception e) {
e.printStackTrace();
}
setVisible(true);
}
public void actionPerformed(ActionEvent ae) {
try {
Conn c= new Conn();
c.s.executeUpdate("delete from account where username= '"+username+"'");
c.s.executeUpdate("delete from customer where username= '"+username+"'");
c.s.executeUpdate("delete from bookpackage where username= '"+username+"'");
c.s.executeUpdate("delete from bookhotel where username= '"+username+"'");
JOptionPane.showMessageDialog(null,"Data Deleted Successfully");
System.exit(0);
}catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
new DeleteDetails("");
}
}