Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 87

Project Report

ON
“HOSPITAL MANAGEMENT SYSTEM”
Submitted for the partial fulfilment for the
award Of
BACHELOR OF COMPUTER APPLICATION

Chaudhary Charan Singh University,


Meerut 2021-24

Submitted To:
DELHI COLLEGE OF MANAGEMENT, MEERUT

Under The supervision of: - Submitted By:-


Mr. NEERAJ CHAUHAN Yashendra Giri -210366106079
(Prof. ,BCA DEPT.) Abhinav Shrivastav-210366106005
BCA – VI Sem

DEPARTMENT OF MANAGEMENT
DELHI COLLEGE OF MANAGEMENT, MEERUT
(U.P.)
CERTIFICATE OF ORIGINALITY

I hereby declare that the Project entitled “HOSPITAL MANAGEMENT

SYSTEM”” submitted to Department of Bachelor in Computer Application,

DELHI COLLEGE OF MANAGEMENT, MEERUT, U.P. in partial

fulfillment for the award of the Degree of MASTER OF COMPUTER

APPLICATION in session 2016-2019 is an authentic record of my own work

carried out under the guidance of Mr. NEERAJ CHAUHAN and that the

Project has not previously formed the basis for the award of any other degree.

Place: Meerut

Date:

Yashendra Giri -210366106079


Abhinav Shrivastav-210366106005
BCA – VI Sem

This is to certify that the above statement made by the candidate is correct to the
best of my knowledge.

Signature of Internal guide

Name
Designation
ACKNOWLEDGEMENT

I take this precious opportunity to express my gratitude toward “HOSPITAL

MANAGEMENT SYSTEM” to grant is permission for undergoing the

training project. Without its willingness to permit this project would not have

been succeed.

First of all, I would like to thanks all those people who helped me directly

or indirectly to complete my project whenever I found myself in problems. Our

all faculties encourages me and due to their kindness and helpful nature and

help I got very much confidence to complete this project.

Last but not least, I would like to express my gratitude to those persons

who directly or indirectly helped in my project.

We owe special debt of gratitude to our project coordinator

Mr. NEERAJ CHAUHAN (H.O.D. & Asst Prof.) DCM, Meerut

YASHENDRA GIRI -210366106079


ABHINAV SHRIVASTAV-210366106005
BCA – VI SEM
TABLE OF CONTENT

Contents

I. Front Page

II. Certificate

III. Acknowledgement

1. Introduction……………………………………………………………………………………………

1.1 Objective

1.2 Scope

1.3 Overview

1.4 Drawback of existing system

1.5 Advantages of proposed system

2. System Analysis…………………………………………………………………….………………..

2.1 Introduction

2.2 Problem Definition

2.3 Requirement Specification

2.3.1 User Interface Requirements

2.3.2 Hardware Interface

2.3.3 Software interface

2.4 Feasibility Study

2.4.1 Technical feasibility

2.4.2 Economical feasibility

2.4.3 Operational feasibility

2.4.4 Behavioral feasibility

3. System Design………………………………………………………………………………………………….

3.1.1 Input design

1
3.1.2 Output design

3.1.3 Database design

3.2 DFD

3.2.1 Context Level DFD

3.2.2 Level 1 DFD

3.3 Entity Relationship Diagram

3.4 Detailed Design

4. Coding………………………………………………………………………………………………………………..

5. Testing………………………………………………………………………………………………………………..

5.1 Black box testing

5.2 White box testing

5.3 Unit testing

5.4 Integration Testing

5.5 Validation Testing

6. Screen Shots………………………………………………………………………………………………………..

7. Conclusion…………………………………………………………………………………………………………..

8. Scope for future Enhancement…………………………………………………………………………….

9. References…………………………………………………………………………………………………………..

2
LIST OF TABLES

Table Number Table Name Page

Table 6.1 Hardware Requirements 12

Table 6.2 Software Requirements 12

Table 10.1 Login Table 43

Table 10.2 Account Details 43

Table 10.3 Journal 44

3
LIST OF FIGURES

Figure Number Figure Name Page no.

Figure 1 Data Flow Diagram 10

Figure 3 Entity Relationship diagram 11

Figure 4 Balance Withdrawal 13

Figure 5 Transfer Funds 14

Figure 6 Change Password 15

Figure 7 Deposit Money 16

Figure 8 Create An Account 18

Figure 9 Screenshots 20-27

Figure 10 Coding 28-42

4
LIST OF SYMBOLS AND ABBREVIATIONS

Entity Symbol

Process Symbol

Data Store Symbol

Relational Model

Weak Entity

Prim Primary Key Attribute

5
TITLE OF THE PROJECT
HOSPITAL MANAGEMENT SYSTEM

6
Introduction
The project Hospital Management System includes registration of patients, storing the
details into the system, and also computerized billing in the pharmacy, and labs. The
software has the facility to give a unique id for every patient and stores the details of every
patient and staff automatically. It includes a search facility to know the current status of
each room. User can search availability of doctor and the details of patient using id.

The Hospital management System can be entered using a username and password. It is
accessible either by an administrator or receptionist. Only they can add data into the
database.The data can be retrieved easily. The interface is very user-friendly. The data are
well protected for personal use and makes the data processing very fast.

Hospital Management System is powerful, flexible and easy to use and is designed and
developed to deliver real conceivable benefits to hospitals.

7
Objective of system
The project “Hospital Management System” is aimed to develop to maintain the day-to –day
state of admission/discharge of patients, list of doctors, reports generation, and etc.It is
designed to achieve the following objectives:

1. To computerized all details regarding patient details & hospital details.

2. Scheduling the appointment of patient with doctors to make it convenient for both.

3. Scheduling the services of specialized doctors and emergency properly so that facilities
provided by hospital are fully utilized in effective and efficient manner.

4. It should be able to handle the test reports of patients conducted in the pathology lab of
the hospital.

5. The inventory should be updated automatically whenever a transaction is made.

6. The information of the patients should be kept up to date and there record should
be kept in the system for further purpose.

8
PROJECT CATEGORY
Windows Application Software
Hardware and Software Requirements
HARDWARE REQUIREMENTS
 Processor :Intel (R) Core (TM) 2 Duo
 Processor Speed : 2.00 GHz
 RAM : 2.00 GB
 Hard Disk : 50 GB hard disk or above

