You are on page 1of 29

Home Projects UML Python Web Dev Compilers Blogs

Project On Hospital Management No.1 Best Web Hosting

System In Java With Source Code


March 8, 2021 by angel jude suarez

Project On Hospital Management


System In Java With Source Code
The Project On Hospital Management System In Java was developed using Java Search
Programming Language, In this Hospital Management System In Java is a mini
project connected to MySQL database.

OPEN

Java API for PPT & PPTX
Slides

Ad
A Hospital Management System Project In Java Documentation can perform the report this ad

actions that you usually see in the hospital, The following features are: Login, Add
Patient, Add Doctor, Add Room, Add User and Generate Bills.

OPEN

Java API for PPT & PPTX
Slides

Ad
In this Project also includes a Hospital Management System Project In Java
Source Code Free Download, just find the downloadable source code below and
click to start downloading. OPEN
x

No compatible source was found for this media. Java API for PPT & PPTX
Slides x
Slides x

Ad

X Ad

Java API for PPT & PPTX
Slides

OPEN

Project On Hospital Management System In Java With Source Code


To start executing Project On Hospital Management System In Java, makes sure Ad
that you have  NeatBeans IDE or any platform of Java installed in your computer.
Java API for PPT & PPTX
Slides
Project On Hospital Management
System In Java With Source Code steps
on how to run the project OPEN

These are the steps on how to run Project On Hospital Management System In
Java With Source Code

Step 1: Download source code. report this ad


First, download the source code given below.

Recent Post

Billing Android App with


Source Code

Component Diagram for


Step 2: Extract file.
Online Food Ordering System
Second, after you finished download the source code, extract the zip file.
Ecommerce Website Project in
Angular JS and MySQL with
Source Code
Component Diagram for ATM
System | UML
Inventory Management System
in Android Studio with Source
Code

Event Management System


Project in Node JS with Source
Code
Chat App on Android with
Source Code
Restaurant Management
System Project in Android
Source Code
Component Diagram for
Online Shopping System
Music Player App In Android
Step 3: Open Netbeans.
Studio With Source Code
Third, open “Netbeans IDE”.

Step 4: Click open project.


Fourth, click open project and choose your download source code.

How to Create Employee


Management System
How to Create Payroll System

How to Create Student


Information System
HTML Editor
Best Online Java Compiler –
Online Java Compiler
Best Online Python Compiler –
Online Python Compiler
Best Online PHP Compiler –
Online PHP Compiler
Hire Us

Search Results

Programming Tutorials
Step 5: Add jar file.
Fifth, add all jar file into the project folder library. C Tutorial
C++ Tutorial

Java Tutorial
PHP Tutorial

Visual basic Tutorial


Python Tutorial
Free Online Compilers

Online Python Compiler

Online Java Compiler


Online PHP Compiler

Step 6: Run the project.


Sixth, right click the project folder and click run.

Step 6: The project design


The actual design of the project.
The Code Given Below Is For The
Doctor Details

import java.awt.HeadlessException;

 
import java.awt.HeadlessException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import javax.swing.JOptionPane;
import java.text.SimpleDateFormat;
 
/*
* 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.
*/
*/
1
/**
2
*
3
* @author Agarwal
4
*/
5
public class Entry extends javax.swing.JFrame {
6
Connection con=null;
7
ResultSet rs=null;
8
PreparedStatement pst=null;
9
 
10
    /**
11
     * Creates new form Entry
12
     */
13
    public Entry() {
14
        initComponents();
15
    }
16
private void reset()
17
{
18
    txtId.setText("");
19
    txtName.setText("");
20
    txtFname.setText("");
21
    txtC.setText("");
22
    txtAd.setText("");
23
    txtQ.setText("");
24
    txtE.setText("");
25
    txtD.setText("");
26
    cmbB.setSelectedIndex(­1);
27
    cmbG.setSelectedIndex(­1);
28
    btnSave.setEnabled(true);
29
    btnUpdate.setEnabled(false);
30
    btnDelete.setEnabled(false);
31
    }
32
    /**
33
     * This method is called from within the constructor to initialize the form.
34
     * WARNING: Do NOT modify this code. The content of this method is always
35
     * regenerated by the Form Editor.
36
     */
37
    @SuppressWarnings("unchecked")
38
    // <editor­fold defaultstate="collapsed" desc="Generated Code">                          
39
    private void initComponents() {
40
 
41
        jPanel1 = new javax.swing.JPanel();
42
        jLabel1 = new javax.swing.JLabel();
43
        jLabel2 = new javax.swing.JLabel();
44
        jLabel3 = new javax.swing.JLabel();
45
        jLabel4 = new javax.swing.JLabel();
46
        jLabel5 = new javax.swing.JLabel();
47
        jLabel6 = new javax.swing.JLabel();
48
        jLabel7 = new javax.swing.JLabel();
49
        jLabel9 = new javax.swing.JLabel();
50
        jLabel10 = new javax.swing.JLabel();
51
        jLabel11 = new javax.swing.JLabel();
52
        txtId = new javax.swing.JTextField();
53
        txtName = new javax.swing.JTextField();
54
        txtFname = new javax.swing.JTextField();
55
        txtE = new javax.swing.JTextField();
56
        txtC = new javax.swing.JTextField();
57
        txtAd = new javax.swing.JTextField();
58
        txtQ = new javax.swing.JTextField();
59
        txtD = new javax.swing.JTextField();
60
        cmbG = new javax.swing.JComboBox();
61
        cmbB = new javax.swing.JComboBox();
62
        jLabel8 = new javax.swing.JLabel();
63
        jPanel2 = new javax.swing.JPanel();
64
        btnSave = new javax.swing.JButton();
65
        btnUpdate = new javax.swing.JButton();
66
        btnDelete = new javax.swing.JButton();
67
        btnNew = new javax.swing.JButton();
68
        btnGet = new javax.swing.JButton();
69
 
70
        addWindowListener(new java.awt.event.WindowAdapter() {
71
            public void windowClosing(java.awt.event.WindowEvent evt) {
72
                formWindowClosing(evt);
73
            }
74
        });
75
 
76
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Doctor Details"));
77
 
78
        jLabel1.setText("Doctor ID");
79
 
80
        jLabel2.setText("Full Name");
81
 
82
        jLabel3.setText("Father's Name");
83
 
84
        jLabel4.setText("Email­id");
85
 
86
        jLabel5.setText("Contact no");
87
 
88
        jLabel6.setText("Address");
89
 
90
        jLabel7.setText("Qualifications");
91
 
92
        jLabel9.setText("Gender");
93
 
94
        jLabel10.setText("Blood Group");
95
 
96
        jLabel11.setText("Date Of Joining");
97
 
98
        txtD.addActionListener(new java.awt.event.ActionListener() {
99
            public void actionPerformed(java.awt.event.ActionEvent evt) {
100
                txtDActionPerformed(evt);
101
            }
102
        });
103
 
104
        cmbG.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "M", "F" }));
105
        cmbG.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "M", "F" }));
105
 
106
        cmbB.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "O+", "O­", "A+", "A­", "B+", "B­",
107
"AB+", "AB­" }));
108
 
109
        jLabel8.setText("YYYY­MM­DD");
110
 
111
        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
112
        jPanel1.setLayout(jPanel1Layout);
113
        jPanel1Layout.setHorizontalGroup(
114
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
115
            .addGroup(jPanel1Layout.createSequentialGroup()
116
                .addContainerGap()
117
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
118
                    .addGroup(jPanel1Layout.createSequentialGroup()
119
                        .addComponent(jLabel11)
120
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 21, Short.MAX_VALUE)
121
                        .addComponent(txtD, javax.swing.GroupLayout.PREFERRED_SIZE, 111,
122
javax.swing.GroupLayout.PREFERRED_SIZE))
123
                    .addGroup(jPanel1Layout.createSequentialGroup()
124
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
125
                            .addComponent(jLabel1)
126
                            .addComponent(jLabel2)
127
                            .addComponent(jLabel3)
128
                            .addComponent(jLabel4)
129
                            .addComponent(jLabel5)
130
                            .addComponent(jLabel6)
131
                            .addComponent(jLabel7))
132
                        .addGap(27, 27, 27)
133
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
134
                            .addComponent(txtQ, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
135
                            .addComponent(txtAd)
136
                            .addComponent(txtC)
137
                            .addComponent(txtE)
138
                            .addComponent(txtFname)
139
                            .addComponent(txtName)
140
                            .addComponent(txtId)))
141
                    .addGroup(jPanel1Layout.createSequentialGroup()
142
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
143
                            .addComponent(jLabel9)
144
                            .addComponent(jLabel10))
145
                        .addGap(36, 36, 36)
146
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
147
                            .addComponent(cmbG, javax.swing.GroupLayout.PREFERRED_SIZE,
148
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
149
                            .addComponent(cmbB, javax.swing.GroupLayout.PREFERRED_SIZE,
150
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
151
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
152
                .addComponent(jLabel8)
153
                .addContainerGap(63, Short.MAX_VALUE))
154
        );
