Você está na página 1de 236

Clinic Management System

TITLE OF THE PROJECT

CLINIC
MANAGEMENT
SYSTEM

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

Clinic Management System

THE
THE
INTRODUCTION/OBJECTIVE
INTRODUCTION/OBJECTIVE
OF
OF PROJECT
PROJECT

Clinic (Nursing Home) is an institution that provides medical,


surgical or psychiatric care & treatment for the sick & injured.
CLINIC MANAGEMENT SYSTEM, entirely different and reliable
software built for Raj clinic, Patna.

Silent

Features

of

the

CLINIC

MANAGEMENT

SYSTEM Software :

Easy to maintain and upgrade.

Object Oriented features.

Proper data validation.

Faster query retrieval.

Reports are easily generated and more attractive.

Proper data back up.

Window based, hence user-friendly.

Database enhancements to provide decision support on


maintenance.

Can be re-modified for further higher version with more


features.

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

Clinic Management System

Two hours training is sufficient to us the system whether computer


literate or illiterate.

OBJECTIVE OF PROJECT
Our objective is to develop CLINIC MANAGEMENT SYSTEM Software
for the management of Raj Clinic Ashok Rajpath , Patna that
fulfils

Registration,

Patient

Detail,

Billing,

Report

related

requirements of the hospital. Our other objective are to provide


exact & quick result, to generate various types of details & Reports
that depends upon the requirement of the user; To provide facility
of authorized user i.e. unauthorized user must not use our software,
categories of user has been created which provide facility for
accessing software in a standalone as well as network system i.e.
more than one user may use our software at a time.
Finally, our most important objective is to make it more
efficient & flexible which are the main criteria for popular and
successful software.

PROPOSED COMPUTER BASED SYSTEM:Current era can be interpreted as computer age. Computer is such a
device, which can be utilized, in different walks in life. In increasing
trend in modern science, hardware and software gradually getting
new to newer version with faster processing capability with larger
memory size to fulfill the needs of society. In availing the facility, a
computer based system for CSMA has been developed after rigorous
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

Clinic Management System

study of the existing manual system and all problem areas. Salient
features of this computer based systems are:

A Comprehensive application Package that has been designed to


be user-friendly with JAVA (Swing).

Front End 32-bit multithreading

A powerful Back End RDBMS i.e. SQL Server.

Total 64-bit architecture on server i.e. Operating System, RDBMS


& Application.

State-of-Art Technology i.e. Connectivity of Front End to Back


End is on ODBC Direct.

Easy to maintain and upgrade.

Object oriented features.

Proper data validation.

Faster query retrieval.

Password based levels of security.

Proper data back up.

Window based, hence user-friendly.

Variety reports to decision making at all levels.

Database enhancements to provide decision support on


maintenance.

Supports multiple activity records.

Can be re-modified for further higher version with more features.

Two hours training is sufficient to us the system whether


computer literate or illiterate.

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

Clinic Management System

PROJECT
PROJECTCATEGORY
CATEGORY

This project has been developing in JAVA. Hence the category of


the project comes into WBA (Web Based Application) and it is an
Object Oriented System. So relation database management system
(RDBMS) is used java is a power full programming language to
develop sophisticated window very quickly.
Our project is delicately falls in Relational
Database Management system (RDBMS) environment; RDBMS is
one of the important environments for commercial data.
Processing in the world. The oracle enterprise version
takes care of the following:
1) Updating the database
2) Retrieving information from the data base
3) Accepting query language statement
4) Enforcing security specification
5) Enforcing data integrity specification
6) Enforcing information consistency
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

Clinic Management System

7) Managing data sharing


8) Optimizing query
9) Managing system catalog

PROPERTIES OF JAVA (FRONT END):JAVA is pure object oriented programming language, which has
derived C syntax and C++ object oriented programming features. Is
compiled and interpreted language and is platform independent and
can do graphics, networking, multithreading. It was initially called
as OAK. Java was conceived by James Gosling, Patrick Naughton,
Chris Warth, Ed Frank, and Mike Sheridan at Sun Microsystems, Inc.
in 1991. Java can used to create two types of programs: application
and applets. Application is a program that runs on your computer,
under the operating system of that computer. That is an application
created by Java is more or less like one created using C or C++. An
applet is an application designed to be transmitted over the Internet
and executed by a Java-compatible Web browser. Java provides the
Java Virtual Machine (JVM).
Java are following list of buzzwords:

Simple

Secure

Portable

Object-oriented

Robust

Multithreading

Architecture-neutral

Interpreted

High Performance

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

Clinic Management System

Distributed

Dynamic

PROPERTIES OF RDBMS-ORACLE (BACK-END):As we know that the worlds longest selling are the DBMS product.
Oracle work groups or enterprise server account major percentage
of RDBMS engine sold worldwide. The natural
programming language of this product is SQL/PLSQL the creation of
user defined function procedure database trigger and other specific
database processing PLSQL for commercial application will always
related to oracle related to oracle engine.
Oracle has introduced a large number of new features such as
analysis queries, scalar sub-queries, joins, pivot insert statement
and merger statement. Object oriented feature such as inheritance,
Polymorphism, undo table space and various PLSQL packages. It
continues to provide the most secure application development and
deployment platform in the industry.

Exception handling Oracle

locating and user defined locking are fully supported. It also


provides the key concept such as primary key, unique key and
foreign key.
Oracle can run across different platforms. They can also transfer
data from various hardware platforms without any conversions of
programs. They, thus satisfy the feature of having open architecture
and distributed data management capability. This database have
industry standard SQL & Report writer which are 4GL tools. This not

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

Clinic Management System

only facilitates faster development, but also enhances professional


productivity.
Oracle has a query optimizer. The main function of a query
optimizer is to determine automatically the fastest method in which
a database request can be handled.
As a result of this programmers and end users do no need any
additional training to obtain good RDBMS performance. These
databases have servers or data mangers, which minimize both
memory and CPU resource utilization. This ensures high
performance during transaction processing.
Oracle 10G
ORCALE is an acronym for
O - Oak
R - Ridge
A - Automatic
C - Computing
L - Logical
E - Engine

Oracle 10g Product and Utility


ORCALE is a kernel package that has a number of tools that can be
purchased separately and integrated the kernel and add-ons. The
tools allows the user to create database objects, like procedure,
trigger function etc. some of tools are:
A.

SQL*PLUS

B.

INTRACTIVE SQL

C.

PL/SQL

The ORCALE RDBMS is a central ORCALE product. It includes the


database manager and several tools intended to assist the users
and DBA in the maintenance and use of data. The core of RDBMS is
the kernel.
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

Clinic Management System

The kernel handles the following task:


1. Manages storage and definition of data.
2. Controls and limits data access and concurring.
3. Allows backup and recovery of data
4. Interprets SQL and PL/SQL

(A)

SQL*PLUS

SQL*PLUS is an interactive tool which establishes an interaction


between the user and the server. It takes Query as input and sends
it on to the server to be interpreted by the SQL Engine and waits for
the result unless until the server process entertains query and
sends the result back to this interactive tool. Finally it displays the
result to the user. It is the command line interface to the oracle
database. It is a powerful oracle product that can take your
instruction for oracle, Check them for correctness, submit them to
oracle and then modify or reformat the response oracle gives, based
on orders or directions that you have set in place. It interacts with
you, which means you can talk back. You can give directions, and
it will follow them precisely. It will tell user if it doesnt understand
something users have told it to do.
As we get started, just think of SQL*PLUS as a co-worker-an
assistant follows your instructions and helps us do our works more
quickly.
(B)

SQL

SQL is a data sub-language. That is to say, the purpose of SQL is to


interface to a relational database such as oracle7 and all SQL
statement are instructions to the database. In this it differs from
general purposes programming language like C and BASIC.
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

Clinic Management System

Some of the important features of SQL are as following: 1. It provides sets of data as groups rather than as individual
units.
2. It provides automatic navigation to the data.
3. It uses statements that are complex and powerful individually, nd
that therefore stand-alone. The flow-control statements of

4. most programming languages are absent in SQL, although they


are provided in Oracles extension to standard SQL called
PL/SQL.
SQL provides commands for a variety of tasks including: 1.

Querying data.

2. Inserting, updating and deleting rows in a table.


3. Creating, replacing altering and dropping objects.
4. Controlling access to the database and its objects.
5. Guaranteeing database consistency and integrity.
( C ) PL/SQL
PL/SQL stands for Procedural Language Extension to SQL.
PL/SQL available primary as an Enabling Technology within
other softer products, it does not exit as a stand along language.
PL/SQL is powerful language,
which incorporate many of most advance elements of procedural
languages including:

A full range of data types.

Explicit block structure.

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

10

Clinic Management System

Conditional and sequential control statements.

Loops of various kinds.

Exception handlers for use in event-based error handling.

Construct that help in the development of modular code functions and procedures.

SYSTEM
SYSTEMANALYSIS
ANALYSIS

SYSTEM STUDY
In this stage, studding the current to find out how it works and
where improvement should be made. System studies results in
evaluation of how current methods are working and where
adjustment is necessary and impossible.

Existing System
The Existing system for clinic is not computerized it is handled
manually. It is very time consuming & need no. of people to do the
jobs of the system.The existing System has many problems
like,users have to do lots of paper work for data entry,

report

generation. The retrieval of data from the register is very tough task
and every calculation on that data is not very simple as manual
calculation is very slow in comparison of

computerised system .

Here in this case too many times consume, even a single mistake
may create a problem &cant be edited easily. Thus I conclude that

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

11

Clinic Management System

existing system not reliable for the organization. hence it require a


perfect computerised system.

SYSTEM ANALYSIS
In this phase, software developers carry out a detailed study of
users requirements. They then arrive at the proposed system to be
built. This phase generates functional specifications, which contain:

Output to be produced.

Inputs that need to be received.

Procedure that will get the output from the input.

Audit and control the requirements that the user can use to
monitor the proper functioning of the system.

Retrieving the data, calculation on the data and the report


generation will take less time.

Acceptance test to list the tests that the user can carry out to
ensure that the system is acceptable.

SCOPE OF THIS DOCUMENT


Describe the scope of this requirements definition effort. Introduces
the requirements elicitation team, including users, customers,
system engineers, and developers.
This section also details any constraints that were placed upon the
requirements elicitation process, such as schedules, costs, or the
software engineering environment used to develop requirements.
BUSINESS CONTEXT
Provide an overview of the Hospitality. This overview should include
the business's mission statement and its organizational objectives
or goals.
This section describes the set of objectives and requirements for the
system from the user's perspective. It may include a "wish list" of
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

12

Clinic Management System

desirable characteristics, along with more feasible solutions that are


in line with the business objectives.
GENERAL CONSTRAINTS
Lists general constraints placed upon the design team, including
speed requirements, industry protocols, hardware platforms, and so
forth.
REQUIEMENT ANALYSIS
This section lists the functional requirements in ranked order.
Functional requirements describe the possible effects of a software
system, in other words, what the system must accomplish. Other
kinds of requirements (such as interface requirements, performance
requirements, or reliability requirements) describe how the system
accomplishes

its

functional

requirements.

Each

functional

requirement should be specified in a format similar to the following:

Short imperative sentence stating highest ranked Functional


Requirement.

Description: A full description of the requirement.

Criticality: Describes how essential this requirement is to the


overall system.

Technical-Issues: Describes any design or implementation


issues involved in satisfying this requirement.

Cost-and-schedule: Describes the relative or absolute costs


associated with this issue.

Risks:

Describes

the

circumstances

under

which

this

requirement might not able to be satisfied, and what actions can


be taken to reduce the probability of this occurrence.

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

13

Clinic Management System

Dependencies with Other Requirements: Describes


interactions with other requirements.

Others as appropriate
2. Interface Requirements
This section describes how the software interfaces with other

software products or users for input or output. Examples of such


interfaces include library routines, token streams, shared memory,
data streams, and so forth.

User-Interfaces: Describes how this product interfaces with the


user.

GUI: Describes the graphical user interface if present. This


ection should include a set of screen dumps or mockups to

illustrate user interface features. If the system is menu-driven, a


description of all menus and their components should be
provided.
3. Design Constraints

Specifies any constraints for the design team using this document.

Standards Compliance

Hardware Limitations

Others as appropriate
OTHER

NON-FUNCTIONAL ATTRIBUTES

Specifies any other particular non-functional attributes required by


the system. Examples are provided below.
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

14

Clinic Management System

Security

Binary Compatibility

Reliability

Maintainability

Portability

Extensibility

Requirement Specification
An information system is intended to meet the need of the
organization. So this step is to specify the needs or requirements.
The software developer to gather the information should evolve a
clear strategy. The strategy consist of

Identifying the system resources.

Forms and documents used by concern.

Various queries from the management and the user.

Various report used in the organization.

The system should generate different type of report to


support the management.

It is also expected that information maintained should be


secured and not accessible in an unauthorized manner.

It is also expected that proper manual should be provided


including how to work with the system.

System should be user friendly.

FEASIBILITY STUDY
Feasibility study is a procedure that identifies, describes and
evaluates the proposed system and selects the best possible action
for job. An initial investigation culminates in a proposal that
determines whether an alternative system is feasible or not. A
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

15

Clinic Management System

summarized thinking of analyst is presented to the user for


reviewing. When approved, the proposal initiates a feasibility study
that describes and evaluates the best system to choose in terms of
Economic, Technical, Operational and Social Feasibility.
Economic Feasibility
Evaluating the effectiveness and determining the monetary benefits
and savings is called economic feasibility. Since the proposed
system improves the efficiency and also the benefits counts more
than cost, the system proposed is economically feasible.
Technical Feasibility
This feasibility is concerned with specifying hardware and software
that will satisfy the user requirements.

DATA FLOW DIAGRAM


Context Analysis Diagram (Level 0 DFD)
Details/Enquires
Service
Patient

1
CMS

1.1

Level 1 DFD

Registration

Patient
Details
Enquiries
NAME Patient: Pawan kumar Singh
ROLL NO. : 520827293

1.2
16

Patient Query

Clinic Management System

Reports
Service
Details
Money Receipt
1.3
Charges/
Billing

Bill_Master

level 2 DFDs

1.2.1
Registration_master

Patient
Query

Service_master
Enquiry
Report

1.2.2
Services
Provides

Patient

Issue /Enquiry

Money
Receipt

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

1.2.3
Service Charges/
Billing/
Refunds

17

Service_charges

Clinic Management System

Request

1.1.1
Admit Detail

Bed_master

ER-DIAGRAM

CONSUL
TANTNT_
ID

ADDRESS

CONSULTANT

collec
ts

DISEASE_INFO

APPOIN
TMENT

REGISTRATION
SERVICE_MASTER
billin
g
NAME
ROLL NO.

SERV
ES

DRUG_MASTER
: Pawan kumar Singh
: 520827293

18

Clinic Management System

ADVANCE_RECEIPT

ADVANCE_R
ECEIPT_DET
AIL

GENERIC_MASTER
PAY_DETAI
L

PAYMENT_DETAIL

In mode
of

PAYMENTMODE_MASTE

CREDITCARD_MASTER

FIG:-

In mode
of

ER-DIAGRAM OF CLINIC MANAGMENT SYSTEM

DATA STRUCTURE AND DATA DICTIONARY


In my project (clinic management system) total 13 Table
exists. They are as follows:
1. ADVANCE_RECEIPT:
COLUMN

DATATYPE

CONSTRAINTS

BILL_NO
PATIENT_ID

VACHAR (6)
NUMBER (8)

BILL_DATE
AMOUNT_PAID
AMOUNT_PAYABLE
DISCOUNT
BALANCE
PAY_MODE

DATE
NUMBER (6,2)
NUMBER (6,2)
NUMBER (6,2)
NUMBER (6,2)
VARCHAR2 (2)

PRIMARY KEY
NOT NULL REFERENCES REGISTRATION
(PATIENT_ID)
DEFAULT SYSDATE

PAY_NO
VALID_UPTO

VARCHAR2 (50)
DATE

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

REFERENCES PAYMENTMODE_MASTER
(CODE)

19

Clinic Management System

2 . ADVANCE_RECEIPT_DETAILS:
COLUMN

DATATYPE

CONSTRAINTS

BILL_NO

VARCHAR (6)

SERVICE_ID

VARCHAR (6)

NOT NULL REFERENCES


ADVANCE_RECEIPT (BILL_NO)
NOT NULL REFERENCES
SERVICE_MASTER (SERVICE_ID)

QTY

NUMBER (4)

3. APPOINTMENT:
COLUMN

DATATYPE

CONSTRAINTS

APPOINTMENT_ID

VARCHAR (6)

PRIMARY KEY

PATIENT_ID

NUMBER (8)

CONSULTANT_ID

VARCHAR (6)

NOT NULL REFERENCES REGISTRATION


(PATIENT_ID)
NOT NULL REFERENCES CONSULTANT
(CONSULTANT_ID)

APPT_DATE_TIME

DATE

NOT NULL

STATUS

VARCHAR2 (1)

CHECK (STATUS IN (P,C,X))

4.

USER_MASTER:

COLUMN

DATATYPE

CONSTRAINTS

USER_NAME
PASSWORD

VARCHAR2 (20)
VARCHAR2 (50)

PRIMARY KEY
NOT NULL

5.

BILLING_CLASS:

COLUMN

DATATYPE

CONSTRAINTS

BILLING_CLASS_ID

VARCHAR (6)

DESCRIPTION

VARCHAR2 (50)

PRIMARY KEY
NOT NULL

DISCOUNT_PERCENTAGE
EFFECTIVE_FROM
EFFECTIVE_TO
ACTIVE

NUMBER (4,2)
DATE
DATE
VARCHAR2 (1)

6.

CHECK (ACTIVE IN (Y,N))

CONSULTANT :

COLUMN

DATATYPE

CONSTRAINTS

CONSULTANT_ID

VARCHAR (6)

PRIMARY KEY

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

20

Clinic Management System

CONSULTANT_NAME

VARCHAR2 (50)

NOT NULL

MEDICAL_REG_ID
CONSULTANT_NATURE
CONSULTANT_TYPE
MOBILE_NO
PHONE_NO
ADDRESS
EMAIL
DOB
DOJ

VARCHAR2
VARCHAR2
VARCHAR2
VARCHAR2
VARCHAR2
VARCHAR2
VARCHAR2
DATE
DATE

NOT NULL
NOT NULL
NOT NULL

7.

(20)
(20)
(20)
(15)
(15)
(50)
(50)

PAYMENT_DETAILS :

COLUMN

DATATYPE

CONSTRAINTS

BILL_NO
PAY_AMT
PAY_DATE

VARCHAR (6)
NUMBER (6,2)
DATE

NOT NULL ADVANCE_RECEIPT (BILL_NO)

8.

REGISTRATION:

COLUMN

DATATYPE

CONSTRAINTS

PATIENT_ID

NUMBER (8)

PRIMARY KEY

REG_CATEGORY
PATIENT_TYPE
REG_DT
DEPT
CONSULTANT_ID

VARCHAR2 (10)
VARCHAR2 (10)
DATE
VARCHAR2 (50)
VARCHAR (6)

NOT NULL
NOT NULL
NOT NULL

FNAME
MNAME
LNAME
DOB
GENDER
MARITAL _STATUS

VARCHAR2
VARCHAR2
VARCHAR2
DATE
VARCHAR2
VARCHAR2

(20)
(20)
(20)

OCCUPATION
REMARKRS
ADDRESS
MOBILE_NO

VARCHAR2
VARCHAR2
VARCHAR2
VARCHAR2

(20)
(50)
(200)
(15)

9.

NOT NULL REFERENCES CONSULTANT


(CONSULTANT_ID)

(1)
(1)

CHECK (GENDER IN (M,F))


CHECK (MARITAL_STATUS IN
(M,U,W,D))

SERVICE_MASTER :

COLUMN
SERVICE_ID
DESCRIPTION

NAME
ROLL NO.

DATATYPE
VARCHAR (6)
VARCHAR2 (50)

: Pawan kumar Singh


: 520827293

CONSTRAINTS
PRIMARY KEY
NOT NULL

21

Clinic Management System

TYPE
ACTIVE
RATE
MINAMT
EFFFROM
EFFTO

10.

VARCHAR2 (10)
VARCHAR2 (1)
NUMBER (6,2)
NUMBER (6,2)
DATE
DATE

DRUGS_MASTER :

COLUMN
CODE
NAME
COMPANY_NAME
UNIT_OF_MEASURE
STOCK_ON_HAND
MANUFACTURE_DT
EXPIRY_DT
SHAPE

11.

CONSTRAINTS
PRIMARY KEY
NOT NULL
NOT NULL
NOT NULL
NOT NULL
NOT NULL
NOT NULL

DATATYPE
VARCHAR2 (6)
VARCHAR2 (20)
VARCHAR2 (20)
NUMBER (6)
NUMBER (4)

CONSTRAINTS
PRIMARY KEY
NOT NULL
NOT NULL
NOT NULL

CREDITCARD_MASTER :

COLUMN
CODE
DESCRIPTION

13.

DATATYPE
VARCHAR2 (6)
VARCHAR2 (20)
VARCHAR2 (20)
NUMBER (6)
NUMBER (4)
DATE
DATE
VARCHAR2 (15)

GENERIC_MASTER :

COLUMN
CODE
NAME
COMPANY_NAME
UNIT_OF_MEASURE
STOCK_ON_HAND

12.

CHECK (ACTIVE IN (Y,N))

DATATYPE
VARCHAR2 (6)
VARCHAR2 (20)

CONSTRAINTS
PRIMARY KEY

PAYMENTMODE_MASTER :

COLUMN
CODE
DESCRIPTION

NAME
ROLL NO.

DATATYPE
VARCHAR2 (6)
VARCHAR2 (20)

: Pawan kumar Singh


: 520827293

CONSTRAINTS
PRIMARY KEY

22

Clinic Management System

Coding
Table Code
create table PaymentMode_Master(
Code varchar(2) primary key,
Description varchar(20)
)
create table CreditCard_Master(
Code varchar(6)primary key,
Description varchar(5)
)
create table Generic_Master(
Code Varchar(6)primary key,
Name varchar(20)not null,
Company_Name varchar(20)not null,
Unit_of_Measure Number(6)not null,
Stock_on_Hand Number(4)
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

23

Clinic Management System

)
create table Drug_Master(
Code varchar(6)primary key,
Name varchar(20)not null,
Company_Name varchar(20)not null,
Unit_of_Measure Number(6)not null,
Stock_on_Hand Number(4),
Manufacture_Dt date not null,
Expiry_Dt date not null,
Shape varchar(15)not null
)
create table Service_Master(
Service_ID varchar(6)primary key,
Description varchar(50)not null,
Type varchar(10),
Active varchar(1)check(Active in('Y','N')),
Rate number(6,2),
MinAmt number(6,2),
EFFfrom date,
EFFto date
)
create table Consultant(
Consultant_ID varchar(6) primary key,
Consultant_Name varchar(50) not null,
Medical_Reg_ID varchar(20)not null,
Consultant_Nature varchar(20)not null,
Consultant_Type varchar(20)not null,
Mobile_No varchar(15),
Phone_No varchar(15),
Address varchar(50),
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

24

Clinic Management System

Email varchar(50),
DOB date,
DOJ date
)
Create Table Registration(
Patient_Id number(8)primary key,
Reg_Category varchar(10)not null,
Patient_Type varchar(10)not null,
Reg_Dt date not null,
Dept varchar(50),
Consultant_ID varchar(6)not null references
Consultant(Consultant_ID),
FName varchar(20),
MName varchar(20),
LName varchar(20),
DOB date,
Gender varchar(1) Check(Gender in('M','F')),
Marital_Status varchar(1) check(Marital_Status in('M','U')),
Occupation varchar(20),
Remarks varchar(50),
Address varchar(50),
Mobile_No varchar(15),
)
Create table Billing_Class(
ID varchar(6)primary key,
Description varchar(50)not null,
Discount_Percentage number(4,2),
Effective_From date,
Effective_To date,
Active varchar(1)check(Active in('Y','N'))
)
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