SOFTWARE REQUIREMENTS
 Front End : JAVA
 Back End : SQL
 Operating System : Widows 7

9
Roles &Responsibility
Name Role &Responsibility
Aruna Analysis & Coding

Ronak Designing

Sweety Designing

Dipanshi Tyagi Testing

10
Analysis
Zero Level DFD:

11
One Level DFD:

12
Login Table

Field Name Type Constraints


User_name Text Primary
Password Text Not Null

Patient Table

Field Type Constraints


Patient_id Number YES
Name Text YES
Gender Text YES
Age Text YES
Contact_no Text YES
Address Text YES
Disease Text YES

13
Room Table

Field Type Constraints


Room_no Number Not Null
Room_type Text Not Null
Price Text Not Null

ROOM ALLOCATION TABLE

Field Type Consraints


Allocation_id Number Not Null
Patient_id Number Not Null
Name Text Not Null
Phone Text Not Null
Disease Text Not Null
Room_type Text Not Null
Room_no Number Not Null
Price Text Not Null
Date Text Not Null

Bill Table

Field Type Constraints


Bill_id Number Not Null
Patient_id Number Not Null
Roomno Number Not Null
Days Number Not Null
Amount Number Not Null

14
Modules

 Complete structure of Program


 No. of Modules
 Login Module
 Patient Registration Module
 Room Module
 Room Allocation Module
 Bill Module
We are work on the above following modules i.e.

15
ARCHITECTURE DIAGRAM

Doctors Toolkit is a stand-alone application. As per the functionality, we are describing


its architecture with the help of few diagrams.

And for the web portal i.e. DoctorsHelpline, we have used J2EE on Net Beans 6.9 and the
database is handled by MY SQL Server 2005.

16
USE CASE DIAGRAM FOR DOCTORS TOOLKIT

A use case diagram in the Unified Modeling Language (UML) is a type of behavioral
diagram defined by and created from a Use-case analysis. Its purpose is to present a graphical
overview of the functionality provided by a system in terms of actors, their goals (represented
as use cases), and any dependencies between those use cases.

The main purpose of a use case diagram is to show what system functions are performed for
which actor. Roles of the actors in the system can be depicted.

Select Body Part


Patient

Select Symptoms

Fetch the diseases as per


symptoms

Fetch the medicines details


and solutions

17
DATA FLOW DIAGRAMS

Context Level Diagram (Zero Level)

Patient Submit Retrive


Doctor’s
Retrive Helpline Submit Database

18
Level 1 DFD

Nose Files
Eye Files Ear Files

Head Files Submit Retrieve SubmitHead fiRleestrieve


Head files
Head files Head Hfileeasd fileHs ead files
Submit Retrieve Head fi Head NoseHead files
l es Ea
r Head files
Head files Head files Head files
Submit Retrieve Head files Eye
Head files Head files
Head files MouthFiles
HeaHdead Select
files Select Head files
Head files
Select Head files Head files

Select Head files


Head files Submit
Head files Retrieve
Head files Head files Head files
Head files
Head files Select Head files Mouth
Patient Select DOCTORS Head files
Head files TOOLKIT
SeHleeacdtfiles HeadSfeilel

Head files es ct Tooth


Head files
Head fSileeslect
Leg Head files
Head files
Select
Head files Retrieve Submit
Head files
Select Head files Head files
Head files Select Head files
HeadTfioleosthFiHleeasd files

Retrieve Chest Head files Head files Head files


Head files Submit Head files Head files
HLeeagd Head files
Shoulder
Ffiilleess Head files
Head files Waist
Head files Retrieve Submit
Head files Head files
Lung
Head files Head files
ChestFiles Retrieve Submit
Head files Head files

Head files Retrieve Submit HeadSfhileosulderHFeialed sfil


es
Head files Head files Head files
Head files Submit
Head files Retrieve Head files
WHeaadisf Head files
tiFleisles HeLaudnfgil
Head files
eFsiles
Head files
Head files
Head files
Head files

19
Head files

20
Data Flow Diagram’s

21
22
ONTROL FLOW DIAGRAMS
For stand-alone application DoctorsToolkit
(Head, eye, ear, nose, throat, chest, back, stomach, skin & others module)

Doctors toolkit

Select body part as


head, ear, eye, etc.

Select Symptoms

Get diseases

Get causes related


to each disease

Allopathic Homeopathic
treatment treatment

23
Forms Screen
Login Screen

24
Main Screen

25
Room Information Screen

26
Add Room InformationScreen

27
Room Update and Delete Screen

28
Patient Registration Screen

29
Room Allocation Screen

30
Patient Bill Screen

31
All Patient Report Screen

32
Patient wise Report Screen

33
Checks and Validation
Patient Form
Name Mandatory Field

Gender Mandatory Field

Age Mandatory Field, Only Numeric Value

Contact No Mandatory Field, Only Numeric Value

Address Mandatory Field

Disease Mandatory Field

Doctor Name Mandatory Field

Room Allocation Form


Name Mandatory Field

Mobile No Mandatory Field

Disease Mandatory Field

Price Mandatory Field, Only Numeric Value

Date Mandatory Field, Only Numeric Value

Patient Bill Form


Name Mandatory Field

Mobile No Mandatory Field, Only Numeric Value

Disease Mandatory Field

Room No Mandatory Field, Only Numeric Value

Days Mandatory Field, Only Numeric Value

