-
Notifications
You must be signed in to change notification settings - Fork 0
/
DoctorInfoView.java
261 lines (198 loc) · 5.3 KB
/
DoctorInfoView.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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
class DoctorInfoView extends JFrame implements ActionListener
{
static Connection cn=null;
static Connection cn2=null;
Statement st=null;
Statement st2=null;
ResultSet rs=null;
ResultSet rs2=null;
JLabel lmain,ldi,lname,ladd,ltel,lspecial,ldid,ldspec,lwork,lworkfrom,lworkto,lpatlist;
JTextField tfname,tftel,tfdid,tfworkf,tfworkt;
TextArea taadd,taspecial,tapatlist;
JButton bsub,bclr,bback;
DoctorInfoView()
{
super("Doctor Information");
setSize(1024,768);
setVisible(true);
setLayout(null);
lmain=new JLabel("Doctor Information");
lmain.setBounds(440,35,107,15);
add(lmain);
ldi=new JLabel("Doctor Information");
ldi.setBounds(40,70,120,15);
add(ldi);
lname=new JLabel("Name :");
lname.setBounds(104,97,70,25);
add(lname);
tfname=new JTextField(30);
tfname.setBounds(270,97,250,20);
add(tfname);
ladd=new JLabel("Address :");
ladd.setBounds(104,138,70,15);
add(ladd);
taadd=new TextArea();
taadd.setBounds(270,138,250,100);
add(taadd);
ltel=new JLabel("Contact :");
ltel.setBounds(575,138,50,25);
add(ltel);
ldid=new JLabel("Doctor ID:");
ldid.setBounds(570,97,70,25);
add(ldid);
tfdid=new JTextField(30);
tfdid.setBounds(643,97,50,20);
add(tfdid);
tftel=new JTextField(30);
tftel.setBounds(640,138,200,20);
add(tftel);
ldspec=new JLabel("Specialization :");
ldspec.setBounds(104,310,100,25);
add(ldspec);
taspecial=new TextArea();
taspecial.setBounds(270,310,250,100);
add(taspecial);
lwork=new JLabel("Working hours :");
lwork.setBounds(570,200,100,15);
add(lwork);
lworkfrom=new JLabel("From :");
lworkfrom.setBounds(670,200,37,25);
add(lworkfrom);
tfworkf=new JTextField(30);
tfworkf.setBounds(710,200,30,20);
add(tfworkf);
lworkto=new JLabel("to :");
lworkto.setBounds(747,200,20,25);
add(lworkto);
tfworkt=new JTextField(30);
tfworkt.setBounds(775,200,30,20);
add(tfworkt);
lpatlist=new JLabel("Patient List");
lpatlist.setBounds(570,290,80,25);
add(lpatlist);
tapatlist=new TextArea();
tapatlist.setBounds(570,310,250,100);
add(tapatlist);
bsub=new JButton("SEARCH",new ImageIcon("images/search.png"));
bsub.setBounds(300,643,110,30);
add(bsub);
bclr=new JButton("CLEAR",new ImageIcon("images/LOGGOFF.PNG"));
bclr.setBounds(470,643,100,30);
add(bclr);
bback=new JButton("BACK",new ImageIcon("images/restore.png"));
bback.setBounds(580,643,100,30);
add(bback);
try{
Class.forName("org.postgresql.Driver");
cn=DriverManager.getConnection("jdbc:postgresql://localhost:5432/hospital", "akhil", "123");
Class.forName("org.postgresql.Driver");
cn2=DriverManager.getConnection("jdbc:postgresql://localhost:5432/hospital", "akhil", "123");
}
catch(Exception e)
{
System.out.println(e);
}
bclr.addActionListener(new clear());
bsub.addActionListener(new submit());
bback.addActionListener(new back());
}
class clear implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
tfname.setText("");
tftel.setText("");
tfdid.setText("");
tfworkf.setText("");
tfworkt.setText("");
taadd.setText("");
taspecial.setText("");
tapatlist.setText("");
}
}
class back implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
new docStart();
setVisible(false);
}
}
public void actionPerformed(ActionEvent ae)
{}
class patinfo implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
}
};
class submit implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
try{
tapatlist.setText("");
Integer num=Integer.parseInt(tfdid.getText());
String name;
String addr;
String contact;
String spec;
String workf;
String workt;
Statement st=cn.createStatement();
ResultSet rs=st.executeQuery("SELECT * FROM DOC WHERE did="+num);
if(rs.next())
{
num=rs.getInt("did");
name=rs.getString("name");
addr=rs.getString("address");
contact=rs.getString("contact");
spec=rs.getString("specialization");
workf=rs.getString("workfrom");
workt=rs.getString("workto");
tfname.setText(name);
taadd.setText(addr);
tftel.setText(contact);
taspecial.setText(spec);
tfworkf.setText(workf);
tfworkt.setText(workt);
}
else {
JOptionPane.showMessageDialog(null, "id no. not Found");}
}
catch(SQLException sq)
{
System.out.println(sq);
}
try{
String docname=tfname.getText();
System.out.println(docname);
Statement st2=cn2.createStatement();
ResultSet rs2=st2.executeQuery("SELECT patientno,name FROM PAT WHERE docname='"+docname+"'");
ResultSetMetaData rsmt=rs2.getMetaData();
int ctr=rsmt.getColumnCount();
while(rs2.next())
{
for(int i=1;i<=ctr;i++)
{
tapatlist.append(rs2.getString(i)+" ");
}
tapatlist.append("\n");
}
}
catch(SQLException sq)
{
System.out.println(sq);
}
}
}
public static void main(String[] args)
{
new DoctorInfoView();
System.out.println("Doctors Info Add");
}
}