25

Clinic Management System

create table Advance_Receipt(


Bill_No varchar(6)primary key,
Patient_ID numeric(6)not null references Registration(Patient_ID),\
Bill_Date date,
Amount_Paid number(6,2),
Amount_Payable number(6,2),
Discount number(6,2),
Balance number(6,2),
Pay_Mode varchar(2)not null references
PaymentMode_Master(Code),
Pay_No varchar(50),
Valid_Upto date
)

create table Advance_Receipt_Details(


Bill_No varchar(6)not null references Advance_Receipt(Bill_No),
Service_ID varchar(6)not null references
Service_Master(Service_ID),
Qty numeric(4)
)
create table Appointment(
Appointment_ID varchar(6)primary key,
Patient_ID number(6)not null references Registration(Patient_ID),
Consultant_ID number(6)not null references
Consultant(Consultant_ID),
Appt_Date_Time date not null,
Status varchar(1)check(Status in('P','C','X'))
)
create table User_Master(
User_Name varchar(20)primary key,
Password varchar(50) not null,
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

26

Clinic Management System

)
CREATE TABLE Payment_Details (
Bill_No varchar(6)not null references Advance_Receipt(Bill_No),
Pay_Amt number(6,2),
Pay_Date date

Home Class
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import javax.swing.JOptionPane;
// Start window to welcome to project
public class Home extends JFrame implements ActionListener
{
Login lg=new Login(); //Loging is class
JFrame frm;
JLabel msg,wellmsg;
JButton cont,cancel;
Container con;
JPanel panel;
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

27

Clinic Management System

Font plain=new Font("courier


new",Font.PLAIN,22);
Font bold=new Font("courier new",Font.BOLD,50);
//..................Home constructor
define............................................
public Home()
{

public void displayHome()


{
GridBagLayout grid=new GridBagLayout();
GridBagConstraints gbc=new
GridBagConstraints();
frm=new JFrame("CLINIC MANAGEMENT
SYSTEM");

con=frm.getContentPane();
panel=new JPanel();
panel.setFont(plain);
msg=new JLabel("CLINIC MANAGEMENT

SYSTEM");
con.setLayout(grid);

panel.setBorder(BorderFactory.createTitledBorder(BorderFacto
ry.createEtchedBorder(),""));
msg.setFont(bold);
msg.setForeground(Color.blue);
panel.setBackground(Color.yellow);
panel.add(msg);
con.add(panel);
wellmsg=new JLabel("WELCOME TO");
wellmsg.setFont(bold);
wellmsg.setForeground(Color.blue);
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

28

Clinic Management System

gbc.ipadx=10;
gbc.ipady=5;
gbc.gridx=0;
gbc.gridy=0;
gbc.insets=new Insets(-250,0,0,0);
grid.setConstraints(wellmsg,gbc);
con.add(wellmsg);
cont=new JButton("Continue");
gbc.fill=GridBagConstraints.BOTH;
gbc.ipadx=25;
gbc.ipady=10;
gbc.insets=new Insets(50,450,0,500);
gbc.gridx=0;
gbc.gridy=2;
gbc.gridwidth=0;
gbc.gridheight=1;
grid.setConstraints(cont,gbc);
con.add(cont);
cancel=new JButton("Cancel");
gbc.fill=GridBagConstraints.BOTH;
gbc.ipadx=25;
gbc.ipady=10;
gbc.insets=new Insets(20,450,0,500);
gbc.gridx=0;
gbc.gridy=3;
grid.setConstraints(cancel,gbc);
con.add(cancel);
//..........Frame
define......................................................
frm.setSize(1000,650);
frm.setVisible(true);
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

29

Clinic Management System

frm.show();
//..........ActionListener
add.............................................
cont.addActionListener(this);
cancel.addActionListener(this);
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
// ...actionPerformed is method of ActionListener where
that work the action event
public void actionPerformed(ActionEvent ae)
{
String str=ae.getActionCommand();
if (str.equals("Continue"))
{
lg.displayLogin();
frm.dispose();
}
else if (str.equals("Cancel"))
{
System.exit(0);
}
}
public void cancel()
{
System.exit(0);
}
public static void main(String[] args) // main class
define.
{
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

30

Clinic Management System

Home h=new Home();


h.displayHome();
}
}

LOGIN CLASS
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class Login implements ActionListener
{
Connecting conn=new Connecting();
Menu mn;
JFrame frm;
JLabel logname,lpassword;
Container con;
JButton blogin,bcancel,bclear,welcome;
JTextField txtlogname;
JPasswordField passwordfield;
JPanel panel;
JTabbedPane tpan;
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

31

Clinic Management System

String log,pass;
String userName="";
String password="";
public Login()
{}
public void displayLogin()
{
GridBagLayout grid=new GridBagLayout();
GridBagConstraints gbc=new
GridBagConstraints();
frm=new JFrame("Login into CMS ");
panel=new JPanel();
frm.setLayout(grid);
con=frm.getContentPane();
logname=new JLabel("User Name");
gbc.ipadx=10;
gbc.ipady=5;
gbc.insets=new Insets(15,0,0,0);
gbc.gridx=0;
gbc.gridy=0;
grid.setConstraints(logname,gbc);
con.add(logname);
logname.setForeground(new
Color(0,0,255));
logname.setFont(new Font("Courier
new",Font.BOLD,15));
txtlogname=new JTextField(12);
gbc.gridx=1;
gbc.gridy=0;
grid.setConstraints(txtlogname,gbc);
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

32

Clinic Management System

con.add(txtlogname);
txtlogname.setForeground(new
Color(0,0,0));
txtlogname.setFont(new Font("Courier
new",Font.BOLD,15));
txtlogname.setBackground(new
Color(255,175,175));
lpassword=new JLabel("Password");
gbc.gridx=0;
gbc.gridy=1;
grid.setConstraints(lpassword,gbc);
con.add(lpassword);

lpassword.setForeground(new
Color(0,0,255));
lpassword.setFont(new Font("Courier
new",Font.BOLD,15));
passwordfield=new JPasswordField(12);
gbc.gridx=1;
gbc.gridy=1;
grid.setConstraints(passwordfield,gbc);
con.add(passwordfield);
passwordfield.setForeground(new
Color(0,0,0));
passwordfield.setFont(new Font("Courier
new",Font.BOLD,15));
passwordfield.setBackground(new
Color(255,175,175));
blogin=new JButton("Login");
gbc.gridx=0;gbc.gridy=2;
gbc.ipady=0;
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

33

Clinic Management System

gbc.insets=new Insets(20,15,0,10);
gbc.anchor=GridBagConstraints.WEST;
grid.setConstraints(blogin,gbc);
con.add(blogin);
bclear=new JButton("Clear");
gbc.gridx=1;gbc.gridy=2;
gbc.insets=new Insets(20,-5,0,0);
grid.setConstraints(bclear,gbc);
con.add(bclear);
bcancel=new JButton("Cancel");
gbc.gridx=2;gbc.gridy=2;
gbc.ipadx=0;

gbc.insets=new Insets(20,-73,0,0);
grid.setConstraints(bcancel,gbc);
con.add(bcancel);
//......................ActionListener ... ...
blogin.addActionListener(this);
bclear.addActionListener(this);
bcancel.addActionListener(this);
frm.setSize(300,200);
frm.setResizable(false);
frm.setLocation(250,190);
frm.setVisible(true);
frm.show();
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void clear()
{
txtlogname.setText("");
passwordfield.setText("");
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

34

Clinic Management System

}
public void cancel()
{
frm.dispose();
}
//......................actionPerformed
public void actionPerformed(ActionEvent ae)
{
String str=ae.getActionCommand();
if (str.equals("Login"))
{
login();
}
if (str.equals("Clear"))
{
clear();
}
if (str.equals("Cancel"))
{
cancel();
}
}
public void login()
{
log=txtlogname.getText();
pass=passwordfield.getText();
int rec=conn.rsCount("Select User_Name,Password
from User_Master where User_Name='"+log+"' and
Password='"+pass+"'");
if(rec!=1)
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

35

Clinic Management System

JOptionPane.showMessageDialog(null,"Sorry ! \nInvalid User


Name or Password");
else if(rec==1)
{
frm.dispose();
mn=new Menu();
mn.f.setTitle("CLINIC Management
System"+" / User-"+log);
mn.Patient.remove(mn.Exit);
mn.Exit=new JMenuItem("Log Off "+log);
mn.Patient.add(mn.Exit);
}

mn.Exit.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
mn.f.dispose();
Login lg=new Login();
lg.displayLogin();
}
});
}
public static void main(String args[])
{
Connecting conn=new Connecting();
int rec=conn.rsCount("Select * from
User_Master");
if(rec!=0)
{
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

36

Clinic Management System

Login lg=new Login();


lg.displayLogin();
}else {
JOptionPane.showMessageDialog(null,"There is no any
user ! \nYou have to create atleat\none user to start this
project!","Welcome to
CMS",JOptionPane.INFORMATION_MESSAGE);
User u=new User();
u.btDelete.setEnabled(false);
}
}
}
MENU CLASS
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import javax.swing.JOptionPane;
class Menu
{
Login log=new Login();
Report rpt;
JFrame f;
JMenuBar menubar;
JMenuItem
Patient,Billing,Service,Admin,Report,Exit,Payment,Quit;
JMenuItem
Consultant,Registration,Appointment,AdvRec,AdvRecDet;
JMenuItem
CrCard,PayMode,PayDet,SerMas,Drug,Generic,Bill,CrUser;
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

37

Clinic Management System

JMenuItem
rptConsultant,rptConAll,rptConType,rptPatient,rptPatDay,PatMonth,r
ptPatDate,before,after,patDept;
JMenuItem
rptAdvRec,AdvPat,AdvDate,AdvDay,AdvBefore,AdvAfter,AdvMY,chLo
g;
String sql="";
Menu()
{
f=new JFrame();
f.setLayout(null);
menubar=new JMenuBar();

Patient=new JMenu("Patient");
Billing=new JMenu("Billing");
Service=new JMenu("Services");
Report=new JMenu("Reports");
Admin=new JMenu("Administrator");
Payment=new JMenu("Payment");
rptConsultant=new JMenu("Consultant");
rptPatient=new JMenu("Patient");
rptPatDate=new JMenu("Registration");
rptAdvRec=new JMenu("Advance Receipt");
AdvDate=new JMenu("Billing");
//......................Patient Menu.......................................
Registration=new JMenuItem("Registartion");
Patient.add(Registration);
Appointment=new JMenuItem("Appointment");
Patient.add(Appointment);
Patient.add(new JSeparator());
Exit=new JMenuItem("Exit");
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

38

Clinic Management System

Patient.add(Exit);
Quit=new JMenuItem("Exit");
Patient.add(Quit);
//...............Billing Menu.......................................
Bill=new JMenuItem("Billing Class");
Billing.add(Bill);
AdvRec=new JMenuItem("Advance Receipt");
Billing.add(AdvRec);
AdvRecDet=new JMenuItem("Advance Receipt Detail");
Billing.add(AdvRecDet);
//............... Payment Menu.........................................
CrCard=new JMenuItem("Credit Card");

Payment.add(CrCard);
PayMode=new JMenuItem("Payment Mode");
Payment.add(PayMode);
PayDet=new JMenuItem("Payment Detail");
Payment.add(PayDet);
//........... Service Menu
SerMas=new JMenuItem("Service");
Service.add(SerMas);
Drug=new JMenuItem("Drugs");
Service.add(Drug);
Generic=new JMenuItem("Generic");
Service.add(Generic);
//.....................Adminstrator
Consultant=new JMenuItem("Consultant");
Admin.add(Consultant);
CrUser=new JMenuItem("Create / Delete User");
Admin.add(CrUser);
chLog=new JMenuItem("Change Password");
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

39

Clinic Management System

Admin.add(chLog);
/*-----------REPORT MENU---------*/
rptConAll=new JMenuItem("All");
rptConsultant.add(rptConAll);
rptConType=new JMenuItem("Type");
rptConsultant.add(rptConType);
Report.add(rptConsultant);
patDept=new JMenuItem("Department");
rptPatient.add(patDept);
rptPatDay=new JMenuItem("Date");
rptPatDate.add(rptPatDay);
before=new JMenuItem("Before Date");

rptPatDate.add(before);
after=new JMenuItem("After Date");
rptPatDate.add(after);
PatMonth=new JMenuItem("Month & Year");
rptPatDate.add(PatMonth);
rptPatient.add(rptPatDate);
Report.add(rptPatient);
AdvPat=new JMenuItem("Patient");
rptAdvRec.add(AdvPat);
AdvDay=new JMenuItem("Date");
AdvDate.add(AdvDay);
AdvBefore=new JMenuItem("Before Date");
AdvDate.add(AdvBefore);
AdvAfter=new JMenuItem("After Date");
AdvDate.add(AdvAfter);
AdvMY=new JMenuItem("Month & Year");
AdvDate.add(AdvMY);
rptAdvRec.add(AdvDate);
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

40

Clinic Management System

Report.add(rptAdvRec);
/*.....Add Menubar To Form.....*/
menubar.add(Patient);
menubar.add(Billing);
menubar.add(Payment);
menubar.add(Service);
menubar.add(Admin);
menubar.add(Report);
JLabel dev=new JLabel("Developed By :- Pawan kumar
singh ");
dev.setBounds(5,500,200,20);
f.add(dev);

/*.......annonymous class*/
Registration.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent a)
{
new Registration();
}
});
Consultant.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
new Consultant();
}
});
Appointment.addActionListener(new ActionListener()
{
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

41

Clinic Management System

public void actionPerformed(ActionEvent ae)


{
new Appointment();
}
});
AdvRec.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent e)
{
new Advance_Receipt();
}
});
AdvRecDet.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent e)
{
new Adv_Rec_Det();
}
});
Bill.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent e)
{
new Billing();
}
});
PayMode.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent e)
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

42

Clinic Management System

{
new PaymentMode();
}
});
PayDet.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent e)
{
new PayDetail();
}
});
CrCard.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent e)
{
new CrMaster();
}
});
SerMas.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent e)
{
new Service_Master();
}
});
Drug.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent e)
{
new Drug_Master();
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

43

Clinic Management System

}
});
Generic.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent e)
{
new Generic_Master();
}
});
CrUser.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent e)
{
new Administrator();
}
});
chLog.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
e)
{
changeLogin log=new
changeLogin();
log.displayLogin();
}
});
Quit.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent e)
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

44

Clinic Management System

{
System.exit(0);
}
});
rptConAll.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
e)
{
rpt=new Report();
rpt.ReportDisplay("select
Consultant_ID,Consultant_Name,Consultant_Type,Mobile_No,Addres
s,Email,DOB,DOJ from Consultant")
rpt.frm.setTitle("All Consultant Report");
}
});
rptConType.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
e)
{
String input=JOptionPane.showInputDialog("Enter Consultant
Type");
rpt=new Report();
rpt.ReportDisplay("Select
Consultant_ID,Consultant_Name,Consultant_Type,Mobile_No,Addres
s,Email,DOB,DOJ from Consultant where
Consultant_Type='"+input+"'");

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

45

Clinic Management System

rpt.frm.setTitle(("Consultant Report of '" +input+"' Department


").toUpperCase());
}
});
patDept.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
e)
{
String
input=JOptionPane.showInputDialog("Enter Department Name");
rpt=new Report();

rpt.ReportDisplay("Select
Patient_Id,FName,MName,LName,Reg_Category,Consultant_ID,DOB
,Mobile_No,Address,Reg_Dt from Registration where
Dept='"+input+"'");
rpt.frm.setTitle(("Patient Report of '" +input+"' Department
").toUpperCase());
}
});
rptPatDay.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
e)
{
String input=JOptionPane.showInputDialog("Enter Date in (MM-DDYY) Form");
rpt=new Report();

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

46

Clinic Management System

rpt.ReportDisplay("Select
Patient_Id,FName,MName,LName,Reg_Category,Consultant_ID,DOB
,Mobile_No,Address,Reg_Dt from Registration where
Reg_Dt='"+input+"'");
rpt.frm.setTitle("Patient Report Who Registered On '" +input+"' ");
}
});
before.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
e)
{
String input=JOptionPane.showInputDialog("Enter Date in
(MM-DD-YY) Form");
rpt=new Report();
rpt.ReportDisplay("Select
Patient_Id,FName,MName,LName,Reg_Category,Consultant_ID,DOB
,Mobile_No,Address,Reg_Dt from Registration where
Reg_Dt<'"+input+"'");
rpt.frm.setTitle("Patient Report Who Registered Before '" +input+"'
");
}
});
after.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
e)
{
String input=JOptionPane.showInputDialog("Enter Date in
(MM-DD-YY) Form");
rpt=new Report();
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

47

Clinic Management System

rpt.ReportDisplay("Select
Patient_Id,FName,MName,LName,Reg_Category,Consultant_ID,DOB
,Mobile_No,Address,Reg_Dt from Registration where
Reg_Dt>'"+input+"'");
rpt.frm.setTitle("Patient Report Who Registered After '" +input+"'
");
}
});
PatMonth.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
e)
{
String input=JOptionPane.showInputDialog("Enter Month & Year in
(MM-YY) Form");
String y=input.substring(3,5);
String m=input.substring(0,2);
String my=m+"-11-"+y;
rpt=new Report();
rpt.ReportDisplay("Select
Patient_Id,FName,MName,LName,Reg_Category,Consultant_ID,DOB
,Mobile_No,Address,Reg_Dt from Registration where
datepart(mm,Reg_Dt)=datepart(mm,'"+my+"') and
datepart(yy,Reg_Dt)=datepart(yy,'"+my+"')");
rpt.frm.setTitle("Patient Report Who Registered in Month '" +m+"'
of Year '"+y+"' ");
}
});
AdvPat.addActionListener(new ActionListener ()
{
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

48

Clinic Management System

public void actionPerformed(ActionEvent


e)
{
String input=JOptionPane.showInputDialog("Enter Patient ID");
rpt=new Report();
rpt.ReportDisplay("Select * from Advance_Receipt where
Patient_ID='"+input+"'");rpt.frm.setTitle(("Advance Receipt of
Patient ID '" +input+"'").toUpperCase());
}
});
AdvDay.addActionListener(new ActionListener ()
{

public void actionPerformed(ActionEvent


e)
{
String input=JOptionPane.showInputDialog("Enter Date in (MM-DDYY) Form");
rpt=new Report();
rpt.ReportDisplay("Select * from Advance_Receipt where
Bill_Date='"+input+"'");
rpt.frm.setTitle("Advance Receipt Which Generated On '" +input+"'
");
}
});
AdvBefore.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
e)
{
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

49

Clinic Management System

String input=JOptionPane.showInputDialog("Enter Date in


(MM-DD-YY) Form");
rpt=new Report();
rpt.ReportDisplay("Select * from Advance_Receipt where
Bill_Date<'"+input+"'");
rpt.frm.setTitle("Advance Receipt Which Generated in Before
'" +input+"' ");
}
});
AdvAfter.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent e)
{

String input=JOptionPane.showInputDialog("Enter Date in


(MM-DD-YY) Form");
rpt=new Report();
rpt.ReportDisplay("Select * from Advance_Receipt where
Bill_Date>'"+input+"'");
rpt.frm.setTitle("Advance Receipt Which Generated After '"
+input+"' ");
}
});
AdvMY.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
e)
{
String input=JOptionPane.showInputDialog("Enter Month & Year in
(MM-YY) Form");
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

50

Clinic Management System

String y=input.substring(3,5);
String m=input.substring(0,2);
String my=m+"-11-"+y;
rpt=new Report();
rpt.ReportDisplay("Select * from Advance_Receipt where
datepart(mm,Bill_Date)=datepart(mm,'"+my+"') and
datepart(yy,Bill_Date)=datepart(yy,'"+my+"')");
rpt.frm.setTitle("Advance Receipt Which Generated in Month '"
+m+"' of Year '"+y+"' ");
}
});
/*..........Display

Frame .............................................*/

Container con=f.getContentPane();
f.setJMenuBar(menubar);
f.pack();
f.setTitle("CLINIC MANAGEMENT SYSTEM");
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(800,590);
f.show();
}
public static void main(String args[])
{
Menu m=new Menu();
}
}

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

51

Clinic Management System