34
CODING
*******Coding of login page*******
import javax.swing.JOptionPane;
import java.sql.*;
/*
* 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 BCA
*/
public class loginform extends javax.swing.JFrame {
Connection con;
Statement st;
ResultSet rs;

public loginform() {

initComponents();

String url="jdbc:mysql://localhost:3306/hospital_mgt";
String user="root";
String password="root";

try{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection(url,user,password);
st=con.createStatement();
}
catch(Exception e)
{
System.out.print (e.getMessage ());

}
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold default state="collapsed" desc="Generated Code">
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


jLabel1 = new javax.swing.JLabel();

35
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
btnLogin = new javax.swing.JButton();
jLabel6 = new javax.swing.JLabel();
txtPassword = new
javax.swing.JPasswordField(); txtUserName =
new javax.swing.JTextField();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jPanel1.setBackground(new java.awt.Color(153, 153, 255));


jPanel1.setLayout(null);

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N


jLabel1.setText("Login Form");
jPanel1.add(jLabel1);
jLabel1.setBounds(230, 20, 195, 40);

jLabel2.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N


jLabel2.setText("User Name");
jPanel1.add(jLabel2);
jLabel2.setBounds(60, 270, 140, 22);

jLabel3.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N


jLabel3.setText("Password");
jPanel1.add(jLabel3);
jLabel3.setBounds(60, 320, 110, 22);

btnLogin.setBackground(new java.awt.Color(204, 204, 255));


btnLogin.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
btnLogin.setText("LOGIN");

btnLogin.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.R
AISED));
btnLogin.addActionListener(new java.awt.event.ActionListener () {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnLoginActionPerformed(evt);
}
});
jPanel1.add(btnLogin);
btnLogin.setBounds (230, 380, 110,
40);
jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/hospital/management/project
image/hospital_1.jpg"))); // NOI18N
jLabel6.setText("jLabel6");
jPanel1.add(jLabel6);
jLabel6.setBounds(190, 70, 220, 170);
txtPassword.addActionListener (new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtPasswordActionPerformed(evt);
}
});

36
txtPassword.addKeyListener(new java.awt.event.KeyAdapter() {

37
public void keyPressed(java.awt.event.KeyEvent evt) {
txtPasswordKeyPressed(evt);
}
public void keyTyped(java.awt.event.KeyEvent evt) {
txtPasswordKeyTyped(evt);
}
});
jPanel1.add(txtPassword);
txtPassword.setBounds(410, 320, 140, 30);
jPanel1.add(txtUserName);
txtUserName.setBounds(410, 280, 140,
30);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup (javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 643, Short.MAX_VALUE)
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, 473, Short.MAX_VALUE)
);
pack();
setLocationRelativeTo(null);
}// </editor-fold>

private void btnLoginActionPerformed (java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
String name=txtUserName.getText();
String pass=txtPassword.getText();
String query="select * from login where user_name='" + name + "' and password='" + pass +"'";
try{
rs=st.executeQuery(query);
if(rs.next())
{
JOptionPane.showMessageDialog (null,"Login success");
new NewMain().setVisible (true);
this.dispose ();
}
else

{
JOptionPane.showMessageDialog(null,"invalid password");
txtUserName.requestFocus();
txtUserName.selectAll ();
return;
}
}
catch (Exception e)
{
38
System.out.print (e.getMessage ());
}
private void txtPasswordActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void txtPasswordKeyPressed(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
int a =evt.getKeyCode();
//JOptionPane.showMessageDialog(this,a);
if(a==10)
btnLogin.doClick ();
}
private void txtPasswordKeyTyped (java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
String pass=txtPassword.getText();
int length=pass.length();
if(length>=10)
evt.consume();
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold default state="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel (info.getClassName ());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger (loginform.class.getName()).log
(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger
(loginform.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(loginform.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger (loginform.class.getName ()).log
(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>

39
/* Create and display the form */
java.awt.EventQueue.invokeLater (new Runnable ()
{
public void run () {
new loginform ().setVisible (true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnLogin;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel6;
private javax.swing.JPanel jPanel1;
private javax.swing.JPasswordField txtPassword;
private javax.swing.JTextField txtUserName;
// End of variables declaration
}

40
*******Coding of Room Form******
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
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 BCA
*/
public class Room extends javax.swing.JFrame {

/**
* Creates new form Room
*/

Connection con;
Statement st;
ResultSet rs;

public Room() {
initComponents();
String url="jdbc:mysql://localhost:3306/hospital_mgt";
String user="root";
String password="root";

try{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection(url,user,password);
st=con.createStatement();
}
catch(Exception e)
{
System.out.print(e.getMessage());

}
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/

41
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


jLabel1 = new javax.swing.JLabel();
lable2 = new javax.swing.JLabel();
lable3 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
txtprice = new javax.swing.JTextField();
btnok = new javax.swing.JButton();
btncancel1 = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
jLabel6 = new javax.swing.JLabel();
btnnew = new javax.swing.JButton();
cmbroomtype = new
javax.swing.JComboBox(); txtRoomno = new
javax.swing.JLabel(); jButton1 = new
javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jPanel1.setBackground(new java.awt.Color(153, 153, 255));

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N


jLabel1.setText("Room Information");

lable2.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N


lable2.setText("Room No");

lable3.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N


lable3.setText("Room Type");

jLabel5.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N


jLabel5.setText("Price");

txtprice.setEnabled(false);
txtprice.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
txtpriceKeyPressed(evt);
}
public void keyTyped(java.awt.event.KeyEvent evt) {
txtpriceKeyTyped(evt);
}
});

btnok.setBackground(new java.awt.Color(204, 204, 255));


btnok.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
btnok.setText("Save");

btnok.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAIS
ED));
42
btnok.setEnabled(false);
btnok.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnokActionPerformed(evt);
}
});

btncancel1.setBackground(new java.awt.Color(204, 204, 255));


btncancel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
btncancel1.setText("Cancel");
btncancel1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btncancel1ActionPerformed(evt);
}
});

jPanel2.setLayout(null);

jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/hospital/management/
project image/7_1.jpg"))); // NOI18N
jLabel6.setText("jLabel6");
jPanel2.add(jLabel6);
jLabel6.setBounds(0, 0, 260,
160);

btnnew.setBackground(new java.awt.Color(204, 204, 255));


btnnew.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
btnnew.setText("New");

btnnew.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RA
ISED));
btnnew.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnnewActionPerformed(evt);
}
});

cmbroomtype.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select", "Ac


Room", "Normal" }));
cmbroomtype.setToolTipText("");
cmbroomtype.setEnabled(false);
cmbroomtype.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmbroomtypeActionPerformed(evt);
}
});

txtRoomno.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N


jButton1.setText("Home");

