-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCancel.java
More file actions
70 lines (59 loc) · 1.64 KB
/
Cancel.java
File metadata and controls
70 lines (59 loc) · 1.64 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
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
class Cancel
{
JFrame f=new JFrame();
Cancel()
{
JLabel label = new JLabel();
label.setIcon(new ImageIcon("viewlogo.png"));
label.setBounds(80,3,200,100);
f.add(label);
JLabel l1=new JLabel("Ticket id");
l1.setBounds(30,90,60,30);
f.add(l1);
JTextField cname=new JTextField();
cname.setBounds(100,90,150,30);
f.add(cname);
JLabel l2=new JLabel("YourName");
l2.setBounds(30,130,60,30);
f.add(l2);
JTextField pass=new JTextField();
pass.setBounds(100,130,150,30);
f.add(pass);
JButton b1=new JButton("Cancel");
b1.setBounds(100,170,80,40);
f.add(b1);
b1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","cw202");
PreparedStatement stmt=con.prepareStatement("delete from booking where Ticket_id =? and Cname=?");
String rm = cname.getText().trim();
stmt.setInt(1, Integer.parseInt(rm));
String r = pass.getText().trim();
stmt.setString(2,r);
stmt.executeUpdate();
JOptionPane.showMessageDialog(f,"Ticket is Canceled");
con.close();
}catch(Exception b)
{
JOptionPane.showMessageDialog(f,"invalid details");
System.out.println(b);
}
}
});
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String ar[])
{
new Cancel();
}
}