REGISTRATION CLASS
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import javax.swing.JOptionPane;
import java.util.*;
public class Registration implements WindowListener,KeyListener
{
Connecting conn=new Connecting();
Registration()
{
display();
}
PreparedStatement pst;
JButton btAdd,btClear,btEdit,btDelete,btSearch;

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

52

Clinic Management System

JTextField
txtpid,txtrc,txtpt,txtdate,txtdept,txtfname,txtmname,txtlname,txtdo
b;
JTextField txtocc,txtrem,txtadd,txtmob;
JFrame frm;
JComboBox cmbcid,cmbgender,cmbms;
String []gender={"Male","Female"};
String []ms={"Maried","Unmaried"};
String sex="",mstatus="";
boolean found=false;
boolean text=false;
public void display()
{
frm=new JFrame("Registration....");
GridBagLayout grid=new GridBagLayout();

GridBagConstraints gbc=new
GridBagConstraints();
frm.setLayout(grid);
Container cont=frm.getContentPane();
gbc.anchor=GridBagConstraints.WEST;
JLabel lbpid=new JLabel("Patient ID");
gbc.gridx=0; gbc.gridy=0;
gbc.ipadx=10;gbc.ipady=5;
gbc.insets=new Insets(10,20,0,0);
grid.setConstraints(lbpid,gbc);
cont.add(lbpid);
lbpid.setForeground(new
Color(0,0,255));

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

53

Clinic Management System

lbpid.setFont(new Font("Courier
new",Font.BOLD,15));
txtpid=new JTextField(10);
gbc.gridx=1; gbc.gridy=0;
gbc.ipadx=10;
grid.setConstraints(txtpid,gbc);
txtpid.setEnabled(false);
cont.add(txtpid);
txtpid.setForeground(new
Color(0,0,0));
txtpid.setFont(new Font("Courier
new",Font.BOLD,15));
txtpid.setBackground(new
Color(255,175,175));
JLabel lbcat=new JLabel("Reg. Category");
gbc.gridx=0; gbc.gridy=1;
gbc.ipadx=10;
grid.setConstraints(lbcat,gbc);
cont.add(lbcat);
lbcat.setForeground(new
Color(0,0,255));
lbcat.setFont(new Font("Courier
new",Font.BOLD,15));
txtrc=new JTextField(10);
gbc.gridx=1; gbc.gridy=1;
grid.setConstraints(txtrc,gbc);
cont.add(txtrc);
txtrc.setForeground(new
Color(0,0,0));
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

54

Clinic Management System

txtrc.setFont(new Font("Courier
new",Font.BOLD,15));
txtrc.setBackground(new
Color(255,175,175));
JLabel lbpt=new JLabel("Patient Type");
gbc.gridx=0; gbc.gridy=2;
gbc.ipadx=10;
gbc.insets=new Insets(10,20,0,0);
grid.setConstraints(lbpt,gbc);
cont.add(lbpt);
lbpt.setForeground(new
Color(0,0,255));
lbpt.setFont(new Font("Courier
new",Font.BOLD,15));
txtpt=new JTextField(10);
gbc.gridx=1; gbc.gridy=2;
grid.setConstraints(txtpt,gbc);
cont.add(txtpt);
txtpt.setForeground(new
Color(0,0,0));
txtpt.setFont(new Font("Courier
new",Font.BOLD,15));
txtpt.setBackground(new
Color(255,175,175));
JLabel lbdep=new JLabel("Department");
gbc.gridx=0; gbc.gridy=3;
gbc.ipadx=10;
grid.setConstraints(lbdep,gbc);
cont.add(lbdep);

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

55

Clinic Management System

lbdep.setForeground(new
Color(0,0,255));
lbdep.setFont(new Font("Courier
new",Font.BOLD,15));
txtdept=new JTextField(10);
gbc.gridx=1; gbc.gridy=3;
grid.setConstraints(txtdept,gbc);
cont.add(txtdept);
txtdept.setForeground(new Color(0,0,0));
txtdept.setFont(new Font("Courier
new",Font.BOLD,15));
txtdept.setBackground(new
Color(255,175,175));
JLabel lbcid=new
JLabel("Consultant ID");

gbc.gridx=0; gbc.gridy=4;
grid.setConstraints(lbcid,gbc);
cont.add(lbcid);
lbcid.setForeground(new Color(0,0,255));
lbcid.setFont(new Font("Courier
new",Font.BOLD,15));
cmbcid=new JComboBox();
gbc.gridx=1; gbc.gridy=4;
gbc.ipadx=50;gbc.ipady=-0;
grid.setConstraints(cmbcid,gbc);
cont.add(cmbcid);
cmbcid.setForeground(new Color(0,0,0));
cmbcid.setFont(new Font("Courier
new",Font.BOLD,15));
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

56

Clinic Management System

cmbcid.setBackground(new
Color(255,175,175));
JLabel lbfn=new JLabel("First Name");
gbc.gridx=0; gbc.gridy=5;
gbc.ipadx=10;gbc.ipady=5;
grid.setConstraints(lbfn,gbc);
cont.add(lbfn);
lbfn.setForeground(new Color(0,0,255));
lbfn.setFont(new Font("Courier
new",Font.BOLD,15));
txtfname=new JTextField(10);
gbc.gridx=1; gbc.gridy=5;
grid.setConstraints(txtfname,gbc);
cont.add(txtfname);
txfname.setForeground(new Color(0,0,0));
txtfname.setFont(new Font("Courier
new",Font.BOLD,15));
txtfname.setBackground(new
Color(255,175,175));
JLabel lbmn=new JLabel("Middle Name");
gbc.gridx=0; gbc.gridy=6;
gbc.ipadx=10;
grid.setConstraints(lbmn,gbc);
cont.add(lbmn);
lbmn.setForeground(new Color(0,0,255));
lbmn.setFont(new Font("Courier
new",Font.BOLD,15));
txtmname=new JTextField(10);
gbc.gridx=1; gbc.gridy=6;
grid.setConstraints(txtmname,gbc);
cont.add(txtmname);
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

57

Clinic Management System

txtmname.setForeground(new Color(0,0,0));
txtmname.setFont(new Font("Courier
new",Font.BOLD,15));
txtmname.setBackground(new
Color(255,175,175));
JLabel lbln=new JLabel("Last Name");
gbc.gridx=0; gbc.gridy=7;
gbc.ipadx=10;
grid.setConstraints(lbln,gbc);
cont.add(lbln);
lbln.setForeground(new Color(0,0,255));
lbln.setFont(new Font("Courier
new",Font.BOLD,15));
txtlname=new JTextField(10);
gbc.gridx=1; gbc.gridy=7;
grid.setConstraints(txtlname,gbc);
cont.add(txtlname);
txtlname.setForeground(new Color(0,0,0));
txtlname.setFont(new Font("Courier
new",Font.BOLD,15));
txtlname.setBackground(new
Color(255,175,175));
JLabel lbdate=new JLabel("Date");
gbc.gridx=2; gbc.gridy=0;
gbc.ipadx=10;
grid.setConstraints(lbdate,gbc);
cont.add(lbdate);
lbdate.setForeground(new Color(0,0,255));
lbdate.setFont(new Font("Courier
new",Font.BOLD,15));
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

58

Clinic Management System

txtdate=new JTextField(10);
gbc.gridx=3; gbc.gridy=0;
txtdate.setEnabled(false);
txtdate.setBackground(Color.blue);
grid.setConstraints(txtdate,gbc);
cont.add(txtdate);
txtdate.setForeground(new Color(0,0,0));
txtdate.setFont(new Font("Courier
new",Font.BOLD,15));
txtdate.setBackground(new
Color(255,175,175));
JLabel lbdob=new JLabel("D.O.B.");
gbc.gridx=2; gbc.gridy=1;
gbc.ipadx=10;
grid.setConstraints(lbdob,gbc);
cont.add(lbdob);
lbdob.setForeground(new Color(0,0,255));
lbdob.setFont(new Font("Courier
new",Font.BOLD,15));
txtdob=new JTextField(10);
gbc.gridx=3; gbc.gridy=1;
grid.setConstraints(txtdob,gbc);
cont.add(txtdob);
txtdob.setForeground(new Color(0,0,0));
txtdob.setFont(new Font("Courier
new",Font.BOLD,15));
txtdob.setBackground(new
Color(255,175,175));
JLabel lbgen=new JLabel("Gender");
gbc.gridx=2; gbc.gridy=2;
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

59

Clinic Management System

gbc.ipadx=10;
grid.setConstraints(lbgen,gbc);
cont.add(lbgen);
lbgen.setForeground(new Color(0,0,255));
lbgen.setFont(new Font("Courier
new",Font.BOLD,15));
cmbgender=new JComboBox(gender);
gbc.gridx=3; gbc.gridy=2;
gbc.ipadx=54;gbc.ipady=0;
grid.setConstraints(cmbgender,gbc);
cont.add(cmbgender);
cmbgender.setForeground(new Color(0,0,0));
cmbgender.setFont(new Font("Courier
new",Font.BOLD,15));
cmbgender.setBackground(new
Color(255,175,175));
JLabel lbms=new JLabel("Marital Status");
gbc.gridx=2; gbc.gridy=3;
gbc.ipadx=10;gbc.ipady=5;
grid.setConstraints(lbms,gbc);
cont.add(lbms);
lbms.setForeground(new Color(0,0,255));
lbms.setFont(new Font("Courier
new",Font.BOLD,15));
cmbms=new JComboBox(ms);
gbc.gridx=3; gbc.gridy=3;
gbc.ipadx=40;gbc.ipady=0;
grid.setConstraints(cmbms,gbc);
cont.add(cmbms);
cmbms.setForeground(new Color(0,0,0));
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

60

Clinic Management System

cmbms.setFont(new Font("Courier
new",Font.BOLD,15));
cmbms.setBackground(new Color(255,175,175));
JLabel lbocc=new JLabel("Occupation");
gbc.gridx=2; gbc.gridy=4;
gbc.ipadx=10;gbc.ipady=5;
grid.setConstraints(lbocc,gbc);
cont.add(lbocc);
lbocc.setForeground(new Color(0,0,255));
lbocc.setFont(new Font("Courier new",Font.BOLD,15));
txtocc=new JTextField(10);
gbc.gridx=3; gbc.gridy=4;
grid.setConstraints(txtocc,gbc);
cont.add(txtocc);
txtocc.setForeground(new Color(0,0,0));
txtocc.setFont(new Font("Courier new",Font.BOLD,15));
txtocc.setBackground(new Color(255,175,175));

JLabel lbadd=new JLabel("Address");


gbc.gridx=2; gbc.gridy=5;
gbc.ipadx=10;
grid.setConstraints(lbadd,gbc);
cont.add(lbadd);
lbadd.setForeground(new Color(0,0,255));
lbadd.setFont(new Font("Courier
new",Font.BOLD,15));
txtadd=new JTextField(10);
gbc.gridx=3; gbc.gridy=5;
grid.setConstraints(txtadd,gbc);
cont.add(txtadd);
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

61

Clinic Management System

txtadd.setForeground(new Color(0,0,0));
txtadd.setFont(new Font("Courier
new",Font.BOLD,15));
txtadd.setBackground(new Color(255,175,175));
JLabel lbmob=new JLabel("Mobile");
gbc.gridx=2; gbc.gridy=6;
gbc.ipadx=10;
grid.setConstraints(lbmob,gbc);
cont.add(lbmob);
lbmob.setForeground(new Color(0,0,255));
lbmob.setFont(new Font("Courier
new",Font.BOLD,15));
txtmob=new JTextField(10);
gbc.gridx=3; gbc.gridy=6;
grid.setConstraints(txtmob,gbc);
cont.add(txtmob);
txtmob.setForeground(new Color(0,0,0));
txtmob.setFont(new Font("Courier
new",Font.BOLD,15));
txtmob.setBackground(new Color(255,175,175));
JLabel lbrem=new JLabel("Remarks");
gbc.gridx=2; gbc.gridy=7;
gbc.ipadx=10;
grid.setConstraints(lbrem,gbc);
cont.add(lbrem);
lbrem.setForeground(new Color(0,0,255));
lbrem.setFont(new Font("Courier
new",Font.BOLD,15));
txtrem=new JTextField(10);
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

62

Clinic Management System

gbc.gridx=3; gbc.gridy=7;
grid.setConstraints(txtrem,gbc);
cont.add(txtrem);
txtrem.setForeground(new Color(0,0,0));
txtrem.setFont(new Font("Courier
new",Font.BOLD,15));
txtrem.setBackground(new Color(255,175,175));
btAdd=new JButton("Add");
gbc.gridx=0; gbc.gridy=9;
gbc.ipadx=29;gbc.ipady=0;
gbc.insets=new
Insets(15,35,0,0);
grid.setConstraints(btAdd,gbc);
cont.add(btAdd);
btClear=new
JButton("Clear");
gbc.gridx=1;gbc.gridy=9;
gbc.ipadx=24;
gbc.insets=new Insets(15,10,0,0);
grid.setConstraints(btClear,gbc);
cont.add(btClear);
btSearch=new
JButton("Search");
gbc.gridx=2;gbc.gridy=9;
gbc.ipadx=9;
gbc.insets=new Insets(15,37,0,0);
grid.setConstraints(btSearch,gbc);
cont.add(btSearch);
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

63

Clinic Management System

btEdit=new JButton("Edit");
gbc.gridx=3;gbc.gridy=9;
gbc.ipadx=29;
gbc.insets=new Insets(15,-53,0,0);

grid.setConstraints(btEdit,gbc);
cont.add(btEdit);
btDelete=new
JButton("Delete");
gbc.gridx=3;gbc.gridy=9;
gbc.ipadx=19;
gbc.insets=new
Insets(15,40,0,0);
grid.setConstraints(btDelete,gbc);
cont.add(btDelete);

frm.addWindowListener(this);
frm.pack();
frm.setSize(600,465);
frm.setLocation(100,60);
frm.setVisible(true);
frm.setResizable(false);
frm.show();
txtmob.addKeyListener(this);
btAdd.addActionListener(new
ActionListener ()
{

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

64

Clinic Management System

public void
onPerformed(ActionEvent ae)
{
add();
}
});
btClear.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
clear();
}
});
btSearch.addActionListener(new ActionListener
()

{
public void actionPerformed(ActionEvent
ae)
{
search();
}
});
btDelete.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
delete();
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

65

Clinic Management System

}
});
btEdit.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
edit();
}
});
}
public void loadConsultant()
{
String str="select Consultant_ID from Consultant order by
Consultant_ID";
conn.connect();
try{

conn.st=conn.con.createStatement();
conn.rs=conn.st.executeQuery(str);
while(conn.rs.next())
{
String item=conn.rs.getString(1);
cmbcid.addItem(item);
}
}catch(Exception e){}
}
public boolean check()
{
conn.setRequire(txtrc,"Registration Category");
conn.setRequire(txtpt,"Patient Type");
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

66

Clinic Management System

if(conn.rsCount("select * from Consultant")==0)


{
JOptionPane.showMessageDialog(null,"There is no Consultant
!");
return false;
}
else
return true;
}
public void add()
{
generateID();
if(check())
{
String id=txtpid.getText();
String rc=txtrc.getText();
String pt=txtpt.getText();
String date=txtdate.getText();
String dept=txtdept.getText();
Object cid=cmbcid.getSelectedItem();
String fn=txtfname.getText();
String mn=txtmname.getText();
String ln=txtlname.getText();
String dob=txtdob.getText();
String occ=txtocc.getText();
String rem=txtrem.getText();
String add=txtadd.getText();
String mob=txtmob.getText();
int gender=cmbgender.getSelectedIndex();
if(gender==0)
sex="M";
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

67

Clinic Management System

else
sex="F";
int ms=cmbms.getSelectedIndex();
if(ms==0)
mstatus="M";
else
mstatus="U";
conn.connect();
try{
pst=conn.con.prepareStatement("insert
into Registration values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
pst.setString(1,id);
pst.setString(2,rc);
pst.setString(3,pt);
pst.setString(4,date);
pst.setString(5,dept);
pst.setObject(6,cid);
pst.setString(7,fn);
pst.setString(8,mn);
pst.setString(9,ln);
pst.setString(10,dob);
pst.setString(11,sex);
pst.setString(12,mstatus);
pst.setString(13,occ);
pst.setString(14,rem);
pst.setString(15,add);
pst.setString(16,mob);
pst.executeUpdate();
JOptionPane.showMessageDialog(null,"Record Added !\nThe Patient
ID is "+id);
clear();
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

68

Clinic Management System

}catch(Exception e){System.out.println(e.getMessage());}
}
}
public void delete()
{
String str=txtpid.getText();
String sp="delete from Registration where
Patient_ID='"+str+"'";
try
{
conn.connect();
conn.st=conn.con.createStatement();
if(found)
{
int
d=JOptionPane.showConfirmDialog(null,"Are you sure to
delete ?\n"+str);
if(d==0)
{
conn.st.executeUpdate(sp);
clear();
}
}
}
catch (Exception e)
}
public void clear()
{
txtpid.setText("");
txtrc.setText("");
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

69

Clinic Management System

txtpt.setText("");
txtdate.setText("");
txtdept.setText("");
txtfname.setText("");
txtmname.setText("");
txtlname.setText("");
txtdob.setText("");
txtocc.setText("");
txtrem.setText("");
txtadd.setText("");
txtdob.setText("");
txtmob.setText("");
cmbcid.setSelectedIndex(0);
cmbgender.setSelectedIndex(0);
cmbms.setSelectedIndex(0);
found=false;
}
public void edit()
{
String id=txtpid.getText();
String rc=txtrc.getText();
String pt=txtpt.getText();
String date=txtdate.getText();
String dept=txtdept.getText();
Object cid=cmbcid.getSelectedItem();
String fn=txtfname.getText();
String mn=txtmname.getText();
String ln=txtlname.getText();
String dob=txtdob.getText();
String occ=txtocc.getText();
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

70

Clinic Management System

String rem=txtrem.getText();
String add=txtadd.getText();
String mob=txtmob.getText();
int gender=cmbgender.getSelectedIndex();
if(gender==0)
sex="M";
else
sex="F";
int ms=cmbms.getSelectedIndex();
if(ms==0)
mstatus="M";
else
mstatus="U";
try{
conn.connect();
pst=conn.con.prepareStatement("Update
Registration set
Patient_ID=?,Reg_Category=?,Patient_Type=?,Reg_Dt=?,Dept=?,C
onsultant_ID=?,FName=?,MName=?,LName=?,DOB=?,Gender=?,M
arital_Status=?,Occupation=?,Remarks=?,Address=?,Mobile_No=?
where Patient_Id='"+id+"'");
pst.setString(1,id);
pst.setString(2,rc);
pst.setString(3,pt);
pst.setString(4,date);
pst.setString(5,dept);
pst.setObject(6,cid);
pst.setString(7,fn);
pst.setString(8,mn);
pst.setString(9,ln);
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

71

Clinic Management System

pst.setString(10,dob);
pst.setString(11,sex);
pst.setString(12,mstatus);
pst.setString(13,occ);
pst.setString(14,rem);
pst.setString(15,add);
pst.setString(16,mob);
pst.executeUpdate();
JOptionPane.showMessageDialog(null,"Updated !");
clear();
}catch(Exception e)
{System.out.println(e.getMessage());}
}
public void generateID()
{
txtdate.setText(conn.sysDate());
try{
conn.connect();

conn.st=conn.con.createStatement(ResultSet.TYPE_SCROLL_SENSI
TIVE,ResultSet.CONCUR_UPDATABLE);

conn.rs=conn.st.executeQuery("select
Patient_Id from Registration where Reg_Dt='"+conn.sysDate()+"'");
int row=0;
while(conn.rs.next())
{row++;}
if(row!=0)
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

72

Clinic Management System

{ conn.rs.last();
String id=conn.rs.getString(1);
String pid=id.substring(6,8);
int n=Integer.parseInt(pid);
n++;
if(String.valueOf(n).length()<2)
id=0+String.valueOf(n);
else
id=String.valueOf(n);
String
i=conn.sysDate().substring(3,5)+conn.sysDate().substring(0,2)+co
nn.sysDate().substring(6,8)+id;
txtpid.setText(i);
conn.rs.beforeFirst();
}
Else

txtpid.setText(conn.sysDate().substring(3,5)+conn.sysDate().substr
ing(0,2)+conn.sysDate().substring(6,8)+"01");
}catch(Exception e){}
}
public void search()
{
String input=JOptionPane.showInputDialog("Enter the Pataient
ID").toUpperCase();
ResultSet rst=conn.getResult("select * from
Registration where Patient_Id='"+input+"'");
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

73

Clinic Management System

try{
rst.first();
txtpid.setText(rst.getString(1));
txtrc.setText(rst.getString(2));
txtpt.setText(rst.getString(3));
txtdate.setText(rst.getString(4).substring(0,10));
txtdept.setText(rst.getString(5));
String cid=rst.getString(6);
txtfname.setText(rst.getString(7));
txtmname.setText(rst.getString(8));
txtlname.setText(rst.getString(9));
txtdob.setText(rst.getString(10).substring(0,10));
String gen=rst.getString(11);
String ms=rst.getString(12);
txtocc.setText(rst.getString(13));
txtrem.setText(rst.getString(14));
txtadd.setText(rst.getString(15));
txtmob.setText(rst.getString(16));
if(gen.equals("M"))
cmbgender.setSelectedIndex(0);
else
cmbgender.setSelectedIndex(1);
if(ms.equals("M"))
cmbms.setSelectedIndex(0);
else
cmbms.setSelectedIndex(1);
loadConsultant();

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

74

Clinic Management System

for(int
i=0;i<=cmbcid.getItemCount();i++)
{
String
cm=cmbcid.getItemAt(i).toString();
if(cid.equals(cm))
{
cmbcid.setSelectedIndex(i);
break;
}
}
txtdept.select(0,0);
txtadd.select(0,0);
txtrem.select(0,0);
txtocc.select(0,0);
found=true;
}catch(Exception e)
{
JOptionPane.showMessageDialog(null,"Sorry !\nNo match
found !");
}
}
public void keyPressed(KeyEvent ke)
{
conn.shouldNumber(txtmob,ke);
}
public void keyReleased(KeyEvent ke){}
public void keyTyped(KeyEvent ke){}
public void windowOpened(WindowEvent we){}
public void windowClosed(WindowEvent we){}
public void windowIconified(WindowEvent we){}
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

75

Clinic Management System

public void windowDeiconified(WindowEvent we){}


public void windowActivated(WindowEvent we)
{

if(cmbcid.getItemCount()<1)
loadConsultant();

}
public void windowDeactivated(WindowEvent
we)
{

cmbcid.removeAllItems(); }

public void windowClosing(WindowEvent we){}


public static void main(String agrs[])
{
new Registration();
}
}

CONNECTING CLASS
import java.sql.*;
import java.util.Date;
import javax.swing.*;
import java.awt.event.*;
class Connecting
{
Connection con;
Statement st;
ResultSet rs;
boolean constate=false,text=false;
public Connecting()
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

76

Clinic Management System

{
}
public void connect()
{
Try
{
if(!constate)
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc: pawan
",pawan,pawan);
System.out.println("Connected");
constate=true;
}
}catch (Exception e){}
}
public int rsCount(String sql)
{
int m=0;
try{
connect();
st=con.createStatement();
rs=st.executeQuery(sql);
while(rs.next())
{ m++;}
}catch(Exception e){}
return m;
}
public String sysDate()
{
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

77

Clinic Management System

Date dt=new Date();


int day=dt.getDate();
int mon=dt.getMonth();
int y=dt.getYear();
mon++;
String m=String.valueOf(mon);
if(m.length()<2)
m=0+m;
String ye=String.valueOf(y);
ye=ye.substring(1,3);
String date=m+"-"+day+"-"+ye;
return(date);
}
public void shouldNumber(JTextField txt,KeyEvent ke)
{
int key=ke.getKeyCode();

boolean
textBox=ke.getComponent().equals(txt);
if(textBox)
{
if((key>57 || key<48) && (key>105 || key<96) && key!=8 && key!
=110)
{
txt.setText("");
text=true;
}
else
{
if(text)
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

78

Clinic Management System

{
txt.setText("");
text=false;
}
}
}
}
public void generateID(JTextField txt,String sql,String
startAs)
{
try{
connect();
st=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,Result
Set.CONCUR_UPDATABLE);
rs=st.executeQuery(sql);
int row=0;
while(rs.next())
{row++;}
if(row!=0)
{ rs.last();
String id=rs.getString(1);
String pid=id.substring(2,6);
int n=Integer.parseInt(pid);
n++;
if(String.valueOf(n).length()<2)
id="000"+String.valueOf(n);
else
if(String.valueOf(n).length()<3)
id="00"+String.valueOf(n);
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

79

Clinic Management System

else
if(String.valueOf(n).length()<4)
id="0"+String.valueOf(n);
else
id=String.valueOf(n);
String i=startAs+id;
txt.setText(i);
rs.beforeFirst();
}
else
txt.setText(startAs+"0001");
}catch(Exception e){}

}
public boolean setRequire(JTextField txt,String message)
{
if(txt.getText().equals(""))
{
JOptionPane.showMessageDialog(null,message+"
can't be blank !","Data
Required",JOptionPane.INFORMATION_MESSAGE);
return false;
}
else
return true;
}
public ResultSet getResult(String sql)
{
try{
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

80

Clinic Management System

connect();

st=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,Result
Set.CONCUR_UPDATABLE);
rs=st.executeQuery(sql);
}catch(Exception e)
{

JOptionPane.showMessageDialog(null,e.getMessage(),"Error",JOptio
nPane.ERROR_MESSAGE);
}
return rs;
}
public static void main(String agrs[])
{
Connecting c=new Connecting();
}
}
CONSULTANT CLASS
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import javax.swing.JOptionPane;
public class Consultant implements KeyListener
{
Connecting conn=new Connecting();

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

81

Clinic Management System

Consultant()
{
display();
}
PreparedStatement pst;
JButton btAdd,btClear,btEdit,btDelete,btSearch;
JTextField
txtcid,txtname,txtmrid,txtcn,txtct,txtmob,txtph,txtadd,txtemail,txtd
ob,txtdoj;
JFrame frm;
boolean found=false;
public void display()
{
frm=new JFrame("Consultant Details");
GridBagLayout grid=new GridBagLayout();
GridBagConstraints gbc=new
GridBagConstraints();

frm.setLayout(grid);
Container cont=frm.getContentPane();
gbc.anchor=GridBagConstraints.WEST;
JLabel lbcid=new JLabel("ID");
gbc.gridx=0; gbc.gridy=0;
gbc.ipadx=10;gbc.ipady=5;
gbc.insets=new Insets(10,20,0,0);
grid.setConstraints(lbcid,gbc);
cont.add(lbcid);
lbcid.setForeground(new Color(0,0,255));

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

82

Clinic Management System

lbcid.setFont(new Font("Courier
new",Font.BOLD,15));
txtcid=new JTextField(10);
gbc.gridx=1; gbc.gridy=0;
gbc.ipadx=10;
txtcid.setEnabled(false);
txtcid.setBackground(Color.BLUE);
grid.setConstraints(txtcid,gbc);
cont.add(txtcid);
txtcid.setForeground(new Color(0,0,0));
txtcid.setFont(new Font("Courier
new",Font.BOLD,15));
txtcid.setBackground(new Color(255,175,175));
JLabel lbname=new JLabel("Name");
gbc.gridx=0; gbc.gridy=1;
gbc.ipadx=10;
grid.setConstraints(lbname,gbc);
cont.add(lbname);
lbname.setForeground(new Color(0,0,255));
lbname.setFont(new Font("Courier
new",Font.BOLD,15));
txtname=new JTextField(10);
gbc.gridx=1; gbc.gridy=1;
grid.setConstraints(txtname,gbc);
cont.add(txtname);
xtname.setForeground(new Color(0,0,0));
txtname.setFont(new Font("Courier
new",Font.BOLD,15));

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

83

Clinic Management System

txtname.setBackground(new
Color(255,175,175));
JLabel lbmrid=new JLabel("MR ID");
gbc.gridx=0; gbc.gridy=2;
gbc.ipadx=10;
gbc.insets=new Insets(10,20,0,0);
grid.setConstraints(lbmrid,gbc);
cont.add(lbmrid);
lbmrid.setForeground(new Color(0,0,255));
lbmrid.setFont(new Font("Courier
new",Font.BOLD,15));
txtmrid=new JTextField(10);
gbc.gridx=1; gbc.gridy=2;
grid.setConstraints(txtmrid,gbc);
cont.add(txtmrid);
txtmrid.setForeground(new Color(0,0,0));
txtmrid.setFont(new Font("Courier
new",Font.BOLD,15));
txtmrid.setBackground(new
Color(255,175,175));
JLabel lbnature=new JLabel("Nature");
gbc.gridx=0; gbc.gridy=3;
gbc.ipadx=10;
grid.setConstraints(lbnature,gbc);
cont.add(lbnature);
lbnature.setForeground(new Color(0,0,255));
lbnature.setFont(new Font("Courier
new",Font.BOLD,15));
txtcn=new JTextField(10);
gbc.gridx=1; gbc.gridy=3;

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

84

Clinic Management System

grid.setConstraints(txtcn,gbc);
cont.add(txtcn);
txtcn.setForeground(new Color(0,0,0));
txtcn.setFont(new Font("Courier
new",Font.BOLD,15));
txtcn.setBackground(new Color(255,175,175));
JLabel lbtype=new JLabel("Type");
gbc.gridx=0; gbc.gridy=4;
gbc.ipadx=10;
grid.setConstraints(lbtype,gbc);
cont.add(lbtype);
lbtype.setForeground(new Color(0,0,255));
lbtype.setFont(new Font("Courier
new",Font.BOLD,15));
txtct=new JTextField(10);
gbc.gridx=1; gbc.gridy=4;
grid.setConstraints(txtct,gbc);
cont.add(txtct);
txtpid.setForeground(new Color(0,0,0));
txtct.setFont(new Font("Courier
new",Font.BOLD,15));

txtct.setBackground(new
Color(255,175,175));
JLabel lbmob=new JLabel("Mobile");
gbc.gridx=0; gbc.gridy=5;
gbc.ipadx=10;
grid.setConstraints(lbmob,gbc);
cont.add(lbmob);
lbmob.setForeground(new Color(0,0,255));
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

85

Clinic Management System

lbmob.setFont(new Font("Courier
new",Font.BOLD,15));
txtmob=new JTextField(10);
gbc.gridx=1; gbc.gridy=5;
grid.setConstraints(txtmob,gbc);
cont.add(txtmob);
txtmob.setForeground(new
Color(0,0,0));
txtmob.setFont(new Font("Courier
new",Font.BOLD,15));
txtmob.setBackground(new
Color(255,175,175));
JLabel lbph=new JLabel("Phone");
gbc.gridx=2; gbc.gridy=0;
gbc.ipadx=10;
grid.setConstraints(lbph,gbc);
cont.add(lbph);
lbph.setForeground(new Color(0,0,255));
lbph.setFont(new Font("Courier
new",Font.BOLD,15));
txtph=new JTextField(10);
gbc.gridx=3; gbc.gridy=0;
grid.setConstraints(txtph,gbc);
cont.add(txtph);
txtph.setForeground(new Color(0,0,0));
txtph.setFont(new Font("Courier
new",Font.BOLD,15));
txtph.setBackground(new Color(255,175,175));
JLabel lbadd=new JLabel("Address");
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

86

Clinic Management System

gbc.gridx=2; gbc.gridy=1;
gbc.ipadx=10;
grid.setConstraints(lbadd,gbc);
cont.add(lbadd);
lbadd.setForeground(new Color(0,0,255));
lbadd.setFont(new Font("Courier
new",Font.BOLD,15));
txtadd=new JTextField(10);
gbc.gridx=3; gbc.gridy=1;
grid.setConstraints(txtadd,gbc);
cont.add(txtadd);
txtadd.setForeground(new Color(0,0,0));
txtadd.setFont(new Font("Courier
new",Font.BOLD,15));
txtadd.setBackground(new Color(255,175,175));
JLabel lbemail=new JLabel("E-Mail");
gbc.gridx=2; gbc.gridy=2;
gbc.ipadx=10;
grid.setConstraints(lbemail,gbc);
cont.add(lbemail);
lbemail.setForeground(new Color(0,0,255));
lbemail.setFont(new Font("Courier
new",Font.BOLD,15));
txtemail=new JTextField(10);
gbc.gridx=3; gbc.gridy=2;
grid.setConstraints(txtemail,gbc);
cont.add(txtemail);
txtemail.setForeground(new Color(0,0,0));

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

87

Clinic Management System

txtemail.setFont(new Font("Courier
new",Font.BOLD,15));
txtemail.setBackground(new
Color(255,175,175));
JLabel lbdob=new JLabel("D.O.B.");
gbc.gridx=2; gbc.gridy=3;
gbc.ipadx=10;
grid.setConstraints(lbdob,gbc);
cont.add(lbdob);
lbdob.setForeground(new Color(0,0,255));
lbdob.setFont(new Font("Courier
new",Font.BOLD,15));
txtdob=new JTextField(10);
gbc.gridx=3; gbc.gridy=3;
grid.setConstraints(txtdob,gbc);
cont.add(txtdob);
txtdob.setForeground(new Color(0,0,0));
txtdob.setFont(new Font("Courier
new",Font.BOLD,15));
txtdob.setBackground(new Color(255,175,175));
JLabel lbdoj=new JLabel("D.O.J.");
gbc.gridx=2; gbc.gridy=4;
gbc.ipadx=10;
grid.setConstraints(lbdoj,gbc);
cont.add(lbdoj);
txtdoj=new JTextField(10);
gbc.gridx=3; gbc.gridy=4;
grid.setConstraints(txtdoj,gbc);
cont.add(txtdoj);
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

88

Clinic Management System

txtpid.setForeground(new Color(0,0,0));
txtdoj.setFont(new Font("Courier
new",Font.BOLD,15));
txtdoj.setBackground(new Color(255,175,175));
btAdd=new JButton("Add");
gbc.gridx=0; gbc.gridy=6;
gbc.ipadx=20;gbc.ipady=0;
gbc.insets=new
Insets(15,35,0,0);
grid.setConstraints(btAdd,gbc);
cont.add(btAdd);
btClear=new
JButton("Clear");
gbc.gridx=1;gbc.gridy=6;
gbc.ipadx=15;
gbc.insets=new Insets(15,10,0,0);
grid.setConstraints(btClear,gbc);
cont.add(btClear);
btSearch=new
JButton("Search");
gbc.gridx=2;gbc.gridy=6;
gbc.ipadx=0;
gbc.insets=new Insets(15,45,0,0);
grid.setConstraints(btSearch,gbc);
cont.add(btSearch);
btEdit=new JButton("Edit");
gbc.gridx=3;gbc.gridy=6;
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

89

Clinic Management System

gbc.ipadx=20;
gbc.insets=new Insets(15,-37,0,0);
grid.setConstraints(btEdit,gbc);
cont.add(btEdit);
btDelete=new
JButton("Delete");
gbc.gridx=3;gbc.gridy=6;
gbc.ipadx=10;
gbc.insets=new
Insets(15,50,0,0);
grid.setConstraints(btDelete,gbc);
cont.add(btDelete);

// ------------------Frame Properties--------------txtmob.addKeyListener(this);
frm.pack();
frm.setSize(500,370); //Size of window
frm.setLocation(160,110); //set the
window
frm.setVisible(true);
frm.setResizable(false);

//Resized the

window...
frm.show();
btAdd.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

90

Clinic Management System

add();
}
});
btClear.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
clear();
}
});
btSearch.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
search();
}
});
btDelete.addActionListener(new ActionListener ()
{

public void actionPerformed(ActionEvent


ae)
{
delete();
}
});
btEdit.addActionListener(new ActionListener
()
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

91

Clinic Management System

{
public void actionPerformed(ActionEvent
ae)
{
edit();
}
});
}
public void add()
{
txtdoj.setText(conn.sysDate());
conn.generateID(txtcid,"select Consultant_ID from
Consultant","CN");
boolean fill=conn.setRequire(txtname,"Name");
fill=conn.setRequire(txtmrid,"MR ID");
fill=conn.setRequire(txtcn,"Cosultant
Nature");
fill=conn.setRequire(txtct,"Cosultant Type");
if(fill)
{
String id=txtcid.getText();
String name=txtname.getText();
String mrid=txtmrid.getText();
String cn=txtcn.getText();
String ct=txtct.getText();
String mob=txtmob.getText();
String ph=txtph.getText();
String add=txtadd.getText();
String email=txtemail.getText();
String dob=txtdob.getText();
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

92

Clinic Management System

String doj=txtdoj.getText();
conn.connect();
try{
pst=conn.con.prepareStatement("insert
into Consultant values(?,?,?,?,?,?,?,?,?,?,?)");
pst.setString(1,id);
pst.setString(2,name);
pst.setString(3,mrid);
pst.setString(4,cn);
pst.setString(5,ct);
pst.setString(6,mob);
pst.setString(7,ph);
pst.setString(8,add);
pst.setString(9,email);
pst.setString(10,dob);
pst.setString(11,doj);
pst.executeUpdate();
JOptionPane.showMessageDialog(null,"Record Added !\nThe
Consultant ID is "+id);
clear();
}catch(Exception e)
{System.out.println(e.getMessage());}
}
}
public void delete()
{
String str=txtcid.getText();
String sp="delete from Consultant where
Consultant_ID='"+str+"'";
try
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

93

Clinic Management System

{
conn.connect();
conn.st=conn.con.createStatement();
if(found)
{
int
d=JOptionPane.showConfirmDialog(null,"Are you sure to
delete ?\n"+str);
if(d==0)
{
conn.st.executeUpdate(sp);
clear();
}
}
}
catch (Exception e)

}
public void edit()
{
String id=txtcid.getText();
String name=txtname.getText();
String mrid=txtmrid.getText();
String cn=txtcn.getText();
String ct=txtct.getText();
String mob=txtmob.getText();
String ph=txtph.getText();
String add=txtadd.getText();
String email=txtemail.getText();
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

94

Clinic Management System

String dob=txtdob.getText();
String doj=txtdoj.getText();
try{
conn.connect();
pst=conn.con.prepareStatement("Update
Consultant set
Consultant_ID=?,Consultant_Name=?,Medical_Reg_ID=?,Consultan
t_Nature=?,Consultant_Type=?,Mobile_No=?,Phone_No=?,Address
=?,Email=?,DOB=?,DOJ=? where Consultant_ID='"+id+"'");
pst.setString(1,id);
pst.setString(2,name);
pst.setString(3,mrid);
pst.setString(4,cn);
pst.setString(5,ct);
pst.setString(6,mob);
pst.setString(7,ph);
pst.setString(8,add);
pst.setString(9,email);
pst.setString(10,dob);
pst.setString(11,doj);
pst.executeUpdate();

JOptionPane.showMessageDialog(null,"Updated !");
}catch(Exception e)
{System.out.println(e.getMessage());}
}
public void search()
{
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

95

Clinic Management System

String input=JOptionPane.showInputDialog("Enter
the Cosultant ID").toUpperCase();
ResultSet rst=conn.getResult("select * from Consultant where
Consultant_ID='"+input+"'");
try{
rst.first();
txtcid.setText(rst.getString(1));
txtname.setText(rst.getString(2));
txtmrid.setText(rst.getString(3));
txtcn.setText(rst.getString(4));
txtct.setText(rst.getString(5));
txtmob.setText(rst.getString(6));
txtph.setText(rst.getString(7));
txtadd.setText(rst.getString(8));
txtadd.select(0,0);
txtemail.setText(rst.getString(9));
txtemail.select(0,0);
txtdob.setText(rst.getString(10).substring(0,10));

txtdoj.setText(rst.getString(11).substring(0,10));
txtname.select(0,0);
found=true;
}catch(Exception e)
{
JOptionPane.showMessageDialog(null,"Sorry !\nNo match
found !");
}
}
public void keyPressed(KeyEvent ke)
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

96

Clinic Management System

{
conn.shouldNumber(txtmob,ke);
}
public void keyReleased(KeyEvent ke){}
public void keyTyped(KeyEvent ke){}
public static void main(String agrs[])
{
new Consultant();
}
}

ADMINSTARATOR

CLASS

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class Administrator implements ActionListener
{
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

97

Clinic Management System

Connecting conn=new Connecting();


JFrame frm;
JLabel logname,password;
Container con;
JButton blogin,bcancel,bclear,welcome;
JTextField txtlogname;
JPasswordField passwordfield;
JPanel panel;
JTabbedPane tpan;
String log="admin",pass="welcome";
Administrator()
{
displayLogin();
}
public void displayLogin()
{
GridBagLayout grid=new GridBagLayout();
GridBagConstraints gbc=new
GridBagConstraints();
frm=new JFrame("Administrtor Login Required");
frm.setLayout(grid);
con=frm.getContentPane();
logname=new JLabel("User Name");
gbc.ipadx=10;
gbc.ipady=5;
gbc.insets=new Insets(15,0,0,0);
gbc.gridx=0;
gbc.gridy=0;
grid.setConstraints(logname,gbc);
con.add(logname);
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

98

Clinic Management System

logname.setForeground(new Color(0,0,255));
logname.setFont(new Font("Courier
new",Font.BOLD,15));
txtlogname=new JTextField(12);
gbc.gridx=1;
gbc.gridy=0;
grid.setConstraints(txtlogname,gbc);
con.add(txtlogname);
txtlogname.setForeground(new Color(0,0,0));
txtlogname.setFont(new Font("Courier
new",Font.BOLD,15));
txtlogname.setBackground(new
Color(255,175,175));
password=new JLabel("Password");
gbc.gridx=0;
gbc.gridy=1;
grid.setConstraints(password,gbc);
con.add(password);
password.setForeground(new Color(0,0,255));
password.setFont(new Font("Courier
new",Font.BOLD,15));
passwordfield=new JPasswordField(12);
gbc.gridx=1;
gbc.gridy=1;
grid.setConstraints(passwordfield,gbc);
con.add(passwordfield);
passwordfield.setForeground(new Color(0,0,0));
passwordfield.setFont(new Font("Courier
new",Font.BOLD,15));

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

99

Clinic Management System

passwordfield.setBackground(new
Color(255,175,175));
blogin=new JButton("Login");
gbc.gridx=0;gbc.gridy=2;
gbc.ipady=0;
gbc.insets=new Insets(20,15,0,10);
gbc.anchor=GridBagConstraints.WEST;
grid.setConstraints(blogin,gbc);
con.add(blogin);
bclear=new JButton("Clear");
gbc.gridx=1;gbc.gridy=2;
gbc.insets=new Insets(20,-5,0,0);
grid.setConstraints(bclear,gbc);
con.add(bclear);
bcancel=new JButton("Cancel");
gbc.gridx=2;gbc.gridy=2;
gbc.ipadx=0;
gbc.insets=new Insets(20,-73,0,0);
grid.setConstraints(bcancel,gbc);
con.add(bcancel);
//......................ActionListener
blogin.addActionListener(this);
bclear.addActionListener(this);
bcancel.addActionListener(this);
//.......................Frame
frm.setSize(300,200);
frm.setResizable(false);
frm.setLocation(250,190);
frm.setVisible(true);
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

100

Clinic Management System

frm.show();
}
public void clear()
{
txtlogname.setText("");
passwordfield.setText("");
}
public void cancel()
{
frm.dispose();
}
public void actionPerformed(ActionEvent ae)
{
String str=ae.getActionCommand();
if (str.equals("Login"))
{
login();
}
if (str.equals("Clear"))
{
clear();
}
if (str.equals("Cancel"))
{
cancel();
}
}
public void login()
{
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

101

Clinic Management System

String userName=txtlogname.getText();
String password=passwordfield.getText();
if(userName.equals(log)&&
password.equals(pass))
{
JOptionPane.showMessageDialog(null,"Welcome !\n"+"
Sir");
frm.dispose();
new User();
}
else
JOptionPane.showMessageDialog(null,"Sorry ! \nInvalid User Name
Or Password");
}
public static void main(String args[])
{
new Administrator();
}
}

Adv_Rec_Det CLASS
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import javax.swing.JOptionPane;
public class Adv_Rec_Det implements
WindowListener,KeyListener
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

102

Clinic Management System

{
Connecting conn=new Connecting();
Adv_Rec_Det()
{
display();
}
JLabel lbcode,lbname,lbccode;
JComboBox cmbbno,cmbsid;
JTextField txtqty;
JFrame frm;
PreparedStatement pst;
JButton btAdd,btClear,btEdit,btDelete,btSearch;
boolean found=false;
public void display()
{
frm=new JFrame("Advace Receipt Deails");
GridBagLayout grid=new GridBagLayout();
GridBagConstraints gbc=new
GridBagConstraints();
frm.setLayout(grid);
Container cont=frm.getContentPane();
gbc.anchor=GridBagConstraints.WEST;
lbcode=new JLabel("Bill NO");
gbc.gridx=0; gbc.gridy=0;
gbc.ipadx=10;gbc.ipady=0;
gbc.insets=new Insets(10,-30,0,0);
grid.setConstraints(lbcode,gbc);
cont.add(lbcode);
lbcode.setForeground(new Color(0,0,255));
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

103

Clinic Management System

lbcode.setFont(new Font("Courier new",Font.BOLD,15));


cmbbno=new JComboBox();
gbc.gridx=1; gbc.gridy=0;
gbc.ipadx=32;
grid.setConstraints(cmbbno,gbc);
cont.add(cmbbno);
cmbbno.setForeground(new Color(0,0,0));
cmbbno.setFont(new Font("Courier new",Font.BOLD,15));
cmbbno.setBackground(new Color(255,175,175));
lbname=new JLabel("Service ID");
gbc.gridx=0; gbc.gridy=1;
gbc.ipadx=38;gbc.ipady=0;
grid.setConstraints(lbname,gbc);
cont.add(lbname);
lbname.setForeground(new Color(0,0,255));
lbname.setFont(new Font("Courier
new",Font.BOLD,15));
cmbsid=new JComboBox();
gbc.gridx=1; gbc.gridy=1;
grid.setConstraints(cmbsid,gbc);
cont.add(cmbsid);
cmbsid.setForeground(new Color(0,0,0));
cmbsid.setFont(new Font("Courier
new",Font.BOLD,15));
cmbsid.setBackground(new Color(255,175,175));
lbccode=new JLabel("Quantity");
gbc.gridx=0; gbc.gridy=2;
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

104

Clinic Management System

gbc.ipadx=0;gbc.ipady=0;
grid.setConstraints(lbccode,gbc);
cont.add(lbccode);
lbccode.setForeground(new Color(0,0,255));
lbccode.setFont(new Font("Courier
new",Font.BOLD,15));
txtqty=new JTextField();
gbc.gridx=1; gbc.gridy=2;
gbc.ipadx=80; gbc.ipady=5;
grid.setConstraints(txtqty,gbc);
cont.add(txtqty);
txtqty.setForeground(new Color(0,0,0));
txtqty.setFont(new Font("Courier
new",Font.BOLD,15));
txtqty.setBackground(new Color(255,175,175));

btAdd=new JButton("Add");
gbc.gridx=0; gbc.gridy=3;
gbc.ipadx=20;gbc.ipady=0;
gbc.insets=new Insets(10,-30,0,0);
grid.setConstraints(btAdd,gbc);
cont.add(btAdd);
btClear=new JButton("Clear");
gbc.gridx=1;gbc.gridy=3;
gbc.ipadx=15;
gbc.insets=new Insets(10,-33,0,0);
grid.setConstraints(btClear,gbc);
cont.add(btClear);
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

105

Clinic Management System

btSearch=new JButton("Search");
gbc.gridx=2;gbc.gridy=3;
gbc.ipadx=0;
gbc.insets=new Insets(10,-35,0,0);
grid.setConstraints(btSearch,gbc);
cont.add(btSearch);
btEdit=new JButton("Edit");
gbc.gridx=0;gbc.gridy=4;
gbc.ipadx=20;
gbc.insets=new Insets(2,5,0,0);
grid.setConstraints(btEdit,gbc);
cont.add(btEdit);
btDelete=new JButton("Delete");
gbc.gridx=1;gbc.gridy=4;
gbc.ipadx=10;
gbc.insets=new Insets(2,2,0,0);
grid.setConstraints(btDelete,gbc);
cont.add(btDelete);
txtqty.addKeyListener(this);
//------------Frame Properties---------frm.addWindowListener(this);
frm.pack();
frm.setSize(300,250); //Size of window
frm.setLocation(250,150); //set the window
frm.setVisible(true);
frm.setResizable(false);
frm.show();
btAdd.addActionListener(new ActionListener ()
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

106

Clinic Management System

{
public void actionPerformed(ActionEvent
ae)
{
add();
clear();
}
});
btClear.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
clear();
}
});
btSearch.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)

{
search();
}
});
btDelete.addActionListener(new ActionListener ()
{
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

107

Clinic Management System

public void actionPerformed(ActionEvent


ae)
{
delete();
}
});
btEdit.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
edit();
}
});
}
public void loadBill()
{
String str="select Bill_No from Advance_Receipt order by Bill_No";
conn.connect();
try{
conn.st=conn.con.createStatement();
conn.rs=conn.st.executeQuery(str);
while(conn.rs.next())
{
String item=conn.rs.getString(1);
cmbbno.addItem(item);
}
}catch(Exception e){}

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

108

Clinic Management System

}
public void loadService()
{
String str="select Service_ID from Service_Master order by
Service_ID";
conn.connect();
try{
conn.st=conn.con.createStatement();
conn.rs=conn.st.executeQuery(str);
while(conn.rs.next())
{
String item=conn.rs.getString(1);
cmbsid.addItem(item);
}
}catch(Exception e){}
}
public void add()
{
Object bno=cmbbno.getSelectedItem();
Object sid=cmbsid.getSelectedItem();
String qty=txtqty.getText();
boolean fill=conn.setRequire(txtqty,"Quantity");
if(fill)
{
conn.connect();
try{

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

109

Clinic Management System

pst=conn.con.prepareStatement("insert into
Advance_Receipt_Details values(?,?,?)");
pst.setObject(1,bno);
pst.setObject(2,sid);
pst.setString(3,qty);
pst.executeUpdate();
JOptionPane.showMessageDialog(null,"Record
Added !");
clear();
System.out.println("Record Added");
}catch(Exception e){}
}
}
public void clear()
{
cmbbno.setSelectedIndex(0);
cmbsid.setSelectedIndex(0);
txtqty.setText("");
found=false;
}
public void delete()
{
Object str=cmbbno.getSelectedItem();

String sp="delete from Advance_Receipt_Details where


Bill_No='"+str+"'";
try
{
conn.connect();
conn.st=conn.con.createStatement();

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

110

Clinic Management System

if(found)
{
int
d=JOptionPane.showConfirmDialog(null,"Are you sure to delete ?");
if(d==0)
{
conn.st.executeUpdate(sp);
clear();
}
}
}
catch (Exception e)

}
public void edit()
{
Object bno=cmbbno.getSelectedItem();
Object sid=cmbsid.getSelectedItem();
String qty=txtqty.getText();
try{
conn.connect();

pst=conn.con.prepareStatement("Update
Advance_Receipt_Details set Bill_No=?,Service_ID=?,Qty=? where
Bill_No='"+bno+"'");
pst.setObject(1,bno);
pst.setObject(2,sid);
pst.setString(3,qty);
pst.executeUpdate();
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

111

Clinic Management System

JOptionPane.showMessageDialog(null,"Updated !");
}catch(Exception e){}
}
public void search()
{
String
input=JOptionPane.showInputDialog("Enter the Bill
Numner").toUpperCase();
ResultSet rst=conn.getResult("select * from
Advance_Receipt_Details where Bill_No='"+input+"'");
try{
rst.first();
String bno=rst.getString(1);
String sid=rst.getString(2);
txtqty.setText(rst.getString(3));
loadBill();
loadService();
for(int i=0;i<=20;i++)
{

String
cm=cmbbno.getItemAt(i).toString();
if(bno.equals(cm))
{
cmbbno.setSelectedIndex(i);
break;
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

112

Clinic Management System

}
}
for(int i=0;i<=20;i++)
{
String cm=cmbsid.getItemAt(i).toString();
if(sid.equals(cm))
{
cmbsid.setSelectedIndex(i);
break;
}
}
found=true;
}catch(Exception e)
{
JOptionPane.showMessageDialog(null,"Sorry !\nNo match
found !");
}
}
public static void main(String agrs[])
{
new Adv_Rec_Det();
}
}

APPOINTMENT

CLASS

import javax.swing.InputVerifier;
import javax.swing.JComponent;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

113

Clinic Management System

import javax.swing.JOptionPane;
import javax.swing.text.JTextComponent;
public class Appointment implements WindowListener
{
Connecting conn=new Connecting();
Appointment()
{
display();
}
PreparedStatement pst;
JButton btAdd,btClear,btEdit,btDelete,btSearch;
JTextField txtaid,txtadt;
JComboBox cmbstatus,cmbpid,cmbcid;
JFrame frm;
String active[]={"P","C","X"};
boolean found=false;
public void display()
{
frm=new JFrame("Appointment...");
GridBagLayout grid=new GridBagLayout();
GridBagConstraints gbc=new
GridBagConstraints();
frm.setLayout(grid);
Container cont=frm.getContentPane();
gbc.anchor=GridBagConstraints.WEST;
JLabel lbbcid=new JLabel("Appointment
ID");
gbc.gridx=0; gbc.gridy=0;
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

114

Clinic Management System

gbc.ipadx=10;gbc.ipady=5;
gbc.insets=new Insets(10,20,0,0);
grid.setConstraints(lbbcid,gbc);
cont.add(lbbcid);
lbbcid.setForeground(new Color(0,0,255));
lbbcid.setFont(new Font("Courier
new",Font.BOLD,15));
txtaid=new JTextField(10);
gbc.gridx=1; gbc.gridy=0;
gbc.ipadx=10;
gbc.insets=new Insets(10,-10,0,0);
grid.setConstraints(txtaid,gbc);
cont.add(txtaid);
txtaid.setForeground(new Color(0,0,0));
txtaid.setFont(new Font("Courier
new",Font.BOLD,15));
txtaid.setBackground(new Color(255,175,175));
JLabel lbdes=new JLabel("Patient ID");
gbc.gridx=0; gbc.gridy=1;
gbc.ipadx=10;
gbc.insets=new Insets(10,20,0,0);
grid.setConstraints(lbdes,gbc);
cont.add(lbdes);
lbdes.setForeground(new Color(0,0,255));
lbdes.setFont(new Font("Courier
new",Font.BOLD,15));
cmbpid=new JComboBox();
gbc.gridx=1; gbc.gridy=1;
gbc.ipadx=38; gbc.ipady=0;
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

115

Clinic Management System

gbc.insets=new Insets(10,-10,0,0);
grid.setConstraints(cmbpid,gbc);
cont.add(cmbpid);
cmbpid.setForeground(new Color(0,0,0));
cmbpid.setFont(new Font("Courier
new",Font.BOLD,15));
cmbpid.setBackground(new Color(255,175,175));
gbc.ipadx=53;
gbc.insets=new Insets(10,20,0,0);
JLabel lbdis=new JLabel("Consultant ID");
gbc.gridx=0; gbc.gridy=2;
gbc.insets=new Insets(10,20,0,0);
grid.setConstraints(lbdis,gbc);
cont.add(lbdis);
lbpid.setForeground(new Color(0,0,255));
lbpid.setFont(new Font("Courier
new",Font.BOLD,15));
cmbcid=new JComboBox();
gbc.gridx=1; gbc.gridy=2;
gbc.ipadx=50; gbc.ipady=0;
gbc.insets=new Insets(10,-10,0,0);
grid.setConstraints(cmbcid,gbc);
cont.add(cmbcid);
cmbcid.setForeground(new Color(0,0,0));
cmbcid.setFont(new Font("Courier
new",Font.BOLD,15));
cmbcid.setBackground(new Color(255,175,175));
JLabel lbefdate=new JLabel("Date &
Time");
gbc.gridx=0; gbc.gridy=3;
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

116

Clinic Management System

gbc.ipadx=10;
gbc.insets=new Insets(10,20,0,0);
grid.setConstraints(lbefdate,gbc);
cont.add(lbefdate);
lbefdate.setForeground(new Color(0,0,255));
cmbcid.setFont(new Font("Courier
new",Font.BOLD,15));
txtadt=new JTextField(10);
gbc.gridx=1; gbc.gridy=3;
gbc.ipady=5;
gbc.insets=new Insets(10,-10,0,0);
grid.setConstraints(txtadt,gbc);
cont.add(txtadt);
txtadt.setForeground(new Color(0,0,0));
txtadt.setFont(new Font("Courier
new",Font.BOLD,15));
txtadt.setBackground(new Color(255,175,175));
JLabel lbact=new JLabel("Status");
gbc.gridx=0; gbc.gridy=4;
gbc.ipadx=10;
gbc.insets=new Insets(10,20,0,0);
grid.setConstraints(lbact,gbc);
cont.add(lbact);
lbact.setForeground(new Color(0,0,255));
lbact.setFont(new Font("Courier
new",Font.BOLD,15));
cmbstatus=new JComboBox(active);
gbc.gridx=1; gbc.gridy=4;
gbc.ipadx=0;gbc.ipady=-3;
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

117

Clinic Management System

gbc.insets=new Insets(10,-10,0,0);
grid.setConstraints(cmbstatus,gbc);
cont.add(cmbstatus);
cmbstatus.setForeground(new Color(0,0,0));
cmbstatus.setFont(new Font("Courier
new",Font.BOLD,15));
cmbstatus.setBackground(new
Color(255,175,175));
btAdd=new JButton("Add");
gbc.gridx=0; gbc.gridy=6;
gbc.ipadx=20;gbc.ipady=0;
gbc.insets=new
Insets(10,15,0,0);
grid.setConstraints(btAdd,gbc);
cont.add(btAdd);
btClear=new
JButton("Clear");
gbc.gridx=1;gbc.gridy=6;
gbc.ipadx=15;
gbc.insets=new Insets(10,-50,0,0);
grid.setConstraints(btClear,gbc);
cont.add(btClear);
btSearch=new
JButton("Search");
gbc.gridx=2;gbc.gridy=6;
gbc.ipadx=0;
gbc.insets=new Insets(10,78,0,0);

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

118

Clinic Management System

grid.setConstraints(btSearch,gbc);
cont.add(btSearch);
btEdit=new JButton("Edit");
gbc.gridx=0;gbc.gridy=7;
gbc.ipadx=20;
gbc.insets=new Insets(10,15,0,0);
grid.setConstraints(btEdit,gbc);
cont.add(btEdit);
btDelete=new
JButton("Delete");
gbc.gridx=1;gbc.gridy=7;
gbc.ipadx=10;
gbc.insets=new Insets(10,50,0,0);
grid.setConstraints(btDelete,gbc);
cont.add(btDelete);

// ------------------Frame Properties--------------frm.addWindowListener(this);
frm.pack();
frm.setSize(400,350); //Size of window
frm.setLocation(160,110); //set the
window
frm.setVisible(true);

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

119

Clinic Management System

frm.setResizable(false);
frm.show();
btAdd.addActionListener(new
ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
add();
}
});
btClear.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
clear();
}
});
btSearch.addActionListener(new ActionListener
()
{
public void actionPerformed(ActionEvent
ae)
{
search();
}
});
btDelete.addActionListener(new ActionListener ()
{
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

120

Clinic Management System

public void actionPerformed(ActionEvent


ae)
{
delete();
}
});
btEdit.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{

edit();

});
}
public void add()
{
conn.generateID(txtaid,"select Appointment_ID from
Appointment","AP");
String id=txtaid.getText();
Object pid=cmbpid.getSelectedItem();
Object cid=cmbcid.getSelectedItem();
String dt=txtadt.getText();
Object act=cmbstatus.getSelectedItem();
if(dt.equals(""))
JOptionPane.showMessageDialog(null,"Date Time can't be
blank !");
else
{
conn.connect();
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

121

Clinic Management System

try{
pst=conn.con.prepareStatement("insert into Appointment
values(?,?,?,?,?)");
pst.setString(1,id);
pst.setObject(2,pid);
pst.setObject(3,cid);
pst.setString(4,dt);
pst.setObject(5,act);
pst.executeUpdate();
System.out.println("Record Added");
clear();
}catch(Exception e){System.out.println(e.getMessage());}
}
}
public void delete()
{
String str=txtaid.getText();
String sp="delete from Appointment where
Appointment_ID='"+str+"'";
try
{
conn.connect();
conn.st=conn.con.createStatement();
if(found)
{
int
d=JOptionPane.showConfirmDialog(null,"Are you sure to delete ?");
if(d==0)
{
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

122

Clinic Management System

conn.st.executeUpdate(sp);
clear();
}
}
}
catch (Exception e)

}
public void edit()
{
String id=txtaid.getText();
Object pid=cmbpid.getSelectedItem();
Object cid=cmbcid.getSelectedItem();
String dt=txtadt.getText();
Object act=cmbstatus.getSelectedItem();
try{
conn.connect();
pst=conn.con.prepareStatement("Update
Appointment set
Appointment_ID=?,Patient_ID=?,Consultant_ID=?,Appt_Date_Time
=?,Status=? where Appointment_ID='"+id+"'");
pst.setString(1,id);
pst.setObject(2,pid);
pst.setObject(3,cid);
pst.setString(4,dt);
pst.setObject(5,act);
pst.executeUpdate();
JOptionPane.showMessageDialog(null,"Updated !");
clear();
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

123

Clinic Management System

}catch(Exception e)
{System.out.println(e.getMessage());}
}
public void search()
{
String input=JOptionPane.showInputDialog("Enter
the Appointment ID").toUpperCase();
ResultSet rst=conn.getResult("select * from
Appointment where Appointment_ID='"+input+"'");
try{
rst.first();
txtaid.setText(rst.getString(1));
String s=rst.getString(2);
String ps=rst.getString(3);
txtadt.setText(rst.getString(4).substring(0,10));
String act=rst.getString(5);
if(act.equals("P"))
cmbstatus.setSelectedIndex(0);
else if(act.equals("C"))
cmbstatus.setSelectedIndex(1);
else
cmbstatus.setSelectedIndex(2);
loadPatient();
loadConsultant();
for(int i=0;i<=cmbpid.getItemCount();i+
+)
{
String cm=cmbpid.getItemAt(i).toString();
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

124

Clinic Management System

if(s.equals(cm))
{
cmbpid.setSelectedIndex(i);
break;
}
}
for(int i=0;i<=cmbcid.getItemCount();i++)
{
String cm=cmbcid.getItemAt(i).toString();
if(ps.equals(cm))
{
cmbcid.setSelectedIndex(i);
break;
}
}
found=true;
}catch(Exception e)
{
JOptionPane.showMessageDialog(null,"Sorry !\nNo match
found !");
}
}}

public static void main(String agrs[])

{
new Appointment();
}
}
BILLING CLASS
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

125

Clinic Management System

import javax.swing.JOptionPane;
public class Billing implements KeyListener
{
Connecting conn=new Connecting();
Billing()
{
display();
}
PreparedStatement pst;
JButton btAdd,btClear,btEdit,btDelete,btSearch;
JTextField txtbcid,txtdes,txtdis,txtefdate,txtetdate;
JComboBox cmbact;
JFrame frm;
String active[]={"Y","N"};
boolean found=false;
public void display()
{
frm=new JFrame("Billing...");
GridBagLayout grid=new GridBagLayout();
GridBagConstraints gbc=new GridBagConstraints();
frm.setLayout(grid);
Container cont=frm.getContentPane();
gbc.anchor=GridBagConstraints.WEST;
JLabel lbbcid=new JLabel("Billing ID");
gbc.gridx=0; gbc.gridy=0;
gbc.ipadx=10;gbc.ipady=5;
gbc.insets=new Insets(10,20,0,0);
grid.setConstraints(lbbcid,gbc);
cont.add(lbbcid);
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

126

Clinic Management System

lbbcid.setForeground(new Color(0,0,255));
lbbcid.setFont(new Font("Courier
new",Font.BOLD,15));
txtbcid=new JTextField(10);
gbc.gridx=1; gbc.gridy=0;
gbc.ipadx=10;
grid.setConstraints(txtbcid,gbc);
cont.add(txtbcid);
txtbcid.setEnabled(false);
txtbcid.setForeground(new
Color(0,0,0));
txtbcid.setFont(new Font("Courier
new",Font.BOLD,15));
txtbcid.setBackground(new
Color(255,175,175));
JLabel lbdes=new JLabel("Description");
gbc.gridx=0; gbc.gridy=1;
gbc.ipadx=10;
grid.setConstraints(lbdes,gbc);
cont.add(lbdes);
lbdes.setForeground(new Color(0,0,255));
lbdes.setFont(new Font("Courier
new",Font.BOLD,15));
txtdes=new JTextField(10);
gbc.gridx=1; gbc.gridy=1;
grid.setConstraints(txtdes,gbc);
cont.add(txtdes);
txtdes.setForeground(new Color(0,0,0));

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

127

Clinic Management System

txtdes.setFont(new Font("Courier
new",Font.BOLD,15));
txtdes.setBackground(new Color(255,175,175));
gbc.insets=new Insets(10,20,0,0);
JLabel lbdis=new JLabel("Discount(%)");
gbc.gridx=0; gbc.gridy=2;
gbc.ipadx=10;
grid.setConstraints(lbdis,gbc);
cont.add(lbdis);
lbdis.setForeground(new Color(0,0,255));
lbdis.setFont(new Font("Courier new",Font.BOLD,15));
txtdis=new JTextField(10);
gbc.gridx=1; gbc.gridy=2;
grid.setConstraints(txtdis,gbc);
cont.add(txtdis);
JLabel lbefdate=new JLabel("Effective From");
gbc.gridx=0; gbc.gridy=3;
gbc.ipadx=10;
grid.setConstraints(lbefdate,gbc);
cont.add(lbefdate);
lbefdate.setForeground(new Color(0,0,255));
lbefdate.setFont(new Font("Courier
new",Font.BOLD,15));
txtefdate=new JTextField(10);
gbc.gridx=1; gbc.gridy=3;
grid.setConstraints(txtefdate,gbc);
cont.add(txtefdate);
txtefdate.setForeground(new Color(0,0,0));
txtefdate.setFont(new Font("Courier
new",Font.BOLD,15));
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

128

Clinic Management System

txtefdate.setBackground(new
Color(255,175,175));
JLabel lbetdate=new JLabel("Effective To");
gbc.gridx=0; gbc.gridy=4;
gbc.ipadx=10;
grid.setConstraints(lbetdate,gbc);
cont.add(lbetdate);
lbetdate.setForeground(new Color(0,0,255));
lbetdate.setFont(new Font("Courier
new",Font.BOLD,15));
txtetdate=new JTextField(10);
gbc.gridx=1; gbc.gridy=4;
grid.setConstraints(txtetdate,gbc);
cont.add(txtetdate);
txtetdate.setForeground(new Color(0,0,0));
txtetdate.setFont(new Font("Courier
new",Font.BOLD,15));
txtetdate.setBackground(new
Color(255,175,175));
JLabel lbact=new JLabel("Active");
gbc.gridx=0; gbc.gridy=5;
gbc.ipadx=10;
grid.setConstraints(lbact,gbc);
cont.add(lbact);
lbact.setForeground(new Color(0,0,255));
lbact.setFont(new Font("Courier
new",Font.BOLD,15));
cmbact=new JComboBox(active);
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

129

Clinic Management System

gbc.gridx=1; gbc.gridy=5;
gbc.ipadx=0;gbc.ipady=-3;
grid.setConstraints(cmbact,gbc);
cont.add(cmbact);
btAdd=new JButton("Add");
gbc.gridx=0; gbc.gridy=6;
gbc.ipadx=20;gbc.ipady=0;
gbc.insets=new
Insets(10,15,0,0);
grid.setConstraints(btAdd,gbc);
cont.add(btAdd);
btClear=new
JButton("Clear");
gbc.gridx=1;gbc.gridy=6;
gbc.ipadx=15;
gbc.insets=new Insets(10,0,0,0);
grid.setConstraints(btClear,gbc);
cont.add(btClear);
btSearch=new
JButton("Search");
gbc.gridx=2;gbc.gridy=6;
gbc.ipadx=0;
gbc.insets=new Insets(10,45,0,0);

grid.setConstraints(btSearch,gbc);
cont.add(btSearch);
btEdit=new JButton("Edit");
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

130

Clinic Management System

gbc.gridx=0;gbc.gridy=7;
gbc.ipadx=20;
gbc.insets=new Insets(10,15,0,0);
grid.setConstraints(btEdit,gbc);
cont.add(btEdit);
btDelete=new
JButton("Delete");
gbc.gridx=1;gbc.gridy=7;
gbc.ipadx=10;
gbc.insets=new
Insets(10,0,0,0);
grid.setConstraints(btDelete,gbc);
cont.add(btDelete);
// ------------------Frame Properties--------------txtdis.addKeyListener(this);
frm.pack();
frm.setSize(400,350); //Size of window
frm.setLocation(160,110); //set the window
frm.setVisible(true);
frm.setResizable(false);
frm.show();
btAdd.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
add();
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

131

Clinic Management System

}
});
btClear.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
clear();
}
});
btSearch.addActionListener(new ActionListener
()
{
public void actionPerformed(ActionEvent ae)
{
search();
}
});
btDelete.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
delete();
}
});
btEdit.addActionListener(new ActionListener ()
{

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

132

Clinic Management System

public void actionPerformed(ActionEvent


ae)
{
edit();
}
});
}
public void add()
{
conn.generateID(txtbcid,"select ID from Billing_Class","BL");
String id=txtbcid.getText();
String des=txtdes.getText();
String dis=txtdis.getText();
String ef=txtefdate.getText();
String et=txtetdate.getText();
Object act=cmbact.getSelectedItem();
if(dis.equals(""))
dis="0";
boolean
fill=conn.setRequire(txtdes,"Description");
if(fill)
{
conn.connect();
try{
pst=conn.con.prepareStatement("insert into Billing_Class
values(?,?,?,?,?,?)");
pst.setString(1,id);
pst.setString(2,des);
pst.setString(3,dis);
pst.setString(4,ef);
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

133

Clinic Management System

pst.setString(5,et);
pst.setObject(6,act);
pst.executeUpdate();
JOptionPane.showMessageDialog(null,"Record Added !\nThe Billing
ID is "+id);
System.out.println("Record Added");
clear();
}catch(Exception e)
{System.out.println(e.getMessage());}
}
}
public void delete()
{
String str=txtbcid.getText();
String sp="delete from Billing_Class where
ID='"+str+"'";
try
{
conn.connect();
conn.st=conn.con.createStatement();
if(found)
{
int
d=JOptionPane.showConfirmDialog(null,"Are you sure to
delete ?\n"+str);
if(d==0)
{
conn.st.executeUpdate(sp);
clear();
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

134

Clinic Management System

}
}
}
catch (Exception e)

}
public void clear()
{
txtbcid.setText("");
txtdes.setText("");
txtdis.setText("");
txtefdate.setText("");
txtetdate.setText("");
cmbact.setSelectedIndex(0);
found=false;
}
public void edit()
{
String id=txtbcid.getText();
String des=txtdes.getText();
String dis=txtdis.getText();
String ef=txtefdate.getText();
String et=txtetdate.getText();
Object act=cmbact.getSelectedItem();
try{
conn.connect();
pst=conn.con.prepareStatement("Update Billing_Class
set
ID=?,Description=?,Discount_Percentage=?,Effective_From=?,Effec
tive_To=?,Active=? where ID='"+id+"'");
pst.setString(1,id);
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

135

Clinic Management System

pst.setString(2,des);
pst.setString(3,dis);
pst.setString(4,ef);
pst.setString(5,et);
pst.setObject(6,act);
pst.executeUpdate();
JOptionPane.showMessageDialog(null,id+"\nUpdated !");
}catch(Exception e)
{System.out.println(e.getMessage());}
}
public void search()
{
String
input=JOptionPane.showInputDialog("Enter the Billing
ID").toUpperCase();
ResultSet rst=conn.getResult("select * from
Billing_Class where ID='"+input+"'");
try{
rst.first();
txtbcid.setText(rst.getString(1));
txtdes.setText(rst.getString(2));
txtdes.select(0,0);
txtdis.setText(rst.getString(3));
txtefdate.setText(rst.getString(4).substring(0,10));

txtetdate.setText(rst.getString(5).substring(0,10));
String act=rst.getString(6);
if(act.equals("Y"))
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

136

Clinic Management System

cmbact.setSelectedIndex(0);
else
cmbact.setSelectedIndex(1);
found=true;
}catch(Exception e)
{
JOptionPane.showMessageDialog(null,"Sorry !\nNo match
found !");
}
}
public void keyPressed(KeyEvent ke)
{
conn.shouldNumber(txtdis,ke);
}
public void keyReleased(KeyEvent ke){}
public void keyTyped(KeyEvent ke){}
public static void main(String agrs[])
{
new Billing();
}
}

CREDIT MASTER CLASS


import java.awt.*;
import java.awt.event.*;
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

137

Clinic Management System

import java.sql.*;
import javax.swing.*;
import javax.swing.JOptionPane;
public class CrMaster
{
Connecting conn=new Connecting();
CrMaster()
{
display();
}
JLabel lbCode,lbName;
JTextField txtCode,txtDes;
PreparedStatement pst;
JFrame frm;
JButton btAdd,btClear,btEdit,btDelete,btSearch;
boolean found=false;
public void display()
{
frm=new JFrame("Credit Card");
GridBagLayout grid=new GridBagLayout();
GridBagConstraints gbc=new GridBagConstraints();
frm.setLayout(grid);
Container cont=frm.getContentPane();
gbc.anchor=GridBagConstraints.WEST;
lbCode=new JLabel("Code");
gbc.gridx=0; gbc.gridy=0;
gbc.ipadx=10;gbc.ipady=5;
gbc.insets=new Insets(10,20,0,0);
grid.setConstraints(lbCode,gbc);
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

138

Clinic Management System

cont.add(lbCode);
lbcode.setForeground(new Color(0,0,255));
lbcode.setFont(new Font("Courier
new",Font.BOLD,15));
txtCode=new JTextField(10);
gbc.gridx=1; gbc.gridy=0;
gbc.ipadx=-20;
txtCode.setEnabled(false);
txtCode.setBackground(Color.BLUE);
grid.setConstraints(txtCode,gbc);
cont.add(txtCode);
txtcode.setForeground(new Color(0,0,0));
txtcode.setFont(new Font("Courier
new",Font.BOLD,15));
txtcode.setBackground(new Color(255,175,175));
lbName=new JLabel("Description");
gbc.gridx=0; gbc.gridy=1;
gbc.ipadx=10;
grid.setConstraints(lbName,gbc);
cont.add(lbName);
lbName.setForeground(new Color(0,0,255));
lbName.setFont(new Font("Courier
new",Font.BOLD,15));
txtDes=new JTextField(10);

gbc.gridx=1; gbc.gridy=1;
grid.setConstraints(txtDes,gbc);
cont.add(txtDes);
txtDes.setForeground(new Color(0,0,0));
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

139

Clinic Management System

txtDes.setFont(new Font("Courier
new",Font.BOLD,15));
txtDes.setBackground(new Color(255,175,175));
btAdd=new JButton("Add");
gbc.gridx=0; gbc.gridy=2;
gbc.ipadx=20;gbc.ipady=0;
gbc.insets=new Insets(10,15,0,0);
grid.setConstraints(btAdd,gbc);
cont.add(btAdd);
btClear=new JButton("Clear");
gbc.gridx=1;gbc.gridy=2;
gbc.ipadx=15;
gbc.insets=new Insets(10,8,0,0);
grid.setConstraints(btClear,gbc);
cont.add(btClear);
btSearch=new JButton("Search");
gbc.gridx=2;gbc.gridy=2;
gbc.ipadx=0;
gbc.insets=new Insets(10,-45,0,0);
grid.setConstraints(btSearch,gbc);
cont.add(btSearch);
btEdit=new JButton("Edit");
gbc.gridx=0;gbc.gridy=3;
gbc.ipadx=20;
gbc.insets=new Insets(10,15,0,0);
grid.setConstraints(btEdit,gbc);
cont.add(btEdit);
btDelete=new JButton("Delete");
gbc.gridx=1;gbc.gridy=3;
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

140

Clinic Management System

gbc.ipadx=10;
gbc.insets=new Insets(10,8,0,0);
grid.setConstraints(btDelete,gbc);
cont.add(btDelete);
//------------Frame Properties---------frm.pack();
frm.setSize(350,250); //Size of window
frm.setLocation(160,110); //set the window
frm.setVisible(true);
frm.setResizable(false);

//Resized the window...

frm.show();
//---------Button Add Event Handler-------btAdd.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent ae)
{
add();
}
});
btClear.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent ae)
{
clear();

}
});
btSearch.addActionListener(new ActionListener ()
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

141

Clinic Management System

{
public void actionPerformed(ActionEvent ae)
{
search();
}
});
btDelete.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
delete();
}
});
btEdit.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
edit();
}
});
}
public void add()
{
conn.generateID(txtCode,"select Code from
CreditCard_Master","CC");
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

142

Clinic Management System

String code=txtCode.getText();
String name=txtDes.getText();
boolean fill=conn.setRequire(txtDes,"Description");
if(fill)
{
conn.connect();
try{
pst=conn.con.prepareStatement("insert into
CreditCard_Master values(?,?)");
pst.setString(1,code.toUpperCase());
pst.setString(2,name.toUpperCase());
pst.executeUpdate();
JOptionPane.showMessageDialog(null,"Record
Added !");
clear();
System.out.println("Record Added");
}catch(Exception e){}
}
}
public void clear()
{
txtCode.setText("");
txtDes.setText("");
found=false;
}
public void delete()
{
String str=txtCode.getText();
String sp="delete from CreditCard_Master where
Code='"+str+"'";
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

143

Clinic Management System

Try
{
conn.connect();
conn.st=conn.con.createStatement();
if(found)
{
int
d=JOptionPane.showConfirmDialog(null,"Are you sure to
delete ?\n"+str);
if(d==0)
{
conn.st.executeUpdate(sp);
clear();
}
}
}
catch (Exception e)

}
public void edit()
{
String code=txtCode.getText();
String name=txtDes.getText();
try{
conn.connect();
pst=conn.con.prepareStatement("Update
CreditCard_Master set Code=?,Description=? where
Code='"+code+"'");
pst.setString(1,code.toUpperCase());
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

144

Clinic Management System

pst.setString(2,name.toUpperCase());
pst.executeUpdate();
JOptionPane.showMessageDialog(null,"Updated !");
clear();
}catch(Exception e){}
}
public void search()
{
String input=JOptionPane.showInputDialog("Enter the
Code").toUpperCase();
ResultSet rst=conn.getResult("select *
from CreditCard_Master where Code='"+input+"'");
try{
rst.first();
txtCode.setText(rst.getString(1));
txtDes.setText(rst.getString(2));
txtDes.select(0,0);
found=true;
}catch(Exception e)
{

JOptionPane.showMessageDialog(null,"Sorry !\nNo match


found !");
}

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

145

Clinic Management System

}
public static void main(String agrs[])
{
CrMaster c=new CrMaster();
}
}

DRUG CLASS
import java.awt.*;
import java.awt.event.*;
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

146

Clinic Management System

import javax.swing.*;
import java.sql.*;
import javax.swing.JOptionPane;
public class Drug_Master implements KeyListener
{
Connecting conn=new Connecting();
Drug_Master()
{
display();
}
PreparedStatement pst;
JButton btAdd,btClear,btEdit,btDelete,btSearch;
JTextField
txtcode,txtname,txtcn,txtuom,txtstock,txtman,txtex,txtshape;
JFrame frm;
boolean found=false;
public void display()
{
frm=new JFrame("Drug Master...");
GridBagLayout grid=new GridBagLayout();
GridBagConstraints gbc=new GridBagConstraints();
frm.setLayout(grid);
Container cont=frm.getContentPane();
gbc.anchor=GridBagConstraints.WEST;
JLabel lbbcid=new JLabel("Code");
gbc.gridx=0; gbc.gridy=0;
gbc.ipadx=10;gbc.ipady=5;
gbc.insets=new Insets(10,20,0,0);
grid.setConstraints(lbbcid,gbc);
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

147

Clinic Management System

cont.add(lbbcid);
lbbcid.setForeground(new Color(0,0,255));
lbbcid.setFont(new Font("Courier
new",Font.BOLD,15));
txtcode=new JTextField(10);
gbc.gridx=1; gbc.gridy=0;
gbc.ipadx=10;
txtcode.setEnabled(false);
txtcode.setBackground(Color.BLUE);
grid.setConstraints(txtcode,gbc);
cont.add(txtcode);
txtcode.setForeground(new Color(0,0,0));
txtcode.setFont(new Font("Courier
new",Font.BOLD,15));
txtcode.setBackground(new
Color(255,175,175));
JLabel lbdes=new JLabel("Name");
gbc.gridx=0; gbc.gridy=1;
gbc.ipadx=10;
grid.setConstraints(lbdes,gbc);
cont.add(lbdes);
lbdes.setForeground(new Color(0,0,255));
lbdes.setFont(new Font("Courier
new",Font.BOLD,15));
txtname=new JTextField(10);
gbc.gridx=1; gbc.gridy=1;
grid.setConstraints(txtname,gbc);
cont.add(txtname);
txtname.setForeground(new Color(0,0,0));

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

148

Clinic Management System

txtname.setFont(new Font("Courier
new",Font.BOLD,15));
txtname.setBackground(new
Color(255,175,175));
gbc.insets=new Insets(10,20,0,0);
JLabel lbtype=new JLabel("Company
Name");
gbc.gridx=0; gbc.gridy=2;
gbc.ipadx=10;
grid.setConstraints(lbtype,gbc);
cont.add(lbtype);
lbtype.setForeground(new Color(0,0,255));
lbtype.setFont(new Font("Courier
new",Font.BOLD,15));
txtcn=new JTextField(10);
gbc.gridx=1; gbc.gridy=2;
grid.setConstraints(txtcn,gbc);
cont.add(txtcn);
txtcn.setForeground(new Color(0,0,0));
txtcn.setFont(new Font("Courier new",Font.BOLD,15));
txtcn.setBackground(new Color(255,175,175));
JLabel lbact=new JLabel("Unit of
Measure");
gbc.gridx=0; gbc.gridy=3;
gbc.ipadx=10;
grid.setConstraints(lbact,gbc);
cont.add(lbact);
lbact.setForeground(new Color(0,0,255));
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

149

Clinic Management System

lbact.setFont(new Font("Courier
new",Font.BOLD,15));
txtuom=new JTextField(10);
gbc.gridx=1; gbc.gridy=3;
gbc.ipady=5;
grid.setConstraints(txtuom,gbc);
cont.add(txtuom);
txtuom.setForeground(new Color(0,0,0));
txtuom.setFont(new Font("Courier
new",Font.BOLD,15));
txtuom.setBackground(new Color(255,175,175));
JLabel lbrate=new JLabel("Stock");
gbc.gridx=2; gbc.gridy=0;
gbc.ipadx=10;gbc.ipady=5;
grid.setConstraints(lbrate,gbc);
cont.add(lbrate);
lbrate.setForeground(new Color(0,0,255));
lbrate.setFont(new Font("Courier new",Font.BOLD,15));
txtstock=new JTextField(10);
gbc.gridx=3; gbc.gridy=0;
grid.setConstraints(txtstock,gbc);
cont.add(txtstock);
txtstock.setForeground(new Color(0,0,0));
txtstock.setFont(new Font("Courier
new",Font.BOLD,15));
txtstock.setBackground(new Color(255,175,175));
JLabel lbma=new JLabel("Manufacture Date");
gbc.gridx=2; gbc.gridy=1;
gbc.ipadx=10;
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

150

Clinic Management System

grid.setConstraints(lbma,gbc);
cont.add(lbma);
lbma.setForeground(new Color(0,0,255));
lbma.setFont(new Font("Courier
new",Font.BOLD,15));
txtman=new JTextField(10);
gbc.gridx=3; gbc.gridy=1;
gbc.ipadx=10;gbc.ipady=5;
grid.setConstraints(txtman,gbc);
cont.add(txtman);
txtman.setForeground(new Color(0,0,0));
txtman.setFont(new Font("Courier
new",Font.BOLD,15));
txtman.setBackground(new Color(255,175,175));
JLabel lbefdate=new JLabel("Expiry Date");
gbc.gridx=2; gbc.gridy=2;
gbc.ipadx=10;
grid.setConstraints(lbefdate,gbc);
cont.add(lbefdate);
lbefdate.setForeground(new Color(0,0,255));
lbefdate.setFont(new Font("Courier
new",Font.BOLD,15));
txtex=new JTextField(10);
gbc.gridx=3; gbc.gridy=2;
gbc.ipadx=10;gbc.ipady=5;
grid.setConstraints(txtex,gbc);
cont.add(txtex);
txtex.setForeground(new Color(0,0,0));
txtex.setFont(new Font("Courier
new",Font.BOLD,15));
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

151

Clinic Management System

txtex.setBackground(new Color(255,175,175));
JLabel lbetdate=new JLabel("Shape");
gbc.gridx=2; gbc.gridy=3;
gbc.ipadx=10;
grid.setConstraints(lbetdate,gbc);
cont.add(lbetdate);
lbetdate.setForeground(new Color(0,0,255));
lbetdate.setFont(new Font("Courier
new",Font.BOLD,15));
btAdd=new JButton("Add");
gbc.gridx=0; gbc.gridy=6;
gbc.ipadx=20;gbc.ipady=0;
gbc.insets=new
Insets(25,35,0,0);
grid.setConstraints(btAdd,gbc);
cont.add(btAdd);
btClear=new
JButton("Clear");
gbc.gridx=1;gbc.gridy=6;
gbc.ipadx=15;
gbc.insets=new Insets(25,10,0,0);
cont.add(btClear);
btSearch=new
JButton("Search");
gbc.gridx=2;gbc.gridy=6;
gbc.ipadx=0;
gbc.insets=new Insets(25,37,0,0);

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

152

Clinic Management System

grid.setConstraints(btSearch,gbc);
cont.add(btSearch);
btEdit=new JButton("Edit");
gbc.gridx=3;gbc.gridy=6;
gbc.ipadx=25;
gbc.insets=new Insets(25,-74,0,0);
grid.setConstraints(btEdit,gbc);
cont.add(btEdit);
btDelete=new
JButton("Delete");
gbc.gridx=3;gbc.gridy=6;
gbc.ipadx=10;
gbc.insets=new
Insets(25,24,0,0);
grid.setConstraints(btDelete,gbc);
cont.add(btDelete);
txtstock.addKeyListener(this);
// ------------------Frame Properties--------------frm.pack();
frm.setSize(550,300); //Size of window
frm.setLocation(160,110); //set the
window
frm.setVisible(true);
frm.setResizable(false);
frm.show();
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

153

Clinic Management System

btAdd.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
add();
}
});
btClear.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
clear();
}
});
btSearch.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
frm.dispose();
conn.connect();
searchDrug sc=new
searchDrug();
sc.search();
}
});
btDelete.addActionListener(new ActionListener ()
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

154

Clinic Management System

{
public void actionPerformed(ActionEvent
ae)
{
delete();
}
});
btEdit.addActionListener(new ActionListener
()
{
public void actionPerformed(ActionEvent
ae)
{
edit();
}
});
}
public void add()
{
conn.generateID(txtcode,"select Code from
Drug_Master","DR");
String id=txtcode.getText();
String name=txtname.getText();
String cn=txtcn.getText();
String uom=txtuom.getText();
String stock=txtstock.getText();
String md=txtman.getText();
String ed=txtex.getText();
String shape=txtshape.getText();
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

155

Clinic Management System

conn.connect();
try{
pst=conn.con.prepareStatement("insert
into Drug_Master values(?,?,?,?,?,?,?,?)");
pst.setString(1,id);
pst.setString(2,name);
pst.setString(3,cn);
pst.setObject(4,uom);
pst.setString(5,stock);
pst.setString(6,md);
pst.setString(7,ed);
pst.setString(8,shape);
pst.executeUpdate();
System.out.println("Record Added");
}catch(Exception e)
{System.out.println(e.getMessage());}
}
public void delete()
{
String str=txtcode.getText();
String sp="delete from Drug_Master where
Code='"+str+"'";
try
{
conn.connect();
conn.st=conn.con.createStatement();
if(found)
{

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

156

Clinic Management System

int
d=JOptionPane.showConfirmDialog(null,"Are you sure to delete ?");
if(d==0)
{
conn.st.executeUpdate(sp);
clear();
}
}
}
catch (Exception e)

}
public void edit()
{
String id=txtcode.getText();
String name=txtname.getText();
String cn=txtcn.getText();
String uom=txtuom.getText();
String stock=txtstock.getText();
String md=txtman.getText();
String ed=txtex.getText();
String shape=txtshape.getText();
try{
conn.connect();

pst=conn.con.prepareStatement("Update
Drug_Master set

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

157

Clinic Management System

Code=?,Name=?,Company_Name=?,Unit_of_Measure=?,Stock_on_
Hand=?,Manufacture_Dt=?,Expiry_Dt=?,Shape=? where
Code='"+id+"'");
pst.setString(1,id);
pst.setString(2,name);
pst.setString(3,cn);
pst.setObject(4,uom);
pst.setString(5,stock);
pst.setString(6,md);
pst.setString(7,ed);
pst.setString(8,shape);
pst.executeUpdate();
JOptionPane.showMessageDialog(null,"Updated !");
}catch(Exception e){System.out.println(e.getMessage());}
}
public void keyPressed(KeyEvent ke)
{
conn.shouldNumber(txtstock,ke);
}
public void keyReleased(KeyEvent ke){}
public void keyTyped(KeyEvent ke){}
public static void main(String agrs[])
{
new Drug_Master();
}
}

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

158

Clinic Management System

GENERIC CLASS
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import javax.swing.JOptionPane;
public class Generic_Master implements KeyListener
{
Connecting conn=new Connecting();
Generic_Master()
{
display();
}
PreparedStatement pst;
JButton btAdd,btClear,btEdit,btDelete,btSearch;
JTextField txtcode,txtname,txtcn,txtuom,txtstock;
JFrame frm;
boolean found=false;
public void display()
{
frm=new JFrame("Generic Master...");
GridBagLayout grid=new GridBagLayout();
GridBagConstraints gbc=new
GridBagConstraints();
frm.setLayout(grid);
Container cont=frm.getContentPane();
gbc.anchor=GridBagConstraints.WEST;
JLabel lbbcid=new JLabel("Code");
gbc.gridx=0; gbc.gridy=0;

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

159

Clinic Management System

gbc.ipadx=10;gbc.ipady=5;
gbc.insets=new Insets(10,20,0,0);
grid.setConstraints(lbbcid,gbc);
cont.add(lbbcid);
txtcode=new JTextField(10);
gbc.gridx=1; gbc.gridy=0;
gbc.ipadx=10;
txtcode.setEnabled(false);
txtcode.setBackground(Color.BLUE);
grid.setConstraints(txtcode,gbc);
cont.add(txtcode);
txtcode.setForeground(new Color(0,0,0));
txtcode.setFont(new Font("Courier
new",Font.BOLD,15));
txtcode.setBackground(new
Color(255,175,175));
JLabel lbdes=new JLabel("Name");
gbc.gridx=0; gbc.gridy=1;
gbc.ipadx=10;
grid.setConstraints(lbdes,gbc);
cont.add(lbdes);
lbdes.setForeground(new Color(0,0,255));
lbdes.setFont(new Font("Courier
new",Font.BOLD,15));
txtname=new JTextField(10);
gbc.gridx=1; gbc.gridy=1;
grid.setConstraints(txtname,gbc);
cont.add(txtname);

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

160

Clinic Management System

txtname.setForeground(new Color(0,0,0));
txtname.setFont(new Font("Courier
new",Font.BOLD,15));
txtname.setBackground(new
Color(255,175,175));
gbc.insets=new Insets(10,20,0,0);
JLabel lbtype=new JLabel("Company
Name");
gbc.gridx=0; gbc.gridy=2;
gbc.ipadx=10;
grid.setConstraints(lbtype,gbc);
cont.add(lbtype);
lbtype.setForeground(new Color(0,0,255));
lbtype.setFont(new Font("Courier
new",Font.BOLD,15));
txtcn=new JTextField(10);
gbc.gridx=1; gbc.gridy=2;
grid.setConstraints(txtcn,gbc);
cont.add(txtcn);
txtcn.setForeground(new Color(0,0,0));
txtcn.setFont(new Font("Courier
new",Font.BOLD,15));
txtcn.setBackground(new
Color(255,175,175));
JLabel lbact=new JLabel("Unit of
Measure");
gbc.gridx=0; gbc.gridy=3;
gbc.ipadx=10;
grid.setConstraints(lbact,gbc);
cont.add(lbact);

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

161

Clinic Management System

lbact.setForeground(new Color(0,0,255));
lbact.setFont(new Font("Courier
new",Font.BOLD,15));
txtuom=new JTextField(10);
gbc.gridx=1; gbc.gridy=3;
gbc.ipady=5;
grid.setConstraints(txtuom,gbc);
cont.add(txtuom);
txtuom.setForeground(new Color(0,0,0));
txtuom.setFont(new Font("Courier
new",Font.BOLD,15));
txtuom.setBackground(new
Color(255,175,175));

JLabel lbrate=new

JLabel("Stock");
gbc.gridx=0; gbc.gridy=4;
gbc.ipadx=10;gbc.ipady=5;
grid.setConstraints(lbrate,gbc);
cont.add(lbrate);
lbrate.setForeground(new Color(0,0,255));
lbrate.setFont(new Font("Courier
new",Font.BOLD,15));
txtstock=new JTextField(10);
gbc.gridx=1; gbc.gridy=4;
grid.setConstraints(txtstock,gbc);
cont.add(txtstock);
btAdd=new
JButton("Add");
gbc.gridx=0; gbc.gridy=5;
gbc.ipadx=23;gbc.ipady=0;

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

162

Clinic Management System

gbc.insets=new
Insets(15,20,0,0);
grid.setConstraints(btAdd,gbc);
cont.add(btAdd);
btClear=new
JButton("Clear");
gbc.gridx=1;gbc.gridy=5;
gbc.ipadx=15;
gbc.insets=new Insets(15,0,0,0);
cont.add(btClear);
btSearch=new
JButton("Search");
gbc.gridx=2;gbc.gridy=5;
gbc.ipadx=0;
gbc.insets=new Insets(15,50,0,0);
grid.setConstraints(btSearch,gbc);
cont.add(btSearch);
btEdit=new JButton("Edit");
gbc.gridx=0;gbc.gridy=6;
gbc.ipadx=25;
gbc.insets=new Insets(15,20,0,0);
grid.setConstraints(btEdit,gbc);
cont.add(btEdit);
btDelete=new
JButton("Delete");
gbc.gridx=1;gbc.gridy=6;

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

163

Clinic Management System

gbc.ipadx=10;
gbc.insets=new
Insets(15,0,0,0);
grid.setConstraints(btDelete,gbc);
cont.add(btDelete);
txtstock.addKeyListener(this);
// ------------------Frame Properties--------------frm.pack();
frm.setSize(400,320); //Size of window
frm.setLocation(160,110); //set the
window
frm.setVisible(true);
frm.setResizable(false);
frm.show();
btAdd.addActionListener(new
ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
add();
}
});
btClear.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

164

Clinic Management System

{
clear();
}
});
btSearch.addActionListener(new ActionListener
()
{
public void actionPerformed(ActionEvent
ae)
{
frm.dispose();
conn.connect();
sc.search();
}
});
btDelete.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
delete();
}
});
btEdit.addActionListener(new ActionListener
()
{
public void actionPerformed(ActionEvent
ae)
{
edit();
}

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

165

Clinic Management System

});
}
public void add()
{
conn.generateID(txtcode,"select Code from
Generic_Master","GN");
String id=txtcode.getText();
String name=txtname.getText();
String cn=txtcn.getText();
String uom=txtuom.getText();
String stock=txtstock.getText();
conn.connect();
try{
pst=conn.con.prepareStatement("insert into Generic_Master
values(?,?,?,?,?)");
pst.setString(1,id);
pst.setString(2,name);
pst.setString(3,cn);
pst.setObject(4,uom);
pst.setString(5,stock);
pst.executeUpdate();
System.out.println("Record Added");
}catch(Exception e)
{System.out.println(e.getMessage());}
}
public void delete()
{
String str=txtcode.getText();
String sp="delete from Generic_Master where
Code='"+str+"'";

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

166

Clinic Management System

try
{
conn.connect();
conn.st=conn.con.createStatement();
if(found)
{
int
d=JOptionPane.showConfirmDialog(null,"Are you sure to delete ?");
if(d==0)
{
conn.st.executeUpdate(sp);
clear();
}
}
}
catch (Exception e)
}
public void clear()
{
txtcode.setText("");
txtname.setText("");
txtcn.setText("");
txtuom.setText("");
txtstock.setText("");
found=false;
}
public void edit()
{
String id=txtcode.getText();

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

167

Clinic Management System

String name=txtname.getText();
String cn=txtcn.getText();
String uom=txtuom.getText();
String stock=txtstock.getText();
try{
conn.connect();
pst=conn.con.prepareStatement("Update
Generic_Master set
Code=?,Name=?,Company_Name=?,Unit_of_Measure=?,Stock_on_
Hand=? where Code='"+id+"'");
pst.setString(1,id);
pst.setString(2,name);
pst.setString(3,cn);
pst.setObject(4,uom);
pst.setString(5,stock);
pst.executeUpdate();
JOptionPane.showMessageDialog(null,"Updated !");
}catch(Exception e)
{System.out.println(e.getMessage());}
}
public void keyPressed(KeyEvent ke)
{
conn.shouldNumber(txtstock,ke);
}
public void keyReleased(KeyEvent ke){}
public void keyTyped(KeyEvent ke){}
public static void main(String agrs[])
{
new Generic_Master();
}
}

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

168

Clinic Management System

PAYMENT DETAIL CLASS


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import javax.swing.JOptionPane;
public class PayDetail implements WindowListener,KeyListener
{
Connecting conn=new Connecting();
PayDetail()
{
display();
}
JLabel lbamt,lbdate;
JTextField txtamt,txtdate;
JFrame frm;
PreparedStatement pst;
JButton btAdd,btClear,btEdit,btDelete,btSearch;
JComboBox cmbbno;
boolean found=false;
public void display()
{
frm=new JFrame("Payment Details");
GridBagLayout grid=new GridBagLayout();
GridBagConstraints gbc=new
GridBagConstraints();
frm.setLayout(grid);
Container cont=frm.getContentPane();
gbc.anchor=GridBagConstraints.WEST;
lbdate=new JLabel("Bill No");

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

169

Clinic Management System

gbc.gridx=0; gbc.gridy=0;
gbc.ipadx=10;gbc.ipady=5;
gbc.insets=new Insets(10,20,0,0);
grid.setConstraints(lbdate,gbc);
cont.add(lbdate);
lbdate.setForeground(new Color(0,0,255));
lbdate.setFont(new Font("Courier
new",Font.BOLD,15));
cmbbno=new JComboBox();
gbc.gridx=1; gbc.gridy=0;
gbc.ipadx=50; gbc.ipady=0;
grid.setConstraints(cmbbno,gbc);
cont.add(cmbbno);
cmbbno.setForeground(new Color(0,0,0));
cmbbno.setFont(new Font("Courier
new",Font.BOLD,15));
cmbbno.setBackground(new
Color(255,175,175));
lbamt=new JLabel("Amount");
gbc.gridx=0; gbc.gridy=1;
gbc.ipadx=10;
grid.setConstraints(lbamt,gbc);
cont.add(lbamt);
lbamt.setForeground(new Color(0,0,255));
lbamt.setFont(new Font("Courier
new",Font.BOLD,15));
txtamt=new JTextField(10);
gbc.gridx=1; gbc.gridy=1;
gbc.ipadx=10; gbc.ipady=5;
gbc.insets=new Insets(12,20,0,0);

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

170

Clinic Management System

grid.setConstraints(txtamt,gbc);
cont.add(txtamt);
txtamt.setForeground(new Color(0,0,0));
txtamt.setFont(new Font("Courier
new",Font.BOLD,15));
txtamt.setBackground(new Color(255,175,175));
lbdate=new JLabel("Pay Date");
gbc.gridx=0; gbc.gridy=2;
gbc.ipadx=10;
gbc.insets=new Insets(12,20,0,0);
grid.setConstraints(lbdate,gbc);
cont.add(lbdate);
lbdate.setForeground(new Color(0,0,255));
lbdate.setFont(new Font("Courier
new",Font.BOLD,15));
txtdate=new JTextField(10);
gbc.gridx=1; gbc.gridy=2;
grid.setConstraints(txtdate,gbc);
txtdate.setForeground(new Color(0,0,0));
txtdate.setFont(new Font("Courier
new",Font.BOLD,15));
txtdate.setBackground(new Color(255,175,175));
btAdd=new JButton("Add");
gbc.gridx=0; gbc.gridy=3;
gbc.ipadx=20;gbc.ipady=0;
gbc.insets=new Insets(10,15,0,0);
grid.setConstraints(btAdd,gbc);
cont.add(btAdd);
btClear=new JButton("Clear");
gbc.gridx=1;gbc.gridy=3;

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

171

Clinic Management System

gbc.ipadx=15;
gbc.insets=new Insets(10,10,0,0);
grid.setConstraints(btClear,gbc);
cont.add(btClear);
btSearch=new JButton("Search");
gbc.gridx=2;gbc.gridy=3;
gbc.ipadx=0;
gbc.insets=new Insets(10,-45,0,0);
grid.setConstraints(btSearch,gbc);
cont.add(btSearch);
btEdit=new JButton("Edit");
gbc.gridx=0;gbc.gridy=4;
gbc.ipadx=20;
gbc.insets=new Insets(10,15,0,0);
grid.setConstraints(btEdit,gbc);
cont.add(btEdit);
btDelete=new JButton("Delete");
gbc.gridx=1;gbc.gridy=4;
gbc.ipadx=10;
gbc.insets=new Insets(10,10,0,0);
grid.setConstraints(btDelete,gbc);
cont.add(btDelete);
txtamt.addKeyListener(this);
//------------Frame Properties---------frm.addWindowListener(this);
frm.pack();
frm.setSize(350,250); //Size of window
frm.setLocation(230,160);
frm.setVisible(true);
frm.setResizable(false);

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

172

Clinic Management System

frm.show();
btAdd.addActionListener(new ActionListener
()
{
public void actionPerformed(ActionEvent
ae)
{
add();
clear();
}
});
btClear.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
clear();
}
});
btSearch.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
frm.dispose();
conn.connect();
searchPayDetail sc=new
searchPayDetail();
sc.search();

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

173

Clinic Management System

}
});
btDelete.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
delete();
}
});
btEdit.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
edit();
}
});
}
public void loadBill()
{
String str="select Bill_No from Advance_Receipt order by Bill_No";
conn.connect();
try{
conn.st=conn.con.createStatement();
conn.rs=conn.st.executeQuery(str);
while(conn.rs.next())
{
String item=conn.rs.getString(1);
cmbbno.addItem(item);
}

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

174

Clinic Management System

}catch(Exception e){}
}
public void add()
{
Object bno=cmbbno.getSelectedItem();
String b=bno.toString();
String amt=txtamt.getText();
String date=txtdate.getText();
conn.connect();
try{
pst=conn.con.prepareStatement("insert into
Payment_Details values(?,?,?)");
pst.setObject(1,b);
pst.setString(2,amt);
pst.setObject(3,date);
pst.executeUpdate();
System.out.println("Record Added");
}catch(Exception e){}
}
public void clear()
{
txtamt.setText("");
txtdate.setText("");
cmbbno.setSelectedIndex(0);
found=false;
}
public void delete()
{
Object str=cmbbno.getSelectedItem();

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

175

Clinic Management System

String sp="delete from Payment_Details where


Bill_No='"+str+"'";
try
{
conn.connect();
conn.st=conn.con.createStatement();
if(found)
{
int
d=JOptionPane.showConfirmDialog(null,"Are you sure to delete ?");
if(d==0)
{
conn.st.executeUpdate(sp);
clear();
}
}
}
catch (Exception e)

}
public void edit()
{
String code=txtamt.getText();
String name=txtamt.getText();
Object c=cmbbno.getSelectedItem();
try{
conn.connect();
pst=conn.con.prepareStatement("Update
Payment_Details set Bill_No=?,Pay_Amt=?,Pay_Date=? where
Bill_No='"+code+"'");
pst.setString(1,code);
pst.setString(2,name);

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

176

Clinic Management System

pst.setObject(3,c);
pst.executeUpdate();
JOptionPane.showMessageDialog(null,"Updated !");
}catch(Exception e){}
}
public void keyPressed(KeyEvent ke)
{
conn.shouldNumber(txtamt,ke);
}
public static void main(String agrs[])
{
new PayDetail();
}
}

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

177

Clinic Management System

REPORT CLASS
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
public class Report extends JFrame
{
Connecting conn=new Connecting();
Container cont;
JFrame frm;
JScrollPane scrollPane;
boolean found=false;
public void ReportDisplay(String sql)
{
frm=new JFrame();
cont=frm.getContentPane();
Vector colNames=new Vector();
Vector data=new Vector();
try
{
conn.connect();
Statement st=conn.con.createStatement();
ResultSet rs=st.executeQuery(sql);
ResultSetMetaData md=rs.getMetaData();
int col=md.getColumnCount();
for(int i=1;i<=col;i++)

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

178

Clinic Management System

{
colNames.addElement(md.getColumnName(i));
}
while(rs.next())
{
Vector row=new Vector(col);
for(int i=1;i<=col;i++)
{
row.addElement(rs.getObject(i));
}
data.addElement(row);
found=true;
}
rs.close();
st.close();
}catch(Exception e){}
if(found)
{
JTable table=new JTable(data,colNames);
scrollPane=new JScrollPane(table);
getContentPane().add(scrollPane);
cont.add(scrollPane);
frm.setLocation(5,60);
frm.setSize(790,490);
frm.show();
}
else
JOptionPane.showMessageDialog(null,"Sorry ! \nNo Match
Found !");

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

179

Clinic Management System

}
public static void main(String agrs[])
{
Report frame=new Report();
frame.ReportDisplay("Select * From Consultant");
}};

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

180

Clinic Management System

SERVICE MASTER CLASS


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import javax.swing.JOptionPane;
public class Service_Master implements KeyListener
{
Connecting conn=new Connecting();
Service_Master()
{
display();
}
PreparedStatement pst;
JButton btAdd,btClear,btEdit,btDelete,btSearch;
JTextField
txtsid,txtdes,txttype,txtrate,txtma,txtefdate,txtetdate;
JComboBox cmbact;
JFrame frm;
JLabel lbdes;
String active[]={"Y","N"};
boolean found=false;
public void display()
{
frm=new JFrame("Service Master...");
GridBagLayout grid=new GridBagLayout();
GridBagConstraints gbc=new
GridBagConstraints();
frm.setLayout(grid);

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

181

Clinic Management System

Container cont=frm.getContentPane();
gbc.anchor=GridBagConstraints.WEST;
JLabel lbbcid=new JLabel("Service ID");
gbc.gridx=0; gbc.gridy=0;
gbc.ipadx=10;gbc.ipady=5;
gbc.insets=new Insets(10,20,0,0);
grid.setConstraints(lbbcid,gbc);
cont.add(lbbcid);
lbbcid.setForeground(new Color(0,0,255));
lbbcid.setFont(new Font("Courier
new",Font.BOLD,15));
txtsid=new JTextField(10);
gbc.gridx=1; gbc.gridy=0;
gbc.ipadx=10;
txtsid.setEnabled(false);
txtsid.setBackground(Color.BLUE);
grid.setConstraints(txtsid,gbc);
cont.add(txtsid);
txtsid.setForeground(new Color(0,0,0));
txtsid.setFont(new Font("Courier
new",Font.BOLD,15));
txtsid.setBackground(new Color(255,175,175));
lbdes=new JLabel("Description");
gbc.gridx=0; gbc.gridy=1;
gbc.ipadx=10;
grid.setConstraints(lbdes,gbc);
cont.add(lbdes);
lbdes.setForeground(new Color(0,0,255));

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

182

Clinic Management System

lbdes.setFont(new Font("Courier
new",Font.BOLD,15));
txtdes=new JTextField(10);
gbc.gridx=1; gbc.gridy=1;
grid.setConstraints(txtdes,gbc);
cont.add(txtdes);
txtdes.setForeground(new Color(0,0,0));
txtdes.setFont(new Font("Courier
new",Font.BOLD,15));
txtdes.setBackground(new Color(255,175,175));
gbc.insets=new Insets(10,20,0,0);
JLabel lbtype=new JLabel("Type");
gbc.gridx=0; gbc.gridy=2;
gbc.ipadx=10;
grid.setConstraints(lbtype,gbc);
cont.add(lbtype);
lbtype.setForeground(new Color(0,0,255));
lbtype.setFont(new Font("Courier
new",Font.BOLD,15));
txttype=new JTextField(10);
gbc.gridx=1; gbc.gridy=2;
grid.setConstraints(txttype,gbc);
cont.add(txttype);
JLabel lbact=new JLabel("Active");
gbc.gridx=0; gbc.gridy=3;
gbc.ipadx=10;
grid.setConstraints(lbact,gbc);
cont.add(lbact);
lbact.setForeground(new Color(0,0,255));

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

183

Clinic Management System

lbact.setFont(new Font("Courier
new",Font.BOLD,15));
cmbact=new
JComboBox(active);
gbc.gridx=1; gbc.gridy=3;
gbc.ipady=-3;
grid.setConstraints(cmbact,gbc);
cont.add(cmbact);
cmbact.setForeground(new Color(0,0,0));
cmbact.setFont(new Font("Courier
new",Font.BOLD,15));
cmbact.setBackground(new
Color(255,175,175));
JLabel lbrate=new JLabel("Rate");
gbc.gridx=2; gbc.gridy=0;
gbc.ipadx=10;gbc.ipady=5;
grid.setConstraints(lbrate,gbc);
cont.add(lbrate);
lbrate.setForeground(new Color(0,0,255));
lbrate.setFont(new Font("Courier
new",Font.BOLD,15));
txtrate=new JTextField(10);
gbc.gridx=3; gbc.gridy=0;
grid.setConstraints(txtrate,gbc);
cont.add(txtrate);
txrate.setForeground(new Color(0,0,0));
txtrate.setFont(new Font("Courier
new",Font.BOLD,15));

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

184

Clinic Management System

txtrate.setBackground(new
Color(255,175,175));

JLabel

lbma=new JLabel("Min. Amount");


gbc.gridx=2; gbc.gridy=1;
gbc.ipadx=10;
grid.setConstraints(lbma,gbc);
cont.add(lbma);
lbma.setForeground(new Color(0,0,255));
lbma.setFont(new Font("Courier
new",Font.BOLD,15));
txtma=new JTextField(10);
gbc.gridx=3; gbc.gridy=1;
gbc.ipadx=10;gbc.ipady=5;
grid.setConstraints(txtma,gbc);
cont.add(txtma);
JLabel lbefdate=new JLabel("Effective From");
gbc.gridx=2; gbc.gridy=2;
gbc.ipadx=10;
grid.setConstraints(lbefdate,gbc);
cont.add(lbefdate);
JLabel lbetdate=new JLabel("Effective To");
gbc.gridx=2; gbc.gridy=3;
gbc.ipadx=10;
grid.setConstraints(lbetdate,gbc);
cont.add(lbetdate);
lbetdate.setForeground(new Color(0,0,255));
lbetdate.setFont(new Font("Courier
new",Font.BOLD,15));
btAdd=new JButton("Add");

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

185

Clinic Management System

gbc.gridx=0; gbc.gridy=6;
gbc.ipadx=20;gbc.ipady=0;
gbc.insets=new
Insets(25,35,0,0);
grid.setConstraints(btAdd,gbc);
cont.add(btAdd);
btClear=new
JButton("Clear");
gbc.gridx=1;gbc.gridy=6;
gbc.ipadx=15;
gbc.insets=new Insets(25,10,0,0);
grid.setConstraints(btClear,gbc);
cont.add(btClear);
btSearch=new
JButton("Search");
gbc.gridx=2;gbc.gridy=6;
gbc.ipadx=0;
gbc.insets=new Insets(25,45,0,0);
grid.setConstraints(btSearch,gbc);
cont.add(btSearch);
btEdit=new JButton("Edit");
gbc.gridx=3;gbc.gridy=6;
gbc.ipadx=25;
gbc.insets=new Insets(25,70,0,0);
grid.setConstraints(btEdit,gbc);

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

186

Clinic Management System

cont.add(btEdit);
btDelete=new
JButton("Delete");
gbc.gridx=3;gbc.gridy=6;
gbc.ipadx=10;
gbc.insets=new Insets(25,22,0,0);
grid.setConstraints(btDelete,gbc);
cont.add(btDelete);
// ------------------Frame Properties--------------txtrate.addKeyListener(this);
txtma.addKeyListener(this);
frm.pack();
frm.setSize(520,300); //Size of window
frm.setLocation(160,110); //set the
window
frm.setVisible(true);
frm.setResizable(false);
frm.show();
btAdd.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
add();
}
});
btClear.addActionListener(new ActionListener ()
{

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

187

Clinic Management System

public void actionPerformed(ActionEvent


ae)
{
clear();
}
});
btSearch.addActionListener(new ActionListener
()
{
public void actionPerformed(ActionEvent
ae)
{
frm.dispose();
conn.connect();
searchService sc=new
searchService();
sc.search();
}
});
btDelete.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
delete();
}
});
btEdit.addActionListener(new ActionListener
()

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

188

Clinic Management System

{
public void actionPerformed(ActionEvent
ae)
{
edit();
}
});
}
public void add()
{
conn.generateID(txtsid,"select Service_ID from
Service_Master","SI");
String id=txtsid.getText();
String des=txtdes.getText();
String type=txttype.getText();
Object act=cmbact.getSelectedItem();
String rate=txtrate.getText();
String ma=txtma.getText();
String ef=txtefdate.getText();
String et=txtetdate.getText();
boolean
fill=conn.setRequire(txtdes,"Description");
fill=conn.setRequire(txtrate,"Rate");
fill=conn.setRequire(txtma,"Minimum
Amout");
if(fill)
{
conn.connect();
try{

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

189

Clinic Management System

pst=conn.con.prepareStatement("insert into Service_Master


values(?,?,?,?,?,?,?,?)");
pst.setString(1,id);
pst.setString(2,des);
pst.setString(3,type);
pst.setObject(4,act);
pst.setString(5,rate);
pst.setString(6,ma);
pst.setString(7,ef);
pst.setString(8,et);
pst.executeUpdate();
JOptionPane.showMessageDialog(null,"Record
Added");
clear();
}catch(Exception e)
{System.out.println(e.getMessage());}
}
}
public void delete()
{
String str=txtsid.getText();
String sp="delete from Service_Master where
Service_ID='"+str+"'";
try
{
conn.connect();
conn.st=conn.con.createStatement();
if(found)
{

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

190

Clinic Management System

int d=JOptionPane.showConfirmDialog(null,"Are you sure to


delete ?");
if(d==0)
{
conn.st.executeUpdate(sp);
clear();
}
}
}
catch (Exception e)

}
public void edit()
{
String id=txtsid.getText();
String des=txtdes.getText();
String type=txttype.getText();
Object act=cmbact.getSelectedItem();
String rate=txtrate.getText();
String ma=txtma.getText();
String ef=txtefdate.getText();
String et=txtetdate.getText();
try{
conn.connect();
pst=conn.con.prepareStatement("Update
Service_Master set
Service_ID=?,Description=?,Type=?,Active=?,Rate=?,MinAmt=?,EF
Ffrom=?,EFFto=? where Service_ID='"+id+"'");
pst.setString(1,id);

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

191

Clinic Management System

pst.setString(2,des);
pst.setString(3,type);
pst.setObject(4,act);
pst.setString(5,rate);
pst.setString(6,ma);
pst.setString(7,ef);
pst.setString(8,et);
pst.executeUpdate();
JOptionPane.showMessageDialog(null,"Updated !");
}catch(Exception e){System.out.println(e.getMessage());}
}
public void keyPressed(KeyEvent ke)
{
conn.shouldNumber(txtrate,ke);
conn.shouldNumber(txtma,ke);
}
public void keyReleased(KeyEvent ke){}
public void keyTyped(KeyEvent ke){}
public static void main(String agrs[])
{
new Service_Master();
}
}

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

192

Clinic Management System

USER CLASS
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
public class User
{
Connecting conn=new Connecting();
User()
{
display();
}
JLabel lbuser,lbpass;
JTextField txtuser;
JPasswordField txtpass;
JFrame frm;
PreparedStatement pst;
JButton btAdd,btDelete;
public void display()
{
frm=new JFrame("Create / Delete User");
GridBagLayout grid=new GridBagLayout();
GridBagConstraints gbc=new
GridBagConstraints();
frm.setLayout(grid);
Container cont=frm.getContentPane();
gbc.anchor=GridBagConstraints.WEST;
lbuser=new JLabel("User Name");

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

193

Clinic Management System

gbc.gridx=0; gbc.gridy=0;
gbc.ipadx=10;gbc.ipady=5;
gbc.insets=new Insets(10,20,0,0);
grid.setConstraints(lbuser,gbc);
cont.add(lbuser);
lbuser.setForeground(new Color(0,0,255));
lbuser.setFont(new Font("Courier
new",Font.BOLD,15));
txtuser=new JTextField(10);
gbc.gridx=1; gbc.gridy=0;
gbc.ipadx=120;
gbc.insets=new Insets(10,-90,0,0);
grid.setConstraints(txtuser,gbc);
cont.add(txtuser);
txtuser.setForeground(new Color(0,0,0));
txtuser.setFont(new Font("Courier
new",Font.BOLD,15));
txtuser.setBackground(new Color(255,175,175));
lbpass=new JLabel("Password");
gbc.gridx=0; gbc.gridy=1;
gbc.insets=new Insets(10,20,0,0);
grid.setConstraints(lbpass,gbc);
cont.add(lbpass);
lbpass.setForeground(new Color(0,0,255));
lbpass.setFont(new Font("Courier
new",Font.BOLD,15));
txtpass=new JPasswordField(10);
gbc.gridx=1; gbc.gridy=1;

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

194

Clinic Management System

gbc.ipadx=120;
gbc.insets=new Insets(10,-90,0,0);
grid.setConstraints(txtpass,gbc);
cont.add(txtpass);
txtpass.setForeground(new Color(0,0,0));
txtpass.setFont(new Font("Courier
new",Font.BOLD,15));
txtpass.setBackground(new
Color(255,175,175));
btAdd=new JButton("Create");
gbc.gridx=0; gbc.gridy=3;
gbc.ipadx=10;gbc.ipady=0;
gbc.insets=new Insets(10,30,0,0);
grid.setConstraints(btAdd,gbc);
cont.add(btAdd);
btDelete=new JButton("Delete");
gbc.gridx=1; gbc.gridy=3;
gbc.ipadx=10;gbc.ipady=0;
gbc.insets=new Insets(10,70,0,0);
grid.setConstraints(btDelete,gbc);
cont.add(btDelete);
//------------Frame Properties---------frm.pack();
frm.setSize(300,175); //Size of window
frm.setLocation(250,200); //set the window
frm.setVisible(true);

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

195

Clinic Management System

frm.setResizable(false);

//Resized the

window...
frm.show();
btAdd.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
add();
}
});
btDelete.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
delete();
}
});
}
public void add()
{
boolean fill=true;
String user=txtuser.getText();
String pass=txtpass.getText();
if(user.equals(""))
fill=false;
if(pass.equals(""))

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

196

Clinic Management System

fill=false;
conn.connect();
try{
pst=conn.con.prepareStatement("insert into User_Master
values(?,?)");
pst.setString(1,user);
pst.setString(2,pass);
if(fill)
{
pst.executeUpdate();
JOptionPane.showMessageDialog(null,"Cogratulation ..!\n "+"
"+user);
frm.dispose();
}
else
JOptionPane.showMessageDialog(null,"Not Valid User Name
Or Password!");
txtuser.setText("");
txtpass.setText("");
}catch(Exception e){}
}
public void delete()
{
boolean fill=true;
String user=txtuser.getText();
if(user.equals(""))
{
JOptionPane.showMessageDialog(null,"Please Enter User
Name,\nWhich You Want To Delete");
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

197

Clinic Management System

fill=false;
}
String sp="delete from User_Master where
User_Name='"+user+"'";
try
{
conn.connect();
conn.st=conn.con.createStatement();
if(fill)
{
int d=JOptionPane.showConfirmDialog(null,"Are you sure to
delete ?\n"+user);
if(d==0)
{
conn.st.executeUpdate(sp);
txtuser.setText("");
JOptionPane.showMessageDialog(null,user+" is
Deleted !");
}
}
}
catch (Exception e)

}
public void edit(String input)
{
String user=txtuser.getText();
String pass=txtpass.getText();
try{
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

198

Clinic Management System

conn.connect();
pst=conn.con.prepareStatement("Update
User_Master set User_Name=?,Password=?where
City_Code='"+input+"'");
pst.setString(1,user);
pst.setString(2,pass);
pst.executeUpdate();
JOptionPane.showMessageDialog(null,"Changed !");
frm.dispose();
}catch(Exception e){}
}
public static void main(String agrs[])
{
new User();

}
}

PAYMENT MODE

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

199

Clinic Management System

import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
import javax.swing.JOptionPane;
public class PaymentMode
{
Connecting conn=new Connecting();
PaymentMode()
{
display();
}
JLabel lbCode,lbName;
JTextField txtCode,txtDes;
PreparedStatement pst;
JFrame frm;
JButton btAdd,btClear,btEdit,btDelete,btSearch;
boolean found=false;
public void display()
{
frm=new JFrame("Payment Mode");
GridBagLayout grid=new GridBagLayout();
GridBagConstraints gbc=new GridBagConstraints();
frm.setLayout(grid);
Container cont=frm.getContentPane();
gbc.anchor=GridBagConstraints.WEST;
lbCode=new JLabel("Code");
gbc.gridx=0; gbc.gridy=0;
gbc.ipadx=10;gbc.ipady=5;
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

200

Clinic Management System

gbc.insets=new Insets(10,20,0,0);
grid.setConstraints(lbCode,gbc);
cont.add(lbCode);
lbcode.setForeground(new Color(0,0,255));
lbcode.setFont(new Font("Courier
new",Font.BOLD,15));
txtCode=new JTextField(2);
gbc.gridx=1; gbc.gridy=0;
gbc.ipadx=20;
grid.setConstraints(txtCode,gbc);
cont.add(txtCode);
txtcode.setForeground(new Color(0,0,0));
txtcode.setFont(new Font("Courier
new",Font.BOLD,15));
txtcode.setBackground(new Color(255,175,175));
lbName=new JLabel("Description");
gbc.gridx=0; gbc.gridy=1;
gbc.ipadx=10;
grid.setConstraints(lbName,gbc);
cont.add(lbName);
lbName.setForeground(new Color(0,0,255));
lbName.setFont(new Font("Courier
new",Font.BOLD,15));
txtDes=new JTextField(10);
gbc.gridx=1; gbc.gridy=1;
grid.setConstraints(txtDes,gbc);
cont.add(txtDes);
txtDes.setForeground(new Color(0,0,0));

txtDes.setFont(new Font("Courier
new",Font.BOLD,15));
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

201

Clinic Management System

txtDes.setBackground(new Color(255,175,175));
btAdd=new JButton("Add");
gbc.gridx=0; gbc.gridy=2;
gbc.ipadx=20;gbc.ipady=0;
gbc.insets=new Insets(10,15,0,0);
grid.setConstraints(btAdd,gbc);
cont.add(btAdd);
btClear=new JButton("Clear");
gbc.gridx=1;gbc.gridy=2;
gbc.ipadx=15;
gbc.insets=new Insets(10,8,0,0);
grid.setConstraints(btClear,gbc);
cont.add(btClear);
btSearch=new JButton("Search");
gbc.gridx=2;gbc.gridy=2;
gbc.ipadx=0;
gbc.insets=new Insets(10,-45,0,0);
grid.setConstraints(btSearch,gbc);
cont.add(btSearch);
btEdit=new JButton("Edit");
gbc.gridx=0;gbc.gridy=3;
gbc.ipadx=20;
gbc.insets=new Insets(10,15,0,0);
grid.setConstraints(btEdit,gbc);
cont.add(btEdit);
btDelete=new JButton("Delete");
gbc.gridx=1;gbc.gridy=3;
gbc.ipadx=10;
gbc.insets=new Insets(10,8,0,0);
grid.setConstraints(btDelete,gbc);
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

202

Clinic Management System

cont.add(btDelete);
//------------Frame Properties---------frm.pack();
frm.setSize(350,250); //Size of window
frm.setLocation(230,160); //set the window
frm.setVisible(true);
frm.setResizable(false);

//Resized the window...

frm.show();
//---------Button Add Event Handler-------btAdd.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent ae)
{
add();
clear();
}
});
btClear.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent ae)
{
clear();
}
});
btSearch.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent ae)

{
frm.dispose();
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

203

Clinic Management System

conn.connect();
searchPaymentMode sc=new
searchPaymentMode();
sc.search();
}
});
btDelete.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent
ae)
{
delete();
}
});
btEdit.addActionListener(new ActionListener ()
{
public void actionPerformed(ActionEvent ae)
{
edit();
}
});
}
public void add()
pst=conn.con.prepareStatement("insert into
PaymentMode_Master values(?,?)");
pst.setString(1,code.toUpperCase());
pst.setString(2,name.toUpperCase());
pst.executeUpdate();
System.out.println("Record Added");

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

204

Clinic Management System

}catch(Exception e){System.out.println("Sql
Exception");}
}
public void clear()
{
txtCode.setText("");
txtDes.setText("");
found=false;
}
public void delete()
{
String str=txtCode.getText();
String sp="delete from PaymentMode_Master where
Code='"+str+"'";
try
{
conn.connect();
conn.st=conn.con.createStatement();
if(found)
{
int d=JOptionPane.showConfirmDialog(null,"Are you sure to
delete ?");
if(d==0)
{
conn.st.executeUpdate(sp);
clear();
}
}
}
catch (Exception e)
}
NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

205

Clinic Management System

public void edit()


{
String code=txtCode.getText();
String name=txtDes.getText();
try{ conn.connect();
pst=conn.con.prepareStatement("Update
PaymentMode_Master set Code=?,Description=? where
Code='"+code+"'");
pst.setString(1,code);
pst.setString(2,name);
pst.executeUpdate();
JOptionPane.showMessageDialog(null,"Updated !");
}catch(Exception e){}
}
public static void main(String agrs[])
{
PaymentMode c=new PaymentMode();

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

206

}}

Clinic Management System

INPUT OUTPUT SCREEN


Home Page

Login Page

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

207

Clinic Management System

Menu Page

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

208

Clinic Management System

Registration

Billing Class

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

209

Clinic Management System

Advance Receipt Details

Advance Receipt

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

210

Clinic Management System

Appointment

Consultant Details

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

211

Clinic Management System

Credit card

Drug Master

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

212

Clinic Management System

Generic Master

Payment Mode

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

213

Clinic Management System

Service Master

Payment details

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

214

Clinic Management System

Testing Approach
Computer s/w has become more complex. The need
for specialized testing approaches has also grown. The white box
and

block

box

testing

methods

are

applicable

across

all

environments.
GUI present integrity challenges for software engineers. Because of
reusable components provided, the creation of the user interface
has become less time consuming and more process. But at the
same time the completely of GUI s has grown, leading to more
difficulty is the design and execution of test crises. Finites step
modeling graphs man be used to drive a series of test that address
specific data and programs objects that are relevant to the GUI.
Due to the large no. of permutation associated with GUI operations
testing should be approached using automated fools.
Verification and validation:Verification refers to the set of activity that insures
that software correctly implements a specific function. Validation
refresh to a different set of activities that insure that the software
that has built that is traceable customer requirements.

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

215

Clinic Management System

In other words validation provides final assurance


that software meets all functional, behavioral and performance
requires.
Boebam states another way: Verification: - Are we building the product right.
Validation: - Are we building the right product.
Verification and validation encompasses a wide array of SQA
(software quality assurance) activities that include formal technical
review, quality and configuration audits, performance monitoring,
simulation, fusibility study, documentation review, development
testing, qualification testing and installation testing.
Software testing strategy:A strategy for software testing may also be viewed
in the context of the spiral.

Context of system test


Validation testing

Integration testing

Unit testing

Code
Design

Requirement
System engineers

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

216

Clinic Management System

Unit testing is begins at the vortex of the spiral and concentration


on each unit (component) of the software as implemented in source
code. Testing programs by moving outward along the spiral to
integrated testing, where the focus is on design and construction of
the software architecture. Taking another term out word on the
spiral be in countered validation testing, where requirements
established as part of software requirement analysis are validated
against the software that has been constructed. Finally we arrive
other at system testing where the s/w , we special out along stream
lines that we spiral the scope of testing with each turned.

Unit testing:Unit testing focus verification afford on the smallest unit of the
software

design-the

software

component

module.

Using

component level design description as a guide, important control


paths are tested to uncover within the boundary of the module. The
unite test is white box printed. The test that occurs as parts of unit
tests is illustrated schematically.
The module interface is tested to insure that information properly
follows into and out of the program unit under test. The local data
structure is examined to insure that data stored temporarily
maintains its integrity during all steps in an algorithms execution.
Boundary condition are tested to insure that the module operates
properly at boundaries established to limit or restrict processing. All

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

217

Clinic Management System

independent paths through the control structure are executed at


least once. And finally all error handling paths are tested.
Integration testing:Integration
contracting

the

testing

program

is

structure

systematic
while

at

technique

the

same

for
time

conducting tests to uncover error associated with interfacing. A


number of different incremental integration strategies are:Components are combining to form clusters 0, 1, 2, & 3. Each of the
cluster is tested using a driver (shown (--) block). Components in
cluster 1 & 2 subordinate to Ma. Similarly driver D3 for cluster
3 is removed prior to integration with module Mb. Both Ma and
Mb will ultimately bee integrated with component Mc and forth.
Integration moves upward.
Validation testing : Software validation is achieved through a series of black box
tests

that

demonstrates

conformity

with

requirements.

Each

validation test case has been conducted, one of two possible


conditions exists:1. The functions or performance characteristics conform
to specification and are accepted.
2. A deviation from specification is uncovered and a
deficiency list is created. Deviation or error

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

218

Clinic Management System

3. discovered at this stage in a project can recovery be


corrected prior to schedule delivery.
There are two type of validation testing are: a. Alpha testing
b. Beta testing

A. alpha testing :The alpha test is conducted at the developers site by a customer.
The software is used in natural setting with the developer looking
over and shoulder of the user and recording errors and using
problems. Alpha test are conducted in a control environment.

B. Beta testing :Beta testing is conducted at one or more costumer site by the end
user of the software. Unlike alpha testing, the developer is generally
not present. There fore the beta test is a live application of the
software in an environment that cam not be controlled by the
developer. The customer records all
problems that are encountered during beta testing and
reports these to the developer at regular intervals. As a result of
problems reported during beta tests, software engineers make
modifications and than prepare for relation of the software product
to the enter customer based.

System testing :NAME


ROLL NO.

: Pawan kumar Singh


: 520827293

219

Clinic Management System

System testing is actually a series of different tests whos


primary purpose is to fully exercise the computer based system.
Although each test has a different purpose, all work of verify that
system elements have been property integrated and perform
allocated functions.
Recovery Testing :Recovery testing is a system test that force the software to fail in a
variety of ways and verifies that recovery is properly perform. If
recovery is automatic (perform by the system itself) reutilization,
check pointing mechanism, data recovery and restart are evaluated
for correctness. If recovery requires human intervention, the meantime-to-repair (MTTR) is evaluated to determine whether it is within
acceptable limits.
Security Testing :Security testing attempts to verify that protection
mechanism built into a system will infect, protect if form improper
penetration. During security testing the tester plays the role of the
individual who desire to penetrate the system. The role of the
system designer is to make penetration cost more than the value of
the information that will be obtained.

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

220

Clinic Management System

Debugging Process : Debugging occurs as a consequence of successful testing.


That is, when a test case uncovers and error, debugging is the
process that results in the removal of the error.

Debugging

Unit testing

Integration Testing

The debugging process will always have one of two outcomes:1. The cause will be found and corrected.
2. The cause will not be found.
PRINT SCREEN OF TESTING
THERE ARE FOLLOWING ERROR IN SYNTEX AND CONNECTION.

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

221

Clinic Management System

ERROR IN METHOD DECLARATION:

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

222

Clinic Management System

REPORT
import java.util.*;
import javax.swing.JTable.*;
import java.lang.String;
import java.util.Vector;
import javax.swing.table.AbstractTableModel;
import java.net.*;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.lang.*;
import java.awt.print.*;
public class bill_report extends JFrame
{
String[]
colhead={"BILLING_CLASS_ID","DESCRIPTION","DISCOUNT_
PERCENTAGE","EFFECTIVE_FROM","EFFECTIVE_TO"};
Object data[][]=new Object[100][10];
JTable table;
ResultSet rs;
private JPanel p1,p2,p;
private JButton dispall,print,exit,pgSetup;
private JLabel title,l1;
private Container cn;
String scd,dcd,dnm,ddate,carea,nomp,nomla,stc;
int i,r;

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

223

Clinic Management System

PageFormat pageFormat;
Dimension screensize;
Connection connection;
Statement statement;
public bill_report()
{
setTitle("BILLING_DETAILS");
setSize(750,550);
setVisible(true);
p1=new JPanel();
p2=new JPanel();
p=new JPanel();
setLayout(null);
cn=getContentPane();
cn.setBackground(new Color(224,232,248));
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
title =new JLabel("BILLING_DETAILS");
title.setFont(new Font("Engravers MT", 1, 30));
title.setForeground(new Color(247,251,249));
p1.add(title);
p1.setBackground(new Color(145,210,70));
cn.add(p1);
p1.setBounds(0,0,745,50);

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

224

Clinic Management System

dispall=new JButton("DISPLAY ALL");


dispall.setMnemonic('I');
dispall.addActionListener(new dispallListener());
dispall.setBounds(110,110,130,25);
cn.add(dispall);
pgSetup=new JButton("PAGE SETUP");
pgSetup.setMnemonic('G');
pgSetup.addActionListener(new setupListener());
pgSetup.setBounds(240,110,130,25);
cn.add(pgSetup);
print=new JButton("PRINT");
print.setMnemonic('P');
print.addActionListener(new printListener());
print.setBounds(370,110,130,25);
cn.add(print);
exit=new JButton("EXIT");
exit.setMnemonic('E');
exit.setBounds(500,110,130,25);
exit.addActionListener(new exitListener());
cn.add(exit);

screensize=Toolkit.getDefaultToolkit().getScreenSize();
setBounds((screensize.width-750)/2,(screensize.height550)/2,750,550);
setVisible(true);
setResizable(false);

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

225

Clinic Management System

connect();
load();
}
public void connect()
{
try
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connection=DriverManager.getConnection("jdbc:odbc: pawan
"," pawan "," pawan ");
statement=connection.createStatement();
}
catch(SQLException sqle)
{
JOptionPane.showMessageDialog(null,sqle);
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,"NOT
CONNECTED");
}
}

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

226

Clinic Management System

public class dispallListener implements ActionListener


{
public void actionPerformed(ActionEvent e)
{
load();
}
}
public void load()
{
try
{
String
q="",q1="",q2="",q3="",q5="",q4="";
int i=0;
rs=statement.executeQuery("select *
from bill");
while(rs.next())
{
data[i][0]=rs.getString(1);
data[i][1]=rs.getString(2);
data[i][2]=rs.getString(3);
data[i][3]=rs.getString(4);
data[i][4]=rs.getString(5);

i++;
}

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

227

Clinic Management System

table=new
JTable(data,colhead);
table.setFont(new
Font("Arial",Font.BOLD,12));
table.setForeground(Color.blue);
JScrollPane jsp=new JScrollPane(table);
jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SC
ROLLBAR_NEVER);
jsp.setBounds(0,200,740,302);
cn.add(jsp);
}
catch(SQLException sq)
{
JOptionPane.showMessageDialog(null,sq);
}
}
public void clear()
{
int i=0;
while(i<100)
{
data[i][0]="";
data[i][1]="";
data[i][2]="";
data[i][3]="";
data[i][4]="";
i++;
}

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

228

Clinic Management System

}
public class exitListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
int n= JOptionPane.showConfirmDialog(null,"Are You
Sure","Enter Carefully",JOptionPane.WARNING_MESSAGE);
if(n==JOptionPane.YES_OPTION)
dispose();
}
}
public class printListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String cmd = e.getActionCommand();
if (cmd.equals("PRINT"))
{
PrinterJob printJob = PrinterJob.getPrinterJob();
if (pageFormat == null)
pageFormat = printJob.defaultPage();
if(printJob.printDialog())
{
try
{
printJob.print();
}
catch (PrinterException exception)
{
JOptionPane.showMessageDialog(null, exception);

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

229

Clinic Management System

}
}
}
}
}
public class setupListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String cmd = e.getActionCommand();
if(cmd.equals("PAGE SETUP"))
{
PrinterJob printJob = PrinterJob.getPrinterJob();
if (pageFormat == null)
pageFormat = printJob.defaultPage();
pageFormat = printJob.pageDialog(pageFormat);
}
}
}
public static void main(String args[])
{
bill_report s=new bill_report();
}
}

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

230

Clinic Management System

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

231

Clinic Management System

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

232

Clinic Management System

Tools/Platform
Environmental Characteristics:
Minimum Hardware required For the Proposed System.

Pentium 600 MHz. Or higher microprocessor.

VGA 640 x 480 or higher resolution screen supported by


Microsoft Windows.

256 MB RAM for Windows XP, 512 MB RAM for Windows


NT/Windows2000.

10 GB or higher capacity hard disk.

Software Used:

Microsoft Windows xp second edition operating


system.

NAME
ROLL NO.

Core java 1.6 as Front-End

Oracle 10g as Back-End.

: Pawan kumar Singh


: 520827293

233

Clinic Management System

Limitations of Project
Although our sample of practices reflected the practices
participating in the randomized controlled trial, within practices we
interviewed staffs of the company who were low users of computers.
The people in the feedback group were self selecting and likely to
include disproportionately more of those with strong reactions to the
system. The voice of the disappointed enthusiast comes across
strongly, and we know less about the views of those people who
chose not to try the system. However, although the level of criticism
of the system varied between staff at different levels in the
company, the nature of the criticisms, in terms of where the
problems lay with the system, was remarkably consistent.

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

234

Clinic Management System

Future Scope of the Project


This project has been developed keeping in view the current
requirements of the Clinic. This project eventually automates all A
to Z training related activities, requirements and master file
maintenance of the system. Generates the important report like as
on range of dates. Employee training system got the option of entry,
amendments report generation as well as printing.
Reduces processing time.
Increases efficiency of system.
Emphasis on accuracy of data
Assures security and validity.
Provision for enhancement without distributing the developed
modules.
Object-Oriented design.
GUI based full mouse and keyboard supported forms

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

235

Clinic Management System

Fully automated, Employee training system got the option of


entry, amendments report generation as well as printing.

BIBLIOGRAPHY
1. DATABASE SYSTEMS CONCEPT KORTH, SUDARSHAN
2. SYSTEM ANALYSIS AND DESIGN E. M. AWARD
3. ORACLE PL/SQL PROGRAMMING OREILLY SERIES
4. AN INTRODUCTION TO DATABASE SYSTEMS C.J. DATE
5. EXPERT ONE BY ONE BY THOMAS KYTE WROX.
6. THE COMPLETE REFERENCE JAVA 2 FOURTH EDITION- NAUGHTON
SCHILDT.
7. JAVA2 PLATFORM UNLEASHED (SAMS) TECHMEDIA-JAWORSKI.
8. DATABASE SYSTEM CONCEPTS FIFTH EDITION SILBERSCHATZ
KORTH SUDARSHAN.

NAME
ROLL NO.

: Pawan kumar Singh


: 520827293

236

Você também pode gostar