43
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton1)
.addGap(18, 18, 18)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 244,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(46, 46, 46)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 131,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(223, 223, 223)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(9, 9, 9)
.addComponent(txtprice, javax.swing.GroupLayout.PREFERRED_SIZE, 114,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(cmbroomtype, javax.swing.GroupLayout.PREFERRED_SIZE, 140,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lable2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(82, 82, 82)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 253,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(lable3, javax.swing.GroupLayout.PREFERRED_SIZE, 216,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(0, 0, Short.MAX_VALUE)))
.addGap(18, 18, 18)

44
.addComponent(txtRoomno, javax.swing.GroupLayout.PREFERRED_SIZE, 138,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(34, 34, 34)
.addComponent(btnnew, javax.swing.GroupLayout.PREFERRED_SIZE, 67,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnok, javax.swing.GroupLayout.PREFERRED_SIZE, 81,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(41, 41, 41)
.addComponent(btncancel1)
.addGap(133, 133, 133)))
.addContainerGap(61, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 148,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addGap(29, 29, 29)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 47,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 83,
Short.MAX_VALUE)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(txtRoomno, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lable2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(27, 27, 27)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lable3)
.addComponent(cmbroomtype, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(44, 44, 44)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5)
.addComponent(txtprice, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(32, 32, 32)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnok)

45
.addComponent(btncancel1)
.addComponent(btnnew))
.addGap(231, 231, 231))
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
);

pack();
setLocationRelativeTo(null);
}// </editor-fold>

private void btnokActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:

int i;
int id=Integer.parseInt(txtRoomno.getText());
//String room=txtRoomno.getText();
String roomtype=cmbroomtype.getSelectedItem().toString();
String price=txtprice.getText();

if(cmbroomtype.getSelectedItem().equals("Select"))
{
JOptionPane.showMessageDialog(null,"Select Room Type");
cmbroomtype.requestFocus();
return;
}
if(price.equals(""))
{
JOptionPane.showMessageDialog(null, "Room Price should be entered");
txtprice.requestFocus();
return;
}
String query ="insert into room values(" + id +",'" + roomtype + "','" + price + "')";
int res = JOptionPane.showConfirmDialog(null, "Do you want to save record?", "Confirm",

46
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if(res == 0) {
System.out.println("Pressed YES");

try{

i=st.executeUpdate(query);
JOptionPane.showMessageDialog(this,"Room Booked Successfully");
//lblpatient.setText("");
//txtroom.setEnabled(false);
cmbroomtype.setEnabled(false);
txtprice.setEnabled(false);
btnnew.setEnabled(true);
btnok.setEnabled(false);
txtRoomno.setText("");
cmbroomtype.setSelectedItem("Select");
txtprice.setText("");
}
catch(Exception ex){
System.out.print(ex.getMessage());
}
}

// JOptionPane.showMessageDialog(this,"Room Booked Successfully");


// new menu().setVisible(true);
// this.dispose();
}

private void btncancel1ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
//lblpatient.setText("");
txtRoomno.setText("");
cmbroomtype.setEnabled(false);
txtprice.setEnabled(false);
btnnew.setEnabled(true);

btnok.setEnabled(false);

//new menu().setVisible(true);
//this.dispose();
}

private void btnnewActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
String query1="select room_no from room";

btnok.setEnabled(true);
btnnew.setEnabled(false);

47
// txtroom.setEnabled(true);
cmbroomtype.setEnabled(true);
txtprice.setEnabled(true);
int id=101;
try
{
rs=st.executeQuery(query1);
while(rs.next())
{
id=rs.getInt(1)+1;

}
txtRoomno.setText(Integer.toString(id));

// txtroom.requestFocus();
}
catch(Exception ex)
{
System.out.print(ex.getMessage());
}

btnok.setEnabled(true);
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.dispose();
new NewMain().setVisible(true);
}
private void cmbroomtypeActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void txtpriceKeyTyped(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
char c=evt.getKeyChar();
//JOptionPane.showMessageDialog(this, c);
if((c>= '0' && c<= '9') || c==8)
{

}
else
evt.consume();
}

private void txtpriceKeyPressed(java.awt.event.KeyEvent evt) {


// TODO add your handling code here:

48
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Room.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Room.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Room.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Room.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Room().setVisible(true);
}
});
}

// Variables declaration - do not modify


private javax.swing.JButton btncancel1;
private javax.swing.JButton btnnew;
private javax.swing.JButton btnok;
private javax.swing.JComboBox cmbroomtype;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JPanel
jPanel1; private
javax.swing.JPanel jPanel2;

49
private javax.swing.JLabel lable2;
private javax.swing.JLabel lable3;
private javax.swing.JLabel txtRoomno;
private javax.swing.JTextField txtprice;
// End of variables declaration
}*******Coding of Room Update and Delete Form*****

import java.sql.*;
import java.sql.DriverManager;
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 BCA
*/
public class RoomDelete extends javax.swing.JFrame {
Connection con;
Statement st;
ResultSet rs;
int globalRoom;
/**
* Creates new form RoomDelete
*/
public RoomDelete() {
initComponents();
String url="jdbc:mysql://localhost:3306/hospital_mgt";
String user="root";
String password="root";

try{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection(url,user,password);
st=con.createStatement();
}
catch(Exception e)
{
System.out.print(e.getMessage());

}
String query="select room_no from room";
try{
rs=st.executeQuery(query);
while(rs.next())
{
cmbRoom.addItem(rs.getString("Room_no"));

50
}
}
cmbRoom.setSelectedItem("select");
cmbRoom.setEnabled(false);
txtPrice.setText("");
txtDate.setText("");
btnadd.setText("");
txtPatient.setText("");
txtId.setText("");

}
catch(Exception ex){
System.out.print(ex.getMessage());
}
}

private void btn10ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
// new menu().setVisible(true);
txtId.setEnabled(false);
txtPatient.setEnabled(false);
txtName.setEnabled(false);
txtPhone.setEnabled(false);
txtDiseases.setEnabled(false);
cmbRoomtype.setEnabled(false);
cmbRoom.setEnabled(false);
cmbRoom.setEnabled(false);
txtDate.setEnabled(false);
btnNew.setEnabled(true);
btnadd.setEnabled(false);
txtName.setText("");
txtPhone .setText("");
txtDiseases.setText("");
cmbRoomtype.setSelectedItem("Select");
cmbRoomtype.setEnabled(false);
cmbRoom.setSelectedItem("select");
cmbRoom.setEnabled(false);
txtPrice.setText("");
txtDate.setText("");
txtId.setText("");
txtPatient.setText("");

51
private void txtPatientActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}

private void btnSearchActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:

if(txtPatient.getText().isEmpty())
{
JOptionPane.showMessageDialog(null,"Enter Patient Id");
return;

}
int id=Integer.parseInt(txtPatient.getText());
String query="select * from patient where patient_id="+ id;
try{
rs=st.executeQuery(query);
if(rs.next())
{

txtName.setText(rs.getString("name"));
txtPhone.setText(rs.getString("contact_no"));
txtDiseases.setText(rs.getString("Disease"));
}
else
JOptionPane.showMessageDialog(this,"no record found");
txtPatient.setEnabled(false);
cmbRoomtype.setEnabled(true);

}
catch(Exception ex){

private void txtPhoneActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
}

private void cmbRoomtypeActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
String roomtype=cmbRoomtype.getSelectedItem().toString();
cmbRoom.removeAllItems();
cmbRoom.addItem("Select");
String query="select room_no from room where room_type='"+ roomtype +"' and room_no not
in(select room_no from room_allocation)";
try{

52
rs=st.executeQuery(query);
cmbRoom.setEnabled(true);
btnPrice.setEnabled(true);
while(rs.next())
{
cmbRoom.addItem(rs.getString("Room_no"));

}
catch(Exception ex){
JOptionPane.showMessageDialog(this,ex.getMessage());
}
}

private void cmbRoomActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:

private void btnPriceActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
if(cmbRoom.getSelectedItem()=="Select")
{
JOptionPane.showMessageDialog(null,"please select Room no. first.");
return;
}
int roomno=Integer.parseInt(cmbRoom.getSelectedItem().toString());

String query="select * from room where room_no="+ roomno;


try{
rs=st.executeQuery(query);
if(rs.next())
{
//cmbroomtype.setSelectedItem(rs.getString("Room_type"));
txtPrice.setText(rs.getString("price"));

}
else
JOptionPane.showMessageDialog(this,"no record found");

}
catch(Exception ex){
JOptionPane.showMessageDialog(this,ex.getMessage());
}
}

private void btnNewActionPerformed(java.awt.event.ActionEvent evt) {

53
// TODO add your handling code here:
String query1="select allocation_id from room_Allocation";

// btnok.setEnabled(true);
//btnnew.setEnabled(false);
// txtroom.setEnabled(true);
//cmbroomtype.setEnabled(true);
txtPatient.setEnabled(true);
btnSearch.setEnabled(true);
int id=101;
try
{
rs=st.executeQuery(query1);
while(rs.next())
{
id=rs.getInt(1)+1;

}
txtId.setText(Integer.toString(id));

// txtroom.requestFocus();
}
catch(Exception ex)
{
System.out.print(ex.getMessage());
}
btnadd.setEnabled(true);
btnNew.setEnabled(false);
}

private void txtNameActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
this.dispose();
new NewMain().setVisible(true);
}

private void txtNameKeyTyped(java.awt.event.KeyEvent evt) {


// TODO add your handling code here:
char c=evt.getKeyChar();
//JOptionPane.showMessageDialog(this, c);
if((c>= 'a' && c<= 'z') || c==8)
{

}
else
evt.consume();

54
}

private void txtPhoneKeyTyped(java.awt.event.KeyEvent evt) {


// TODO add your handling code here:
char c=evt.getKeyChar();
//JOptionPane.showMessageDialog(this, c);
if((c>= '0' && c<= '9') || c==8)
{

}
else
evt.consume();
}

private void txtDiseasesKeyTyped(java.awt.event.KeyEvent evt) {


// TODO add your handling code here:
char c=evt.getKeyChar();
//JOptionPane.showMessageDialog(this, c);
if((c>= 'a' && c<= 'z') || c==8)
{

}
else
evt.consume();
}

private void txtPriceKeyTyped(java.awt.event.KeyEvent evt) {


// TODO add your handling code here:char c=evt.getKeyChar();
//JOptionPane.showMessageDialog(this, c);
char c=evt.getKeyChar();
//JOptionPane.showMessageDialog(this, c);
if((c>= '0' && c<= '9') || c==8)
{

}
else
evt.consume();

private void txtDateKeyTyped(java.awt.event.KeyEvent evt) {


// TODO add your handling code here:
char c=evt.getKeyChar();
//JOptionPane.showMessageDialog(this, c);
if((c>= '0' && c<= '9') || c==8 || c=='/')
{

}
else
evt.consume();
}

55
private void txtDateActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(checkout.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(checkout.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(checkout.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(checkout.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new checkout().setVisible(true);
}
});
}

// Variables declaration - do not modify


private javax.swing.JButton btn10;

56
private javax.swing.JButton btnNew;
private javax.swing.JButton btnPrice;
private javax.swing.JButton btnSearch;
private javax.swing.JButton btnadd;
private javax.swing.JComboBox
cmbRoom;
private javax.swing.JComboBox cmbRoomtype;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JTextField txtDate;
private javax.swing.JTextField txtDiseases;
private javax.swing.JLabel txtId;
private javax.swing.JTextField txtName;
private javax.swing.JTextField txtPatient;
private javax.swing.JTextField txtPhone;
private javax.swing.JTextField txtPrice;
// End of variables declaration
}

57
*******Coding of Bill Form******
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
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 BCA
*/
public class frmBill extends javax.swing.JFrame {

/**
* Creates new form frmBill
*/
Connection con;
Statement st;
ResultSet rs;

public frmBill() {
initComponents();
String url="jdbc:mysql://localhost:3306/hospital_mgt";
String user="root";
String password="root";

try{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection(url,user,password);
st=con.createStatement();
}
catch(Exception e)
{
System.out.print(e.getMessage());

}
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">

58
private void initComponents() {

jPopupMenu1 = new javax.swing.JPopupMenu();


jTextField1 = new javax.swing.JTextField();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
txtpatient = new javax.swing.JTextField();
btnsearch = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
txtphone = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
txtdiseases = new
javax.swing.JTextField(); jLabel5 = new
javax.swing.JLabel(); txtroomNo = new
javax.swing.JTextField(); jLabel9 = new
javax.swing.JLabel(); txtbillId = new
javax.swing.JLabel(); txtname = new
javax.swing.JTextField(); jLabel8 = new
javax.swing.JLabel(); jButton2 = new
javax.swing.JButton(); jPanel2 = new
javax.swing.JPanel(); jLabel6 = new
javax.swing.JLabel(); txtdays = new
javax.swing.JTextField(); jLabel7 = new
javax.swing.JLabel();
txttotalprice = new javax.swing.JTextField();
btncalculate = new javax.swing.JButton();
jLabel10 = new javax.swing.JLabel();
txtprice = new javax.swing.JTextField();
btnnew = new javax.swing.JButton();
btnadd = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();

jTextField1.setText("jTextField1");

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jPanel1.setBackground(new java.awt.Color(153, 153, 255));

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N


jLabel1.setText("Patient Id");

txtpatient.setEnabled(false);

btnsearch.setBackground(new java.awt.Color(204, 204, 255));


btnsearch.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
btnsearch.setText("Search");

btnsearch.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.
RAISED));
btnsearch.setEnabled(false);
btnsearch.addActionListener(new java.awt.event.ActionListener() {
59
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnsearchActionPerformed(evt);
}
});

