-
Notifications
You must be signed in to change notification settings - Fork 4
/
DeleteCustomer.java
220 lines (177 loc) · 7.6 KB
/
DeleteCustomer.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
package travel_and_Tourism_Organisation_System;
/*
* 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.
*/
import java.awt.BorderLayout;
import java.awt.*;
import java.awt.EventQueue;
import javax.swing.border.EmptyBorder;
import java.awt.Font;
import java.awt.Image;
import java.sql.*;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class DeleteCustomer extends JFrame {
private JPanel contentPane;
Choice c1;
JLabel l2,l3,l4,l5,l6,l7,l8,l9;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
DeleteCustomer frame = new DeleteCustomer();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public DeleteCustomer() throws SQLException {
setBounds(340, 120, 850, 550);
contentPane = new JPanel();
setContentPane(contentPane);
contentPane.setLayout(null);
ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("travel_and_Tourism_Organisation_System/icons/delete.png"));
Image i3 = i1.getImage().getScaledInstance(300, 300,Image.SCALE_DEFAULT);
ImageIcon i2 = new ImageIcon(i3);
JLabel l1 = new JLabel(i2);
l1.setBounds(520,120,300,300);
add(l1);
JLabel lblName = new JLabel("DELETE CUSTOMER DETAILS");
lblName.setFont(new Font("Yu Mincho", Font.PLAIN, 20));
lblName.setBounds(118, 11, 300, 53);
contentPane.add(lblName);
JLabel lb3 = new JLabel("Id number :");
lb3.setBounds(35, 70, 200, 14);
contentPane.add(lb3);
c1 = new Choice();
Conn c = new Conn();
try{
ResultSet rs = c.s.executeQuery("select * from customer");
while(rs.next()){
c1.add(rs.getString("number"));
}
rs.close();
}catch(SQLException e){}
c1.setBounds(271, 70, 150, 30);
add(c1);
JLabel lblId = new JLabel("ID :");
lblId.setBounds(35, 110, 200, 14);
contentPane.add(lblId);
l2 = new JLabel();
l2.setBounds(271, 110, 200, 14);
contentPane.add(l2);
JLabel lb2 = new JLabel("Username :");
lb2.setBounds(35, 150, 200, 14);
contentPane.add(lb2);
l3 = new JLabel();
l3.setBounds(271, 150, 200, 14);
contentPane.add(l3);
JLabel lblName_1 = new JLabel("Name :");
lblName_1.setBounds(35, 190, 200, 14);
contentPane.add(lblName_1);
l4 = new JLabel();
l4.setBounds(271, 190, 200, 14);
contentPane.add(l4);
JLabel lblGender = new JLabel("Gender :");
lblGender.setBounds(35, 230, 200, 14);
contentPane.add(lblGender);
l5 = new JLabel();
l5.setBounds(271, 230, 200, 14);
contentPane.add(l5);
JLabel lblCountry = new JLabel("Country :");
lblCountry.setBounds(35, 270, 200, 14);
contentPane.add(lblCountry);
l6 = new JLabel();
l6.setBounds(271, 270, 200, 14);
contentPane.add(l6);
JLabel lblReserveRoomNumber = new JLabel("Permanent Address :");
lblReserveRoomNumber.setBounds(35, 310, 200, 14);
contentPane.add(lblReserveRoomNumber);
l7 = new JLabel();
l7.setBounds(271, 310, 200, 14);
contentPane.add(l7);
JLabel lblCheckInStatus = new JLabel("Phone :");
lblCheckInStatus.setBounds(35, 350, 200, 14);
contentPane.add(lblCheckInStatus);
l8 = new JLabel();
l8.setBounds(271, 350, 200, 14);
contentPane.add(l8);
JLabel lblDeposite = new JLabel("Email :");
lblDeposite.setBounds(35, 390, 200, 14);
contentPane.add(lblDeposite);
l9 = new JLabel();
l9.setBounds(271, 390, 200, 14);
contentPane.add(l9);
JButton b1 = new JButton("Check");
b1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Conn c = new Conn();
try{
ResultSet rs = c.s.executeQuery("select * from customer where number = '"+c1.getSelectedItem()+"'");
if(rs.next()){
l2.setText(rs.getString(2));
l3.setText(rs.getString(1));
l4.setText(rs.getString(4));
l5.setText(rs.getString(5));
l6.setText(rs.getString(6));
l7.setText(rs.getString(7));
l8.setText(rs.getString(8));
l9.setText(rs.getString(9));
}
}catch(Exception ee){ }
}
});
b1.setBounds(425, 70, 80, 22);
b1.setBackground(Color.BLACK);
b1.setForeground(Color.WHITE);
contentPane.add(b1);
JButton btnNewButton = new JButton("Delete");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Conn c = new Conn();
try{
String s1 = c1.getSelectedItem();
String s3 = l3.getText();
c.s.executeUpdate( "delete from customer where number = '"+s1+"'");
c.s.executeUpdate( "delete from account where username = '"+s3+"'");
// c.s.executeUpdate( "delete from customer where username = '"+s1+"'");
c.s.executeUpdate( "delete from bookpackage where number = '"+s1+"'");
c.s.executeUpdate( "delete from bookhotel where number = '"+s1+"'");
JOptionPane.showMessageDialog(null, "Customer Detail Deleted Successfully");
setVisible(false);
// new Dashboard("").setVisible(false);
new background().setVisible(true);
new SplashFrame().setVisible(true);
}catch(SQLException e1){
System.out.println(e1.getMessage());
}
catch(NumberFormatException s){
JOptionPane.showMessageDialog(null, "Please enter a valid Number");
}
}
});
btnNewButton.setBounds(100, 430, 120, 30);
btnNewButton.setBackground(Color.BLACK);
btnNewButton.setForeground(Color.WHITE);
contentPane.add(btnNewButton);
JButton btnExit = new JButton("Back");
btnExit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
});
btnExit.setBounds(260, 430, 120, 30);
btnExit.setBackground(Color.BLACK);
btnExit.setForeground(Color.WHITE);
contentPane.add(btnExit);
getContentPane().setBackground(Color.cyan);
}
}