-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeletePatient.java
More file actions
89 lines (54 loc) · 1.42 KB
/
DeletePatient.java
File metadata and controls
89 lines (54 loc) · 1.42 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
package bootathonfinal;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
public class DeletePatient {
public DeletePatient(JFrame f) {
String id=JOptionPane.showInputDialog(f,"Enter the Patient id");
Connection con=ObjectFile.getjdbc();
String Query="Select Patient_id from Patients where Patient_id='"+id+"'";
Statement st;
try {
st = con.createStatement();
ResultSet rs=st.executeQuery(Query);
String s="";
while(rs.next())
{
s=rs.getString("Patient_id");
System.out.println(s);
}
if(s.equals(id))
{
System.out.println("Success");
try {
String query="delete from Patients where Patient_id='"+id+"'";
st.executeUpdate(query);
con.close();
JOptionPane.showMessageDialog(f, "The Patient is removed Successfully");
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
else
{
JOptionPane.showMessageDialog(f,"Enter the Valid Patient_id");
}
}
catch(Exception e)
{
System.out.println(e);
}
}
public static void main(String []args)
{
}
}