jLabel2.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N


jLabel2.setText("Name");

jLabel3.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N


jLabel3.setText("Mobile");

txtphone.setEnabled(false);
txtphone.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
txtphoneKeyTyped(evt);
}
});

jLabel4.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N


jLabel4.setText("Disease");

txtdiseases.setEnabled(false);
txtdiseases.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
txtdiseasesKeyTyped(evt);
}
});

jLabel5.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N


jLabel5.setText("Room No");

txtroomNo.setEnabled(false);
txtroomNo.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
txtroomNoKeyTyped(evt);
}
});

jLabel9.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N


jLabel9.setText("Bill Id");

txtbillId.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));


txtbillId.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
txtbillIdKeyTyped(evt);
}
});

txtname.setEnabled(false);
txtname.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {

60
txtnameKeyTyped(evt);
}
});

jLabel8.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N


jLabel8.setText("Patient Bill");

jButton2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N


jButton2.setText("Home");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(31, 31, 31)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 92,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jLabel9, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton2)))
.addGap(112, 112, 112)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 151,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()

61
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(txtbillId, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(txtpatient)
.addComponent(txtroomNo, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtdiseases, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtphone, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtname, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE))
.addGap(16, 16, 16)
.addComponent(btnsearch)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2))
.addGap(18, 18, 18)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(txtbillId, javax.swing.GroupLayout.PREFERRED_SIZE, 21,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel9))
.addGap(18, 18, 18)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtpatient, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnsearch))
.addGap(8, 8, 8))
.addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING))
.addGap(18, 18, 18)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(18, 18, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)

62
.addComponent(txtname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(25, 25, 25)))

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel3)
.addGap(20, 20, 20))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addComponent(txtphone, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)))

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel4)
.addGap(21, 21, 21))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addComponent(txtdiseases, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(20, 20, 20)))

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5)
.addComponent(txtroomNo, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);

jPanel2.setBackground(new java.awt.Color(153, 153, 255));

jLabel6.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N


jLabel6.setText("No of Days");

txtdays.setEnabled(false);
txtdays.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {
txtdaysFocusLost(evt);
}
});
txtdays.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
txtdaysKeyTyped(evt);
}
});

jLabel7.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N


jLabel7.setText("Total Price");

63
txttotalprice.setEnabled(false);
txttotalprice.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
txttotalpriceKeyTyped(evt);
}
});

btncalculate.setBackground(new java.awt.Color(204, 204, 255));


btncalculate.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
btncalculate.setText("Calculate");

btncalculate.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBord
er.RAISED));
btncalculate.setEnabled(false);
btncalculate.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btncalculateActionPerformed(evt);
}
});

jLabel10.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N


jLabel10.setText("Room Price");

txtprice.setEnabled(false);
txtprice.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
txtpriceKeyTyped(evt);
}
});

btnnew.setBackground(new java.awt.Color(204, 204, 255));


btnnew.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
btnnew.setText("NEW");

btnnew.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RA
ISED));
btnnew.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnnewActionPerformed(evt);
}
});

btnadd.setBackground(new java.awt.Color(204, 204, 255));


btnadd.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
btnadd.setText("SUBMIT");

btnadd.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAI
SED));
btnadd.setEnabled(false);
btnadd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {

64
btnaddActionPerformed(evt);
}
});

jButton4.setBackground(new java.awt.Color(204, 204, 255));


jButton4.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jButton4.setText("CANCEL");

jButton4.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.R
AISED));
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);


jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 113,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30,
Short.MAX_VALUE)
.addComponent(txtprice, javax.swing.GroupLayout.PREFERRED_SIZE, 72,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(btnnew)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btnadd)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton4))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 100,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtdays, javax.swing.GroupLayout.PREFERRED_SIZE, 73,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btncalculate)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 103,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

65
.addComponent(txttotalprice, javax.swing.GroupLayout.PREFERRED_SIZE, 73,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(6, 6, 6))
);
jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()

.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING)

.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btncalculate)
.addComponent(jLabel10)
.addComponent(txtprice, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtdays, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7)))
.addComponent(txttotalprice, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 53,
Short.MAX_VALUE)

.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnnew)
.addComponent(btnadd)
.addComponent(jButton4))
.addGap(31, 31, 31))
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addGroup(layout.createSequentialGroup()

66
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);

pack();
setLocationRelativeTo(null);
}// </editor-fold>

private void btnnewActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code
here: String query1="select billId from
bill"; int id=101;
try
{
rs=st.executeQuery(query1);
while(rs.next())
{
id=rs.getInt(1)+1;

}
txtbillId.setText(Integer.toString(id));
txtpatient.setEnabled(true);
btnsearch.setEnabled(true);
btnnew.setEnabled(false);
btnadd.setEnabled(true);
// txtroom.requestFocus();
}
catch(Exception ex)
{
System.out.print(ex.getMessage());
}
}

private void btnsearchActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:

if(txtpatient.getText().isEmpty())
{
JOptionPane.showMessageDialog(this,"Enter Patient Id First" );
return;
}
int id=Integer.parseInt(txtpatient.getText());
String query="select * from room_allocation where patient_id="+ id;
try{
rs=st.executeQuery(query);
if(rs.next())

67
{

txtname.setText(rs.getString("name"));
txtphone.setText(rs.getString("phone"));
txtdiseases.setText(rs.getString("disease"));
txtroomNo.setText(Integer.toString(rs.getInt("room_no")));
txtprice.setText( rs.getString("price"));
txtdays.setEnabled(true);
}
else
JOptionPane.showMessageDialog(this,"no record found");

}
catch(Exception ex){

}
}