155
        jPanel1Layout.setVerticalGroup(
156
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
157
            .addGroup(jPanel1Layout.createSequentialGroup()
158
                .addGap(20, 20, 20)
159
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
160
                    .addComponent(jLabel1)
161
                    .addComponent(txtId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
162
javax.swing.GroupLayout.PREFERRED_SIZE))
163
                .addGap(18, 18, 18)
164
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
165
                    .addComponent(jLabel2)
166
                    .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE,
167
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
168
                .addGap(18, 18, 18)
169
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
170
                    .addComponent(jLabel3)
171
                    .addComponent(txtFname, javax.swing.GroupLayout.PREFERRED_SIZE,
172
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
173
                .addGap(18, 18, 18)
174
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
175
                    .addComponent(jLabel4)
176
                    .addComponent(txtE, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
177
javax.swing.GroupLayout.PREFERRED_SIZE))
178
                .addGap(18, 18, 18)
179
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
180
                    .addComponent(jLabel5)
181
                    .addComponent(txtC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
182
javax.swing.GroupLayout.PREFERRED_SIZE))
183
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
184
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
185
                    .addComponent(jLabel6)
186
                    .addComponent(txtAd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
187
javax.swing.GroupLayout.PREFERRED_SIZE))
188
                .addGap(18, 18, 18)
189
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
190
                    .addComponent(jLabel7)
191
                    .addComponent(txtQ, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
192
javax.swing.GroupLayout.PREFERRED_SIZE))
193
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
194
                    .addGroup(jPanel1Layout.createSequentialGroup()
195
                        .addGap(24, 24, 24)
196
                        .addComponent(jLabel9))
197
                    .addGroup(jPanel1Layout.createSequentialGroup()
198
                        .addGap(18, 18, 18)
199
                        .addComponent(cmbG, javax.swing.GroupLayout.PREFERRED_SIZE,
200
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
201
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
202
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
203
                    .addComponent(jLabel10)
204
                    .addComponent(cmbB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
205
javax.swing.GroupLayout.PREFERRED_SIZE))
206
                .addGap(17, 17, 17)
207
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
208
                    .addComponent(jLabel11)
209
                    .addComponent(jLabel11)
209
                    .addComponent(txtD, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
210
javax.swing.GroupLayout.PREFERRED_SIZE)
211
                    .addComponent(jLabel8))
212
                .addContainerGap(38, Short.MAX_VALUE))
213
        );
214
 
215
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
216
 
217
        btnSave.setText("Save");
218
        btnSave.addActionListener(new java.awt.event.ActionListener() {
219
            public void actionPerformed(java.awt.event.ActionEvent evt) {
220
                btnSaveActionPerformed(evt);
221
            }
222
        });
223
 
224
        btnUpdate.setText("Update");
225
        btnUpdate.setEnabled(false);
226
        btnUpdate.addActionListener(new java.awt.event.ActionListener() {
227
            public void actionPerformed(java.awt.event.ActionEvent evt) {
228
                btnUpdateActionPerformed(evt);
229
            }
230
        });
231
 
232
        btnDelete.setText("Delete");
233
        btnDelete.setEnabled(false);
234
        btnDelete.addActionListener(new java.awt.event.ActionListener() {
235
            public void actionPerformed(java.awt.event.ActionEvent evt) {
236
                btnDeleteActionPerformed(evt);
237
            }
238
        });
239
 
240
        btnNew.setText("New");
241
        btnNew.addActionListener(new java.awt.event.ActionListener() {
242
            public void actionPerformed(java.awt.event.ActionEvent evt) {
243
                btnNewActionPerformed(evt);
244
            }
245
        });
246
 
247
        btnGet.setText("Get Data");
248
        btnGet.addActionListener(new java.awt.event.ActionListener() {
249
            public void actionPerformed(java.awt.event.ActionEvent evt) {
250
                btnGetActionPerformed(evt);
251
            }
252
        });
253
 
254
        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
255
        jPanel2.setLayout(jPanel2Layout);
256
        jPanel2Layout.setHorizontalGroup(
257
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
258
            .addGroup(jPanel2Layout.createSequentialGroup()
259
                .addGap(42, 42, 42)
260
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
261
                    .addComponent(btnNew, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
262
Short.MAX_VALUE)
263
                    .addComponent(btnDelete, javax.swing.GroupLayout.DEFAULT_SIZE,
264
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
265
                    .addComponent(btnUpdate, javax.swing.GroupLayout.DEFAULT_SIZE,
266
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
267
                    .addComponent(btnSave, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
268
Short.MAX_VALUE)
269
                    .addComponent(btnGet, javax.swing.GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE))
270
                .addContainerGap(86, Short.MAX_VALUE))
271
        );
272
        jPanel2Layout.setVerticalGroup(
273
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
274
            .addGroup(jPanel2Layout.createSequentialGroup()
275
                .addGap(24, 24, 24)
276
                .addComponent(btnSave)
277
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
278
                .addComponent(btnUpdate)
279
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
280
                .addComponent(btnDelete)
281
                .addGap(18, 18, 18)
282
                .addComponent(btnNew)
283
                .addGap(18, 18, 18)
284
                .addComponent(btnGet)
285
                .addContainerGap(32, Short.MAX_VALUE))
286
        );
287
 
288
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
289
        getContentPane().setLayout(layout);
290
        layout.setHorizontalGroup(
291
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
292
            .addGroup(layout.createSequentialGroup()
293
                .addContainerGap()
294
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
295
Short.MAX_VALUE)
296
                .addGap(18, 18, 18)
297
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
298
javax.swing.GroupLayout.PREFERRED_SIZE))
299
        );
300
        layout.setVerticalGroup(
301
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
302
            .addGroup(layout.createSequentialGroup()
303
                .addGap(50, 50, 50)
304
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
305
javax.swing.GroupLayout.PREFERRED_SIZE))
306
            .addGroup(layout.createSequentialGroup()
307
                .addGap(41, 41, 41)
308
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
309
javax.swing.GroupLayout.PREFERRED_SIZE))
310
        );
311
 
312
        pack();
313
        pack();
313
    }// </editor­fold>                        
314
 