private void btnaddActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
if(txtpatient.getText().isEmpty())
{
JOptionPane.showMessageDialog(this,"Enter Patient Id First" );
return;
}
if(txttotalprice.getText().isEmpty())
{
JOptionPane.showMessageDialog(this,"Fill values" );
return;
}
int bId=Integer.parseInt(txtbillId.getText());
int PId=Integer.parseInt(txtpatient.getText());
//String name=txtname.getText();
//String phone=txtphone.getText();
//String disease=txtdiseases.getText();
int roomno=Integer.parseInt(txtroomNo.getText());
int price=Integer.parseInt(txttotalprice.getText());
int days=Integer.parseInt(txtdays.getText());
//String totalamount=txttotalprice.getText();
String query ="insert into bill values(" + bId+"," + PId + "," + roomno+ "," + days + "," + price +
")";
int res = JOptionPane.showConfirmDialog(null, "Do you want to save record?", "Confirm",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if(res == 0) {
System.out.println("Pressed YES");

try{

int i=st.executeUpdate(query);
JOptionPane.showMessageDialog(this,"Bill Generate Succesfully");

68
btnnew.setEnabled(true);
btnadd.setEnabled(false);
txtpatient.setText("");
txtname.setText("");
txtphone.setText("");
txtdiseases.setText("");
txtprice.setText("");
txtbillId.setText("");
txtroomNo.setText("");
txttotalprice.setText("");
txtdays.setText("");

}
catch(Exception ex){
System.out.print(ex.getMessage());
}
}

private void btncalculateActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
int price=Integer.parseInt(txtprice.getText());
int days=Integer.parseInt(txtdays.getText());
txttotalprice.setText(Integer.toString(price*days));
}

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
txtbillId.setEnabled(false);
txtpatient.setEnabled(true);
txtroomNo.setEnabled(false);
txttotalprice.setEnabled(false);
txtdays.setEnabled(false);
btnnew.setEnabled(true);
btnadd.setEnabled(false);
txtpatient.setEnabled(false);
btnsearch.setEnabled(false);
txtdays.setEnabled(false);
btncalculate.setEnabled(false);
txtpatient.setText("");
txtname.setText("");
txtphone.setText("");
txtdiseases.setText("");
txtprice.setText("");
txtbillId.setText("");
txtroomNo.setText("");
txttotalprice.setText("");
txtdays.setText("");

69
}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
this.dispose();
new NewMain().setVisible(true);

private void txtbillIdKeyTyped(java.awt.event.KeyEvent evt) {


// TODO add your handling code here:

private void txtnameKeyTyped(java.awt.event.KeyEvent evt) {


// TODO add your handling code here:
char c=evt.getKeyChar();
//JOptionPane.showMessageDialog(this, c);
if((c>= 'a' && c<= 'z') || c==8)
{

}
else
evt.consume();
}

private void txtphoneKeyTyped(java.awt.event.KeyEvent evt) {


// TODO add your handling code here:
char c=evt.getKeyChar();
//JOptionPane.showMessageDialog(this, c);
if((c>= '0' && c<= '9') || c==8)
{

}
else
evt.consume();
}

private void txtdiseasesKeyTyped(java.awt.event.KeyEvent evt) {


// TODO add your handling code here:
char c=evt.getKeyChar();
//JOptionPane.showMessageDialog(this, c);
if((c>= 'a' && c<= 'z') || c==8)
{

}
else
evt.consume();
}

70
private void txtroomNoKeyTyped(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
char c=evt.getKeyChar();
//JOptionPane.showMessageDialog(this, c);
if((c>= '0' && c<= '9') || c==8)
{

}
else
evt.consume();
}

private void txtpriceKeyTyped(java.awt.event.KeyEvent evt) {


// TODO add your handling code here:
char c=evt.getKeyChar();
//JOptionPane.showMessageDialog(this, c);
if((c>= '0' && c<= '9') || c==8)
{

}
else
evt.consume();
}

private void txtdaysKeyTyped(java.awt.event.KeyEvent evt) {


// TODO add your handling code here:
char c=evt.getKeyChar();
//JOptionPane.showMessageDialog(this, c);
if((c>= '0' && c<= '9') || c==8)
{

}
else
evt.consume();
}

private void txttotalpriceKeyTyped(java.awt.event.KeyEvent evt) {


// TODO add your handling code here:
char c=evt.getKeyChar();
//JOptionPane.showMessageDialog(this, c);
if((c>= '0' && c<= '9') || c==8)
{
}
else
evt.consume();
}
private void txtdaysFocusLost(java.awt.event.FocusEvent evt) {
// TODO add your handling code here:
btncalculate.setEnabled(true);
}
/**

71
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(frmBill.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(frmBill.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(frmBill.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(frmBill.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new frmBill().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnadd;
private javax.swing.JButton btncalculate;
private javax.swing.JButton btnnew;
private javax.swing.JButton btnsearch;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton4;
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;

72
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.JPopupMenu jPopupMenu1;
private javax.swing.JTextField jTextField1;
private javax.swing.JLabel txtbillId;
private javax.swing.JTextField txtdays;
private javax.swing.JTextField txtdiseases;
private javax.swing.JTextField txtname;
private javax.swing.JTextField txtpatient;
private javax.swing.JTextField txtphone;
private javax.swing.JTextField txtprice;
private javax.swing.JTextField txtroomNo;
private javax.swing.JTextField txttotalprice;
// End of variables declaration
}

******Coding of All Patient Report******


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

/*
* 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 BCA
*/
public class report extends javax.swing.JFrame {

/**
* Creates new form report
*/
Connection con;
Statement st;
ResultSet rs;

public report() {
initComponents();
String url="jdbc:mysql://localhost:3306/hospital_mgt";
String user="root";
73
String password="root";

try{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection(url,user,password);
st=con.createStatement();
}
catch(Exception e)
{
System.out.print(e.getMessage());

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jScrollPane2 = new javax.swing.JScrollPane();


jTable1 = new javax.swing.JTable();
jScrollBar1 = new javax.swing.JScrollBar();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
table1 = new javax.swing.JTable();
btnReport = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();

jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane2.setViewportView(jTable1);

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

74
jPanel1.setBackground(new java.awt.Color(153, 153, 255));
jPanel1.setLayout(null);

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N


jLabel1.setText("Patients Report");
jPanel1.add(jLabel1);
jLabel1.setBounds(270, 30, 210, 29);

table1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null, null, null},
{null, null, null, null, null, null},
{null, null, null, null, null, null},
{null, null, null, null, null, null}
},
new String [] {
"PATIENT REG.", "NAME", "CONTACT NO.", "DIEASES", "ADDRESS", "DOCTOR"
}
));
jScrollPane1.setViewportView(table1);

jPanel1.add(jScrollPane1);
jScrollPane1.setBounds(60, 300, 599, 209);

btnReport.setBackground(new java.awt.Color(204, 204, 255));


btnReport.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
btnReport.setText("GENERATE REPORT");

btnReport.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.Beve
lBorder.RAISED));
btnReport.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnReportActionPerformed(evt);
}
});
jPanel1.add(btnReport);
btnReport.setBounds(290, 540, 230,
50);

jPanel2.setLayout(null);

jLabel3.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/hospital/management/project
image/patient.jpg"))); // NOI18N
jLabel3.setText("jLabel3");
jPanel2.add(jLabel3);
jLabel3.setBounds(0, 0, 240,
130);

jPanel1.add(jPanel2);
jPanel2.setBounds(230, 90, 240, 120);

75
jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

76
jButton1.setText("Home");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jPanel1.add(jButton1);
jButton1.setBounds(20, 20, 80, 25);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, 823, Short.MAX_VALUE)
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 624,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
);

pack();
setLocationRelativeTo(null);
}// </editor-fold>

private void btnReportActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
//String name=txtName.getText();
// JOptionPane.showMessageDialog(this,"done");
// String query="select * from patient where name='" + name + "'";
String query="select * from patient";
String registration;
String contact;
String Disease;
String Address;
String doctor;
String name;
DefaultTableModel dm = (DefaultTableModel) table1.getModel();
int i=0;
try{
rs=st.executeQuery(query);
dm.setRowCount(0);
while(rs.next())
{
registration=rs.getString("patient_id");
contact=rs.getString("contact_no");
Disease=rs.getString("Disease");

77
Address=rs.getString("Address");
doctor=rs.getString("doctorname");
name=rs.getString("name");
i++;

dm.addRow(new Object[]{registration,name,contact,Disease,Address,doctor});

}
if(i==0)
{
JOptionPane.showMessageDialog(null, "Record Not Found");

}
} catch(Exception e)
{
System.out.print(e.getMessage());
}
}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
this.dispose();
new NewMain().setVisible(true);
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(report.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {

78
java.util.logging.Logger.getLogger(report.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(report.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(report.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new report().setVisible(true);
}
});
}

// Variables declaration - do not modify


private javax.swing.JButton btnReport;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollBar
jScrollBar1;
private javax.swing.JScrollPane
jScrollPane1; private
javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTable jTable1;
private javax.swing.JTable table1;
// End of variables declaration
}

79
Feasibility Study
Feasibility study is a test of a system proposal according to its workability, impact on the
organization, ability to meet user’s needs, and effective use of resources. The objective of
feasibility study is not solve the problem but to acquire a sense of its scope. During the
study, the problem definition is crystallized and aspects of the problem to be included in the
system are determine

The result of Feasibility study is formal proposal. This is simply a report-a formal document
detailing the nature and scope of the Propose solution. Finally, Feasibility study is carried
out to select the best system that meets the performance requirements. Feasibility is the
determination of whether or not project is worth doing. The process followed in making this
determination is called a Feasibility study.

Objective of Feasibility study

 To identify the deficiencies in the current system.


 To determine objectives of the proposed system.
 To acquire a sense of scope of the system.
 To identify the responsible users.
 To determine whether it is feasible to develop the new system.

80
Testing
Testing is a process of executing a program with the aim of finding error. To makes our
software perform well it should be error free. If testing is done successfully it will remove all
the errors from the software. The various types of testing are:

 Unit Testing
 Integration Testing
 Regression Testing
 Alpha Testing
 Beta Testing
 System Testing
 Performance Testing
 Stress Testing

1. Unit Testing

It focuses on smallest unit of software design. In this we test an individual unit or group of
interrelated units. It often done by programmer by using sample input and observing its
corresponding outputs.

2. Integration Testing

The objective is to take unit tested components and build a program structure that has been
dictated by design. Integration testing in which a group of component is combine to
produce output.

Integration Testing are of four types:-

 Top Down
 Bottom Up
 Sandwich
 Big-Bang

3 .Regression Testing

Every time a new module is added leads to change in program. This type of testing make
sure that whole component works properly even after adding component to the complete
program.

4. Smoke Testing

This test is done to make sure that software under testing is ready or stable for further
testing.

81
It is called Smoke test as testing initial pass is done to check if it did not catch the fire or
smoked in the initial switch on.

5. Alpha Testing

This is a type of validation testing .It is a type of acceptance testing which is done before the
product is released to the customers. It is typically done by QA people.

6. Beta Testing

The beta test is done at one or more customer sites by the end-user of the software. This
version is released for the limited number of users for testing in real time environment.

7. System Testing

In this software is tested such that it works fine for different operating system .It is covered
under the Black Box testing technquie.In this we just focus on internal working.

In this we have security testing, recovery testing, stress testing, and performance testing.

8. Performance Testing

It is designed to test the runtime performance of software within the context of an


integrated system. It is used to test speed and effectiveness of program.

9. Stress Testing

In this we give unfavorable conditions to the system and check how they perform in those
conditions.

82
Future Scope
The proposed software product is the Hospital Management System. The system will be
used in any Hospital, Clinic, Dispensary or pathology labs to get the information from the
patients and then storing the data for future usage.

The current system in use is a paper –based system. It is too slow and cannot provide
update lists of patients within a reasonable timeframe. The intentions of the system are to
reduce over –time pay and increase the number of patients that can be treated accurately.
Requirements statements in this document are both functional and non-functional.

83
Bibliography
o Websites
 http://www.tcs.com
 http://www.msdn.microsoft.com
 http://www.codeguru.com

84

You might also like