315
    private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {                                          
316
        try{
317
            int P = JOptionPane.showConfirmDialog(null," Are you sure want to delete
318
?","Confirmation",JOptionPane.YES_NO_OPTION);
319
            if (P==0)
320
            {
321
                con=Connect.ConnectDB();
322
                String sql= "delete from Doctor where DoctorID = '" + txtId.getText() + "'";
323
                pst=con.prepareStatement(sql);
324
                pst.execute();
325
                JOptionPane.showMessageDialog(this,"Successfully deleted","Record",JOptionPane.INFORMATION_MESSAGE);
326
 
327
                reset();
328
            }
329
        }catch(HeadlessException | SQLException ex){
330
            JOptionPane.showMessageDialog(this,ex);
331
        }
332
        // TODO add your handling code here:
333
    }                                        
334
 
335
    private void btnNewActionPerformed(java.awt.event.ActionEvent evt) {                                      
336
      reset();  // TODO add your handling code here:
337
    }                                      
338
 
339
    private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {                                        
340
try{
341
            con=Connect.ConnectDB();
342
            if (txtId.getText().equals("")) {
343
                JOptionPane.showMessageDialog( this, "Please enter doctor id","Error", JOptionPane.ERROR_MESSAGE);
344
                return;
345
 
346
            }
347
            if (txtName.getText().equals("")) {
348
                JOptionPane.showMessageDialog( this, "Please enter doctor name","Error", JOptionPane.ERROR_MESSAGE);
349
                return;
350
 
351
            }
352
            if (txtFname.getText().equals("")) {
353
                JOptionPane.showMessageDialog( this, "Please enter Father's name","Error", JOptionPane.ERROR_MESSAGE);
354
                return;
355
            }
356
            if (txtAd.getText().equals("")) {
357
                JOptionPane.showMessageDialog( this, "Please enter address","Error", JOptionPane.ERROR_MESSAGE);
358
                return;
359
            }
360
           if (txtC.getText().equals("")) {
361
                JOptionPane.showMessageDialog( this, "Please enter contact no.","Error", JOptionPane.ERROR_MESSAGE);
362
                return;
363
            }
364
        
365
            if (txtQ.getText().equals("")) {
366
                JOptionPane.showMessageDialog( this, "Please enter qualifications","Error",
367
JOptionPane.ERROR_MESSAGE);
368
                return;
369
            }
370
            
371
             if (cmbG.getSelectedItem().equals("")) {
372
                JOptionPane.showMessageDialog( this, "Please select gender","Error", JOptionPane.ERROR_MESSAGE);
373
                return;
374
            }
375
            if (cmbB.getSelectedItem().equals("")) {
376
                JOptionPane.showMessageDialog( this, "Please select blood group","Error", JOptionPane.ERROR_MESSAGE);
377
                return;
378
            }
379
          
380
            if (txtD.getText().equals("")) {
381
                JOptionPane.showMessageDialog( this, "Please enter joining date","Error", JOptionPane.ERROR_MESSAGE);
382
                return;
383
            }
384
        Statement stmt;
385
        stmt= con.createStatement();
386
        String sql1="Select DoctorID from Doctor where DoctorID= '" + txtId.getText() + "'";
387
        rs=stmt.executeQuery(sql1);
388
        if(rs.next()){
389
            JOptionPane.showMessageDialog( this, "Doctor ID already exists","Error", JOptionPane.ERROR_MESSAGE);
390
        txtId.setText("");
391
      
392
       return;
393
      }
394
            String sql= "insert into
395
Doctor(DoctorID,Doctorname,FatherName,Email,ContacNo,Qualifications,Gender,BloodGroup,DateOfJoining,Address)values('"+
396
txtId.getText() + "','"+ txtName.getText() + "','"+ txtFname.getText() + "','"+ txtE.getText() + "','"+ txtC.getText()
397
+ "','"+ txtQ.getText() + "','"+  cmbG.getSelectedItem() + "','"+ cmbB.getSelectedItem() + "','" + txtD.getText() +
398
"','" + txtAd.getText() + "')";
399
 
400
            pst=con.prepareStatement(sql);
401
            pst.execute();
402
            JOptionPane.showMessageDialog(this,"Successfully saved","Doctor Record",JOptionPane.INFORMATION_MESSAGE);
403
            btnSave.setEnabled(false);
404
 
405
        }catch(HeadlessException | SQLException ex){
406
            JOptionPane.showMessageDialog(this,ex);
407
        }        // TODO add your handling code here:
408
    }                                      
409
 
410
    private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt) {                                          
411
        try{
412
            con=Connect.ConnectDB();
413
            String sql= "update Doctor set Doctorname='" + txtName.getText() + "',FatherName='" + txtFname.getText() +
414
"',Email='" + txtE.getText() + "',ContacNo='"+ txtC.getText() + "',Qualifications='"+ txtQ.getText() +  "',Gender='" +
415
cmbG.getSelectedItem() + "',BloodGroup='"+ cmbB.getSelectedItem() + "',DateOfJoining='" + txtD.getText() +
416
"',Address='" + txtAd.getText() + "' where DoctorID='" + txtId.getText() + "'";
417
"',Address='" + txtAd.getText() + "' where DoctorID='" + txtId.getText() + "'";
417
            pst=con.prepareStatement(sql);
418
            pst.execute();
419
            JOptionPane.showMessageDialog(this,"Successfully updated");
420
            btnUpdate.setEnabled(false);
421
            }catch(HeadlessException | SQLException ex){
422
            JOptionPane.showMessageDialog(this,ex);
423
            }        // TODO add your handling code here:
424
    }                                        
425
 
426
    private void btnGetActionPerformed(java.awt.event.ActionEvent evt) {                                      
427
     this.hide();
428
     DocRec frm=new DocRec();
429
     frm.setVisible(true);        // TODO add your handling code here:
430
    }                                      
431
 
432
    private void formWindowClosing(java.awt.event.WindowEvent evt) {                                  
433
         // TODO add your handling code here:
434
    }                                  
435
 
436
    private void txtDActionPerformed(java.awt.event.ActionEvent evt) {                                    
437
        // TODO add your handling code here:
438
    }                                    
439
 
440
    /**
441
     * @param args the command line arguments
442
     */
443
    public static void main(String args[]) {
444
        /* Set the Nimbus look and feel */
445
        //<editor­fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
446
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
447
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
448
         */
449
        try {
450
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
451
                if ("Nimbus".equals(info.getName())) {
452
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
453
                    break;
454
                }
455
            }
456
        } catch (ClassNotFoundException ex) {
457
            java.util.logging.Logger.getLogger(Entry.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
458
        } catch (InstantiationException ex) {
459
            java.util.logging.Logger.getLogger(Entry.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
460
        } catch (IllegalAccessException ex) {
461
            java.util.logging.Logger.getLogger(Entry.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
462
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
463
            java.util.logging.Logger.getLogger(Entry.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
464
        }
465
        //</editor­fold>
466
 
467
        /* Create and display the form */
468
        java.awt.EventQueue.invokeLater(new Runnable() {
469
            @Override
470
            public void run() {
471
                new Entry().setVisible(true);
472
            }
473
        });
474
    }
475
 
476
    // Variables declaration ­ do not modify                    
477
    public javax.swing.JButton btnDelete;
478
    public javax.swing.JButton btnGet;
479
    public javax.swing.JButton btnNew;
480
    public javax.swing.JButton btnSave;
481
    public javax.swing.JButton btnUpdate;
482
    public javax.swing.JComboBox cmbB;
483
    public javax.swing.JComboBox cmbG;
484
    private javax.swing.JLabel jLabel1;
485
    private javax.swing.JLabel jLabel10;
486
    private javax.swing.JLabel jLabel11;
487
    private javax.swing.JLabel jLabel2;
488
    private javax.swing.JLabel jLabel3;
489
    private javax.swing.JLabel jLabel4;
490
    private javax.swing.JLabel jLabel5;
491
    private javax.swing.JLabel jLabel6;
492
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    public javax.swing.JTextField txtAd;
    public javax.swing.JTextField txtC;
    public javax.swing.JTextField txtD;
    public javax.swing.JTextField txtE;
    public javax.swing.JTextField txtFname;
    public javax.swing.JTextField txtId;
    public javax.swing.JTextField txtName;
    public javax.swing.JTextField txtQ;
    // End of variables declaration                  
}
 

In this module which is the doctor details or doctor registration module.


The Code Given Below Is For The
Patient Details Module

import java.awt.HeadlessException;

 
import java.awt.HeadlessException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
 
/*
* 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.
*/
/**
*
* @author Agarwal
*/
public class Registration extends javax.swing.JFrame {
Connection con=null;
ResultSet rs=null;
PreparedStatement pst=null;
    /**
     * Creates new form Registration
     */
1     public Registration() {
2         initComponents();
3     }
4 private void Reset()
5 {
6     txtId.setText("");
7     txtName.setText("");
8     txtFname.setText("");
9     txtContact.setText("");
10     txtAdd.setText("");
11     txtAge.setText("");
12     txtEmail.setText("");
13     txtInfo.setText("");
14     cmbBG.setSelectedIndex(­1);
15     cmbGender.setSelectedIndex(­1);
16     btnSave.setEnabled(true);
17     btnUpdate.setEnabled(false);
18     btnDelete.setEnabled(false);
19     txtId.requestDefaultFocus();
20 }
21     /**
22      * This method is called from within the constructor to initialize the form.
23      * WARNING: Do NOT modify this code. The content of this method is always
24      * regenerated by the Form Editor.
25      */
26     @SuppressWarnings("unchecked")
27     // <editor­fold defaultstate="collapsed" desc="Generated Code">                          
28     private void initComponents() {
29  
30         jPanel1 = new javax.swing.JPanel();
31         jLabel1 = new javax.swing.JLabel();
32         jLabel2 = new javax.swing.JLabel();
33         jLabel3 = new javax.swing.JLabel();
34         jLabel4 = new javax.swing.JLabel();
35         jLabel5 = new javax.swing.JLabel();
36         jLabel6 = new javax.swing.JLabel();
37         jLabel7 = new javax.swing.JLabel();
38         txtId = new javax.swing.JTextField();
39         txtName = new javax.swing.JTextField();
40         txtFname = new javax.swing.JTextField();
41         txtAdd = new javax.swing.JTextField();
42         txtContact = new javax.swing.JTextField();
43         txtEmail = new javax.swing.JTextField();
44         txtAge = new javax.swing.JTextField();
45         jLabel8 = new javax.swing.JLabel();
46         jLabel9 = new javax.swing.JLabel();
47         cmbGender = new javax.swing.JComboBox();
48         cmbBG = new javax.swing.JComboBox();
49         jLabel10 = new javax.swing.JLabel();
50         jScrollPane1 = new javax.swing.JScrollPane();
51         txtInfo = new javax.swing.JTextArea();
52         jPanel2 = new javax.swing.JPanel();
53         btnSave = new javax.swing.JButton();
54         btnNew = new javax.swing.JButton();
55         btnUpdate = new javax.swing.JButton();
56         btnDelete = new javax.swing.JButton();
57         btnGetData = new javax.swing.JButton();
57         btnGetData = new javax.swing.JButton();
58  
59         addWindowListener(new java.awt.event.WindowAdapter() {
60             public void windowClosed(java.awt.event.WindowEvent evt) {
61                 formWindowClosed(evt);
62             }
63         });
64  
65         jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Patient Detail's"));
66  
67         jLabel1.setText("Patient ID");
68  
69         jLabel2.setText("Name");
70  
71         jLabel3.setText("Father's Name");
72  
73         jLabel4.setText("Address");
74  
75         jLabel5.setText("Contact No.");
76  
77         jLabel6.setText("Email­id");
78  
79         jLabel7.setText("Age");
80  
81         txtEmail.addActionListener(new java.awt.event.ActionListener() {
82             public void actionPerformed(java.awt.event.ActionEvent evt) {
83                 txtEmailActionPerformed(evt);
84             }
85         });
86  
87         jLabel8.setText("Gender");
88  
89         jLabel9.setText("Blood Group");
90  
91         cmbGender.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "M", "F" }));
92  
93         cmbBG.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "O+", "O­", "A+", "A­", "B+", "B­
94 ", "AB+", "AB­" }));
95  
96         jLabel10.setText("Information");
97  
98         txtInfo.setColumns(20);
99         txtInfo.setRows(5);
100         jScrollPane1.setViewportView(txtInfo);
101  
102         javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
103         jPanel1.setLayout(jPanel1Layout);
104         jPanel1Layout.setHorizontalGroup(
105             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
106             .addGroup(jPanel1Layout.createSequentialGroup()
107                 .addContainerGap()
108                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
109                     .addComponent(jLabel1)
110                     .addComponent(jLabel2)
111                     .addComponent(jLabel3)
112                     .addComponent(jLabel4)
113                     .addComponent(jLabel5)
114                     .addComponent(jLabel6)
115                     .addComponent(jLabel7)
116                     .addComponent(jLabel8)
117                     .addComponent(jLabel9)
118                     .addComponent(jLabel10))
119                 .addGap(52, 52, 52)
120                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
121                     .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
122 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
123                     .addComponent(cmbBG, javax.swing.GroupLayout.PREFERRED_SIZE,
124 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
125                     .addComponent(cmbGender, javax.swing.GroupLayout.PREFERRED_SIZE,
126 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
127                     .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
128 false)
129                         .addComponent(txtAge, javax.swing.GroupLayout.Alignment.LEADING,
130 javax.swing.GroupLayout.DEFAULT_SIZE, 147, Short.MAX_VALUE)
131                         .addComponent(txtEmail, javax.swing.GroupLayout.Alignment.LEADING)
132                         .addComponent(txtContact, javax.swing.GroupLayout.Alignment.LEADING)
133                         .addComponent(txtAdd, javax.swing.GroupLayout.Alignment.LEADING)
134                         .addComponent(txtFname, javax.swing.GroupLayout.Alignment.LEADING)
135                         .addComponent(txtName, javax.swing.GroupLayout.Alignment.LEADING)
136                         .addComponent(txtId, javax.swing.GroupLayout.Alignment.LEADING)))
137                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
138         );
139         jPanel1Layout.setVerticalGroup(
140             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
141             .addGroup(jPanel1Layout.createSequentialGroup()
142                 .addGap(24, 24, 24)
143                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
144                     .addComponent(jLabel1)
145                     .addComponent(txtId, javax.swing.GroupLayout.PREFERRED_SIZE,
146 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
147                 .addGap(14, 14, 14)
148                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
149                     .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE,
150 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
151                     .addComponent(jLabel2))
152                 .addGap(12, 12, 12)
153                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
154                     .addComponent(txtFname, javax.swing.GroupLayout.PREFERRED_SIZE,
155 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
156                     .addComponent(jLabel3))
157                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
158                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
159                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
160                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
161                             .addComponent(jLabel4)
161                             .addComponent(jLabel4)
162                             .addComponent(txtAdd, javax.swing.GroupLayout.PREFERRED_SIZE,
163 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
164                         .addGap(18, 18, 18)
165                         .addComponent(jLabel5))
166                     .addComponent(txtContact, javax.swing.GroupLayout.Alignment.TRAILING,
167 javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
168 javax.swing.GroupLayout.PREFERRED_SIZE))
169                 .addGap(18, 18, 18)
170                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
171                     .addComponent(jLabel6)
172                     .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE,
173 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
174                 .addGap(18, 18, 18)
175                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
176                     .addComponent(jLabel7)
177                     .addComponent(txtAge, javax.swing.GroupLayout.PREFERRED_SIZE,
178 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
179                 .addGap(18, 18, 18)
180                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
181                     .addComponent(jLabel8)
182                     .addComponent(cmbGender, javax.swing.GroupLayout.PREFERRED_SIZE,
183 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
184                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
185                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
186                     .addComponent(jLabel9)
187                     .addComponent(cmbBG, javax.swing.GroupLayout.PREFERRED_SIZE,
188 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
189                 .addGap(23, 23, 23)
190                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
191                     .addComponent(jLabel10)
192                     .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
193 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
194                 .addContainerGap(60, Short.MAX_VALUE))
195         );
196  
197         jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
198  
199         btnSave.setText("Save");
200         btnSave.addActionListener(new java.awt.event.ActionListener() {
201             public void actionPerformed(java.awt.event.ActionEvent evt) {
202                 btnSaveActionPerformed(evt);
203             }
204         });
205  
206         btnNew.setText("New");
207         btnNew.addActionListener(new java.awt.event.ActionListener() {
208             public void actionPerformed(java.awt.event.ActionEvent evt) {
209                 btnNewActionPerformed(evt);
210             }
211         });
212  
213         btnUpdate.setText("Update");
214         btnUpdate.setEnabled(false);
215         btnUpdate.addActionListener(new java.awt.event.ActionListener() {
216             public void actionPerformed(java.awt.event.ActionEvent evt) {
217                 btnUpdateActionPerformed(evt);
218             }
219         });
220  
221         btnDelete.setText("Delete");
222         btnDelete.setEnabled(false);
223         btnDelete.addActionListener(new java.awt.event.ActionListener() {
224             public void actionPerformed(java.awt.event.ActionEvent evt) {
225                 btnDeleteActionPerformed(evt);
226             }
227         });
228  
229         btnGetData.setText("GetData");
230         btnGetData.addActionListener(new java.awt.event.ActionListener() {
231             public void actionPerformed(java.awt.event.ActionEvent evt) {
232                 btnGetDataActionPerformed(evt);
233             }
234         });
235  
236         javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
237         jPanel2.setLayout(jPanel2Layout);
238         jPanel2Layout.setHorizontalGroup(
239             jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
240             .addGroup(jPanel2Layout.createSequentialGroup()
241                 .addGap(43, 43, 43)
242                 .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
243                     .addComponent(btnSave, javax.swing.GroupLayout.DEFAULT_SIZE,
244 javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
245                     .addComponent(btnNew, javax.swing.GroupLayout.DEFAULT_SIZE,
246 javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
247                     .addComponent(btnUpdate, javax.swing.GroupLayout.DEFAULT_SIZE,
248 javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
249                     .addComponent(btnDelete, javax.swing.GroupLayout.DEFAULT_SIZE,
250 javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
251                     .addComponent(btnGetData, javax.swing.GroupLayout.DEFAULT_SIZE, 104, Short.MAX_VALUE))
252                 .addContainerGap(18, Short.MAX_VALUE))
253         );
254         jPanel2Layout.setVerticalGroup(
255             jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
256             .addGroup(jPanel2Layout.createSequentialGroup()
257                 .addGap(25, 25, 25)
258                 .addComponent(btnSave)
259                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
260                 .addComponent(btnNew)
261                 .addGap(18, 18, 18)
262                 .addComponent(btnUpdate)
263                 .addGap(18, 18, 18)
264                 .addComponent(btnDelete)
265                 .addGap(18, 18, 18)
265                 .addGap(18, 18, 18)
266                 .addComponent(btnGetData)
267                 .addContainerGap(34, Short.MAX_VALUE))
268         );
269  
270         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
271         getContentPane().setLayout(layout);
272         layout.setHorizontalGroup(
273             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
274             .addGroup(layout.createSequentialGroup()
275                 .addContainerGap()
276                 .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
277 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
278                 .addGap(18, 18, 18)
279                 .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
280 javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
281                 .addContainerGap())
282         );
283         layout.setVerticalGroup(
284             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
285             .addGroup(layout.createSequentialGroup()
286                 .addContainerGap()
287                 .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
288 javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
289                 .addContainerGap())
290             .addGroup(layout.createSequentialGroup()
291                 .addGap(69, 69, 69)
292                 .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
293 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
294                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
295         );
296  
297         pack();
298     }// </editor­fold>                        
299  
300     private void txtEmailActionPerformed(java.awt.event.ActionEvent evt)
301 {                                        
302         // TODO add your handling code here:
303     }                                        
304  
305     private void btnNewActionPerformed(java.awt.event.ActionEvent evt) {                                      
306     Reset();        // TODO add your handling code here:
307     }                                      
308  
309     private void btnSaveActionPerformed(java.awt.event.ActionEvent evt)
310 {                                        
311 try{
312             con=Connect.ConnectDB();
313             if (txtId.getText().equals("")) {
314                 JOptionPane.showMessageDialog( this, "Please enter patient id","Error",
315 JOptionPane.ERROR_MESSAGE);
316                 return;
317  
318             }
319             if (txtName.getText().equals("")) {
320                 JOptionPane.showMessageDialog( this, "Please enter patient name","Error",
321 JOptionPane.ERROR_MESSAGE);
322                 return;
323  
324             }
325             if (txtFname.getText().equals("")) {
326                 JOptionPane.showMessageDialog( this, "Please enter Father's name","Error",
327 JOptionPane.ERROR_MESSAGE);
328                 return;
329             }
330             if (txtAdd.getText().equals("")) {
331                 JOptionPane.showMessageDialog( this, "Please enter address","Error", JOptionPane.ERROR_MESSAGE);
332                 return;
333             }
334            if (txtContact.getText().equals("")) {
335                 JOptionPane.showMessageDialog( this, "Please enter contact no.","Error",
336 JOptionPane.ERROR_MESSAGE);
337                 return;
338             }
339         
340             if (txtAge.getText().equals("")) {
341                 JOptionPane.showMessageDialog( this, "Please enter age","Error", JOptionPane.ERROR_MESSAGE);
342                 return;
343             }
344              if (cmbGender.getSelectedItem().equals("")) {
345                 JOptionPane.showMessageDialog( this, "Please select gender","Error", JOptionPane.ERROR_MESSAGE);
346                 return;
347             }
348             if (cmbBG.getSelectedItem().equals("")) {
349                 JOptionPane.showMessageDialog( this, "Please select blood group","Error",
350 JOptionPane.ERROR_MESSAGE);
351                 return;
352             }
353           
354           
355    Statement stmt;
356        stmt= con.createStatement();
357        String sql1="Select PatientID from PatientRegistration where PatientID= '" + txtId.getText() + "'";
358       rs=stmt.executeQuery(sql1);
359       if(rs.next()){
360         JOptionPane.showMessageDialog( this, "Patient ID already exists","Error", JOptionPane.ERROR_MESSAGE);
361         txtId.setText("");
362         txtId.requestDefaultFocus();
363        return;
364       }
365             String sql= "insert into
366 PatientRegistration(PatientID,Patientname,FatherName,Email,ContactNo,Age,Remarks,Gen,BG,Address)values('"+
367 txtId.getText() + "','"+ txtName.getText() + "','"+ txtFname.getText() + "','"+ txtEmail.getText() + "','"+
368 txtContact.getText() + "'," + txtAge.getText() + ",'"+ txtInfo.getText() + "','" + cmbGender.getSelectedItem() +
369 "','"+ cmbBG.getSelectedItem() + "','" + txtAdd.getText() + "')";
369 "','"+ cmbBG.getSelectedItem() + "','" + txtAdd.getText() + "')";
370  
371             pst=con.prepareStatement(sql);
372             pst.execute();
373             JOptionPane.showMessageDialog(this,"Successfully
374 Registered","Patient",JOptionPane.INFORMATION_MESSAGE);
375             btnSave.setEnabled(false);
376  
377         }catch(HeadlessException | SQLException ex){
378             JOptionPane.showMessageDialog(this,ex);
379         }
380                                           
381  
382        // TODO add your handling code here:
383     }                                      
384  
385     private void btnGetDataActionPerformed(java.awt.event.ActionEvent evt)
386 {                                          
387 this.hide();
388 PatientRec frm=new PatientRec();
389 frm.setVisible(true);        // TODO add your handling code here:
390     }                                          
391  
392     private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt)
393 {                                          
394         try{
395             con=Connect.ConnectDB();
396             String sql= "update PatientRegistration set Patientname='"+ txtName.getText() + "',Fathername='"+
397 txtFname.getText() + "',Email='"+ txtEmail.getText() + "',ContactNo='"+ txtContact.getText() + "',Age=" +
398 txtAge.getText() + ",Remarks='"+ txtInfo.getText() + "',Gen='" + cmbGender.getSelectedItem() + "',BG='"+
399 cmbBG.getSelectedItem() + "',Address='" + txtAdd.getText() + "' where PatientID='" + txtId.getText() + "'";
400             pst=con.prepareStatement(sql);
401             pst.execute();
402             JOptionPane.showMessageDialog(this,"Successfully updated","Record",JOptionPane.INFORMATION_MESSAGE);
403             btnUpdate.setEnabled(false);
404  
405         }catch(HeadlessException | SQLException ex){
406             JOptionPane.showMessageDialog(this,ex);
407         }          // TODO add your handling code here:
408     }                                        
409  
410     private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt)
411 {                                          
412 try{
413             int P = JOptionPane.showConfirmDialog(null," Are you sure want to delete
414 ?","Confirmation",JOptionPane.YES_NO_OPTION);
415             if (P==0)
416             {
417                 con=Connect.ConnectDB();
418                 String sql= "delete from patientregistration where PatientID = '" + txtId.getText() + "'";
419                 pst=con.prepareStatement(sql);
420                 pst.execute();
421                 JOptionPane.showMessageDialog(this,"Successfully
422 deleted","Record",JOptionPane.INFORMATION_MESSAGE);
423  
424                 Reset();
425             }
426         }catch(HeadlessException | SQLException ex){
427             JOptionPane.showMessageDialog(this,ex);
428         }        // TODO add your handling code here:
429     }                                        
430  
431     private void formWindowClosed(java.awt.event.WindowEvent evt) {                                  
432   
433              ;// TODO add your handling code here:
434     }                                
435  
436     /**
437      * @param args the command line arguments
438      */
439     public static void main(String args[]) {
440         /* Set the Nimbus look and feel */
441         //<editor­fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
442         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
443          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
444          */
445         try {
446             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels())
447 {
448                 if ("Nimbus".equals(info.getName())) {
449                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
450                     break;
451                 }
452             }
453         } catch (ClassNotFoundException ex) {
454             java.util.logging.Logger.getLogger(Registration.class.getName()).log(java.util.logging.Level.SEVERE,
455 null, ex);
456         } catch (InstantiationException ex) {
457             java.util.logging.Logger.getLogger(Registration.class.getName()).log(java.util.logging.Level.SEVERE,
458 null, ex);
459         } catch (IllegalAccessException ex) {
460             java.util.logging.Logger.getLogger(Registration.class.getName()).log(java.util.logging.Level.SEVERE,
461 null, ex);
462         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
463             java.util.logging.Logger.getLogger(Registration.class.getName()).log(java.util.logging.Level.SEVERE,
464 null, ex);
465         }
466         //</editor­fold>
467  
468         /* Create and display the form */
469         java.awt.EventQueue.invokeLater(new Runnable() {
470             public void run() {
471                 new Registration().setVisible(true);
472             }
473         });
473         });
474     }
475  
476     // Variables declaration ­ do not modify                    
477     public javax.swing.JButton btnDelete;
478     public javax.swing.JButton btnGetData;
479     public javax.swing.JButton btnNew;
480     public javax.swing.JButton btnSave;
481     public javax.swing.JButton btnUpdate;
482     public javax.swing.JComboBox cmbBG;
    public javax.swing.JComboBox cmbGender;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    public javax.swing.JTextField txtAdd;
    public javax.swing.JTextField txtAge;
    public javax.swing.JTextField txtContact;
    public javax.swing.JTextField txtEmail;
    public javax.swing.JTextField txtFname;
    public javax.swing.JTextField txtId;
    public javax.swing.JTextArea txtInfo;
    public javax.swing.JTextField txtName;
    // End of variables declaration                  
}
 

In this module which is the patient details or patient registration module.

The Code Given Below Is For The


Patient Admission Module

import java.awt.HeadlessException;

 
import java.awt.HeadlessException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;
 
/*
* 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.
*/
/**
*
* @author Agarwal
*/
public class Patient_Admit_Room extends javax.swing.JFrame {
    Connection con=null;
    ResultSet rs=null;
    PreparedStatement pst=null;
    /**
     * Creates new form PatientAdmit_Room
     */
1     public Patient_Admit_Room() {
2         initComponents();
3         setLocationRelativeTo(null);
4         fillcombo();
5         cmbRoomNo.setSelectedIndex(­1);
6         cmbRoomNo1.setVisible(false);
7          Get_Data1();
8          GetRecord();
9     }
10 private void fillcombo(){
11     
12     try{
13         con=Connect.ConnectDB();
14         String sql= "select distinct RoomNo from Room order by RoomNo";
15         pst=con.prepareStatement(sql);
16         rs=pst.executeQuery();
17         while(rs.next()){
18           String add=rs.getString("RoomNo");
19           cmbRoomNo.addItem(add);
20           }
21        }catch(HeadlessException | SQLException ex){
22            JOptionPane.showMessageDialog(this,ex);
23        }
24 }
25 private void GetRecord(){
26      String sql="select DoctorID as 'Doctor ID', DoctorName as 'Doctor Name' from Doctor order by DoctorName";  
27      try{
28         con=Connect.ConnectDB();
28         con=Connect.ConnectDB();
29         pst=con.prepareStatement(sql);
30         rs= pst.executeQuery();
31         jTable2.setModel(DbUtils.resultSetToTableModel(rs));
32      }catch(Exception e){
33             JOptionPane.showMessageDialog(null, e);
34      }
35 }
36   private void Get_Data1(){
37         String sql="select PatientID as 'Patient ID', PatientName as 'Patient Name',Gen as 'Gender',BG as 'Blood
38 Group' from Patientregistration order by PatientName";
39         try{
40             con=Connect.ConnectDB();
41             pst=con.prepareStatement(sql);
42             rs= pst.executeQuery();
43             jTable1.setModel(DbUtils.resultSetToTableModel(rs));
44          }catch(Exception e){
45             JOptionPane.showMessageDialog(null, e);
46          }
47     }
48   private void Reset(){
49     txtDoctorID.setText("");
50     txtDoctorName.setText("");
51     PatientID.setText("");
52     txtPatientName.setText("");
53     txtBloodGroup.setText("");
54     txtGender.setText("");
55     txtDisease.setText("");
56     txtAdmitDate.setText("");
57     
58     txtRemarks.setText("");
59     cmbRoomNo.setSelectedIndex(­1);
60     btnSave.setEnabled(true);
61     btnUpdate.setEnabled(false);
62     btnDelete.setEnabled(false);
63 }
64     /**
65      * Creates new form Patient_Admit_Room
66      */
67     
68  
69     /**
70      * This method is called from within the constructor to initialize the form.
71      * WARNING: Do NOT modify this code. The content of this method is always
72      * regenerated by the Form Editor.
73      */
74     @SuppressWarnings("unchecked")
75     // <editor­fold defaultstate="collapsed" desc="Generated Code">                          
76     private void initComponents() {
77  
78         jPanel1 = new javax.swing.JPanel();
79         jLabel1 = new javax.swing.JLabel();
80         jLabel2 = new javax.swing.JLabel();
81         jLabel9 = new javax.swing.JLabel();
82         jLabel10 = new javax.swing.JLabel();
83         PatientID = new javax.swing.JTextField();
84         txtPatientName = new javax.swing.JTextField();
85         jLabel11 = new javax.swing.JLabel();
86         jLabel22 = new javax.swing.JLabel();
87         txtGender = new javax.swing.JTextField();
88         txtBloodGroup = new javax.swing.JTextField();
89         jLabel12 = new javax.swing.JLabel();
90         jLabel13 = new javax.swing.JLabel();
91         jLabel14 = new javax.swing.JLabel();
92         jLabel16 = new javax.swing.JLabel();
93         jLabel17 = new javax.swing.JLabel();
94         txtDoctorID = new javax.swing.JTextField();
95         txtDoctorName = new javax.swing.JTextField();
96         jScrollPane1 = new javax.swing.JScrollPane();
97         txtRemarks = new javax.swing.JTextArea();
98         cmbRoomNo = new javax.swing.JComboBox();
99         cmbRoomNo1 = new javax.swing.JComboBox();
100         txtAdmitDate = new javax.swing.JTextField();
101         txtDisease = new javax.swing.JTextField();
102         jScrollPane2 = new javax.swing.JScrollPane();
103         jTable1 = new javax.swing.JTable();
104         jScrollPane3 = new javax.swing.JScrollPane();
105         jTable2 = new javax.swing.JTable();
106         jPanel2 = new javax.swing.JPanel();
107         btnNew = new javax.swing.JButton();
108         btnSave = new javax.swing.JButton();
109         btnDelete = new javax.swing.JButton();
110         btnUpdate = new javax.swing.JButton();
111         btnGetData = new javax.swing.JButton();
112  
113         jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Patient Admit Info"));
114  
115         jLabel1.setText("Patient ID");
116  
117         jLabel2.setText("Patient Name");
118  
119         jLabel9.setText("Blood Group");
120  
121         jLabel10.setText("Remarks");
122  
123         PatientID.setEditable(false);
124  
125         txtPatientName.setEditable(false);
126  
127         jLabel11.setText("Gender");
128  
129         jLabel22.setText("(YYYY­MM­DD)");
130  
131         txtGender.setEditable(false);
132  
132  
133         txtBloodGroup.setEditable(false);
134  
135         jLabel12.setText("Disease");
136  
137         jLabel13.setText("Admit Date");
138  
139         jLabel14.setText("Room No.");
140  
141         jLabel16.setText("Doctor ID");
142  
143         jLabel17.setText("Doctor Name");
144  
145         txtDoctorID.setEditable(false);
146  
147         txtDoctorName.setEditable(false);
148  
149         txtRemarks.setColumns(20);
150         txtRemarks.setRows(5);
151         jScrollPane1.setViewportView(txtRemarks);
152  
153         cmbRoomNo.setEditable(true);
154         cmbRoomNo.addItemListener(new java.awt.event.ItemListener() {
155             public void itemStateChanged(java.awt.event.ItemEvent evt) {
156                 cmbRoomNoItemStateChanged(evt);
157             }
158         });
159         cmbRoomNo.addActionListener(new java.awt.event.ActionListener() {
160             public void actionPerformed(java.awt.event.ActionEvent evt) {
161                 cmbRoomNoActionPerformed(evt);
162             }
163         });
164  
165         cmbRoomNo1.setEditable(true);
166  
167         txtAdmitDate.addActionListener(new java.awt.event.ActionListener() {
168             public void actionPerformed(java.awt.event.ActionEvent evt) {
169                 txtAdmitDateActionPerformed(evt);
170             }
171         });
172  
173         javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
174         jPanel1.setLayout(jPanel1Layout);
175         jPanel1Layout.setHorizontalGroup(
176             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
177             .addGroup(jPanel1Layout.createSequentialGroup()
178                 .addGap(33, 33, 33)
179                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
180                     .addComponent(jLabel1)
181                     .addComponent(jLabel2)
182                     .addComponent(jLabel9)
183                     .addComponent(jLabel11)
184                     .addComponent(jLabel13)
185                     .addComponent(jLabel12)
186                     .addComponent(jLabel14)
187                     .addComponent(jLabel16)
188                     .addComponent(jLabel17)
189                     .addComponent(jLabel10))
190                 .addGap(62, 62, 62)
191                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
192                     .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
193                         .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
194 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
195                         .addGroup(jPanel1Layout.createSequentialGroup()
196                             .addComponent(txtAdmitDate, javax.swing.GroupLayout.PREFERRED_SIZE, 120,
197 javax.swing.GroupLayout.PREFERRED_SIZE)
198                             .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
199                             .addComponent(jLabel22))
200                         .addComponent(PatientID, javax.swing.GroupLayout.PREFERRED_SIZE, 89,
201 javax.swing.GroupLayout.PREFERRED_SIZE)
202                         .addComponent(txtPatientName, javax.swing.GroupLayout.PREFERRED_SIZE, 193,
203 javax.swing.GroupLayout.PREFERRED_SIZE)
204                         .addComponent(txtBloodGroup)
205                         .addComponent(txtGender)
206                         .addGroup(jPanel1Layout.createSequentialGroup()
207                             .addComponent(cmbRoomNo, javax.swing.GroupLayout.PREFERRED_SIZE, 74,
208 javax.swing.GroupLayout.PREFERRED_SIZE)
209                             .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
210                             .addComponent(cmbRoomNo1, javax.swing.GroupLayout.PREFERRED_SIZE, 90,
211 javax.swing.GroupLayout.PREFERRED_SIZE))
212                         .addComponent(txtDoctorName)
213                         .addComponent(txtDoctorID, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
214 javax.swing.GroupLayout.PREFERRED_SIZE))
215                     .addComponent(txtDisease, javax.swing.GroupLayout.PREFERRED_SIZE, 120,
216 javax.swing.GroupLayout.PREFERRED_SIZE))
217                 .addContainerGap(18, Short.MAX_VALUE))
218         );
219         jPanel1Layout.setVerticalGroup(
220             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
221             .addGroup(jPanel1Layout.createSequentialGroup()
222                 .addContainerGap()
223                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
224                     .addComponent(jLabel1)
225                     .addComponent(PatientID, javax.swing.GroupLayout.PREFERRED_SIZE,
226 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
227                 .addGap(19, 19, 19)
228                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
229                     .addComponent(jLabel2)
230                     .addComponent(txtPatientName, javax.swing.GroupLayout.PREFERRED_SIZE,
231 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
232                 .addGap(18, 18, 18)
233                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
234                     .addComponent(jLabel11)
235                     .addComponent(txtGender, javax.swing.GroupLayout.PREFERRED_SIZE,
236 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
236 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
237                 .addGap(18, 18, 18)
238                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
239                     .addComponent(jLabel9)
240                     .addComponent(txtBloodGroup, javax.swing.GroupLayout.PREFERRED_SIZE,
241 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
242                 .addGap(18, 18, 18)
243                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
244                     .addComponent(jLabel12)
245                     .addComponent(txtDisease, javax.swing.GroupLayout.PREFERRED_SIZE,
246 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
247                 .addGap(20, 20, 20)
248                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
249                     .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
250                         .addComponent(jLabel13)
251                         .addComponent(jLabel22))
252                     .addComponent(txtAdmitDate, javax.swing.GroupLayout.PREFERRED_SIZE,
253 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
254                 .addGap(18, 18, 18)
255                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
256                     .addComponent(jLabel14)
257                     .addComponent(cmbRoomNo, javax.swing.GroupLayout.PREFERRED_SIZE,
258 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
259                     .addComponent(cmbRoomNo1, javax.swing.GroupLayout.PREFERRED_SIZE,
260 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
261                 .addGap(18, 18, 18)
262                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
263                     .addComponent(jLabel16)
264                     .addComponent(txtDoctorID, javax.swing.GroupLayout.PREFERRED_SIZE, 21,
265 javax.swing.GroupLayout.PREFERRED_SIZE))
266                 .addGap(18, 18, 18)
267                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
268                     .addComponent(jLabel17)
269                     .addComponent(txtDoctorName, javax.swing.GroupLayout.PREFERRED_SIZE,
270 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
271                 .addGap(18, 18, 18)
272                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
273                     .addComponent(jLabel10)
274                     .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 104,
275 javax.swing.GroupLayout.PREFERRED_SIZE))
276                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
277         );
278  
279         jTable1.setModel(new javax.swing.table.DefaultTableModel(
280             new Object [][] {
281                 {null, null, null, null},
282                 {null, null, null, null},
283                 {null, null, null, null},
284                 {null, null, null, null}
285             },
286             new String [] {
287                 "Title 1", "Title 2", "Title 3", "Title 4"
288             }
289         ));
290         jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
291             public void mouseClicked(java.awt.event.MouseEvent evt) {
292                 jTable1MouseClicked(evt);
293             }
294         });
295         jScrollPane2.setViewportView(jTable1);
296  
297         jTable2.setModel(new javax.swing.table.DefaultTableModel(
298             new Object [][] {
299                 {null, null, null, null},
300                 {null, null, null, null},
301                 {null, null, null, null},
302                 {null, null, null, null}
303             },
304             new String [] {
305                 "Title 1", "Title 2", "Title 3", "Title 4"
306             }
307         ));
308         jTable2.addMouseListener(new java.awt.event.MouseAdapter() {
309             public void mouseClicked(java.awt.event.MouseEvent evt) {
310                 jTable2MouseClicked(evt);
311             }
312         });
313         jScrollPane3.setViewportView(jTable2);
314  
315         jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
316  
317         btnNew.setText("New");
318         btnNew.addActionListener(new java.awt.event.ActionListener() {
319             public void actionPerformed(java.awt.event.ActionEvent evt) {
320                 btnNewActionPerformed(evt);
321             }
322         });
323  
324         btnSave.setText("Save");
325         btnSave.addActionListener(new java.awt.event.ActionListener() {
326             public void actionPerformed(java.awt.event.ActionEvent evt) {
327                 btnSaveActionPerformed(evt);
328             }
329         });
330  
331         btnDelete.setText("Delete");
332         btnDelete.setEnabled(false);
333         btnDelete.addActionListener(new java.awt.event.ActionListener() {
334             public void actionPerformed(java.awt.event.ActionEvent evt) {
335                 btnDeleteActionPerformed(evt);
336             }
337         });
338  
339         btnUpdate.setText("Update");
340         btnUpdate.setEnabled(false);
340         btnUpdate.setEnabled(false);
341         btnUpdate.addActionListener(new java.awt.event.ActionListener() {
342             public void actionPerformed(java.awt.event.ActionEvent evt) {
343                 btnUpdateActionPerformed(evt);
344             }
345         });
346  
347         btnGetData.setText("Get Data");
348         btnGetData.addActionListener(new java.awt.event.ActionListener() {
349             public void actionPerformed(java.awt.event.ActionEvent evt) {
350                 btnGetDataActionPerformed(evt);
351             }
352         });
353  
354         javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
355         jPanel2.setLayout(jPanel2Layout);
356         jPanel2Layout.setHorizontalGroup(
357             jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
358             .addGroup(jPanel2Layout.createSequentialGroup()
359                 .addContainerGap()
360                 .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
361                     .addComponent(btnGetData, javax.swing.GroupLayout.DEFAULT_SIZE,
362 javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
363                     .addComponent(btnUpdate, javax.swing.GroupLayout.DEFAULT_SIZE,
364 javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
365                     .addComponent(btnDelete, javax.swing.GroupLayout.DEFAULT_SIZE,
366 javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
367                     .addComponent(btnSave, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
368 Short.MAX_VALUE)
369                     .addComponent(btnNew, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
370 Short.MAX_VALUE))
371                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
372         );
373         jPanel2Layout.setVerticalGroup(
374             jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
375             .addGroup(jPanel2Layout.createSequentialGroup()
376                 .addContainerGap()
377                 .addComponent(btnNew)
378                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
379                 .addComponent(btnSave)
380                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
381                 .addComponent(btnDelete)
382                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
383                 .addComponent(btnUpdate)
384                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
385                 .addComponent(btnGetData)
386                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
387         );
388  
389         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
390         getContentPane().setLayout(layout);
391         layout.setHorizontalGroup(
392             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
393             .addGroup(layout.createSequentialGroup()
394                 .addContainerGap()
395                 .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
396 javax.swing.GroupLayout.PREFERRED_SIZE)
397                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
398                 .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
399 javax.swing.GroupLayout.PREFERRED_SIZE)
400                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 45, Short.MAX_VALUE)
401                 .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE)
402                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
403                 .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 257,
404 javax.swing.GroupLayout.PREFERRED_SIZE)
405                 .addContainerGap())
406         );
407         layout.setVerticalGroup(
408             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
409             .addGroup(layout.createSequentialGroup()
410                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
411                     .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
412                         .addGap(21, 21, 21)
413                         .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
414 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
415                     .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
416                         .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 523,
417 javax.swing.GroupLayout.PREFERRED_SIZE)
418                         .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 523,
419 javax.swing.GroupLayout.PREFERRED_SIZE)))
420                 .addGap(0, 30, Short.MAX_VALUE))
421             .addGroup(layout.createSequentialGroup()
422                 .addContainerGap()
423                 .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
424 javax.swing.GroupLayout.PREFERRED_SIZE)
425                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
426         );
427  
428         pack();
429     }// </editor­fold>                        
430  
431     private void cmbRoomNoItemStateChanged(java.awt.event.ItemEvent evt) {                                          
432  
433     }                                          
434  
435     private void cmbRoomNoActionPerformed(java.awt.event.ActionEvent evt) {                                          
436  
437     }                                        
438  
439     private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {                                    
440         try{
441             con=Connect.ConnectDB();
442             int row= jTable1.getSelectedRow();
443             String table_click= jTable1.getModel().getValueAt(row, 0).toString();
444             String sql= "select * from PatientRegistration where PatientID = '" + table_click + "'";
444             String sql= "select * from PatientRegistration where PatientID = '" + table_click + "'";
445             pst=con.prepareStatement(sql);
446             rs=  pst.executeQuery();
447             if(rs.next()){
448  
449                 String add1=rs.getString("PatientID");
450                 PatientID.setText(add1);
451                 String add2=rs.getString("Patientname");
452                 txtPatientName.setText(add2);
453                 String add9=rs.getString("BG");
454                 txtBloodGroup.setText(add9);
455                 String add11=rs.getString("Gen");
456                 txtGender.setText(add11);
457  
458             }
459         }catch(Exception ex){
460             JOptionPane.showMessageDialog(this,ex);
461         }
462     }                                    
463  
464     private void jTable2MouseClicked(java.awt.event.MouseEvent evt) {                                    
465         try{
466             con=Connect.ConnectDB();
467             int row= jTable2.getSelectedRow();
468             String table_click= jTable2.getModel().getValueAt(row, 0).toString();
469             String sql= "select * from Doctor where DoctorID = '" + table_click + "'";
470             pst=con.prepareStatement(sql);
471             rs=  pst.executeQuery();
472             if(rs.next()){
473                 String add1=rs.getString("DoctorID");
474                 txtDoctorID.setText(add1);
475                 String add2=rs.getString("Doctorname");
476                 txtDoctorName.setText(add2);
477             }
478         }catch(Exception ex){
479             JOptionPane.showMessageDialog(this,ex);
480         }
481     }                                    
482  
483     private void btnNewActionPerformed(java.awt.event.ActionEvent evt) {                                      
484         Reset();
485     }                                      
486  
487     private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {                                        
488         try{
489             con=Connect.ConnectDB();
490             if (PatientID.getText().equals("")) {
491                 JOptionPane.showMessageDialog( this, "Please retrieve Patient ID","Error", JOptionPane.ERROR_MESSAGE);
492                 return;
493             }
494             if (txtPatientName.getText().equals("")) {
495                 JOptionPane.showMessageDialog( this, "Please retrieve Patient Name","Error",
496 JOptionPane.ERROR_MESSAGE);
497                 return;
498             }
499             if (txtGender.getText().equals("")) {
500                 JOptionPane.showMessageDialog( this, "Please retrieve Gender","Error", JOptionPane.ERROR_MESSAGE);
501                 return;
502             }
503  
504             if (txtBloodGroup.getText().equals("")) {
505                 JOptionPane.showMessageDialog( this, "Please retrieve blood group","Error",
506 JOptionPane.ERROR_MESSAGE);
507                 return;
508             }
509             if (txtDisease.getText().equals("")) {
510                 JOptionPane.showMessageDialog( this, "Please enter disease","Error", JOptionPane.ERROR_MESSAGE);
511                 return;
512             }
513             if (txtAdmitDate.getText().equals("")) {
514                 JOptionPane.showMessageDialog( this, "Please enter admit date","Error", JOptionPane.ERROR_MESSAGE);
515                 return;
516             }
517             if (cmbRoomNo.getSelectedItem().equals("")) {
518                 JOptionPane.showMessageDialog( this, "Please select room no.","Error", JOptionPane.ERROR_MESSAGE);
519                 return;
520             }
521  
522             if (txtDoctorID.getText().equals("")) {
523                 JOptionPane.showMessageDialog( this, "Please retrieve doctor id","Error", JOptionPane.ERROR_MESSAGE);
524                 return;
525  
526             }
527             if (txtDoctorName.getText().equals("")) {
528                 JOptionPane.showMessageDialog( this, "Please enter retrieve doctor name","Error",
529 JOptionPane.ERROR_MESSAGE);
530                 return;
531  
532             }
533             Statement stmt1;
534             stmt1= con.createStatement();
535             String sql2="Select RoomNo from Room where RoomNo= '" + cmbRoomNo.getSelectedItem()+ "' and
536 RoomStatus='Booked'";
537             rs=stmt1.executeQuery(sql2);
538             if(rs.next()){
539                 JOptionPane.showMessageDialog( this, "Room is already booked","Error", JOptionPane.ERROR_MESSAGE);
540                 cmbRoomNo.setSelectedItem("");
541                 cmbRoomNo.requestDefaultFocus();
542                 return;
543             }
544             Statement stmt;
545             stmt= con.createStatement();
546             String sql1="Select PatientID,AdmitDate from AdmitPatient_Room where PatientID= '" + PatientID.getText() +
547 "' and AdmitDate='" + txtAdmitDate + "'";
548             rs=stmt.executeQuery(sql1);
548             rs=stmt.executeQuery(sql1);
549             if(rs.next()){
550                 JOptionPane.showMessageDialog( this, "Record already exists","Error", JOptionPane.ERROR_MESSAGE);
551                 return;
552             }
553  
554             String sql= "insert into
555 admitpatient_room(PatientID,Disease,AdmitDate,RoomNo,DoctorID,AP_Remarks)values('"+ PatientID.getText() + "','"+
556 txtDisease.getText() + "','"+ txtAdmitDate.getText() + "','"+ cmbRoomNo.getSelectedItem()+ "','" +
557 txtDoctorID.getText() + "','"+ txtRemarks.getText() + "')";
558  
559             pst=con.prepareStatement(sql);
560             pst.execute();
561             String sql3= "update room set RoomStatus='Booked' where RoomNo='" + cmbRoomNo.getSelectedItem() + "'";
562             pst=con.prepareStatement(sql3);
563             pst.execute();
564             JOptionPane.showMessageDialog(this,"Successfully admitted","Patient",JOptionPane.INFORMATION_MESSAGE);
565             btnSave.setEnabled(false);
566  
567         }catch(HeadlessException | SQLException ex){
568             JOptionPane.showMessageDialog(this,ex);
569         }
570     }                                      
571  
572     private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {                                          
573         try{
574             int P = JOptionPane.showConfirmDialog(null," Are you sure want to delete
575 ?","Confirmation",JOptionPane.YES_NO_OPTION);
576             if (P==0)
577             {
578                 con=Connect.ConnectDB();
579                 String sql= "delete from AdmitPatient_Room where PatientID = " + PatientID.getText() + "";
580                 pst=con.prepareStatement(sql);
581                 pst.execute();
582                 JOptionPane.showMessageDialog(this,"Successfully deleted","Record",JOptionPane.INFORMATION_MESSAGE);
583  
584                 Reset();
585             }
586         }catch(HeadlessException | SQLException ex){
587             JOptionPane.showMessageDialog(this,ex);
588         }
589     }                                        
590  
591     private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt) {                                          
592         
593         try{
594             con=Connect.ConnectDB();
595             Statement stmt1;
596             stmt1= con.createStatement();
597             String s= cmbRoomNo.getSelectedItem().toString();
598             String t= cmbRoomNo1.getSelectedItem().toString();
599             if (!t.equals(s)){
600                 String sql2="Select RoomNo from Room where RoomNo= '" + cmbRoomNo.getSelectedItem()+ "' and
601 RoomStatus='Booked'";
602                 rs=stmt1.executeQuery(sql2);
603                 if(rs.next()){
604                     JOptionPane.showMessageDialog( this, "Room is already booked","Error", JOptionPane.ERROR_MESSAGE);
605                     cmbRoomNo.setSelectedItem("");
606                     cmbRoomNo.requestDefaultFocus();
607                     return;
608                 }
609             }
610  
611             String sql= " update AdmitPatient_Room set  PatientID='"+ PatientID.getText() + "',Disease='"+
612 txtDisease.getText() + "',AdmitDate='"+ txtAdmitDate.getText() + "',RoomNo='"+ cmbRoomNo.getSelectedItem()+
613 "',DoctorID='" + txtDoctorID.getText() + "',AP_Remarks='"+ txtRemarks.getText() + "' where PatientID= " +
614 PatientID.getText() + "";
615             pst=con.prepareStatement(sql);
616             pst.execute();
617  
618             if (!t.equals(s)){
619                 String sql3= "update room set RoomStatus='Booked' where RoomNo='" + cmbRoomNo.getSelectedItem() + "'";
620                 pst=con.prepareStatement(sql3);
621                 pst.execute();
622             }
623  
624             if (!t.equals(s)){
625                 String sql4= "update room set RoomStatus='Vacant' where RoomNo='" + cmbRoomNo1.getSelectedItem() +
626 "'";
627                 pst=con.prepareStatement(sql4);
628                 pst.execute();
629             }
630             JOptionPane.showMessageDialog(this,"Successfully updated","Patient
631 Record",JOptionPane.INFORMATION_MESSAGE);
632             btnUpdate.setEnabled(false);
633  
634         }catch(HeadlessException | SQLException ex){
635             JOptionPane.showMessageDialog(this,ex);
636         }
637     }                                        
638  
639     private void btnGetDataActionPerformed(java.awt.event.ActionEvent evt) {                                          
640         this.hide();
641         Patient_Admit_roomRec1 frm= new Patient_Admit_roomRec1();
642         frm.setVisible(true);
643     }                                          
644  
645     private void txtAdmitDateActionPerformed(java.awt.event.ActionEvent evt)
646 {                                            
647         // TODO add your handling code here:
648     }                                            
649  
650     /**
651      * @param args the command line arguments
652      */
652      */
653     public static void main(String args[]) {
654         /* Set the Nimbus look and feel */
655         //<editor­fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
656         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
657          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
658          */
659         try {
660             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
661                 if ("Nimbus".equals(info.getName())) {
662                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
663                     break;
664                 }
665             }
666         } catch (ClassNotFoundException ex) {
667             java.util.logging.Logger.getLogger(Patient_Admit_Room.class.getName()).log(java.util.logging.Level.SEVERE,
668 null, ex);
669         } catch (InstantiationException ex) {
670             java.util.logging.Logger.getLogger(Patient_Admit_Room.class.getName()).log(java.util.logging.Level.SEVERE,
671 null, ex);
672         } catch (IllegalAccessException ex) {
673             java.util.logging.Logger.getLogger(Patient_Admit_Room.class.getName()).log(java.util.logging.Level.SEVERE,
674 null, ex);
675         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
676             java.util.logging.Logger.getLogger(Patient_Admit_Room.class.getName()).log(java.util.logging.Level.SEVERE,
677 null, ex);
678         }
679         //</editor­fold>
680  
681         /* Create and display the form */
682         java.awt.EventQueue.invokeLater(new Runnable() {
683             public void run() {
684                 new Patient_Admit_Room().setVisible(true);
685             }
686         });
687     }
688  
689     // Variables declaration ­ do not modify                    
690     public javax.swing.JTextField PatientID;
691     public javax.swing.JButton btnDelete;
692     private javax.swing.JButton btnGetData;
693     private javax.swing.JButton btnNew;
694     public javax.swing.JButton btnSave;
695     public javax.swing.JButton btnUpdate;
696     public javax.swing.JComboBox cmbRoomNo;
697     public javax.swing.JComboBox cmbRoomNo1;
698     private javax.swing.JLabel jLabel1;
699     private javax.swing.JLabel jLabel10;
700     private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    public javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTable jTable1;
    private javax.swing.JTable jTable2;
    public javax.swing.JTextField txtAdmitDate;
    public javax.swing.JTextField txtBloodGroup;
    public javax.swing.JTextField txtDisease;
    public javax.swing.JTextField txtDoctorID;
    public javax.swing.JTextField txtDoctorName;
    public javax.swing.JTextField txtGender;
    public javax.swing.JTextField txtPatientName;
    public javax.swing.JTextArea txtRemarks;
    // End of variables declaration                  
}
 

Screenshots Hospital Management


System Modules
Hospital Management System Doctor’s Detail

Hospital Management System Patient Admitting Info


Hospital Management System Patient Billing

Hospital Management System Patient Registration

Hospital Management System Patient Services Info


Hospital Management System Room Info

About The Hospital Management


System Project
Project Name: Hospital Management System Project

Language/s Used: JAVA

Database: MySQL

Type: Desktop Application

Developer: IT SOURCECODE

Updates: 0

Hospital Management System Project In Java– Project Information

Run Quick Virus Scan for secure


Download
Run Quick Scan for secure Download

Downloadable Source Code Below.


Anyway, if you want to level up your programming knowledge, especially Java, try
this new article I’ve made for you Best Java Projects With Source Code For Beginners
Free Download 2021.
DOWNLOAD

Summary
The Java Project With Source Code is built fully in Java and MySQL Database. It has
full‐featured Graphical User Interface ﴾GUI﴿ with all the functionalities. This project in
Java with source code can be used for your final year project in the future.

This Article is the way to enhance and develop our skills and logic ideas which is
important in practicing the Java programming language which is most well known
and most usable programming language in many company.

Related articles below


Load data from MySQL database to Combo box Using Java
How to use Scanner in Java Tutorial Using Netbeans IDE
Update Data using MySQL Database and Java with Netbeans IDE
Join Two String Value using MySQL CONCAT Function in Java
How to convert text to speech in Java Tutorial using Netbeans IDE
How to Load data from Mysql Database to Table Element Using Java

Other articles in different


programming languages
Simple Hospital Management System In C With Source Code | 2020
Hospital Information Management System VB.NET Project 2019
Hospital Management System PHP Project With Source Code | VIDEO
Hospital Management System Project In Python With Source Code
Hospital Management System Project In Django With Source Code
Hospital Management System in C# with Source Code 2021 |

Inquiries

If you have any questions or suggestions about Project On Hospital Management


System In Java With Source Code, please feel free to leave a comment below.

4 thoughts on “Project On Hospital Management


System In Java With Source Code”

1.
sheikh
May 31, 2021 at 12:33 am
what is user name and password — ak for user , password12345 not working
Reply

2.

alazar
June 16, 2021 at 10:45 am
what about the database table content you didn’t include it would give the
detail of the content;

Reply

3.
Austine Baraka
July 19, 2021 at 6:54 am
what about the database table content you didn’t include it would give the
detail of the content;

Reply

4.
Abin Joseph
July 23, 2021 at 10:56 am
What is the username and password

Reply

Leave a Comment

Name * Email *

Website

Post Comment
Ezoic

Quick Links
About Us

Contact Us
Advertise with Us
Hire Us

Free Online Tools


Java Online Compiler
PHP Online Compiler
Python Online Compiler
HTML Online Editor

Follow

Find Your Source Code Here

Type your keyword...

Home

Contact Us
About Us

Hire Us
© 2022 Itsourcecode.com • Built with GeneratePress
Advertise

Disclaimer
Privacy Policy

Terms and Agreement

report this ad

You might also like