Sie sind auf Seite 1von 152

Project Report

On
Patient Billing Software
Submitted in partial fulfillment of the requirements
For the award of the degree of

Post Graduate Diploma


In
Information Technology

Submitted by
Pankaj Batra:

SYMBIOSIS CENTER FOR DISTANCE LEARNING


TABLE OF CONTENTS

1. Study of Existing System and System Requirements

• What is the existing system?


• Define its scope.
• How the existing system works?
• What are the issues/problems with the existing system?
• How are you going to improve on the issues/problems with the existing
System?

2. Analysis

• Context diagram
• Data flow diagram (Level I, II, III)
• Functional decomposition Diagram

3. Design

• ER diagram
• Data dictionary
• Table design
• Input forms design
• Report Layouts

4. Coding

• Quality of code
• Input data validations
• Quality of report

1 Introduction:
The basic problem with existing hospital management system is that manual operation is still going on in
various hospitals. About 75% of the government hospitals use manual operating system for maintaining the
records, however in some hospitals computerized system is used but it is not up to the mark. The basic
problems are:
• Improper maintenance of records
• Time management problem
• Unfulfillment of user requirements
The main objective for the creation of this project is to fulfill the basic needs of its users. It will keep proper
records and maintain a proper working environment for the users. It will eradicate time management
problems and enhance the performance of the system. This system is used to reduce the manual work of the
staff thus increasing the efficiency of the existing work flow.
Patient Billing System helps to keep track of patient’s charges consumption and helps to keep track and
evaluate patient’s bills.
The hospital can computerize its system so that a clear picture of patient’s reports and charges are always
available and the patient can make use of facilities provided by hospital in proper way in future.

1.1 Objective:

The Software is for the automation of Hospital Management.


Main purpose of the proposed system is to:
1. Decreasing the manual work while maintaining the reliability.
2. Generation of desired information about patient and doctors.
3. To make the hectic billing system fast and easy.
4. To prevent unauthorized access to system.
5. To provide facility for editing information and password.

2.1 Tools and Enviroment Used:

 Hardware Requirement Estimation: -


The proposed configuration is best for daily maintenance of the record.

Hardware components Proposed configuration Alternative 1 Alternative 2

Processor Intel Pentium-III Intel Pentium-IV Intel Pentium-IV


(1.1GHZ) (1.3GHZ) (1.5GHZ)
Cache memory 512KB L2 256KB L2 512KB L2
Bus speed 256MHZ 400MHZ 512MHZ
Motherboard Intel 810E Intel 833E Intel 440E
Chipset Chipset Chipset
Hard disk drive Seagate 40GB Seagate 20GB 20GBUltra 160SCSIhard
SCSI hard drive SCSI hard drive drive
Random access memory 256MB 128MB 64MB

CD-ROM 30X CD-ROM 24X CD-ROM 40X CD-ROM


FloppyDisk Drive 1.44MB 3.5”Diskette 1.44MB 3.5”Diskette 1.44MB 3.5”Diskette
drive drive drive
Keyboard 104 key 104key 104 key
Mouse 2-Button easy mouse 3-Button scroll 2-Buttoneasy mouse
Mouse
Power supply 5KVA (UPS) 5KVA (UPS) 5KVA (UPS)
VDU (visual display unit) 15”(SVGA MONITOR) 14”(SVGA MONITOR) 17”(SVGA MONITOR)

Printer NLQ dot matrix printer HLQ laser printer NLQ dot matrix printer
Sound card PCI sound card PCI sound card PCI sound card
Speaker Normal Normal Normal
500watt 650watt 900watt
Other: Printing and Backup Media.

 Software Requirements: -
Operating System Database
Win-98, Win-XP, Linux or any other higher version Ms Access

Technologies to be used:

Db2-Database
Eclipse: Development tool
Rational-Design Tool
WAS Web Server

2.2 Process Model Chosen:

The process model which is chosen is the Water Fall Model. It is so because it is a sequential software
development model (a process for the creation of software) in which development is seen as flowing
steadily downwards (like a waterfall) through the phases of requirements analysis, design, implementation,
testing (validation),integration, and maintenance.

Waterfall Model
What is existing system
The traditional way of maintaining details of a patient in a hospital was to record those, using case sheets
manually. It was difficult to manually retrieve data whenever needed and almost next to impossible to
maintain such capacious data as the years passed by. It was difficult to update information for a patient
after some years. The billing had become a hard-hitting task for the data operators. Hence to prevent losing
of data and enhance the maintainability, various computerized approaches have been evolved. This project
is aimed at developing a patient billing software system that is of importance to a hospital. This system can
be used to maintain all patient information the treatment given to the patient the location or bed no. allotted
to each patient either in the ward or the ICU. The charges to be paid are computed automatically
considering the treatment charges specified the doctor’s charges and the ward bed charges. It also computes
the tax and generates a user bill.

2.4 Advantages of Proposed System:

The various advantages of this propose systems are:


• Reduces paper work.
• Secure system.
• Generation of desired information is just a click away.
• Proper availability of resources.
• Proper time utilization.
• Reduce the work of hospital staff.
• Decreasing the manual work while maintaining the reliability.

3. Overall Description:

3.1 Goals of Proposed System:

1. Planned approach towards working: - The working in the


organization will be well planned and organized. The data will be stored properly in data stores, which
will help in retrieval of information as well as its storage.

2. Accuracy: - The level of accuracy in the proposed system will be higher. All operation would be done
correctly and it ensures that whatever information is coming from the center is accurate.

3. Reliability: - The reliability of the proposed system will be high due to the above stated reasons. The
reason for the increased reliability of the system is that now there would be proper storage of
information.

4. No Redundancy: - In the proposed system utmost care would be that no information is repeated
anywhere, in storage or otherwise. This would assure economic use of storage space and consistency in
the data stored.

5. Immediate retrieval of information: - The main objective of proposed system is to provide for a
quick and efficient retrieval of information. Any type of information would be available whenever the
user requires.

6. Immediate storage of information: - In manual system there are many problems to store the largest
amount of information.

7. Easy to Operate: - The system should be easy to operate and should be such that it can be developed
within a short period of time and fit in the limited budget of the user.

3.2 Background:
A Hospital is a place where Patients come up for general diseases. Hospitals provide facilities like:-

• Consultation by Doctors on diseases.


• Diagnosis for diseases.
• Providing treatment facility.
• Facility for admitting Patients (providing beds, nursing, medicines, etc.)

Various operational works that are done in a Hospital are:-

• Recording information about the Patients that come.


• Generating bills.
• Recording information related to diagnosis given to Patients.
• Keeping information about various diseases and medicines available to cure them.

These are the various jobs that need to be done in a Hospital by the operational staff and Doctors. All these
works are done on papers.
The work is done as follows:-

• Information about Patients is done by just writing the Patients name, age and gender. Whenever
the Patient comes up his information is stored freshly.
• Bills are generated by recording price for each facility provided to Patient on a separate sheet and
at last they all are summed up.
• Diagnosis information to patients is generally recorded on the document, which contains Patient
information. It is destroyed after some time period to decrease the paper load in the office.

All this work is done manually by the receptionist and other operational staff and lot of papers are needed
to be handled and taken care of. Doctors have to remember various medicines available for diagnosis and
sometimes miss better alternatives as they can’t remember them at that time.

3.3 User Characteristics:

Every user should be:

• Comfortable of working with computer.


• Better to have knowledge in medical field.
• He must also have basic knowledge of English too.

3.5 Constraints:

• GUI is only in English.


• Login and password is used for identification of user and there is no facility for guest.

3.6 Definition of Problem:

Problems with conventional system


1. Lack of immediate retrievals: - The information is very difficult to retrieve and to find particular
information E.g. - To find out about the patient’s history, the user has to go through various registers. This
results in inconvenience and wastage of time.

2. Lack of immediate information storage: - The information generated by various transactions takes
time and efforts to be stored at right place.

3. Lack of prompt updating: - Various changes to information like patient details or immunization details
of child are difficult to make as paper work is involved.

4. Error prone manual calculation: - Manual calculations are error prone and take a lot of time this may
result in incorrect information. For example: calculation of patient’s bill based on various treatments.

5. Preparation of accurate and prompt reports: - This becomes a difficult task as information is difficult
to collect from various registers.

3.7 Alternative Solutions:

1. Improved Manual System: - One of the alternative solutions is the improvement of the manual system.
Anything, which can be done by using automated methods, can be done manually. But the question arises
how to perform thing manually in a sound manner. Following are some suggestions, which can be useful in
the manual system.

A more sophisticate register maintenance for various patient Information, doctor diary and a good system
for writing bill amount employees and stock availed for the customers can be maintained at central place.

Adequate staff may be maintained so that updations are made at the very moment at the same time. Proper
person for proper work should be made responsible so that a better efficiency could be achieved. This
needs a lot of work force.

2. Batch System: - Another alternative solution can be used of computer based batch system for
maintaining the information regarding purchase details, customers and employees. A batch system refers to
a system in which data is processed in a periodical basis.
The batch system is able to achieve most of the goals and sub goals. But a batch system data is processed in
sequential basis. Therefore batch system is not suggested.

3. Online System: - This system provides online storage/ updations and retrieval facility. This system
promises very less or no paper work and also provides help to doctor and operational staff.

In this system everything is stored electronically so very less amount of paper work is required and
information can be retrieved very easily without searching here and there into registers. This system is been
discussed here.

4. Feasibility Study:

“FEASIBILITY STUDY” is a test of system proposal according to its workability, impact of the
organization, ability to meet needs and effective use of the resources. It focuses on these major questions:
1. What are the user’s demonstrable needs and how does a candidate system meet them?
2. What resources are available for given candidate system?
3. What are the likely impacts of the candidate system on the organization?
4. Whether it is worth to solve the problem?

During feasibility analysis for this project, following primary areas of interest are to be considered.
Investigation and generating ideas about a new system does this.

Steps in feasibility analysis

Eight steps involved in the feasibility analysis are:

• Form a project team and appoint a project leader.


• Prepare system flowcharts.
• Enumerate potential proposed system.
• Define and identify characteristics of proposed system.
• Determine and evaluate performance and cost effective of each proposed system.
• Weight system performance and cost data.
• Select the best-proposed system.
• Prepare and report final project directive to management.

4.1 Technical Feasibility:

A study of resource availability that may affect the ability to achieve an acceptable system. This evaluation
determines whether the technology needed for the proposed system is available or not.

• Can the work for the project be done with current equipment existing software technology & available
personal?
• Can the system be upgraded if developed?
• If new technology is needed then what can be developed?
This is concerned with specifying equipment and software that will successfully satisfy the user
requirement. The technical needs of the system may include:

Front-end and back-end selection

An important issue for the development of a project is the selection of suitable front-end and back-end.
When we decided to develop the project we went through an extensive study to determine the most suitable
platform that suits the needs of the organization as well as helps in development of the project.

The aspects of our study included the following factors.

Front-end selection:
1. It must have a graphical user interface that assists employees that are not from IT background.
2. Scalability and extensibility.
3. Flexibility.
4. Robustness.
5. According to the organization requirement and the culture.
6. Must provide excellent reporting features with good printing support.
7. Platform independent.
8. Easy to debug and maintain.
9. Event driven programming facility.

Back-end Selection:

1. Multiple user support.


2. Efficient data handling.
3. Provide inherent features for security.
4. Efficient data retrieval and maintenance.
5. Stored procedures.
6. Popularity.
7. Operating System compatible.
8. Easy to install.
9. Various drivers must be available.

The technical feasibility is frequently the most difficult area encountered at this stage. It is essential that the
process of analysis and definition be conducted in parallel with an assessment to technical feasibility. It
centers on the existing computer system (hardware, software etc.) and to what extent it can support the
proposed system.

4.2 Economical Feasibility:

Economic justification is generally the “Bottom Line” consideration for most systems. Economic
justification includes a broad range of concerns that includes cost benefit analysis. In this we weight the
cost and the benefits associated with the candidate system and if it suits the basic purpose of the
organization i.e. profit making, the project is making to the analysis and design phase.

The financial and the economic questions during the preliminary investigation are verified to estimate the
following:

• The cost to conduct a full system investigation.


• The cost of hardware and software for the class of application being considered.
• The benefits in the form of reduced cost.
• The proposed system will give the minute information, as a result the performance is improved
which in turn may be expected to provide increased profits.
• This feasibility checks whether the system can be developed with the available funds. The Patient
Billing System does not require enormous amount of money to be developed. This can be done
economically if planned judicially, so it is economically feasible. The cost of project depends
upon the number of man-hours required.

4.3 Operational Feasibility:

It is mainly related to human organizations and political aspects. The points to be considered are:

• What changes will be brought with the system?


• What organization structures are disturbed?
• What new skills will be required? Do the existing staff members
have these skills? If not, can they be trained in due course of
time?
The system is operationally feasible as it very easy for the End users to operate it. It only needs basic
information about Windows platform.

4.4) Schedule Feasibility:

Time evaluation is the most important consideration in the development of project. The time schedule
required for the developed of this project is very important since more development time effect machine
time, cost and cause delay in the development of other systems.

A reliable Patient Billing System can be developed in the considerable amount of time.

5. System Requirement Specification:

Patient Billing Software basic requirement is that it should maintain the record of patient and information
regarding the bills as well as the treatment they have got in that hospital. The task should be divided among
the users according to their classification.

5.1 Definitions, Acronyms & Abbreviations:

(a) Patient Register (PR):

The Patient Register contains information related to each patient. Whenever a new patient is admitted in the
hospital, an entry is made in Patient Register. The Registration-No is automatically generated in the form
and so is unique for each patient. The Patient’s name i.e. First name and Last name cannot be left Blank,
similarly Address, City is automatically formatted and cannot be left blank. The date of admission is
automatically taken as current date by the system.

(b) Bed Allocation Register (BAR):

The Bed Allocation Register contains details regarding a patient’s bed allocation viz. Reg-no, Patient’s
name, bed-no, bed-charges, advance etc. The Registration-no once entered is checked for in the Patient
Register, and only if the NO is found the record is entered into the Bed Allocation Register. The bed to be
allocated is checked for availability.

(c) Medicine Detail Register (MDR):

The Medicine Detail Register is used to display all the medicines currently in stock of the hospital.
Whenever a patient requires any medicine, it is issued against a bill in name of patient.

(d) Bill Register:

This register includes the bill printing and display options. A registration number is entered to generate bill,
which is first checked in patient register for existence.

(e) Reception:

The Administrator will create different bills for the patient. The system users will be created and will be
assigned with the different roles. More than one patient can be granted or revoked from the system.

(f) Patient Admission:


Responsible for checking In and checking Out of the patient.

(g) See room Status:

Checking the status of the room to be allotted.

(h) Patient:

Play the role of the person whose bill has to be generated.

(i) Payment of bill:

Records the details of the final bill which he has to pay.

(j) Admission:

Record and details of the patient at the time of Check in.

(k) Take medicine:

Details of the prescription.

(l) Room Transfer:

Details of the different rooms in which the patient has to be transferred for different operations.

(m) Doctor:

List all the details of the allotted patients.

(n) Room Status:

Check the status of the room to be allotted.

5.2 Use Case Model Survey:

USE CASE MODEL


5.3 Data Dictionary:

Table & Data Structure:

• The Tables used in the modules are as follows:-

Patient Register

Attribute Date Type Length


RegNo Varchar 10
Name Varchar 25
Fname Varchar 25
Address Varchar 35
Age Number 2
Sex Varchar 1
Phone Number 10
Mobile Number 10
DoA Date
Timein Date
CaseType Varchar 25
c_no Number 5

Bed Detail Register

Attribute Date Type Length


BedType Varchar 20
Charge Number 7,2
No_of_Beds Number 5
BedNo Register

Attribute Date Type Length


BedType varchar(10), Varchar 10
BedNo varchar(20) Number 20

Case Detail Register

Attribute Date Type Length


CaseType varchar(25), Varchar 25
SurFee number(5), Number 5
ConsulFee number(5), Number 5
Dname varchar(25) Varchar 25

Bed Allocation Register

Attribute Date Type Length


RegNo varchar(10) Varchar 10
Name varchar(25), Varchar 25
Fname varchar(25), Varchar 25
Address varchar(35), Varchar 35
BedNo varchar(25), Varchar 25
Charge number(10), number 10
Avail varchar(1), Varchar 1
Advance number(10) Number 10

Extra Charges Register

Attribute Date Type Length


RegNo Varchar 10
Name Varchar 25
Room Number 10
Investigate Number 10
Xray Number 10
Other1 Number 10
Other2 Number 10
Total Number 10

Bill Register

Attribute Date Type Length


RegNo Varchar 10
Name Varchar 25
DoA Date
Timein Date
DoD Date
Timeout Date
BedNo Varchar 25
BedType Varchar 35
Charge Number 10
CaseType Varchar 25
ConsulFee Number 10
SurFee Number 10
Dname Varchar 25
OTCharge Number 5
NurCharge Number 5
Other Number 5
Total Number 10

PasswordMaster

Attribute Date Type Length


username Varchar 25
password Varchar 25
right Varchar 25

Assumptions and Dependencies:

• All the records of patient have to be provided.


• Administrator is created in the system already.
• Roles and tasks are predefined.

5.4 Use Case Diagrams & Activity Diagrams:

5.4.1 Use Case 1:


Use Case Reports:

Use cases1 related to reception and authentication login.

Primary Actor: Administrator


Description: Login is for authentication. It ensures that no fraud user can access.
Pre Condition: User should have an account.

Main Scenario:

1. Start the application. User prompted for login and password.


2. User gives the login and password.
3. System does authentication.

ACTIVITY CASE 1
SELECT

N
e Go To Patient
EXIST
s Admission

Y
e
s
Modify Record

View Record

5.4.2 Use Case 2:


Use Case Reports:

Use case 2 related to patient billing.

Primary Actor: Administrator


Description: Ensures correct billing details and patient billing details
Pre Condition: User should be logged in

Main Scenario:

1. Start the billing application


2. User gives the patient details.
3. System checks for records.

ACTIVITY CASE 2
SELECT
PATIENT

N
e Go To Patient
EXIST
s Admission

Y
e
s
Modify Bill

Generate Bill
5.4.3 USE CASE 3:

Use Case Reports:

Use case 3 related to new admission.

Primary Actor: Admission


Description: After logging in user can create new patient records
Pre Condition: user should be logged in

Main Scenario:

1. Start the application.


2. User gives details for new patient.

ACTIVITY CASE 3
SELECT
PATIENT

Y
e
EXIST
s Go To Stop

N
e
s
Create New
Patient Record

5.4.4 USE CASE 4:


New Bed

Edit Details

Bed Detail

View Bed Details

Use Case Reports:

Use Case 4 related to bed details.

Primary Actor: Administrator


Description: Updation of bed details
Pre Condition: user should be logged in

Main Scenario:

1. Start the application.


2. User gives the bed details.

ACTIVITY CASE 4
SELECT BED
DETAILS

N
e
EXIST
s Add the Details

Y
e
s
Modify Details

Generate Final
details

E-R Diagram
DFD Diagram
6. SYSTEM IMPLEMENTATION:

• PLATFORM USED:

6.1 About JAVA:


Java refers to a number of computer software products and specifications from Sun Microsystems that
together provide a system for developing application software and deploying it in a cross-platform
environment. Java is used in a wide variety of computing platforms from embedded devices and mobile
phones on the low end, to enterprise servers and supercomputers on the high end. Java is nearly ubiquitous
in mobile phones, Web servers and enterprise applications, and while less common on desktop computers;
Java applets are often used to provide improved functionality while browsing the World Wide Web.

Writing in the Java programming language is the primary way to produce code that will be deployed as
Java bytecode, though there are compilers available for other languages such as JavaScript, Python and
Ruby, and a native Java scripting language called Groovy. Java syntax borrows heavily from C and C++
but it eliminates certain low-level constructs such as pointers and has a very simple memory model where
every object is allocated on the heap and all variables of object types are references. Memory management
is handled through integrated automatic garbage collection performed by the Java Virtual Machine (JVM).

On 13 November 2006, Sun Microsystems made the bulk of its implementation of Java available under the
GNU General Public License, although there are still a few parts distributed as precompiled binaries due to
intellectual property restrictions.

An edition of the Java platform is the name for a bundle of related programs, or platform, from Sun which
allow for developing and running programs written in the Java programming language.

The platform is not specific to any one processor or operating system, but rather an execution engine
(called a virtual machine) and a compiler with a set of standard libraries that are implemented for various
hardware and operating systems so that Java programs can run identically on all of them.

• Java Card: refers to a technology that allows small Java-based applications (applets) to be run
securely on smart cards and similar small memory footprint devices.

• Java ME (Micro Edition): Specifies several different sets of libraries (known as profiles) for
devices which are sufficiently limited that supplying the full set of Java libraries would take up
unacceptably large amounts of storage.

• Java SE (Standard Edition): For general purpose use on desktop PCs, servers and similar devices.

• Java EE (Enterprise Edition): Java SE plus various APIs useful for multi-tier client-server
enterprise applications.

As of September 2008, the current version of the Java Platform is specified as either 1.6.0 or 6 (both refer
to the same version). Version 6 is the product version, while 1.6.0 is the developer version.

The Java Platform consists of several programs, each of which provides a distinct portion of its overall
capabilities. For example, the Java compiler, which converts Java source code into Java bytecode (an
intermediate language for the Java Virtual Machine (JVM)), is provided as part of the Java Development
Kit (JDK). The Java Runtime Environment (JRE), complementing the JVM with a just-in-time (JIT)
compiler, converts intermediate bytecode into native machine code on the fly. Also supplied are extensive
libraries (pre-compiled in There are several other components, some available only in certain editions.

The essential components in the platform are the Java language compiler, the libraries, and the runtime
environment in which Java intermediate bytecode "executes" according to the rules laid out in the virtual
machine specification.

6.2 About Eclipse:


ECLIPSE is a multi-language software development platform comprising an IDE and a plug-in system to
extend it. It is written primarily in Java and is used to develop applications in this language and, by means
of the various plug-INS, in other languages as well—C/C++, COBOL, Python, Perl, PHP and more.

The initial codebase originated from VisualAge. In its default form it is meant for Java developers,
consisting of the Java Development Tools (JDT). Users can extend its capabilities by installing plug-ins
written for the Eclipse software framework, such as development toolkits for other programming
languages, and can write and contribute their own plug-in modules. Language packs provide translations
into over a dozen natural languages.

Architecture:

Eclipse employs plug-ins in order to provide all of its functionality on top of (and including) the runtime
system, in contrast to some other applications where functionality is typically hard coded. The runtime
system of Eclipse is based on Equinox, an OSGi standard compliant implementation.

This plug-in mechanism is a lightweight software componentry framework. In addition to allowing Eclipse
to be extended using other programming languages such as C and Python, the plug-in framework allows
Eclipse to work with typesetting languages like LaTeX, networking applications such as telnet, and
database management systems. The plug-in architecture supports writing any desired extension to the
environment, such as for configuration management. Java and CVS support is provided in the Eclipse
SDK.

The key to the seamless integration (but not of seamless interoperability) of tools with Eclipse is the plug-
in. With the exception of a small run-time kernel, everything in Eclipse is a plug-in.
This means that every plug-in developed integrates with Eclipse in exactly the same way as other plug-ins;
in this respect, all features are created equal.
Eclipse provides plug-ins for a wide variety of features, some of which are through third parties using both
free and commercial models. Examples of plug-ins include UML plug-in for Sequence and other UML
diagrams, plug-in for Database explorer, and many others.

The Eclipse SDK includes the Eclipse Java Development Tools, offering an IDE with a built-in incremental
Java compiler and a full model of the Java source files. This allows for advanced refactoring techniques
and code analysis. The IDE also makes use of a workspace, in this case a set of metadata over a flat file
space allowing external file modifications as long as the corresponding workspace "resource" is refreshed
afterwards. The Visual Editor project (discontinued since June 30, 2006) allows interfaces to be created
interactively, thus allowing Eclipse to be used as a RAD tool.

Eclipse's widgets are implemented by a widget toolkit for Java called SWT, unlike most Java applications,
which use the Java standard Abstract Window Toolkit (AWT) or Swing. Eclipse's user interface also uses
an intermediate GUI layer called JFace, which simplifies the construction of applications based on SWT.

Rich Client Platform:

Eclipse provides the Eclipse Rich Client Platform (RCP) for developing general purpose applications. The
following components constitute the rich client platform:

• Equinox OSGi – a standard bundling framework


• Core platform – boot Eclipse, run plug-ins
• Standard Widget Toolkit (SWT) – a portable widget toolkit
• JFace – viewer classes to bring model view controller programming to SWT, file buffers, text
handling, text editors.
• Eclipse Workbench – views, editors, perspectives, wizards
6.3 About DB2 Server:

DB2 is one of IBM's families of relational database management system (RDBMS) software products
within IBM's broader Information Management Software line. Although there are different "editions" and
"versions" of DB2 which run on devices ranging from handhelds to mainframes, most often DB2 refers to
DB2 Enterprise Server Edition, which runs on Unix (AIX), Windows or Linux servers; or DB2 for z/OS.
DB2 powers the different IBM InfoSphere Warehouse editions. Alongside DB2 is another RDBMS:
Informix, which was acquired by IBM in 2001.

DB2 is available in several "editions," or licensing arrangements. By opting for a reduced-feature "edition,"
IBM allows customers to avoid paying for database features which they do not need. Sample editions
include the Express, Workgroup, and Enterprise Edition. The most sophisticated edition for
Linux/UNIX/Windows is DB2 Data Warehouse Enterprise Edition or DB2 for short. This edition is
intended for mixed workload (OLTP and data warehousing) or business intelligence (BI) implementations.
DB2 DWE includes several "BI" features such as ETL, data mining, OLAP acceleration, and in-line
analytics.

DB2 for z/OS is available under its own licensing terms. Starting with Version 8, IBM brought DB2 for
z/OS and for the other platforms into much closer alignment. (Previously there were significant differences
in SQL vocabularies, for example.) DB2 for z/OS has some exclusives — notably Multi-Level Security
(MLS), extremely large table sizes, and hardware-assisted compression — owing to its special environment
and the demanding needs of its customers. DB2 for z/OS has always been known for its leading OLTP
performance and capabilities, and for its reliability and availability to support mission-critical business
operations, but the z/OS version is now starting to acquire BI features as well, such as materialized query
tables (MQTs) and star schema. Oracle's CEO Larry Ellison commented that DB2 for z/OS is the one
competitive database he respects and admires.

On January 30, 2006, IBM released a no-charge version of DB2 called DB2 Express-C. This was an
expected response to the recently announced free versions of Oracle 10g and Microsoft SQL Server. Unlike
Microsoft or Oracle's free editions, Express-C has no limit on number of users or on database size. While
versions 8.2 and 9.1 of DB2 Express-C imposed hardware limits on the server on which it ran, DB2
Express-C 9.5 can run on Windows and Linux machines of any size, but the database engine will not utilize
more than two CPU cores and 2GB RAM. In 2007, IBM introduced a yearly support subscription called the
Fixed Term License (FTL), which offers a year of telephone support for Express-C. Purchasing the FTL
also allows the DB2 Express-C engine to use up to four CPU cores and 4GB RAM.

Users of DB2 Express-C who don't purchase an FTL subscription can receive support and assistance on a
free, public web forum staffed by IBM technicians and other DB2 users.
DB2 can be administered from either the command-line or a GUI. The command-line interface requires
more knowledge of the product but can be more easily scripted and automated. The GUI is a multi-platform
Java client that contains a variety of wizards suitable for novice users. DB2 supports both SQL and
XQuery. DB2 has native implementation of XML data storage, where XML data is stored as XML (not as
relational data or CLOB data) for faster access using XQuery.
Program Code

mainpage.java

package patient;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
//import java.sql.Connection;
//import java.sql.DriverManager;
//import java.sql.PreparedStatement;
//import java.sql.ResultSet;
//import java.sql.Statement;
//import java.sql.ResultSet;
//import java.sql.SQLException;
//import java.sql.Statement;
//import java.util.ArrayList;
//import java.sql.*;
import javax.swing.JButton;
import javax.swing.JFrame;
//import javax.swing.JLabel;
//import javax.swing.JOptionPane;
//import javax.swing.JTextField;

public class mainpage implements ActionListener


{

// private Connection con;


JFrame appFrame;

JButton
jbnadddoctor,jbneditdoctor,jbnmedicine,jbneditmedicine,jbnreg,jbneditreg,jbnbloodbank,jbneditbl
oodbank,jbndepartment,jbneditdepartment,jbndiet,jbneditdiet,jbnschedule,jbneditschedule,jbndrug
master,jbneditdrugmaster,jbnlab,jbneditlab,jbnward,jbneditward,jbnpatientroom,jbneditpatientroo
m,jbntreatment,jbnedittreatment,jbnroom,jbneditroom,jbnroomtransfer,jbnpatientbill,jbnback,jbn
exit;

Container cPane;
public static void main(String args[]){
new mainpage();
}
public mainpage()
{
createGUI();
}
public void createGUI(){
/*Create a frame, get its contentpane and set layout*/
appFrame = new JFrame("mainpage");

cPane = appFrame.getContentPane();
cPane.setLayout(new GridBagLayout());

//Arrange components on contentPane and set Action Listeners to each JButton


arrangeComponents();

appFrame.setSize(1200,1200);
appFrame.setResizable(false);
appFrame.setVisible(true);
appFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void arrangeComponents(){
jbnadddoctor = new JButton("ADD NEW DOCTORS ENTRY");
jbneditdoctor = new JButton("EDIT DOCTORS ENTRY");
jbnmedicine = new JButton("NEW MEDICINE ENTRY");
jbneditmedicine = new JButton("EDIT MEDICINE ENTRY");
jbnreg = new JButton("REGISTRATION OF PATIENT");
jbneditreg = new JButton("EDIT REGISTRATION OF PATIENT");
jbnbloodbank = new JButton(" BLOOD BANK ");
jbneditbloodbank = new JButton("EDIT BLOOD BANK");
jbndepartment = new JButton(" DEPARTMENT ");
jbneditdepartment = new JButton("EDIT DEPARTMENT");
jbndiet = new JButton(" DIET ");
jbneditdiet = new JButton(" EDIT DIET ");
jbndrugmaster = new JButton(" DRUGMASTER ");
jbneditdrugmaster = new JButton("EDIT DRUGMASTER");
jbnlab = new JButton(" LAB ENTRY ");
jbneditlab = new JButton("EDIT LAB ENTRY ");
jbnward = new JButton(" WARD ENTRY ");
jbneditward = new JButton("EDIT WARD ENTRY");
jbnpatientroom = new JButton( "Patient ROOM " );
jbneditpatientroom = new JButton("EDIT PATIENT ROOM");
jbntreatment = new JButton(" DAILY CHARGES " );
jbnedittreatment = new JButton(" EDIT CHARGES " );
jbnroom = new JButton(" ROOMS ENTRY " );
jbneditroom = new JButton("EDIT ROOMS ENTRY" );
jbnroomtransfer = new JButton(" ROOM TRANSFER ");
jbnpatientbill = new JButton(" PATIENT BILL ");
jbnback = new JButton(" BACK " );
jbnexit = new JButton(" EXIT ");

/*add all initiaeized components to the container*/


GridBagConstraints gridBagConstraintsx01 = new GridBagConstraints();
gridBagConstraintsx01.gridx = 0;
gridBagConstraintsx01.gridy = 0;
gridBagConstraintsx01.insets = new Insets(5,5,5,5);
cPane.add(jbnadddoctor, gridBagConstraintsx01);

GridBagConstraints gridBagConstraintsx02 = new GridBagConstraints();


gridBagConstraintsx02.gridx = 1;
gridBagConstraintsx02.insets = new Insets(5,5,5,5);
gridBagConstraintsx02.gridy = 0;
//gridBagConstraintsx02.gridwidth = 2;
gridBagConstraintsx02.fill = GridBagConstraints.BOTH;
cPane.add(jbneditdoctor, gridBagConstraintsx02);

GridBagConstraints gridBagConstraintsx03 = new GridBagConstraints();


gridBagConstraintsx03.gridx = 2;
gridBagConstraintsx03.gridy = 0;
gridBagConstraintsx03.insets = new Insets(5,5,5,5);
cPane.add(jbnmedicine, gridBagConstraintsx03);

GridBagConstraints gridBagConstraintsx04 = new GridBagConstraints();


gridBagConstraintsx04.gridx = 3;
gridBagConstraintsx04.insets = new Insets(5,5,5,5);
gridBagConstraintsx04.gridy = 0;
//gridBagConstraintsx02.gridwidth = 2;
gridBagConstraintsx04.fill = GridBagConstraints.BOTH;
cPane.add(jbneditmedicine, gridBagConstraintsx04);

GridBagConstraints gridBagConstraintsx05 = new GridBagConstraints();


gridBagConstraintsx05.gridx = 0;
gridBagConstraintsx05.gridy = 1;
gridBagConstraintsx05.insets = new Insets(5,5,5,5);
cPane.add(jbnreg, gridBagConstraintsx05);
GridBagConstraints gridBagConstraintsx06 = new GridBagConstraints();
gridBagConstraintsx06.gridx = 1;
gridBagConstraintsx06.insets = new Insets(5,5,5,5);
gridBagConstraintsx06.gridy = 1;
//gridBagConstraintsx.gridwidth = 2;
gridBagConstraintsx06.fill = GridBagConstraints.BOTH;
cPane.add(jbneditreg, gridBagConstraintsx06);

GridBagConstraints gridBagConstraintsx07 = new GridBagConstraints();


gridBagConstraintsx07.gridx = 2;
gridBagConstraintsx07.gridy = 1;
gridBagConstraintsx07.insets = new Insets(5,5,5,5);
cPane.add(jbnbloodbank, gridBagConstraintsx07);

GridBagConstraints gridBagConstraintsx08 = new GridBagConstraints();


gridBagConstraintsx08.gridx = 3;
gridBagConstraintsx08.insets = new Insets(5,5,5,5);
gridBagConstraintsx08.gridy = 1;
//gridBagConstraintsx.gridwidth = 2;
gridBagConstraintsx08.fill = GridBagConstraints.BOTH;
cPane.add(jbneditbloodbank, gridBagConstraintsx08);

GridBagConstraints gridBagConstraintsx09 = new GridBagConstraints();


gridBagConstraintsx09.gridx = 0;
gridBagConstraintsx09.gridy = 2;
gridBagConstraintsx09.insets = new Insets(5,5,5,5);
cPane.add(jbndepartment, gridBagConstraintsx09);

GridBagConstraints gridBagConstraintsx10 = new GridBagConstraints();


gridBagConstraintsx10.gridx = 1;
gridBagConstraintsx10.insets = new Insets(5,5,5,5);
gridBagConstraintsx10.gridy = 2;
//gridBagConstraintsx.gridwidth = 2;
gridBagConstraintsx10.fill = GridBagConstraints.BOTH;
cPane.add(jbneditdepartment, gridBagConstraintsx10);

GridBagConstraints gridBagConstraintsx11 = new GridBagConstraints();


gridBagConstraintsx11.gridx = 2;
gridBagConstraintsx11.gridy = 2;
gridBagConstraintsx11.insets = new Insets(5,5,5,5);
cPane.add(jbndiet, gridBagConstraintsx11);

GridBagConstraints gridBagConstraintsx12 = new GridBagConstraints();


gridBagConstraintsx12.gridx = 3;
gridBagConstraintsx12.insets = new Insets(5,5,5,5);
gridBagConstraintsx12.gridy = 2;
//gridBagConstraintsx.gridwidth = 2;
gridBagConstraintsx12.fill = GridBagConstraints.BOTH;
cPane.add(jbneditdiet, gridBagConstraintsx12);

GridBagConstraints gridBagConstraintsx13 = new GridBagConstraints();


gridBagConstraintsx13.gridx = 0;
gridBagConstraintsx13.gridy = 3;
gridBagConstraintsx13.insets = new Insets(5,5,5,5);
cPane.add(jbndrugmaster, gridBagConstraintsx13);

GridBagConstraints gridBagConstraintsx14 = new GridBagConstraints();


gridBagConstraintsx14.gridx = 1;
gridBagConstraintsx14.insets = new Insets(5,5,5,5);
gridBagConstraintsx14.gridy = 3;
//gridBagConstraintsx.gridwidth = 2;
gridBagConstraintsx14.fill = GridBagConstraints.BOTH;
cPane.add(jbneditdrugmaster, gridBagConstraintsx14);

GridBagConstraints gridBagConstraintsx15 = new GridBagConstraints();


gridBagConstraintsx15.gridx = 2;
gridBagConstraintsx15.gridy = 3;
gridBagConstraintsx15.insets = new Insets(5,5,5,5);
cPane.add(jbnlab ,gridBagConstraintsx15);

GridBagConstraints gridBagConstraintsx16 = new GridBagConstraints();


gridBagConstraintsx16.gridx = 3;
gridBagConstraintsx16.insets = new Insets(5,5,5,5);
gridBagConstraintsx16.gridy = 3;
//gridBagConstraintsx.gridwidth = 2;
gridBagConstraintsx16.fill = GridBagConstraints.BOTH;
cPane.add(jbneditlab, gridBagConstraintsx16);

GridBagConstraints gridBagConstraintsx17 = new GridBagConstraints();


gridBagConstraintsx17.gridx = 0;
gridBagConstraintsx17.gridy = 4;
gridBagConstraintsx17.insets = new Insets(5,5,5,5);
cPane.add(jbnward, gridBagConstraintsx17);

GridBagConstraints gridBagConstraintsx18 = new GridBagConstraints();


gridBagConstraintsx18.gridx = 1;
gridBagConstraintsx18.insets = new Insets(5,5,5,5);
gridBagConstraintsx18.gridy = 4;
//gridBagConstraintsx.gridwidth = 2;
gridBagConstraintsx18.fill = GridBagConstraints.BOTH;
cPane.add(jbneditward, gridBagConstraintsx18);

GridBagConstraints gridBagConstraintsx19 = new GridBagConstraints();


gridBagConstraintsx19.gridx = 2;
gridBagConstraintsx19.gridy = 4;
gridBagConstraintsx19.insets = new Insets(5,5,5,5);
cPane.add(jbnpatientroom, gridBagConstraintsx19);

GridBagConstraints gridBagConstraintsx20 = new GridBagConstraints();


gridBagConstraintsx20.gridx = 3;
gridBagConstraintsx20.insets = new Insets(5,5,5,5);
gridBagConstraintsx20.gridy = 4;
//gridBagConstraintsx.gridwidth = 2;
gridBagConstraintsx20.fill = GridBagConstraints.BOTH;
cPane.add(jbneditpatientroom, gridBagConstraintsx20);

GridBagConstraints gridBagConstraintsx21 = new GridBagConstraints();


gridBagConstraintsx21.gridx = 0;
gridBagConstraintsx21.gridy = 5;
gridBagConstraintsx21.insets = new Insets(5,5,5,5);
cPane.add(jbntreatment, gridBagConstraintsx21);

GridBagConstraints gridBagConstraintsx22 = new GridBagConstraints();


gridBagConstraintsx22.gridx = 1;
gridBagConstraintsx22.insets = new Insets(5,5,5,5);
gridBagConstraintsx22.gridy = 5;
//gridBagConstraintsx.gridwidth = 2;
gridBagConstraintsx22.fill = GridBagConstraints.BOTH;
cPane.add(jbnedittreatment, gridBagConstraintsx22);

GridBagConstraints gridBagConstraintsx23 = new GridBagConstraints();


gridBagConstraintsx23.gridx = 2;
gridBagConstraintsx23.gridy =5;
gridBagConstraintsx23.insets = new Insets(5,5,5,5);
cPane.add(jbnroom, gridBagConstraintsx23);

GridBagConstraints gridBagConstraintsx24 = new GridBagConstraints();


gridBagConstraintsx24.gridx = 3;
gridBagConstraintsx24.insets = new Insets(5,5,5,5);
gridBagConstraintsx24.gridy = 5;
//gridBagConstraintsx.gridwidth = 2;
gridBagConstraintsx24.fill = GridBagConstraints.BOTH;
cPane.add(jbneditroom, gridBagConstraintsx24);

GridBagConstraints gridBagConstraintsx25 = new GridBagConstraints();


gridBagConstraintsx25.gridx = 0;
gridBagConstraintsx25.gridy = 6;
gridBagConstraintsx25.insets = new Insets(5,5,5,5);
cPane.add(jbnroomtransfer, gridBagConstraintsx25);

GridBagConstraints gridBagConstraintsx26 = new GridBagConstraints();


gridBagConstraintsx26.gridx = 1;
gridBagConstraintsx26.insets = new Insets(5,5,5,5);
gridBagConstraintsx26.gridy = 6;
//gridBagConstraintsx.gridwidth = 2;
gridBagConstraintsx26.fill = GridBagConstraints.BOTH;
cPane.add(jbnpatientbill, gridBagConstraintsx26);

GridBagConstraints gridBagConstraintsx27 = new GridBagConstraints();


gridBagConstraintsx27.gridx = 2;
gridBagConstraintsx27.gridy = 6;
gridBagConstraintsx27.insets = new Insets(5,5,5,5);
cPane.add(jbnback, gridBagConstraintsx27);

GridBagConstraints gridBagConstraintsx28 = new GridBagConstraints();


gridBagConstraintsx28.gridx = 3;
gridBagConstraintsx28.insets = new Insets(5,5,5,5);
gridBagConstraintsx28.gridy = 6;
//gridBagConstraintsx.gridwidth = 2;
gridBagConstraintsx28.fill = GridBagConstraints.BOTH;
cPane.add(jbnexit, gridBagConstraintsx28);

jbnadddoctor.addActionListener(this);
jbneditdoctor.addActionListener(this);
jbnmedicine.addActionListener(this);
jbneditmedicine.addActionListener(this);
jbnreg.addActionListener(this);
jbneditreg.addActionListener(this);
jbnbloodbank.addActionListener(this);
jbneditbloodbank.addActionListener(this);
jbndepartment.addActionListener(this);
jbneditdepartment.addActionListener(this);
jbndiet.addActionListener(this);
jbneditdiet.addActionListener(this);
jbndrugmaster.addActionListener(this);
jbneditdrugmaster.addActionListener(this);
jbnlab.addActionListener(this);
jbneditlab.addActionListener(this);
jbnward.addActionListener(this);
jbneditward.addActionListener(this);
jbnpatientroom.addActionListener(this);
jbneditpatientroom.addActionListener(this);
jbntreatment.addActionListener(this);
jbnedittreatment.addActionListener(this);
jbnroom.addActionListener(this);
jbneditroom.addActionListener(this);
jbnroomtransfer.addActionListener(this);
jbneditward.addActionListener(this);
jbnpatientbill.addActionListener(this);
jbnback.addActionListener(this);
jbnexit.addActionListener(this);
}
public void actionPerformed (ActionEvent e)
{
if (e.getSource() == jbnadddoctor){
new docmaster();
}
else if (e.getSource() == jbneditdoctor){
new docmaster1();
}
else if (e.getSource() == jbnmedicine){
new medicines();
}
else if (e.getSource() == jbneditmedicine){
new medicines1();
}
else if (e.getSource() == jbnreg){
new registration();
}
else if (e.getSource() == jbneditreg){
new registration1();
}
else if (e.getSource() == jbnbloodbank){
new bloodbank();
}
else if (e.getSource() == jbneditbloodbank){
new bloodbank1();
}
else if (e.getSource() == jbndepartment){
new departement();
}
else if (e.getSource() == jbneditdepartment){
new department1();
}
else if (e.getSource() == jbndiet){
new diet();
}
else if (e.getSource() == jbneditdiet){
new diet1();
}
else if (e.getSource() == jbndrugmaster){
new drugmaster();
}
else if (e.getSource() == jbneditdrugmaster){
new drugmaster1();
}
else if (e.getSource() == jbnlab){
new lab();
}
else if (e.getSource() == jbneditlab){
new lab1();
}
else if (e.getSource() == jbnward){
new wardmaster();
}
else if (e.getSource() == jbneditward){
new wa();
}
else if (e.getSource() == jbnpatientroom){
new patientroom();
}
else if (e.getSource() == jbneditpatientroom){
new editpatientroom();
}
else if (e.getSource() == jbntreatment){
new treatment();
}
else if (e.getSource() == jbnedittreatment){
new edittreatment();
}
else if (e.getSource() == jbnroom){
new room();
}
else if (e.getSource() == jbneditroom){
new editroom();
}
else if (e.getSource() == jbnroomtransfer){
new roomtransfer();
}
else if (e.getSource() == jbnpatientbill){
new patientbilling();
}
else if (e.getSource() == jbnback){
new loginenter();
}
else if (e.getSource() == jbnexit){
System.exit(0);
}}
// Save the Person into the Address Book
}

loginenter.java

package patient;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
//import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
//import java.sql.ResultSet;
import java.sql.SQLException;
//import java.sql.Statement;
//import java.util.ArrayList;
//import java.sql.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
//import javax.swing.JOptionPane;
import javax.swing.*;

public class loginenter implements ActionListener


{
private Connection con;
JFrame appFrame;
JLabel jlbloginname, jlbpassword,hello;
JTextField jtfloginname;
JPasswordField jtfpassword;
JButton jbnsubmit , jbnClear,jbnexit;
String login,pass;
// JTextArea jTextArea1;

Container cPane;
public static void main(String args[]){
new loginenter();
}
public loginenter()
{
login="";
pass="";
createGUI();
}
public void createGUI(){
/*Create a frame, get its contentpane and set layout*/
appFrame = new JFrame("Login Page");

cPane = appFrame.getContentPane();
cPane.setLayout(new GridBagLayout());

//Arrange components on contentPane and set Action Listeners to each JButton


arrangeComponents();

appFrame.setSize(1200,1200);
appFrame.setResizable(false);
appFrame.setVisible(true);
appFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void arrangeComponents(){

hello =new JLabel("Hospital Billing Software");


hello.setFont(new java.awt.Font("Times New Roman", 0, 36));
hello.setText("PATIENT BILLING SOFTWARE");

jlbloginname = new JLabel("Login");


jlbpassword = new JLabel("Password");

//jTextArea1 = new javax.swing.JTextArea();

jtfloginname = new JTextField(20);

jtfpassword = new JPasswordField(20);

jbnsubmit = new JButton("Submit");


jbnClear = new JButton("Clear");
jbnexit = new JButton("Exit");

GridBagConstraints gridBagConstraintsx30 = new GridBagConstraints();


gridBagConstraintsx30.gridx = 0;
gridBagConstraintsx30.gridy = 1;
gridBagConstraintsx30.insets = new Insets(5,5,5,5);
cPane.add(hello, gridBagConstraintsx30);
/*add all initialized components to the container*/
GridBagConstraints gridBagConstraintsx01 = new GridBagConstraints();
gridBagConstraintsx01.gridx = 0;
gridBagConstraintsx01.gridy = 3;
gridBagConstraintsx01.insets = new Insets(5,5,5,5);
cPane.add(jlbloginname, gridBagConstraintsx01);

GridBagConstraints gridBagConstraintsx02 = new GridBagConstraints();


gridBagConstraintsx02.gridx = 1;
gridBagConstraintsx02.insets = new Insets(5,5,5,5);
gridBagConstraintsx02.gridy = 3;
gridBagConstraintsx02.gridwidth = 2;
gridBagConstraintsx02.fill = GridBagConstraints.BOTH;
cPane.add(jtfloginname, gridBagConstraintsx02);

GridBagConstraints gridBagConstraintsx03 = new GridBagConstraints();


gridBagConstraintsx03.gridx = 0;
gridBagConstraintsx03.insets = new Insets(5,5,5,5);
gridBagConstraintsx03.gridy = 4;
cPane.add(jlbpassword, gridBagConstraintsx03);

GridBagConstraints gridBagConstraintsx04 = new GridBagConstraints();


gridBagConstraintsx04.gridx = 1;
gridBagConstraintsx04.gridy = 4;
gridBagConstraintsx04.insets = new Insets(5,5,5,5);
gridBagConstraintsx04.gridwidth = 2;
gridBagConstraintsx04.fill = GridBagConstraints.BOTH;
cPane.add(jtfpassword, gridBagConstraintsx04);

// jComboBox1.addActionListener(this);

GridBagConstraints gridBagConstraintsx07 = new GridBagConstraints();


gridBagConstraintsx07.gridx = 0;
gridBagConstraintsx07.gridy = 5;
gridBagConstraintsx07.insets = new Insets(5,5,5,5);
cPane.add(jbnsubmit, gridBagConstraintsx07);

GridBagConstraints gridBagConstraintsx08 = new GridBagConstraints();


gridBagConstraintsx08.gridx = 1;
gridBagConstraintsx08.insets = new Insets(5,5,5,5);
gridBagConstraintsx08.gridy = 5;
cPane.add(jbnClear, gridBagConstraintsx08);

GridBagConstraints gridBagConstraintsx09 = new GridBagConstraints();


gridBagConstraintsx09.gridx = 2;
gridBagConstraintsx09.insets = new Insets(5,5,5,5);
gridBagConstraintsx09.gridy = 5;
cPane.add(jbnexit, gridBagConstraintsx09);

jbnsubmit.addActionListener(this);
jbnClear.addActionListener(this);
jbnexit.addActionListener(this);
}
void searchPerson()
{
// jtfloginname.setText(com);
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
try {
//JComboBox x=jComboBox1.getSelectedItem()

// jtfloginname.setText(com);
String sql = "SELECT * FROM login3 WHERE loginname= '"+
jtfloginname.getText() +"' and password= '"+ jtfpassword.getText() +"' ";
//jtfloginname.setText(sql);

// Create a prepared statement


Statement s = con.createStatement();

ResultSet rs = s.executeQuery(sql);
if(rs.next())
{
login = rs.getString("loginname");
pass= rs.getString("password");

new mainpage();
}
else
{
JOptionPane.showMessageDialog(null, "Wrong Entry");
}}
catch(Exception e){
System.out.println("D");
System.out.println(e);
jtfloginname.setText("problem");
}
//return personsList;
}
public void actionPerformed (ActionEvent e){
if (e.getSource () == jbnsubmit){
searchPerson();
}
else if (e.getSource() == jbnClear){
clear();
}
else if (e.getSource() == jbnexit){
System.exit(0);
}}
// submit the Person into the Address Book
public void clear(){
jtfloginname.setText("");
jtfpassword.setText("");
}}

Wardmaster.java

package patient;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
//import java.sql.ResultSet;
import java.sql.SQLException;
//import java.sql.Statement;
//import java.util.ArrayList;
//import java.sql.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

public class wardmaster implements ActionListener


{
private Connection con;
JFrame appFrame;

JLabel jlbwardno,jlbwardname, jlbwardincharge,jlbheadnurse,jlbnoofbeds,jlbaviablebeds;


JTextField jtfwardno,jtfwardname, jtfwardincharge,jtfheadnurse,jtfnoofbeds,
jtfaviablebeds;

String wardno,wardname,wardincharge, headnurse, noofbeds,aviablebeds;

JButton jbnSave,jbnClear,back;

Container cPane;
public static void main(String args[]){
new wardmaster();
}
public wardmaster()
{
wardno="";
wardname="";
wardincharge="";
headnurse="";
noofbeds="";
aviablebeds="";
createGUI();
}
public void createGUI(){
/*Create a frame, get its contentpane and set layout*/
appFrame = new JFrame("WARD MASTER");

cPane = appFrame.getContentPane();
cPane.setLayout(new GridBagLayout());

//Arrange components on contentPane and set Action Listeners to each JButton


arrangeComponents();

appFrame.setSize(1200,1200);
appFrame.setResizable(false);
appFrame.setVisible(true);
appFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void arrangeComponents(){
jlbwardno = new JLabel("Ward Number");
jlbwardname = new JLabel(" wardname");
jlbwardincharge = new JLabel("wardincharge");
jlbheadnurse = new JLabel("headnurse");
jlbnoofbeds = new JLabel("noofbeds");
jlbaviablebeds= new JLabel("aviable");
jtfwardno = new JTextField(20);
jtfwardname = new JTextField(20);
jtfwardincharge = new JTextField(20);
jtfheadnurse = new JTextField(20);
jtfnoofbeds = new JTextField(20);
jtfaviablebeds = new JTextField(20);
jbnSave = new JButton("Save");
jbnClear = new JButton("Clear");
back = new JButton("Back");

/*add all initialized components to the container*/


GridBagConstraints gridBagConstraintsx01 = new GridBagConstraints();
gridBagConstraintsx01.gridx = 0;
gridBagConstraintsx01.gridy = 0;
gridBagConstraintsx01.insets = new Insets(5,5,5,5);
cPane.add(jlbwardno, gridBagConstraintsx01);

GridBagConstraints gridBagConstraintsx02 = new GridBagConstraints();


gridBagConstraintsx02.gridx = 1;
gridBagConstraintsx02.insets = new Insets(5,5,5,5);
gridBagConstraintsx02.gridy = 0;
gridBagConstraintsx02.gridwidth = 2;
gridBagConstraintsx02.fill = GridBagConstraints.BOTH;
cPane.add(jtfwardno, gridBagConstraintsx02);

GridBagConstraints gridBagConstraintsx03 = new GridBagConstraints();


gridBagConstraintsx03.gridx = 0;
gridBagConstraintsx03.insets = new Insets(5,5,5,5);
gridBagConstraintsx03.gridy = 1;
cPane.add(jlbwardname, gridBagConstraintsx03);

GridBagConstraints gridBagConstraintsx04 = new GridBagConstraints();


gridBagConstraintsx04.gridx = 1;
gridBagConstraintsx04.insets = new Insets(5,5,5,5);
gridBagConstraintsx04.gridy = 1;
gridBagConstraintsx04.gridwidth = 2;
gridBagConstraintsx04.fill = GridBagConstraints.BOTH;
cPane.add(jtfwardname, gridBagConstraintsx04);

GridBagConstraints gridBagConstraintsx05 = new GridBagConstraints();


gridBagConstraintsx05.gridx = 0;
gridBagConstraintsx05.insets = new Insets(5,5,5,5);
gridBagConstraintsx05.gridy = 2;
cPane.add(jlbwardincharge, gridBagConstraintsx05);

GridBagConstraints gridBagConstraintsx06 = new GridBagConstraints();


gridBagConstraintsx06.gridx = 1;
gridBagConstraintsx06.gridy = 2;
gridBagConstraintsx06.insets = new Insets(5,5,5,5);
gridBagConstraintsx06.gridwidth = 2;
gridBagConstraintsx06.fill = GridBagConstraints.BOTH;
cPane.add(jtfwardincharge, gridBagConstraintsx06);

GridBagConstraints gridBagConstraintsx07 = new GridBagConstraints();


gridBagConstraintsx07.gridx = 0;
gridBagConstraintsx07.insets = new Insets(5,5,5,5);
gridBagConstraintsx07.gridy = 3;
cPane.add(jlbheadnurse, gridBagConstraintsx07);

GridBagConstraints gridBagConstraintsx08 = new GridBagConstraints();


gridBagConstraintsx08.gridx = 1;
gridBagConstraintsx08.gridy = 3;
gridBagConstraintsx08.gridwidth = 2;
gridBagConstraintsx08.insets = new Insets(5,5,5,5);
gridBagConstraintsx08.fill = GridBagConstraints.BOTH;
cPane.add(jtfheadnurse, gridBagConstraintsx08);

GridBagConstraints gridBagConstraintsx09 = new GridBagConstraints();


gridBagConstraintsx09.gridx = 0;
gridBagConstraintsx09.gridy = 4;
gridBagConstraintsx09.insets = new Insets(5,5,5,5);
cPane.add(jlbnoofbeds, gridBagConstraintsx09);

GridBagConstraints gridBagConstraintsx10 = new GridBagConstraints();


gridBagConstraintsx10.gridx = 1;
gridBagConstraintsx10.gridy = 4;
gridBagConstraintsx10.insets = new Insets(5,5,5,5);
gridBagConstraintsx10.gridwidth = 2;
gridBagConstraintsx10.fill = GridBagConstraints.BOTH;
cPane.add(jtfnoofbeds, gridBagConstraintsx10);

GridBagConstraints gridBagConstraintsx11 = new GridBagConstraints();


gridBagConstraintsx11.gridx = 0;
gridBagConstraintsx11.gridy = 5;
gridBagConstraintsx11.insets = new Insets(5,5,5,5);
cPane.add(jlbaviablebeds, gridBagConstraintsx11);

GridBagConstraints gridBagConstraintsx12 = new GridBagConstraints();


gridBagConstraintsx12.gridx = 1;
gridBagConstraintsx12.gridy = 5;
gridBagConstraintsx12.insets = new Insets(5,5,5,5);
gridBagConstraintsx12.gridwidth = 2;
gridBagConstraintsx12.fill = GridBagConstraints.BOTH;
cPane.add(jtfaviablebeds, gridBagConstraintsx12);

GridBagConstraints gridBagConstraintsx13 = new GridBagConstraints();


gridBagConstraintsx13.gridx = 1;
gridBagConstraintsx13.gridy = 12;
gridBagConstraintsx13.insets = new Insets(5,5,5,5);
cPane.add(jbnSave, gridBagConstraintsx13);

GridBagConstraints gridBagConstraintsx14 = new GridBagConstraints();


gridBagConstraintsx14.gridx = 2;
gridBagConstraintsx14.insets = new Insets(5,5,5,5);
gridBagConstraintsx14.gridy = 12;
cPane.add(jbnClear, gridBagConstraintsx14);

GridBagConstraints gridBagConstraintsx15 = new GridBagConstraints();


gridBagConstraintsx15.gridx = 3;
gridBagConstraintsx15.insets = new Insets(5,5,5,5);
gridBagConstraintsx15.gridy = 12;
cPane.add(back, gridBagConstraintsx15);

jbnSave.addActionListener(this);
jbnClear.addActionListener(this);
back.addActionListener(this);
}
public void actionPerformed (ActionEvent e){
if (e.getSource () == jbnSave){
savePerson();
clear();
}
else if (e.getSource() == jbnClear){
clear();
}else if (e.getSource() == back){
new mainpage();
}}
// Save the Person into the Address Book
public void savePerson(){
wardno = jtfwardno.getText();
if(wardno.equals("")){
JOptionPane.showMessageDialog(null, "Please enter Department regno.");
}else{
//create a PersonInfo object and pass it to PersonDAO to save it
// PersonInfo person = new PersonInfo(name, address, phone, email);
// pDAO.savePerson(person);
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
try
{
String sql = "INSERT INTO wardmaster2 VALUES ('" + jtfwardno.getText()+
"','" + jtfwardname.getText() + "','" + jtfwardincharge.getText() + "','" + jtfheadnurse.getText() +
"','" + jtfnoofbeds.getText() + "','" + jtfaviablebeds.getText() + "')";

//JTextField jtfName, jtfAddress, jtfPhone,


jtfEmail,jtfIpdno,jtfGender,jtfMarital,jtfFname,jtfDoa,jtfDocref,jtfTpo,jtfCons;;

PreparedStatement ps = con.prepareStatement(sql);
ps.executeUpdate();
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e.toString());
}
JOptionPane.showMessageDialog(null, "Record Saved");
}}
public void clear(){
jtfwardno.setText("");
jtfwardname.setText("");
jtfwardincharge.setText("");
jtfheadnurse.setText("");
jtfnoofbeds.setText("");
jtfaviablebeds.setText("");
} }

Roomtransfer.java

package patient;
import java.awt.Container;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
//import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
//import java.sql.Statement;
//import java.util.ArrayList;
//import java.sql.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

public class roomtransfer implements ActionListener


{
private Connection con;
JFrame appFrame;
JLabel one;
JLabel jlbid,jlbdate, jlbroomfrom,jlbamount,jlbroomto;
JTextField jtfId,jtfdate, jtfroomfrom,jtfamount,jtfroomto;
JButton jbbsubmit , jbnClear,jbnback,search;
String id, date,roomfrom,amount,roomto;

Container cPane;
public static void main(String args[]){
new roomtransfer();
}
public roomtransfer()
{
id="";
date="";
roomfrom="";
amount="";
roomto="";
createGUI();
}
public void createGUI(){
/*Create a frame, get its contentpane and set layout*/
appFrame = new JFrame("Room Allocation");

cPane = appFrame.getContentPane();
cPane.setLayout(new GridBagLayout());

//Arrange components on contentPane and set Action Listeners to each JButton


arrangeComponents();

appFrame.setSize(1000,1000);
appFrame.setResizable(false);
appFrame.setVisible(true);
appFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void arrangeComponents(){
jlbid = new JLabel("patient ID");
jlbdate = new JLabel(" date");
jlbroomfrom = new JLabel("roomfrom no");
jlbamount = new JLabel("amount");
jlbroomto= new JLabel("roomto");
one=new JLabel("Hospital roomtransfers");
Font f=new Font("Arial",Font.BOLD,50);
one.setFont(f);
jtfId = new JTextField(20);
jtfdate = new JTextField(20);
jtfroomfrom = new JTextField(20);
jtfamount = new JTextField(20);
jtfroomto = new JTextField(20);
jbbsubmit = new JButton("submit");
jbnClear = new JButton("Clear");
jbnback=new JButton("Back");
search=new JButton("Search");
Date s=new Date();
String ss=s.toString();

jtfdate.setText(ss);

/*add all initialized components to the container*/


GridBagConstraints gridBagConstraintsx01 = new GridBagConstraints();
gridBagConstraintsx01.gridx = 0;
gridBagConstraintsx01.gridy = 0;
gridBagConstraintsx01.insets = new Insets(5,5,5,5);
cPane.add(jlbid, gridBagConstraintsx01);

GridBagConstraints gridBagConstraintsx02 = new GridBagConstraints();


gridBagConstraintsx02.gridx = 1;
gridBagConstraintsx02.insets = new Insets(5,5,5,5);
gridBagConstraintsx02.gridy = 0;
gridBagConstraintsx02.gridwidth = 2;
gridBagConstraintsx02.fill = GridBagConstraints.BOTH;
cPane.add(jtfId, gridBagConstraintsx02);

GridBagConstraints gridBagConstraintsx03 = new GridBagConstraints();


gridBagConstraintsx03.gridx = 0;
gridBagConstraintsx03.insets = new Insets(5,5,5,5);
gridBagConstraintsx03.gridy = 1;
cPane.add(jlbdate, gridBagConstraintsx03);

GridBagConstraints gridBagConstraintsx04 = new GridBagConstraints();


gridBagConstraintsx04.gridx = 1;
gridBagConstraintsx04.insets = new Insets(5,5,5,5);
gridBagConstraintsx04.gridy = 1;
gridBagConstraintsx04.gridwidth = 2;
gridBagConstraintsx04.fill = GridBagConstraints.BOTH;
cPane.add(jtfdate, gridBagConstraintsx04);

GridBagConstraints gridBagConstraintsx05 = new GridBagConstraints();


gridBagConstraintsx05.gridx = 0;
gridBagConstraintsx05.insets = new Insets(5,5,5,5);
gridBagConstraintsx05.gridy = 3;
cPane.add(jlbroomfrom, gridBagConstraintsx05);

GridBagConstraints gridBagConstraintsx06 = new GridBagConstraints();


gridBagConstraintsx06.gridx = 1;
gridBagConstraintsx06.gridy = 3;
gridBagConstraintsx06.insets = new Insets(5,5,5,5);
gridBagConstraintsx06.gridwidth = 2;
gridBagConstraintsx06.fill = GridBagConstraints.BOTH;
cPane.add(jtfroomfrom, gridBagConstraintsx06);

GridBagConstraints gridBagConstraintsx07 = new GridBagConstraints();


gridBagConstraintsx07.gridx = 0;
gridBagConstraintsx07.insets = new Insets(5,5,5,5);
gridBagConstraintsx07.gridy = 4;
cPane.add(jlbamount, gridBagConstraintsx07);

GridBagConstraints gridBagConstraintsx08 = new GridBagConstraints();


gridBagConstraintsx08.gridx = 1;
gridBagConstraintsx08.gridy = 4;
gridBagConstraintsx08.gridwidth = 2;
gridBagConstraintsx08.insets = new Insets(5,5,5,5);
gridBagConstraintsx08.fill = GridBagConstraints.BOTH;
cPane.add(jtfamount, gridBagConstraintsx08);

GridBagConstraints gridBagConstraintsx09 = new GridBagConstraints();


gridBagConstraintsx09.gridx = 0;
gridBagConstraintsx09.insets = new Insets(5,5,5,5);
gridBagConstraintsx09.gridy = 5;
cPane.add(jlbroomto, gridBagConstraintsx09);

GridBagConstraints gridBagConstraintsx10 = new GridBagConstraints();


gridBagConstraintsx10.gridx = 1;
gridBagConstraintsx10.gridy = 5;
gridBagConstraintsx10.gridwidth = 2;
gridBagConstraintsx10.insets = new Insets(5,5,5,5);
gridBagConstraintsx10.fill = GridBagConstraints.BOTH;
cPane.add(jtfroomto, gridBagConstraintsx10);

GridBagConstraints gridBagConstraintsx17 = new GridBagConstraints();


gridBagConstraintsx17.gridx = 3;
gridBagConstraintsx17.gridy = 5;
gridBagConstraintsx17.gridwidth = 2;
gridBagConstraintsx17.insets = new Insets(5,5,5,5);
gridBagConstraintsx17.fill = GridBagConstraints.BOTH;
cPane.add(search, gridBagConstraintsx17);

GridBagConstraints gridBagConstraintsx19 = new GridBagConstraints();


gridBagConstraintsx19.gridx = 0;
gridBagConstraintsx19.gridy = 10;
gridBagConstraintsx19.insets = new Insets(5,5,5,5);
cPane.add(jbbsubmit, gridBagConstraintsx19);

GridBagConstraints gridBagConstraintsx20 = new GridBagConstraints();


gridBagConstraintsx20.gridx = 1;
gridBagConstraintsx20.insets = new Insets(5,5,5,5);
gridBagConstraintsx20.gridy =10;
cPane.add(jbnClear, gridBagConstraintsx20);

GridBagConstraints gridBagConstraintsx21 = new GridBagConstraints();


gridBagConstraintsx21.gridx = 2;
gridBagConstraintsx21.insets = new Insets(5,5,5,5);
gridBagConstraintsx21.gridy =10;
cPane.add(jbnback, gridBagConstraintsx21);

jbbsubmit.addActionListener(this);
jbnClear.addActionListener(this);
jbnback.addActionListener(this);
search.addActionListener(this);
}
public void actionPerformed (ActionEvent e){
if (e.getSource () == jbbsubmit){
deletePerson();
submitPerson();
clear();
}else if (e.getSource() == jbnClear){
clear();
}
else if (e.getSource() == jbnback){
new mainpage();
}
else if (e.getSource() == search){
searchPerson();
} }
void searchPerson()
{
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
try {
String sql = "SELECT * FROM room WHERE roomno= '"+ jtfroomto.getText() +"'";
// Create a prepared statement
Statement s = con.createStatement();
ResultSet rs = s.executeQuery(sql);
if(rs.next())
{
amount = rs.getString("charges");
//Create a PersonInfo object
//PersonInfo person = new
PersonInfo(pid,did,ddate,address,fdate,lline,mobile,room,exp,eid,tfrom,tto,rno,ipdpatientroom,opdp
atientroom);

//Add the person object to array list


//personsList.add(person);
jtfamount.setText(amount);
}}
catch(Exception e){
System.out.println("D");
System.out.println(e);
}
//return personsList;
}
public void deletePerson(){
id= jtfId.getText();
id = id.toUpperCase();
if(id.equals("")){
JOptionPane.showMessageDialog(null,"Please enter patientroom id to
delete.");
}
else{
//remove Person of the given name from the Address Book database
int numberOfDeleted =removePerson(id);
JOptionPane.showMessageDialog(null, numberOfDeleted + " Record(s)
deleted.");
} }
public int removePerson(String id)
{
int no = 0;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
try{
String sql = "DELETE FROM patientroom WHERE ipdno = '" + id + "'";
System.out.println(id);
// Create a Prepared statement
//con=DriverManager.getConnection("jdbc:odbc:hos","","");
} catch(SQLException ex) {
PreparedStatement ps = con.prepareStatement(sql);
ps.executeUpdate();
no=1;
}
catch(Exception e){
System.out.println(e);
}
return no;
}
// submit the Person into the Address Book
public void submitPerson(){
id = jtfId.getText();
if(id.equals("")){
JOptionPane.showMessageDialog(null, "Please enter roomtransfer Id.");
}else{
//create a PersonInfo object and pass it to PersonDAO to submit it
// PersonInfo person = new PersonInfo(name, address, phone, email);
// pDAO.submitPerson(person);
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
try
{
String sql = "INSERT INTO patientroom VALUES ('" +
jtfId.getText()+ "','" + jtfdate.getText() + "','" + jtfroomfrom.getText() + "','" + jtfamount.getText()
+ "','" + jtfroomto.getText() + "')";

//JTextField jtfName, jtfAddress, jtfPhone,


jtfEmail,jtfIpdno,jtfGender,jtfMarital,jtfFname,jtfDoa,jtfDocref,jtfTpo,jtfCons;;
PreparedStatement ps = con.prepareStatement(sql);
ps.executeUpdate();
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e.toString());
}

JOptionPane.showMessageDialog(null, "Record submitd");


}}
public void clear(){
jtfId.setText("");
jtfdate.setText("");
jtfroomfrom.setText("");
jtfamount.setText("");
jtfroomto.setText("");
}}

Patientbilling.java

package patient;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
//import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
//import java.sql.Statement;
//import java.util.ArrayList;
//import java.sql.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

public class patientbilling implements ActionListener


{
private Connection con;
JFrame appFrame;

JLabel jlbbillno,jlbdate,
jlbipd,jlbname,jlbtreatment,jlbamt,jlbroomcharges,jlbmedcharges,jlblabtestcharges,jlbbloodcharges
,jlbothercharges,jlbtotalcharges;
JTextField jtfbillno,jtfdate,
jtfipd,jtfname,jtftreatment,jtfamt,jtfroomcharges,jtfmedcharges,jtflabtestcharges,jtfbloodcharges,jtf
othercharges,jtftotalcharges;
JButton jbbSave , jbnClear,back,auto,total;
String
billno,date,ipd,name,treatment,amt,roomcharges,medcharges,labtestcharges,bloodcharges,otherchar
ges,totalcharges;

Container cPane;
public static void main(String args[]){
new patientbilling();
}

public patientbilling()
{
billno="";
date="";
ipd="";
name="";
treatment="";
amt="";
roomcharges="";
medcharges="";
labtestcharges="";
bloodcharges="";
othercharges="";
totalcharges="";

createGUI();

public void createGUI(){

/*Create a frame, get its contentpane and set layout*/


appFrame = new JFrame("Patient Bill");

cPane = appFrame.getContentPane();
cPane.setLayout(new GridBagLayout());

//Arrange components on contentPane and set Action Listeners to each JButton


arrangeComponents();

appFrame.setSize(1200,1200);
appFrame.setResizable(false);
appFrame.setVisible(true);
appFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

public void arrangeComponents(){


jlbbillno = new JLabel("Bill No");
jlbdate = new JLabel(" Date");
jlbipd = new JLabel("Pid");
jlbname = new JLabel("Name");
jlbtreatment = new JLabel("Treatment");
jlbamt= new JLabel("Treatment charges");
jlbroomcharges = new JLabel("Room Charges");
jlbmedcharges = new JLabel("MEDICINE charges");
jlblabtestcharges=new JLabel("lAB TEST Charges");
jlbbloodcharges=new JLabel("blood CHARGES");
jlbothercharges=new JLabel("OTHER Charges");
jlbtotalcharges=new JLabel("TOTAL");

jtfbillno = new JTextField(20);


jtfdate = new JTextField(20);
jtfipd = new JTextField(20);
jtfname = new JTextField(20);
jtftreatment = new JTextField(20);
jtfamt = new JTextField(20);
jtfroomcharges = new JTextField(20);
jtfmedcharges = new JTextField(20);
jtflabtestcharges = new JTextField(20);
jtfbloodcharges = new JTextField(20);
jtfothercharges = new JTextField(20);
jtftotalcharges = new JTextField(20);

jbbSave = new JButton("Save");


jbnClear = new JButton("Clear");
back = new JButton("Back");
auto=new JButton("Auto");
total=new JButton("Total");

Date s=new Date();


String ss=s.toString();

jtfdate.setText(ss);

/*add all initialized components to the container*/


GridBagConstraints gridBagConstraintsx01 = new GridBagConstraints();
gridBagConstraintsx01.gridx = 0;
gridBagConstraintsx01.gridy = 0;
gridBagConstraintsx01.insets = new Insets(5,5,5,5);
cPane.add(jlbbillno, gridBagConstraintsx01);

GridBagConstraints gridBagConstraintsx02 = new GridBagConstraints();


gridBagConstraintsx02.gridx = 1;
gridBagConstraintsx02.insets = new Insets(5,5,5,5);
gridBagConstraintsx02.gridy = 0;
gridBagConstraintsx02.gridwidth = 2;
gridBagConstraintsx02.fill = GridBagConstraints.BOTH;
cPane.add(jtfbillno, gridBagConstraintsx02);
GridBagConstraints gridBagConstraintsx03 = new GridBagConstraints();
gridBagConstraintsx03.gridx = 0;
gridBagConstraintsx03.insets = new Insets(5,5,5,5);
gridBagConstraintsx03.gridy = 1;
cPane.add(jlbdate, gridBagConstraintsx03);

GridBagConstraints gridBagConstraintsx04 = new GridBagConstraints();


gridBagConstraintsx04.gridx = 1;
gridBagConstraintsx04.insets = new Insets(5,5,5,5);
gridBagConstraintsx04.gridy = 1;
gridBagConstraintsx04.gridwidth = 2;
gridBagConstraintsx04.fill = GridBagConstraints.BOTH;
cPane.add(jtfdate, gridBagConstraintsx04);

GridBagConstraints gridBagConstraintsx05 = new GridBagConstraints();


gridBagConstraintsx05.gridx = 0;
gridBagConstraintsx05.insets = new Insets(5,5,5,5);
gridBagConstraintsx05.gridy = 2;
cPane.add(jlbipd, gridBagConstraintsx05);

GridBagConstraints gridBagConstraintsx06 = new GridBagConstraints();


gridBagConstraintsx06.gridx = 1;
gridBagConstraintsx06.gridy = 2;
gridBagConstraintsx06.insets = new Insets(5,5,5,5);
gridBagConstraintsx06.gridwidth = 2;
gridBagConstraintsx06.fill = GridBagConstraints.BOTH;
cPane.add(jtfipd, gridBagConstraintsx06);

GridBagConstraints gridBagConstraintsx88 = new GridBagConstraints();


gridBagConstraintsx88.gridx = 3;
gridBagConstraintsx88.gridy = 2;
gridBagConstraintsx88.insets = new Insets(5,5,5,5);
cPane.add(auto, gridBagConstraintsx88);

GridBagConstraints gridBagConstraintsx07 = new GridBagConstraints();


gridBagConstraintsx07.gridx = 0;
gridBagConstraintsx07.insets = new Insets(5,5,5,5);
gridBagConstraintsx07.gridy = 3;
cPane.add(jlbname, gridBagConstraintsx07);

GridBagConstraints gridBagConstraintsx08 = new GridBagConstraints();


gridBagConstraintsx08.gridx = 1;
gridBagConstraintsx08.gridy = 3;
gridBagConstraintsx08.gridwidth = 2;
gridBagConstraintsx08.insets = new Insets(5,5,5,5);
gridBagConstraintsx08.fill = GridBagConstraints.BOTH;
cPane.add(jtfname, gridBagConstraintsx08);

GridBagConstraints gridBagConstraintsx09 = new GridBagConstraints();


gridBagConstraintsx09.gridx = 0;
gridBagConstraintsx09.gridy = 4;
gridBagConstraintsx09.insets = new Insets(5,5,5,5);
cPane.add(jlbtreatment, gridBagConstraintsx09);

GridBagConstraints gridBagConstraintsx10 = new GridBagConstraints();


gridBagConstraintsx10.gridx = 1;
gridBagConstraintsx10.gridy = 4;
gridBagConstraintsx10.insets = new Insets(5,5,5,5);
gridBagConstraintsx10.gridwidth = 2;
gridBagConstraintsx10.fill = GridBagConstraints.BOTH;
cPane.add(jtftreatment, gridBagConstraintsx10);

GridBagConstraints gridBagConstraintsx11 = new GridBagConstraints();


gridBagConstraintsx11.gridx = 0;
gridBagConstraintsx11.gridy = 5;
gridBagConstraintsx11.insets = new Insets(5,5,5,5);
cPane.add(jlbamt, gridBagConstraintsx11);

GridBagConstraints gridBagConstraintsx12 = new GridBagConstraints();


gridBagConstraintsx12.gridx = 1;
gridBagConstraintsx12.gridy = 5;
gridBagConstraintsx12.insets = new Insets(5,5,5,5);
gridBagConstraintsx12.gridwidth = 2;
gridBagConstraintsx12.fill = GridBagConstraints.BOTH;
cPane.add(jtfamt, gridBagConstraintsx12);

GridBagConstraints gridBagConstraintsx13 = new GridBagConstraints();


gridBagConstraintsx13.gridx = 0;
gridBagConstraintsx13.gridy = 6;
gridBagConstraintsx13.insets = new Insets(5,5,5,5);
cPane.add(jlbroomcharges, gridBagConstraintsx13);

searchPerson();
GridBagConstraints gridBagConstraintsx14 = new GridBagConstraints();
gridBagConstraintsx14.gridx = 1;
gridBagConstraintsx14.gridy = 6;
gridBagConstraintsx14.insets = new Insets(5,5,5,5);
gridBagConstraintsx14.gridwidth = 2;
gridBagConstraintsx14.fill = GridBagConstraints.BOTH;
cPane.add(jtfroomcharges, gridBagConstraintsx14);

GridBagConstraints gridBagConstraintsx15 = new GridBagConstraints();


gridBagConstraintsx15.gridx = 0;
gridBagConstraintsx15.gridy = 7;
gridBagConstraintsx15.insets = new Insets(5,5,5,5);
cPane.add(jlbmedcharges, gridBagConstraintsx15);

GridBagConstraints gridBagConstraintsx16 = new GridBagConstraints();


gridBagConstraintsx16.gridx = 1;
gridBagConstraintsx16.gridy = 7;
gridBagConstraintsx16.insets = new Insets(5,5,5,5);
gridBagConstraintsx16.gridwidth = 2;
gridBagConstraintsx16.fill = GridBagConstraints.BOTH;
cPane.add(jtfmedcharges, gridBagConstraintsx16);

// GridBagConstraints gridBagConstraintsx50 = new GridBagConstraints();


//gridBagConstraintsx50.gridx = 3;
//gridBagConstraintsx50.gridy = 7;
//gridBagConstraintsx50.insets = new Insets(5,5,5,5);
//cPane.add(total, gridBagConstraintsx50);

GridBagConstraints gridBagConstraintsx17 = new GridBagConstraints();


gridBagConstraintsx17.gridx = 0;
gridBagConstraintsx17.gridy = 8;
gridBagConstraintsx17.insets = new Insets(5,5,5,5);
cPane.add(jlblabtestcharges, gridBagConstraintsx17);

GridBagConstraints gridBagConstraintsx18 = new GridBagConstraints();


gridBagConstraintsx18.gridx = 1;
gridBagConstraintsx18.gridy = 8;
gridBagConstraintsx18.insets = new Insets(5,5,5,5);
gridBagConstraintsx18.gridwidth = 2;
gridBagConstraintsx18.fill = GridBagConstraints.BOTH;
cPane.add(jtflabtestcharges, gridBagConstraintsx18);

GridBagConstraints gridBagConstraintsx19 = new GridBagConstraints();


gridBagConstraintsx19.gridx = 0;
gridBagConstraintsx19.gridy = 9;
gridBagConstraintsx19.insets = new Insets(5,5,5,5);
cPane.add(jlbbloodcharges, gridBagConstraintsx19);

GridBagConstraints gridBagConstraintsx20 = new GridBagConstraints();


gridBagConstraintsx20.gridx = 1;
gridBagConstraintsx20.gridy = 9;
gridBagConstraintsx20.insets = new Insets(5,5,5,5);
gridBagConstraintsx20.gridwidth = 2;
gridBagConstraintsx20.fill = GridBagConstraints.BOTH;
cPane.add(jtfbloodcharges, gridBagConstraintsx20);

GridBagConstraints gridBagConstraintsx21 = new GridBagConstraints();


gridBagConstraintsx21.gridx = 0;
gridBagConstraintsx21.gridy = 10;
gridBagConstraintsx21.insets = new Insets(5,5,5,5);
cPane.add(jlbothercharges, gridBagConstraintsx21);

GridBagConstraints gridBagConstraintsx22 = new GridBagConstraints();


gridBagConstraintsx22.gridx = 1;
gridBagConstraintsx22.gridy = 10;
gridBagConstraintsx22.insets = new Insets(5,5,5,5);
gridBagConstraintsx22.gridwidth = 2;
gridBagConstraintsx22.fill = GridBagConstraints.BOTH;
cPane.add(jtfothercharges, gridBagConstraintsx22);

GridBagConstraints gridBagConstraintsx23 = new GridBagConstraints();


gridBagConstraintsx23.gridx = 0;
gridBagConstraintsx23.gridy =11;
gridBagConstraintsx23.insets = new Insets(5,5,5,5);
cPane.add(jlbtotalcharges, gridBagConstraintsx23);

GridBagConstraints gridBagConstraintsx24 = new GridBagConstraints();


gridBagConstraintsx24.gridx = 1;
gridBagConstraintsx24.gridy = 11;
gridBagConstraintsx24.insets = new Insets(5,5,5,5);
gridBagConstraintsx24.gridwidth = 2;
gridBagConstraintsx24.fill = GridBagConstraints.BOTH;
cPane.add(jtftotalcharges, gridBagConstraintsx24);

GridBagConstraints gridBagConstraintsx28 = new GridBagConstraints();


gridBagConstraintsx28.gridx = 3;
gridBagConstraintsx28.gridy = 11;
gridBagConstraintsx28.insets = new Insets(5,5,5,5);
cPane.add(total, gridBagConstraintsx28);

GridBagConstraints gridBagConstraintsx25 = new GridBagConstraints();


gridBagConstraintsx25.gridx = 0;
gridBagConstraintsx25.gridy = 12;
gridBagConstraintsx25.insets = new Insets(5,5,5,5);
cPane.add(jbbSave, gridBagConstraintsx25);

GridBagConstraints gridBagConstraintsx26 = new GridBagConstraints();


gridBagConstraintsx26.gridx = 1;
gridBagConstraintsx26.insets = new Insets(5,5,5,5);
gridBagConstraintsx26.gridy = 12;
cPane.add(jbnClear, gridBagConstraintsx26);

GridBagConstraints gridBagConstraintsx27 = new GridBagConstraints();


gridBagConstraintsx27.gridx = 2;
gridBagConstraintsx27.insets = new Insets(5,5,5,5);
gridBagConstraintsx27.gridy = 12;
cPane.add(back, gridBagConstraintsx27);

jbbSave.addActionListener(this);
jbnClear.addActionListener(this);
back.addActionListener(this);
auto.addActionListener(this);
total.addActionListener(this);
}

public void actionPerformed (ActionEvent e){

if (e.getSource () == jbbSave){
savePerson();
deletePerson();
clear();
}
else if (e.getSource() == jbnClear){
clear();
}
else if (e.getSource() == back){
new mainpage();
}
else if (e.getSource() ==total){
total();
}
else if (e.getSource() == auto){
searchPerson1();
searchPerson2();
searchPerson3();
searchPerson4();
searchPerson5();
searchPerson6();
searchPerson7();

}
public void total()
{
String tc=jtfamt.getText();
int tc1=Integer.parseInt(tc);

String rc=jtfroomcharges.getText();
int rc1=Integer.parseInt(rc);

String lab=jtflabtestcharges.getText();
int lab1=Integer.parseInt(lab);

String med=jtfmedcharges.getText();
int med1=Integer.parseInt(med);

String bl=jtfbloodcharges.getText();
int bl1=Integer.parseInt(bl);

String oc=jtfothercharges.getText();
int oc1=Integer.parseInt(oc);

int total=0;

total=tc1+rc1+lab1+med1+oc1+bl1;
String xx=Integer.toString(total);

jtftotalcharges.setText(xx);
}
void searchPerson()
{
String billno;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try {

String sql = "SELECT max(billno)+1 as bill FROM patientbill2 ";

// Create a prepared statement


Statement s = con.createStatement();

ResultSet rs = s.executeQuery(sql);

if(rs.next())
{

billno = rs.getString("bill");
//Create a PersonInfo object
//PersonInfo person = new
PersonInfo(pid,did,dname,address,fname,lline,mobile,category,exp,eid,tfrom,tto,rno,ipdcharge,opdc
harge);

//Add the person object to array list


//personsList.add(person);

jtfbillno.setText(billno);

}
}
catch(Exception e){
System.out.println("D");
System.out.println(e);
}

//return personsList;

void searchPerson1()
{
String amt;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try {

String sql = "SELECT sum(amount) as amt FROM treatment3 where


pid='" + jtfipd.getText() + "' ";

// Create a prepared statement


Statement s = con.createStatement();

ResultSet rs = s.executeQuery(sql);

if(rs.next())
{

amt = rs.getString("amt");
//Create a PersonInfo object
//PersonInfo person = new
PersonInfo(pid,did,dname,address,fname,lline,mobile,category,exp,eid,tfrom,tto,rno,ipdcharge,opdc
harge);

//Add the person object to array list


//personsList.add(person);
jtfamt.setText(amt);

}
}
catch(Exception e){
System.out.println("D");
System.out.println(e);
}

//return personsList;

}
void searchPerson5()
{
String amt;

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try {

String sql = "SELECT sum(charges) as amt FROM medicines1 where pid='" + jtfipd.getText() + "'
";

// Create a prepared statement


Statement s = con.createStatement();

ResultSet rs = s.executeQuery(sql);

if(rs.next())
{

amt = rs.getString("amt");
//Create a PersonInfo object
//PersonInfo person = new
PersonInfo(pid,did,dname,address,fname,lline,mobile,category,exp,eid,tfrom,tto,rno,ipdcharge,opdc
harge);

//Add the person object to array list


//personsList.add(person);
jtfmedcharges.setText(amt);

}
}
catch(Exception e){
System.out.println("D");
System.out.println(e);
}

//return personsList;

}
void searchPerson6()
{
String amt;

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try {

String sql = "SELECT sum(amount) as amt FROM lab1 where pid='" + jtfipd.getText() + "' ";

// Create a prepared statement


Statement s = con.createStatement();

ResultSet rs = s.executeQuery(sql);

if(rs.next())
{

amt = rs.getString("amt");
//Create a PersonInfo object
//PersonInfo person = new
PersonInfo(pid,did,dname,address,fname,lline,mobile,category,exp,eid,tfrom,tto,rno,ipdcharge,opdc
harge);

//Add the person object to array list


//personsList.add(person);
jtflabtestcharges.setText(amt);

}
}
catch(Exception e){
System.out.println("D");
System.out.println(e);
}

//return personsList;

}
void searchPerson7()
{
String amt;

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try {

String sql = "SELECT sum(amount) as amt FROM bloodbank4 where


pid='" + jtfipd.getText() + "' ";

// Create a prepared statement


Statement s = con.createStatement();

ResultSet rs = s.executeQuery(sql);
if(rs.next())
{

amt = rs.getString("amt");
//Create a PersonInfo object
//PersonInfo person = new
PersonInfo(pid,did,dname,address,fname,lline,mobile,category,exp,eid,tfrom,tto,rno,ipdcharge,opdc
harge);

//Add the person object to array list


//personsList.add(person);

jtfbloodcharges.setText(amt);

}
}
catch(Exception e){
System.out.println("D");
System.out.println(e);
}

//return personsList;

}
void searchPerson2()
{
String treatment;

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try {

String sql = "SELECT * FROM treatment3 where pid='" + jtfipd.getText() + "' ";

// Create a prepared statement


Statement s = con.createStatement();

ResultSet rs = s.executeQuery(sql);

if(rs.next())
{

treatment = rs.getString("treatment");

//Create a PersonInfo object


//PersonInfo person = new
PersonInfo(pid,did,dname,address,fname,lline,mobile,category,exp,eid,tfrom,tto,rno,ipdcharge,opdc
harge);

//Add the person object to array list


//personsList.add(person);

jtftreatment.setText(treatment);

}
}
catch(Exception e){
System.out.println("D");
System.out.println(e);
}

//return personsList;

}
void searchPerson3()
{
String name;

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try {

String sql = "SELECT * FROM registration1 where pid='" + jtfipd.getText() + "'


";

// Create a prepared statement


Statement s = con.createStatement();

ResultSet rs = s.executeQuery(sql);

if(rs.next())
{

name = rs.getString("pname");
//Create a PersonInfo object
//PersonInfo person = new
PersonInfo(pid,did,dname,address,fname,lline,mobile,category,exp,eid,tfrom,tto,rno,ipdcharge,opdc
harge);

//Add the person object to array list


//personsList.add(person);

jtfname.setText(name);

}
}
catch(Exception e){
System.out.println("D");
System.out.println(e);
}

//return personsList;

void searchPerson4()
{
String roomcharges;

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try {

String sql = "SELECT * FROM patientroom where ipdno='" + jtfipd.getText() + "'


";

// Create a prepared statement


Statement s = con.createStatement();

ResultSet rs = s.executeQuery(sql);

if(rs.next())
{

roomcharges = rs.getString("amount");

//Create a PersonInfo object


//PersonInfo person = new
PersonInfo(pid,did,dname,address,fname,lline,mobile,category,exp,eid,tfrom,tto,rno,ipdcharge,opdc
harge);

//Add the person object to array list


//personsList.add(person);

jtfroomcharges.setText(roomcharges);

}
}
catch(Exception e){
System.out.println("D");
System.out.println(e);
}

//return personsList;

}
public void deletePerson(){
ipd= jtfipd.getText();
ipd = ipd.toUpperCase();
if(ipd.equals("")){
JOptionPane.showMessageDialog(null,"Please enter doctor id to delete.");
}
else{
//remove Person of the given name from the Address Book database
int numberOfDeleted =removePerson(ipd);
JOptionPane.showMessageDialog(null, numberOfDeleted + " Record(s)
deleted. from treatment");
}

}
public int removePerson(String id)
{
int no = 0;

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try{
String sql = "DELETE FROM treatment3 WHERE pid = '" + ipd + "'";
System.out.println(id);
// Create a Pressared statement
//con=DriverManager.getConnection("jdbc:odbc:ho","","");
} catch(SQLException ex) {

PreparedStatement ps = con.prepareStatement(sql);

ps.executeUpdate();
no=1;
}
catch(Exception e){
System.out.println(e);
}

return no;
}

// Save the Person into the labtest Book


public void savePerson(){

billno = jtfbillno.getText();

if(billno.equals("")){
JOptionPane.showMessageDialog(null, "Please enter Department regno.");
}else{
//create a PersonInfo object and pass it to PersonDAO to save it
// PersonInfo person = new PersonInfo(name, labtest, medchargess, email);
// pDAO.savePerson(person);

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try
{
String sql = "INSERT INTO patientbilling2 VALUES (" +
jtfbillno.getText()+ ",'" + jtfdate.getText() + "','" + jtfipd.getText() + "','" + jtfname.getText() + "','"
+ jtftreatment.getText() + "'," + jtfamt.getText() + "," + jtfroomcharges.getText() + "," +
jtfmedcharges.getText() + "," + jtflabtestcharges.getText() + "," + jtfbloodcharges.getText() + "," +
jtfothercharges.getText() + "," + jtftotalcharges.getText() + ")";

//JTextField jtfName, jtflabtest, jtfmedchargess,


jtfEmail,jtfIpdno,jtfGender,jtfMarital,jtfFname,jtfDoa,jtfDocref,jtfTpo,jtfCons;;

PreparedStatement ps = con.prepareStatement(sql);

ps.executeUpdate();
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e.toString());
}

JOptionPane.showMessageDialog(null, "Record Saved");


}}

public void clear(){

jtfbillno.setText("");
jtfdate.setText("");
jtfipd.setText("");
jtfname.setText("");
jtftreatment.setText("");
jtfamt.setText("");
jtfroomcharges.setText("");
jtfmedcharges.setText("");
jtflabtestcharges.setText("");
jtfbloodcharges.setText("");
jtfothercharges.setText("");
jtftotalcharges.setText("");
}}
Medicines.java

package patient;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
//import java.sql.ResultSet;
import java.sql.SQLException;
//import java.sql.Statement;
//import java.util.ArrayList;
//import java.sql.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

public class medicines1 implements ActionListener


{

private Connection con;


JFrame appFrame;

JLabel jlbpid, jlbdrugcode,jlbquantity,jlbdregno,jlbdosage,jlbcharges;


JTextField jtfpid, jtfdrugcode,jtfquantity,jtfdregno,jtfdosage,jtfcharges;

JButton jbnDelete, jbnUpdate, jbnSearch, jbnback;


String pid, drugcode,quantity,dregno,dosage,charges;

Container cPane;
public static void main(String args[]){
new medicines1();
}

public medicines1()
{
pid="";
drugcode="";
quantity="";
dregno="";
dosage="";
charges="";

createGUI();
}

public void createGUI(){

/*Create a frame, get its contentpane and set layout*/


appFrame = new JFrame("MEDICINES");

cPane = appFrame.getContentPane();
cPane.setLayout(new GridBagLayout());

//Arrange components on contentPane and set Action Listeners to each JButton


arrangeComponents();

appFrame.setSize(1200,1200);
appFrame.setResizable(false);
appFrame.setVisible(true);
appFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

public void arrangeComponents(){


jlbpid = new JLabel("Pid");
jlbdrugcode = new JLabel("Drug code");
jlbquantity = new JLabel("Quantity");
jlbdregno = new JLabel("Doctor Reg No");
jlbdosage = new JLabel("Dosage");
jlbcharges = new JLabel("charges");

jtfpid = new JTextField(20);


jtfdrugcode = new JTextField(20);
jtfquantity = new JTextField(20);
jtfdregno = new JTextField(20);
jtfdosage = new JTextField(20);
jtfcharges = new JTextField(20);

jbnDelete = new JButton("Delete");


jbnSearch = new JButton("Search");
jbnUpdate = new JButton("Update");
jbnback = new JButton("back");

/*add all initialized components to the container*/


GridBagConstraints gridBagConstraintsx01 = new GridBagConstraints();
gridBagConstraintsx01.gridx = 0;
gridBagConstraintsx01.gridy = 0;
gridBagConstraintsx01.insets = new Insets(5,5,5,5);
cPane.add(jlbpid, gridBagConstraintsx01);

GridBagConstraints gridBagConstraintsx02 = new GridBagConstraints();


gridBagConstraintsx02.gridx = 1;
gridBagConstraintsx02.insets = new Insets(5,5,5,5);
gridBagConstraintsx02.gridy = 0;
gridBagConstraintsx02.gridwidth = 2;
gridBagConstraintsx02.fill = GridBagConstraints.BOTH;
cPane.add(jtfpid, gridBagConstraintsx02);

GridBagConstraints gridBagConstraintsx03 = new GridBagConstraints();


gridBagConstraintsx03.gridx = 0;
gridBagConstraintsx03.insets = new Insets(5,5,5,5);
gridBagConstraintsx03.gridy = 1;
cPane.add(jlbdrugcode, gridBagConstraintsx03);

GridBagConstraints gridBagConstraintsx04 = new GridBagConstraints();


gridBagConstraintsx04.gridx = 1;
gridBagConstraintsx04.gridy = 1;
gridBagConstraintsx04.insets = new Insets(5,5,5,5);
gridBagConstraintsx04.gridwidth = 2;
gridBagConstraintsx04.fill = GridBagConstraints.BOTH;
cPane.add(jtfdrugcode, gridBagConstraintsx04);

GridBagConstraints gridBagConstraintsx05 = new GridBagConstraints();


gridBagConstraintsx05.gridx = 0;
gridBagConstraintsx05.insets = new Insets(5,5,5,5);
gridBagConstraintsx05.gridy = 2;
cPane.add(jlbquantity, gridBagConstraintsx05);

GridBagConstraints gridBagConstraintsx06 = new GridBagConstraints();


gridBagConstraintsx06.gridx = 1;
gridBagConstraintsx06.gridy = 2;
gridBagConstraintsx06.insets = new Insets(5,5,5,5);
gridBagConstraintsx06.gridwidth = 2;
gridBagConstraintsx06.fill = GridBagConstraints.BOTH;
cPane.add(jtfquantity, gridBagConstraintsx06);

GridBagConstraints gridBagConstraintsx07 = new GridBagConstraints();


gridBagConstraintsx07.gridx = 0;
gridBagConstraintsx07.insets = new Insets(5,5,5,5);
gridBagConstraintsx07.gridy = 3;
cPane.add(jlbdregno, gridBagConstraintsx07);

GridBagConstraints gridBagConstraintsx08 = new GridBagConstraints();


gridBagConstraintsx08.gridx = 1;
gridBagConstraintsx08.gridy = 3;
gridBagConstraintsx08.insets = new Insets(5,5,5,5);
gridBagConstraintsx08.gridwidth = 2;
gridBagConstraintsx08.fill = GridBagConstraints.BOTH;
cPane.add(jtfdregno, gridBagConstraintsx08);

GridBagConstraints gridBagConstraintsx09 = new GridBagConstraints();


gridBagConstraintsx09.gridx = 0;
gridBagConstraintsx09.insets = new Insets(5,5,5,5);
gridBagConstraintsx09.gridy = 4;
cPane.add(jlbdosage, gridBagConstraintsx09);
GridBagConstraints gridBagConstraintsx10 = new GridBagConstraints();
gridBagConstraintsx10.gridx = 1;
gridBagConstraintsx10.gridy = 4;
gridBagConstraintsx10.insets = new Insets(5,5,5,5);
gridBagConstraintsx10.gridwidth = 2;
gridBagConstraintsx10.fill = GridBagConstraints.BOTH;
cPane.add(jtfdosage, gridBagConstraintsx10);

GridBagConstraints gridBagConstraintsx11 = new GridBagConstraints();


gridBagConstraintsx11.gridx = 0;
gridBagConstraintsx11.insets = new Insets(5,5,5,5);
gridBagConstraintsx11.gridy = 5;
cPane.add(jlbcharges, gridBagConstraintsx11);

GridBagConstraints gridBagConstraintsx12 = new GridBagConstraints();


gridBagConstraintsx12.gridx = 1;
gridBagConstraintsx12.gridy = 5;
gridBagConstraintsx12.insets = new Insets(5,5,5,5);
gridBagConstraintsx12.gridwidth = 2;
gridBagConstraintsx12.fill = GridBagConstraints.BOTH;
cPane.add(jtfcharges, gridBagConstraintsx12);

GridBagConstraints gridBagConstraintsx13 = new GridBagConstraints();


gridBagConstraintsx13.gridx = 0;
gridBagConstraintsx13.gridy = 6;
gridBagConstraintsx13.insets = new Insets(5,5,5,5);
cPane.add(jbnDelete, gridBagConstraintsx13);

GridBagConstraints gridBagConstraintsx14 = new GridBagConstraints();


gridBagConstraintsx14.gridx = 1;
gridBagConstraintsx14.insets = new Insets(5,5,5,5);
gridBagConstraintsx14.gridy = 6;
cPane.add(jbnUpdate, gridBagConstraintsx14);

GridBagConstraints gridBagConstraintsx15 = new GridBagConstraints();


gridBagConstraintsx15.gridx = 2;
gridBagConstraintsx15.gridy = 6;
gridBagConstraintsx15.insets = new Insets(5,5,5,5);
cPane.add(jbnSearch, gridBagConstraintsx15);

GridBagConstraints gridBagConstraintsx16 = new GridBagConstraints();


gridBagConstraintsx16.gridx = 3;
gridBagConstraintsx16.insets = new Insets(5,5,5,5);
gridBagConstraintsx16.gridy = 6;
cPane.add(jbnback, gridBagConstraintsx16);

jbnDelete.addActionListener(this);
jbnSearch.addActionListener(this);
jbnUpdate.addActionListener(this);
jbnback.addActionListener(this);
}
public void actionPerformed (ActionEvent e){

if (e.getSource() == jbnDelete){
deletePerson();
clear();
}

else if (e.getSource() == jbnUpdate){


deletePerson();
savePerson();
clear();
}

else if (e.getSource() == jbnSearch){


searchPerson();
}
else if (e.getSource() == jbnback){
new mainpage();
}

}
// Save the Person into the Address Book
public void savePerson(){

pid = jtfpid.getText();

if(pid.equals("")){
JOptionPane.showMessageDialog(null, "Please enter Doctor If.");
}else{
//create a PersonInfo object and pass it to PersonDAO to save it
// PersonInfo person = new PersonInfo(name, address, phone, email);
// pDAO.savePerson(person);

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try
{
String amount=jtfcharges.getText();
int amt=Integer.parseInt(amount);

String sql = "INSERT INTO medicines1 VALUES ('" +


jtfpid.getText()+ "','" + jtfdrugcode.getText() + "','" + jtfquantity.getText() + "','" +
jtfdregno.getText() + "','" + jtfdosage.getText() + "'," + amt + ")";

//JTextField jtfName, jtfAddress, jtfPhone,


jtfEmail,jtfIpdno,jtfGender,jtfMarital,jtfFname,jtfDoa,jtfDocref,jtfTpo,jtfCons;;

PreparedStatement ps = con.prepareStatement(sql);

ps.executeUpdate();
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e.toString());
}

JOptionPane.showMessageDialog(null, "Record Saved");


}}

public void deletePerson(){


pid= jtfpid.getText();
pid = pid.toUpperCase();
if(pid.equals("")){
JOptionPane.showMessageDialog(null,"Please enter partient number.");
}
else{
//remove Person of the given name from the Address Book database
int numberOfDeleted =removePerson(pid);
JOptionPane.showMessageDialog(null, numberOfDeleted + " Record(s)
deleted.");
}

}
public int removePerson(String id)
{
int no = 0;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try{
String sql = "DELETE FROM medicines1 WHERE pid = '" + pid + "'";
System.out.println(id);
// Create a Pressared statement
//con=DriverManager.getConnection("jdbc:odbc:ho","","");
} catch(SQLException ex) {

PreparedStatement ps = con.prepareStatement(sql);

ps.executeUpdate();
no=1;
}
catch(Exception e){
System.out.println(e);
}

return no;
}
//Perform a Case-Insensitive Search to find the Person
void searchPerson()
{
String pid,drugcode,quantity,dregno,dosage,charges;

pid="";
drugcode="";
quantity="";
dregno="";
dosage="";
charges="";

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try {

String sql = "SELECT * FROM medicines1 WHERE pid= '"+ jtfpid.getText() +"'";

// Create a prepared statement


Statement s = con.createStatement();

ResultSet rs = s.executeQuery(sql);

if(rs.next())
{

pid = rs.getString("pid");
drugcode= rs.getString("drugcode");
quantity = rs.getString("quantity");
dregno = rs.getString("dregno");
dosage = rs.getString("dosage");
charges= rs.getString("charges");
//Create a PersonInfo object
//PersonInfo person = new
PersonInfo(pid,did,dname,address,fname,lline,mobile,category,exp,eid,tfrom,tto,rno,ipdcharge,opdc
harge);

//Add the person object to array list


//personsList.add(person);
jtfpid.setText(pid);
jtfdrugcode.setText(drugcode);
jtfquantity.setText(quantity);
jtfdregno.setText(dregno);
jtfdosage.setText(dosage);
jtfcharges.setText(charges);
}
}
catch(Exception e){
System.out.println("D");
System.out.println(e);
}

//return personsList;

public void clear(){

jtfpid.setText("");

jtfdrugcode.setText("");
jtfquantity.setText("");
jtfdregno.setText("");
jtfdosage.setText("");
jtfcharges.setText("");

}}

Edittreatment.java

package patient;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
//import java.sql.ResultSet;
import java.sql.SQLException;
//import java.sql.Statement;
//import java.util.ArrayList;
//import java.sql.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

public class edittreatment implements ActionListener


{

private Connection con;


JFrame appFrame;

JLabel jlbpid,jlbtreatment, jlbamount,jlbdate;


JTextField jtfpid,jtftreatment, jtfamount,jtfdate;;

String pid,treatment, amount,date;

JButton jbnDelete, jbnUptreatment, jbnSearch, jbnback;

Container cPane;
public static void main(String args[]){
new edittreatment();
}

public edittreatment()
{

pid="";
treatment="";
amount="";
date="";
createGUI();

public void createGUI(){

/*Create a frame, get its contentpane and set layout*/


appFrame = new JFrame("EDIT TREATMENT");

cPane = appFrame.getContentPane();
cPane.setLayout(new GridBagLayout());

//Arrange components on contentPane and set Action Listeners to each JButton


arrangeComponents();

appFrame.setSize(1200,1200);
appFrame.setResizable(false);
appFrame.setVisible(true);
appFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void arrangeComponents(){
jlbpid = new JLabel("pid");
jlbtreatment= new JLabel(" treatment");
jlbamount = new JLabel("amount");
jlbdate = new JLabel("date");

jtfpid = new JTextField(20);


jtftreatment = new JTextField(20);
jtfamount = new JTextField(20);
jtfdate = new JTextField(20);

jbnDelete = new JButton("Delete");


jbnSearch = new JButton("Search");
jbnUptreatment = new JButton("Update");
jbnback = new JButton("back");

/*add all initialized components to the container*/


GridBagConstraints gridBagConstraintsx01 = new GridBagConstraints();
gridBagConstraintsx01.gridx = 0;
gridBagConstraintsx01.gridy = 0;
gridBagConstraintsx01.insets = new Insets(5,5,5,5);
cPane.add(jlbpid, gridBagConstraintsx01);

GridBagConstraints gridBagConstraintsx02 = new GridBagConstraints();


gridBagConstraintsx02.gridx = 1;
gridBagConstraintsx02.insets = new Insets(5,5,5,5);
gridBagConstraintsx02.gridy = 0;
gridBagConstraintsx02.gridwidth = 2;
gridBagConstraintsx02.fill = GridBagConstraints.BOTH;
cPane.add(jtfpid, gridBagConstraintsx02);

GridBagConstraints gridBagConstraintsx03 = new GridBagConstraints();


gridBagConstraintsx03.gridx = 0;
gridBagConstraintsx03.insets = new Insets(5,5,5,5);
gridBagConstraintsx03.gridy = 1;
cPane.add(jlbtreatment, gridBagConstraintsx03);

GridBagConstraints gridBagConstraintsx04 = new GridBagConstraints();


gridBagConstraintsx04.gridx = 1;
gridBagConstraintsx04.insets = new Insets(5,5,5,5);
gridBagConstraintsx04.gridy = 1;
gridBagConstraintsx04.gridwidth = 2;
gridBagConstraintsx04.fill = GridBagConstraints.BOTH;
cPane.add(jtftreatment, gridBagConstraintsx04);

GridBagConstraints gridBagConstraintsx05 = new GridBagConstraints();


gridBagConstraintsx05.gridx = 0;
gridBagConstraintsx05.insets = new Insets(5,5,5,5);
gridBagConstraintsx05.gridy = 2;
cPane.add(jlbamount, gridBagConstraintsx05);

GridBagConstraints gridBagConstraintsx06 = new GridBagConstraints();


gridBagConstraintsx06.gridx = 1;
gridBagConstraintsx06.gridy = 2;
gridBagConstraintsx06.insets = new Insets(5,5,5,5);
gridBagConstraintsx06.gridwidth = 2;
gridBagConstraintsx06.fill = GridBagConstraints.BOTH;
cPane.add(jtfamount, gridBagConstraintsx06);

GridBagConstraints gridBagConstraintsx07 = new GridBagConstraints();


gridBagConstraintsx07.gridx = 0;
gridBagConstraintsx07.insets = new Insets(5,5,5,5);
gridBagConstraintsx07.gridy = 3;
cPane.add(jlbdate, gridBagConstraintsx07);

GridBagConstraints gridBagConstraintsx08 = new GridBagConstraints();


gridBagConstraintsx08.gridx = 1;
gridBagConstraintsx08.gridy = 3;
gridBagConstraintsx08.gridwidth = 2;
gridBagConstraintsx08.insets = new Insets(5,5,5,5);
gridBagConstraintsx08.fill = GridBagConstraints.BOTH;
cPane.add(jtfdate, gridBagConstraintsx08);

GridBagConstraints gridBagConstraintsx09 = new GridBagConstraints();


gridBagConstraintsx09.gridx = 1;
gridBagConstraintsx09.gridy = 4;
gridBagConstraintsx09.insets = new Insets(5,5,5,5);
cPane.add(jbnDelete, gridBagConstraintsx09);

GridBagConstraints gridBagConstraintsx10 = new GridBagConstraints();


gridBagConstraintsx10.gridx = 2;
gridBagConstraintsx10.insets = new Insets(5,5,5,5);
gridBagConstraintsx10.gridy = 4;
cPane.add(jbnUptreatment, gridBagConstraintsx10);

GridBagConstraints gridBagConstraintsx11 = new GridBagConstraints();


gridBagConstraintsx11.gridx = 1;
gridBagConstraintsx11.insets = new Insets(5,5,5,5);
gridBagConstraintsx11.gridy = 5;
cPane.add(jbnSearch,gridBagConstraintsx11);

GridBagConstraints gridBagConstraintsx12 = new GridBagConstraints();


gridBagConstraintsx12.gridx = 2;
gridBagConstraintsx12.insets = new Insets(5,5,5,5);
gridBagConstraintsx12.gridy = 5;
cPane.add(jbnback, gridBagConstraintsx12);

jbnDelete.addActionListener(this);
jbnSearch.addActionListener(this);
jbnUptreatment.addActionListener(this);
jbnback.addActionListener(this);
}
public void actionPerformed (ActionEvent e){
if (e.getSource() == jbnDelete){
deletePerson();
clear();
}
else if (e.getSource() == jbnUptreatment){
deletePerson();
savePerson();
clear();
}

else if (e.getSource() == jbnSearch){


searchPerson();
}
else if (e.getSource() == jbnback){
new mainpage();
}}
// Save the Person into the Address Book
public void savePerson(){

pid = jtfpid.getText();
if(pid.equals("")){
JOptionPane.showMessageDialog(null, "Please enter Department
regno.");
}else{
//create a PersonInfo object and pass it to PersonDAO to save it
// PersonInfo person = new PersonInfo(name, address, phone,
email);
// pDAO.savePerson(person);

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {

con=DriverManager.getConnection("jdbc:odbc:bil","",""); }
catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
try
{
String amount=jtfamount.getText();
int amt=Integer.parseInt(amount);

String sql = "INSERT INTO treatment1 VALUES


('" + jtfpid.getText()+ "','" + jtftreatment.getText() + "'," + amt + ",'" + jtfdate.getText() + "')";

//JTextField jtfName, jtfAddress, jtfPhone,


jtfEmail,jtfIpdno,jtfGender,jtfMarital,jtfFname,jtfDoa,jtfDocref,jtfTpo,jtfCons;;

jtfpid.setText(sql);

PreparedStatement ps =
con.prepareStatement(sql);
ps.executeUpdate();
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e.toString());
}

JOptionPane.showMessageDialog(null, "Record Saved");


}}

public void deletePerson(){


pid= jtfpid.getText();
pid = pid.toUpperCase();
if(pid.equals("")){
JOptionPane.showMessageDialog(null,"Please enter doctor registration number.");
}
else{
//remove Person of the given name from the Address Book database
int numberOfDeleted =removePerson(pid);
JOptionPane.showMessageDialog(null, numberOfDeleted + " Record(s)
deleted.");
}}
public int removePerson(String id)
{
int no = 0;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try{
String sql = "DELETE FROM treatment1 WHERE pid = '" + pid + "'";
System.out.println(id);
// Create a Pressared statement
//con=DriverManager.getConnection("jdbc:odbc:ho","","");
} catch(SQLException ex) {

PreparedStatement ps = con.prepareStatement(sql);

ps.executeUpdate();
no=1;
}
catch(Exception e){
System.out.println(e);
}

return no;
}
//Perform a Case-Insensitive Search to find the Person

void searchPerson()
{
String pid,treatment, amount,date;
pid="";
treatment="";
amount="";
date="";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try {

String sql = "SELECT * FROM treatment1 WHERE pid= '"+ jtfpid.getText() +"'";

// Create a prepared statement


Statement s = con.createStatement();

ResultSet rs = s.executeQuery(sql);
if(rs.next())
{

pid = rs.getString("pid");
treatment= rs.getString("treatment");
amount= rs.getString("amount");
date = rs.getString("date");
//Create a PersonInfo object
//PersonInfo person = new
PersonInfo(pid,did,dname,address,fname,lline,mobile,category,exp,eid,tfrom,tto,rno,ipdcharge,opdc
harge);

//Add the person object to array list


//personsList.add(person);
jtfpid.setText(pid);
jtftreatment.setText(treatment);
jtfamount.setText(amount);
jtfdate.setText(date);
}
}
catch(Exception e){
System.out.println("D");
System.out.println(e);
}
//return personsList;
}

public void clear(){


jtfpid.setText("");
jtftreatment.setText("");
jtfamount.setText("");
jtfdate.setText("");
}}

Editroom.java

package patient;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
//import java.sql.ResultSet;
import java.sql.SQLException;
//import java.sql.Statement;
//import java.util.ArrayList;
//import java.sql.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

public class editroom implements ActionListener


{

private Connection con;


JFrame appFrame;

JLabel jlbroomtype,jlbroomno, jlbcharges,jlbipd;


JTextField jtfroomtype,jtfroomno, jtfcharges,jtfipd;;

String roomtype,roomno, charges,ipd;

JButton jbnDelete, jbnUpdate, jbnSearch, jbnExit,jbnback;

Container cPane;
public static void main(String args[]){
new editroom();
}
public editroom()
{
roomtype="";
roomno="";
charges="";
ipd="";
createGUI();

public void createGUI(){

/*Create a frame, get its contentpane and set layout*/


appFrame = new JFrame("Edit Room Details");

cPane = appFrame.getContentPane();
cPane.setLayout(new GridBagLayout());

//Arrange components on contentPane and set Action Listeners to each JButton


arrangeComponents();

appFrame.setSize(1200,1200);
appFrame.setResizable(false);
appFrame.setVisible(true);
appFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

public void arrangeComponents(){


jlbroomtype = new JLabel("roomtype");
jlbroomno= new JLabel(" roomno");
jlbcharges = new JLabel("charges");
jlbipd = new JLabel("ipd");

jtfroomtype = new JTextField(20);


jtfroomno = new JTextField(20);
jtfcharges = new JTextField(20);
jtfipd = new JTextField(20);
jbnDelete = new JButton("Delete");
jbnSearch = new JButton("Search");
jbnUpdate = new JButton("Update");
jbnExit = new JButton("Exit");
jbnback=new JButton("Back");

/*add all initialized components to the container*/


GridBagConstraints gridBagConstraintsx01 = new GridBagConstraints();
gridBagConstraintsx01.gridx = 0;
gridBagConstraintsx01.gridy = 0;
gridBagConstraintsx01.insets = new Insets(5,5,5,5);
cPane.add(jlbroomtype, gridBagConstraintsx01);

GridBagConstraints gridBagConstraintsx02 = new GridBagConstraints();


gridBagConstraintsx02.gridx = 1;
gridBagConstraintsx02.insets = new Insets(5,5,5,5);
gridBagConstraintsx02.gridy = 0;
gridBagConstraintsx02.gridwidth = 2;
gridBagConstraintsx02.fill = GridBagConstraints.BOTH;
cPane.add(jtfroomtype, gridBagConstraintsx02);

GridBagConstraints gridBagConstraintsx03 = new GridBagConstraints();


gridBagConstraintsx03.gridx = 0;
gridBagConstraintsx03.insets = new Insets(5,5,5,5);
gridBagConstraintsx03.gridy = 1;
cPane.add(jlbroomno, gridBagConstraintsx03);

GridBagConstraints gridBagConstraintsx04 = new GridBagConstraints();


gridBagConstraintsx04.gridx = 1;
gridBagConstraintsx04.insets = new Insets(5,5,5,5);
gridBagConstraintsx04.gridy = 1;
gridBagConstraintsx04.gridwidth = 2;
gridBagConstraintsx04.fill = GridBagConstraints.BOTH;
cPane.add(jtfroomno, gridBagConstraintsx04);

GridBagConstraints gridBagConstraintsx05 = new GridBagConstraints();


gridBagConstraintsx05.gridx = 0;
gridBagConstraintsx05.insets = new Insets(5,5,5,5);
gridBagConstraintsx05.gridy = 2;
cPane.add(jlbcharges, gridBagConstraintsx05);

GridBagConstraints gridBagConstraintsx06 = new GridBagConstraints();


gridBagConstraintsx06.gridx = 1;
gridBagConstraintsx06.gridy = 2;
gridBagConstraintsx06.insets = new Insets(5,5,5,5);
gridBagConstraintsx06.gridwidth = 2;
gridBagConstraintsx06.fill = GridBagConstraints.BOTH;
cPane.add(jtfcharges, gridBagConstraintsx06);

GridBagConstraints gridBagConstraintsx09 = new GridBagConstraints();


gridBagConstraintsx09.gridx = 0;
gridBagConstraintsx09.gridy = 4;
gridBagConstraintsx09.insets = new Insets(5,5,5,5);
cPane.add(jbnDelete, gridBagConstraintsx09);

GridBagConstraints gridBagConstraintsx10 = new GridBagConstraints();


gridBagConstraintsx10.gridx = 1;
gridBagConstraintsx10.insets = new Insets(5,5,5,5);
gridBagConstraintsx10.gridy = 4;
cPane.add(jbnUpdate, gridBagConstraintsx10);

GridBagConstraints gridBagConstraintsx11 = new GridBagConstraints();


gridBagConstraintsx11.gridx = 2;
gridBagConstraintsx11.insets = new Insets(5,5,5,5);
gridBagConstraintsx11.gridy = 4;
cPane.add(jbnSearch,gridBagConstraintsx11);

GridBagConstraints gridBagConstraintsx12 = new GridBagConstraints();


gridBagConstraintsx12.gridx = 3;
gridBagConstraintsx12.insets = new Insets(5,5,5,5);
gridBagConstraintsx12.gridy = 4;
cPane.add(jbnExit, gridBagConstraintsx12);

GridBagConstraints gridBagConstraintsx13 = new GridBagConstraints();


gridBagConstraintsx13.gridx = 4;
gridBagConstraintsx13.insets = new Insets(5,5,5,5);
gridBagConstraintsx13.gridy = 4;
cPane.add(jbnback, gridBagConstraintsx13);

jbnDelete.addActionListener(this);
jbnSearch.addActionListener(this);
jbnUpdate.addActionListener(this);
jbnExit.addActionListener(this);
jbnback.addActionListener(this);

} public void actionPerformed (ActionEvent e){

if (e.getSource() == jbnDelete){
deletePerson();
clear();
}

else if (e.getSource() == jbnUpdate){


deletePerson();
savePerson();
clear();
}

else if (e.getSource() == jbnSearch){


searchPerson();
}
else if (e.getSource() == jbnExit){
System.exit(0);
}
else if (e.getSource() == jbnback){
new mainpage();
}

}
// Save the Person into the Address Book
public void savePerson(){

roomtype = jtfroomtype.getText();
if(roomtype.equals("")){
JOptionPane.showMessageDialog(null, "Please enter Department
regno.");
}else{
//create a PersonInfo object and pass it to PersonDAO to save it
// PersonInfo person = new PersonInfo(name, address, phone,
email);
// pDAO.savePerson(person);

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {

con=DriverManager.getConnection("jdbc:odbc:bil","",""); }
catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try
{
String sql = "INSERT INTO room VALUES ('" +
jtfroomtype.getText()+ "','" + jtfroomno.getText() + "','" + jtfcharges.getText() + "','" + jtfipd.getText()
+ "')";

//JTextField jtfName, jtfAddress, jtfPhone,


jtfEmail,jtfIpdno,jtfGender,jtfMarital,jtfFname,jtfDoa,jtfDocref,jtfTpo,jtfCons;;

PreparedStatement ps =
con.prepareStatement(sql);

ps.executeUpdate();
}
catch(Exception e){
JOptionPane.showMessageDialog(null,
e.toString());
}

JOptionPane.showMessageDialog(null, "Record Saved");


}}

public void deletePerson(){


roomno= jtfroomno.getText();
roomno = roomno.toUpperCase();
if(roomno.equals("")){
JOptionPane.showMessageDialog(null,"Please enter doctor registration
number.");
}
else{
//remove Person of the given name from the Address Book database
int numberOfDeleted =removePerson(roomno);
JOptionPane.showMessageDialog(null, numberOfDeleted + " Record(s)
deleted.");
}

}
public int removePerson(String id)
{
int no = 0;

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try{
String sql = "DELETE FROM room WHERE roomno = '" + roomno +
"'";
System.out.println(id);
// Create a Pressared statement
//con=DriverManager.getConnection("jdbc:odbc:ho","","");
} catch(SQLException ex) {

PreparedStatement ps = con.prepareStatement(sql);

ps.executeUpdate();
no=1;
}
catch(Exception e){
System.out.println(e);
}

return no;
}
//Perform a Case-Insensitive Search to find the Person

void searchPerson()
{
String roomtype,roomno, charges,ipd;
roomtype="";
roomno="";
charges="";
ipd="";

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try {

String sql = "SELECT * FROM room WHERE roomno= '"+ jtfroomno.getText() +"'";

// Create a prepared statement


Statement s = con.createStatement();

ResultSet rs = s.executeQuery(sql);

if(rs.next())
{

roomtype = rs.getString("roomtype");
roomno= rs.getString("roomno");
charges= rs.getString("charges");
ipd = rs.getString("ipd");
//Create a PersonInfo object
//PersonInfo person = new
PersonInfo(pid,did,dname,address,fname,lline,mobile,category,exp,eid,tfrom,tto,rno,ipdcharge,opdc
harge);

//Add the person object to array list


//personsList.add(person);
jtfroomtype.setText(roomtype);
jtfroomno.setText(roomno);
jtfcharges.setText(charges);
jtfipd.setText(ipd);
}
else
{
JOptionPane.showMessageDialog(cPane, " Record Not Exist");
}

}
catch(Exception e){
System.out.println("D");
System.out.println(e);
}

//return personsList;

public void clear(){

jtfroomtype.setText("");
jtfroomno.setText("");
jtfcharges.setText("");
jtfipd.setText("");
}}
Drugmaster.java

package patient;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
//import java.sql.ResultSet;
import java.sql.SQLException;
//import java.sql.Statement;
//import java.util.ArrayList;
//import java.sql.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

public class drugmaster1 implements ActionListener


{

private Connection con;


JFrame appFrame;

JLabel jlbdrugcode,jlbdrugtype, jlbdrugname,jlbdate,jlbquantity,jlbbalance,jlbexpirydate;


JTextField jtfdrugcode,jtfdrugtype, jtfdrugname,jtfdate,jtfquantity,jtfbalance,jtfexpirydate;
JButton jbnDelete, jbnUpdate, jbnSearch, jbnback;

String drugcode,drugtype,drugname,date,quantity,balance,expirydate;

Container cPane;
public static void main(String args[]){
new drugmaster1();
}

public drugmaster1()
{
drugcode="";
drugtype="";
drugname="";
date="";
quantity="";
balance="";
expirydate="";
createGUI();
}

public void createGUI(){

/*Create a frame, get its contentpane and set layout*/


appFrame = new JFrame("DRUG MASTER");

cPane = appFrame.getContentPane();
cPane.setLayout(new GridBagLayout());

//Arrange components on contentPane and set Action Listeners to each JButton


arrangeComponents();

appFrame.setSize(1200,1200);
appFrame.setResizable(false);
appFrame.setVisible(true);
appFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

public void arrangeComponents(){


jlbdrugcode = new JLabel("Drug Code");
jlbdrugtype = new JLabel(" Drug Type");
jlbdrugname = new JLabel("Drug Name");
jlbdate = new JLabel("Date");
jlbquantity = new JLabel("Quantity");
jlbbalance= new JLabel("Balance");
jlbexpirydate = new JLabel("Expiry Date");

jtfdrugcode = new JTextField(20);


jtfdrugtype = new JTextField(20);
jtfdrugname = new JTextField(20);
jtfdate = new JTextField(20);
jtfquantity = new JTextField(20);
jtfbalance = new JTextField(20);
jtfexpirydate = new JTextField(20);

jbnDelete = new JButton("Delete");


jbnSearch = new JButton("Search");
jbnUpdate = new JButton("Update");
jbnback = new JButton("back");

/*add all initialized components to the container*/


GridBagConstraints gridBagConstraintsx01 = new GridBagConstraints();
gridBagConstraintsx01.gridx = 0;
gridBagConstraintsx01.gridy = 0;
gridBagConstraintsx01.insets = new Insets(5,5,5,5);
cPane.add(jlbdrugcode, gridBagConstraintsx01);

GridBagConstraints gridBagConstraintsx02 = new GridBagConstraints();


gridBagConstraintsx02.gridx = 1;
gridBagConstraintsx02.insets = new Insets(5,5,5,5);
gridBagConstraintsx02.gridy = 0;
gridBagConstraintsx02.gridwidth = 2;
gridBagConstraintsx02.fill = GridBagConstraints.BOTH;
cPane.add(jtfdrugcode, gridBagConstraintsx02);

GridBagConstraints gridBagConstraintsx03 = new GridBagConstraints();


gridBagConstraintsx03.gridx = 0;
gridBagConstraintsx03.insets = new Insets(5,5,5,5);
gridBagConstraintsx03.gridy = 1;
cPane.add(jlbdrugtype, gridBagConstraintsx03);

GridBagConstraints gridBagConstraintsx04 = new GridBagConstraints();


gridBagConstraintsx04.gridx = 1;
gridBagConstraintsx04.insets = new Insets(5,5,5,5);
gridBagConstraintsx04.gridy = 1;
gridBagConstraintsx04.gridwidth = 2;
gridBagConstraintsx04.fill = GridBagConstraints.BOTH;
cPane.add(jtfdrugtype, gridBagConstraintsx04);

GridBagConstraints gridBagConstraintsx05 = new GridBagConstraints();


gridBagConstraintsx05.gridx = 0;
gridBagConstraintsx05.insets = new Insets(5,5,5,5);
gridBagConstraintsx05.gridy = 2;
cPane.add(jlbdrugname, gridBagConstraintsx05);

GridBagConstraints gridBagConstraintsx06 = new GridBagConstraints();


gridBagConstraintsx06.gridx = 1;
gridBagConstraintsx06.gridy = 2;
gridBagConstraintsx06.insets = new Insets(5,5,5,5);
gridBagConstraintsx06.gridwidth = 2;
gridBagConstraintsx06.fill = GridBagConstraints.BOTH;
cPane.add(jtfdrugname, gridBagConstraintsx06);

GridBagConstraints gridBagConstraintsx07 = new GridBagConstraints();


gridBagConstraintsx07.gridx = 0;
gridBagConstraintsx07.insets = new Insets(5,5,5,5);
gridBagConstraintsx07.gridy = 3;
cPane.add(jlbdate, gridBagConstraintsx07);

GridBagConstraints gridBagConstraintsx08 = new GridBagConstraints();


gridBagConstraintsx08.gridx = 1;
gridBagConstraintsx08.gridy = 3;
gridBagConstraintsx08.gridwidth = 2;
gridBagConstraintsx08.insets = new Insets(5,5,5,5);
gridBagConstraintsx08.fill = GridBagConstraints.BOTH;
cPane.add(jtfdate, gridBagConstraintsx08);

GridBagConstraints gridBagConstraintsx09 = new GridBagConstraints();


gridBagConstraintsx09.gridx = 0;
gridBagConstraintsx09.gridy = 4;
gridBagConstraintsx09.insets = new Insets(5,5,5,5);
cPane.add(jlbquantity, gridBagConstraintsx09);

GridBagConstraints gridBagConstraintsx10 = new GridBagConstraints();


gridBagConstraintsx10.gridx = 1;
gridBagConstraintsx10.gridy = 4;
gridBagConstraintsx10.insets = new Insets(5,5,5,5);
gridBagConstraintsx10.gridwidth = 2;
gridBagConstraintsx10.fill = GridBagConstraints.BOTH;
cPane.add(jtfquantity, gridBagConstraintsx10);

GridBagConstraints gridBagConstraintsx11 = new GridBagConstraints();


gridBagConstraintsx11.gridx = 0;
gridBagConstraintsx11.gridy = 5;
gridBagConstraintsx11.insets = new Insets(5,5,5,5);
cPane.add(jlbbalance, gridBagConstraintsx11);

GridBagConstraints gridBagConstraintsx12 = new GridBagConstraints();


gridBagConstraintsx12.gridx = 1;
gridBagConstraintsx12.gridy = 5;
gridBagConstraintsx12.insets = new Insets(5,5,5,5);
gridBagConstraintsx12.gridwidth = 2;
gridBagConstraintsx12.fill = GridBagConstraints.BOTH;
cPane.add(jtfbalance, gridBagConstraintsx12);

GridBagConstraints gridBagConstraintsx13 = new GridBagConstraints();


gridBagConstraintsx13.gridx = 0;
gridBagConstraintsx13.gridy = 6;
gridBagConstraintsx13.insets = new Insets(5,5,5,5);
cPane.add(jlbexpirydate, gridBagConstraintsx13);

GridBagConstraints gridBagConstraintsx14 = new GridBagConstraints();


gridBagConstraintsx14.gridx = 1;
gridBagConstraintsx14.gridy = 6;
gridBagConstraintsx14.insets = new Insets(5,5,5,5);
gridBagConstraintsx14.gridwidth = 2;
gridBagConstraintsx14.fill = GridBagConstraints.BOTH;
cPane.add(jtfexpirydate, gridBagConstraintsx14);

GridBagConstraints gridBagConstraintsx15 = new GridBagConstraints();


gridBagConstraintsx15.gridx = 1;
gridBagConstraintsx15.gridy = 7;
gridBagConstraintsx15.insets = new Insets(5,5,5,5);
cPane.add(jbnDelete, gridBagConstraintsx15);

GridBagConstraints gridBagConstraintsx16 = new GridBagConstraints();


gridBagConstraintsx16.gridx = 2;
gridBagConstraintsx16.insets = new Insets(5,5,5,5);
gridBagConstraintsx16.gridy = 7;
cPane.add(jbnUpdate, gridBagConstraintsx16);

GridBagConstraints gridBagConstraintsx17 = new GridBagConstraints();


gridBagConstraintsx17.gridx = 1;
gridBagConstraintsx17.gridy = 8;
gridBagConstraintsx17.insets = new Insets(5,5,5,5);
cPane.add(jbnSearch, gridBagConstraintsx17);

GridBagConstraints gridBagConstraintsx18 = new GridBagConstraints();


gridBagConstraintsx18.gridx = 2;
gridBagConstraintsx18.insets = new Insets(5,5,5,5);
gridBagConstraintsx18.gridy = 8;
cPane.add(jbnback, gridBagConstraintsx18);

jbnDelete.addActionListener(this);
jbnSearch.addActionListener(this);
jbnUpdate.addActionListener(this);
jbnback.addActionListener(this);
}

public void actionPerformed (ActionEvent e){

if (e.getSource() == jbnDelete){
deletePerson();
clear();
}

else if (e.getSource() == jbnUpdate){


deletePerson();
savePerson();
clear();
}

else if (e.getSource() == jbnSearch){


searchPerson();
}
else if (e.getSource() == jbnback){
new mainpage();
}}
// Save the Person into the Address Book
public void savePerson(){

drugcode = jtfdrugcode.getText();
if(drugcode.equals("")){
JOptionPane.showMessageDialog(null, "Please enter Department regno.");
}else{
//create a PersonInfo object and pass it to PersonDAO to save it
// PersonInfo person = new PersonInfo(name, address, phone, email);
// pDAO.savePerson(person);

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try
{
String sql = "INSERT INTO drugmaster1 VALUES ('" +
jtfdrugcode.getText()+ "','" + jtfdrugtype.getText() + "','" + jtfdrugname.getText() + "','" +
jtfdate.getText() + "','" + jtfquantity.getText() + "','" + jtfbalance.getText() + "','" +
jtfexpirydate.getText() + "')";

//JTextField jtfName, jtfAddress, jtfPhone,


jtfEmail,jtfIpdno,jtfGender,jtfMarital,jtfFname,jtfDoa,jtfDocref,jtfTpo,jtfCons;;

PreparedStatement ps = con.prepareStatement(sql);

ps.executeUpdate();
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e.toString());
}

JOptionPane.showMessageDialog(null, "Record Saved");


}}

public void deletePerson(){


drugcode= jtfdrugcode.getText();
drugcode = drugcode.toUpperCase();
if(drugcode.equals("")){
JOptionPane.showMessageDialog(null,"Please enter doctor registration number.");
}
else{
//remove Person of the given name from the Address Book database
int numberOfDeleted =removePerson(drugcode);
JOptionPane.showMessageDialog(null, numberOfDeleted + " Record(s)
deleted.");
}

}
public int removePerson(String id)
{
int no = 0;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try{
String sql = "DELETE FROM drugmaster1 WHERE drug = '" + drugcode + "'";
System.out.println(id);
// Create a Pressared statement
//con=DriverManager.getConnection("jdbc:odbc:ho","","");
} catch(SQLException ex) {

PreparedStatement ps = con.prepareStatement(sql);

ps.executeUpdate();
no=1;
}
catch(Exception e){
System.out.println(e);
}

return no;
}
//Perform a Case-Insensitive Search to find the Person

void searchPerson()
{
String drugcode,drugtype,drugname,date,quantity,balance,expirydate;

drugcode="";
drugtype="";
drugname="";
date="";
quantity="";
balance="";
expirydate="";

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try {

String sql = "SELECT * FROM drugmaster1 WHERE drug= '"+


jtfdrugcode.getText() +"'";

// Create a prepared statement


Statement s = con.createStatement();

ResultSet rs = s.executeQuery(sql);

if(rs.next())
{
drugcode = rs.getString("drug");
drugtype= rs.getString("drugtype");
drugname = rs.getString("drugname");
date = rs.getString("date");
quantity = rs.getString("quantity");
balance= rs.getString("balance");
expirydate = rs.getString("expirydate");
//Create a PersonInfo object
//PersonInfo person = new
PersonInfo(pid,did,dname,address,fname,lline,mobile,category,exp,eid,tfrom,tto,rno,ipdcharge,opdc
harge);
//Add the person object to array list
//personsList.add(person);
jtfdrugcode.setText(drugcode);
jtfdrugtype.setText(drugtype);
jtfdrugname.setText(drugname);
jtfdate.setText(date);
jtfquantity.setText(quantity);
jtfbalance.setText(balance);
jtfexpirydate.setText(expirydate);
}
}
catch(Exception e){
System.out.println("D");
System.out.println(e);
}

//return personsList;

public void clear(){


jtfdrugcode.setText("");
jtfdrugtype.setText("");
jtfdrugname.setText("");
jtfdate.setText("");
jtfquantity.setText("");
jtfbalance.setText("");
jtfexpirydate.setText("");

}}

Docschedule.java

package patient;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
//import java.sql.ResultSet;
import java.sql.SQLException;
//import java.sql.Statement;
//import java.util.ArrayList;
//import java.sql.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

public class docschedule1 implements ActionListener


{

private Connection con;


JFrame appFrame;

JLabel jlbdregno, jlbday,jlboperations,jlbinpatients,jlboutpatients,jlbworkinghours;


JTextField jtfdregno,
jtfday,jtfoperations,jtfinpatients,jtfoutpatients,jtfworkinghours;

JButton jbnDelete, jbnUpdate, jbnSearch, jbnback;


String dregno, day,operations,inpatients,outpatients,workinghours;

Container cPane;
public static void main(String args[]){
new docschedule1();
}

public docschedule1()
{
dregno="";
day="";
operations="";
inpatients="";
outpatients="";
workinghours="";

createGUI();

public void createGUI(){

/*Create a frame, get its contentpane and set layout*/


appFrame = new JFrame("EDIT DOCTOR SCHEDULE");

cPane = appFrame.getContentPane();
cPane.setLayout(new GridBagLayout());
//Arrange components on contentPane and set Action Listeners to each JButton
arrangeComponents();

appFrame.setSize(1200,1200);
appFrame.setResizable(false);
appFrame.setVisible(true);
appFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

public void arrangeComponents(){


jlbdregno = new JLabel("Doctors reg no");
jlbday = new JLabel("Day");
jlboperations = new JLabel("operations");
jlbinpatients = new JLabel("inpatients");
jlboutpatients = new JLabel("Out Patients");
jlbworkinghours = new JLabel("Working Hours");

jtfdregno = new JTextField(20);


jtfday = new JTextField(20);
jtfoperations = new JTextField(20);
jtfinpatients = new JTextField(20);
jtfoutpatients = new JTextField(20);

jtfworkinghours = new JTextField(20);


jbnDelete = new JButton("Delete");
jbnSearch = new JButton("Search");
jbnUpdate = new JButton("Update");
jbnback = new JButton("back");

/*add all initialized components to the container*/


GridBagConstraints gridBagConstraintsx01 = new GridBagConstraints();
gridBagConstraintsx01.gridx = 0;
gridBagConstraintsx01.gridy = 0;
gridBagConstraintsx01.insets = new Insets(5,5,5,5);
cPane.add(jlbdregno, gridBagConstraintsx01);

GridBagConstraints gridBagConstraintsx02 = new GridBagConstraints();


gridBagConstraintsx02.gridx = 1;
gridBagConstraintsx02.insets = new Insets(5,5,5,5);
gridBagConstraintsx02.gridy = 0;
gridBagConstraintsx02.gridwidth = 2;
gridBagConstraintsx02.fill = GridBagConstraints.BOTH;
cPane.add(jtfdregno, gridBagConstraintsx02);

GridBagConstraints gridBagConstraintsx03 = new GridBagConstraints();


gridBagConstraintsx03.gridx = 0;
gridBagConstraintsx03.insets = new Insets(5,5,5,5);
gridBagConstraintsx03.gridy = 1;
cPane.add(jlbday, gridBagConstraintsx03);

GridBagConstraints gridBagConstraintsx04 = new GridBagConstraints();


gridBagConstraintsx04.gridx = 1;
gridBagConstraintsx04.gridy = 1;
gridBagConstraintsx04.insets = new Insets(5,5,5,5);
gridBagConstraintsx04.gridwidth = 2;
gridBagConstraintsx04.fill = GridBagConstraints.BOTH;
cPane.add(jtfday, gridBagConstraintsx04);

GridBagConstraints gridBagConstraintsx05 = new GridBagConstraints();


gridBagConstraintsx05.gridx = 0;
gridBagConstraintsx05.insets = new Insets(5,5,5,5);
gridBagConstraintsx05.gridy = 2;
cPane.add(jlboperations, gridBagConstraintsx05);

GridBagConstraints gridBagConstraintsx06 = new GridBagConstraints();


gridBagConstraintsx06.gridx = 1;
gridBagConstraintsx06.gridy = 2;
gridBagConstraintsx06.insets = new Insets(5,5,5,5);
gridBagConstraintsx06.gridwidth = 2;
gridBagConstraintsx06.fill = GridBagConstraints.BOTH;
cPane.add(jtfoperations, gridBagConstraintsx06);

GridBagConstraints gridBagConstraintsx07 = new GridBagConstraints();


gridBagConstraintsx07.gridx = 0;
gridBagConstraintsx07.insets = new Insets(5,5,5,5);
gridBagConstraintsx07.gridy = 3;
cPane.add(jlbinpatients, gridBagConstraintsx07);

GridBagConstraints gridBagConstraintsx08 = new GridBagConstraints();


gridBagConstraintsx08.gridx = 1;
gridBagConstraintsx08.gridy = 3;
gridBagConstraintsx08.insets = new Insets(5,5,5,5);
gridBagConstraintsx08.gridwidth = 2;
gridBagConstraintsx08.fill = GridBagConstraints.BOTH;
cPane.add(jtfinpatients, gridBagConstraintsx08);

GridBagConstraints gridBagConstraintsx09 = new GridBagConstraints();


gridBagConstraintsx09.gridx = 0;
gridBagConstraintsx09.insets = new Insets(5,5,5,5);
gridBagConstraintsx09.gridy = 4;
cPane.add(jlboutpatients, gridBagConstraintsx09);

GridBagConstraints gridBagConstraintsx10 = new GridBagConstraints();


gridBagConstraintsx10.gridx = 1;
gridBagConstraintsx10.gridy = 4;
gridBagConstraintsx10.insets = new Insets(5,5,5,5);
gridBagConstraintsx10.gridwidth = 2;
gridBagConstraintsx10.fill = GridBagConstraints.BOTH;
cPane.add(jtfoutpatients, gridBagConstraintsx10);

GridBagConstraints gridBagConstraintsx11 = new GridBagConstraints();


gridBagConstraintsx11.gridx = 0;
gridBagConstraintsx11.insets = new Insets(5,5,5,5);
gridBagConstraintsx11.gridy = 5;
cPane.add(jlbworkinghours, gridBagConstraintsx11);

GridBagConstraints gridBagConstraintsx12 = new GridBagConstraints();


gridBagConstraintsx12.gridx = 1;
gridBagConstraintsx12.gridy = 5;
gridBagConstraintsx12.insets = new Insets(5,5,5,5);
gridBagConstraintsx12.gridwidth = 2;
gridBagConstraintsx12.fill = GridBagConstraints.BOTH;
cPane.add(jtfworkinghours, gridBagConstraintsx12);

GridBagConstraints gridBagConstraintsx13 = new GridBagConstraints();


gridBagConstraintsx13.gridx = 1;
gridBagConstraintsx13.gridy = 6;
gridBagConstraintsx13.insets = new Insets(5,5,5,5);
cPane.add(jbnDelete, gridBagConstraintsx13);

GridBagConstraints gridBagConstraintsx14 = new GridBagConstraints();


gridBagConstraintsx14.gridx = 2;
gridBagConstraintsx14.insets = new Insets(5,5,5,5);
gridBagConstraintsx14.gridy = 6;
cPane.add(jbnUpdate, gridBagConstraintsx14);

GridBagConstraints gridBagConstraintsx15 = new GridBagConstraints();


gridBagConstraintsx15.gridx = 1;
gridBagConstraintsx15.gridy = 7;
gridBagConstraintsx15.insets = new Insets(5,5,5,5);
cPane.add(jbnSearch, gridBagConstraintsx15);

GridBagConstraints gridBagConstraintsx16 = new GridBagConstraints();


gridBagConstraintsx16.gridx = 2;
gridBagConstraintsx16.insets = new Insets(5,5,5,5);
gridBagConstraintsx16.gridy = 7;
cPane.add(jbnback, gridBagConstraintsx16);

jbnDelete.addActionListener(this);
jbnSearch.addActionListener(this);
jbnUpdate.addActionListener(this);
jbnback.addActionListener(this);
}

public void actionPerformed (ActionEvent e){

if (e.getSource() == jbnDelete){
deletePerson();
clear();
}

else if (e.getSource() == jbnUpdate){


deletePerson();
savePerson();
clear();
}

else if (e.getSource() == jbnSearch){


searchPerson();
}
else if (e.getSource() == jbnback){
new mainpage();
}
}
// Save the Person into the Address Book
public void savePerson(){

dregno = jtfdregno.getText();

if(dregno.equals("")){
JOptionPane.showMessageDialog(null, "Please enter Doctor If.");
}else{
//create a PersonInfo object and pass it to PersonDAO to save it
// PersonInfo person = new PersonInfo(name, address, phone, email);
// pDAO.savePerson(person);

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try
{
String sql = "INSERT INTO docschedule VALUES ('" +
jtfdregno.getText()+ "','" + jtfday.getText() + "','" + jtfoperations.getText() + "','" +
jtfinpatients.getText() + "','" + jtfoutpatients.getText() + "','" + jtfworkinghours.getText() + "')";

//JTextField jtfName, jtfAddress, jtfPhone,


jtfEmail,jtfIpdno,jtfGender,jtfMarital,jtfFname,jtfDoa,jtfDocref,jtfTpo,jtfCons;;
PreparedStatement ps = con.prepareStatement(sql);
ps.executeUpdate();
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e.toString());
}

JOptionPane.showMessageDialog(null, "Record Saved");


}}
public void deletePerson(){
dregno= jtfdregno.getText();
dregno = dregno.toUpperCase();
if(dregno.equals("")){
JOptionPane.showMessageDialog(null,"Please enter doctor registration
number.");
}
else{
//remove Person of the given name from the Address Book database
int numberOfDeleted =removePerson(dregno);
JOptionPane.showMessageDialog(null, numberOfDeleted + " Record(s)
deleted.");
}

}
public int removePerson(String id)
{
int no = 0;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try{
String sql = "DELETE FROM docschedule WHERE dregno = '" + dregno + "'";
System.out.println(id);
// Create a Pressared statement
//con=DriverManager.getConnection("jdbc:odbc:ho","","");
} catch(SQLException ex) {

PreparedStatement ps = con.prepareStatement(sql);

ps.executeUpdate();
no=1;
}
catch(Exception e){
System.out.println(e);
}

return no;
}

//Perform a Case-Insensitive Search to find the Person

void searchPerson()
{
String dregno, day,operations,inpatients,outpatients,workinghours;

dregno="";
day="";
operations="";
inpatients="";
outpatients="";
workinghours="";

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try {

String sql = "SELECT * FROM docschedule WHERE dregno= '"+


jtfdregno.getText() +"'";

// Create a prepared statement


Statement s = con.createStatement();

ResultSet rs = s.executeQuery(sql);

if(rs.next())
{

dregno = rs.getString("dregno");
day= rs.getString("day");
operations = rs.getString("operations");
inpatients = rs.getString("inpatients");
outpatients = rs.getString("outpatients");
workinghours= rs.getString("working");
//Create a PersonInfo object
//PersonInfo person = new
PersonInfo(pid,did,dname,address,fname,lline,mobile,category,exp,eid,tfrom,tto,rno,ipdcharge,opdc
harge);

//Add the person object to array list


//personsList.add(person);
jtfdregno.setText(dregno);
jtfday.setText(day);
jtfoperations.setText(operations);
jtfinpatients.setText(inpatients);
jtfoutpatients.setText(outpatients);
jtfworkinghours.setText(workinghours);
}
}
catch(Exception e){
System.out.println("D");
System.out.println(e);
}

//return personsList;

public void clear(){

jtfdregno.setText("");

jtfday.setText("");
jtfoperations.setText("");
jtfinpatients.setText("");
jtfoutpatients.setText("");
jtfworkinghours.setText("");
}}

Docmaster.java

package patient;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
//import java.util.ArrayList;
//import java.sql.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

public class docmaster1 implements ActionListener


{

private Connection con;


JFrame appFrame;

JLabel jlbDregno,jlbDoc_name,
jlbDesign,jlbDept,jlbDoc_room,jlbSpec,jlbWork_hour,jlbPhone;
JTextField jtfDregno,jtfDoc_name,
jtfDesign,jtfDept,jtfDoc_room,jtfSpec,jtfWork_hour,jtfPhone;
JButton jbnDelete, jbnUpdate, jbnSearch, jbnback;
String dregno,doc_name,design,dept,doc_room,spec,work_hour,phone;

Container cPane;
public static void main(String args[]){
new docmaster1();
}

public docmaster1()
{
dregno="";
doc_name="";
design="";
dept="";
doc_room="";
spec="";
work_hour="";
phone="";
createGUI();

public void createGUI(){

/*Create a frame, get its contentpane and set layout*/


appFrame = new JFrame("Doctor details");

cPane = appFrame.getContentPane();
cPane.setLayout(new GridBagLayout());

//Arrange components on contentPane and set Action Listeners to each JButton


arrangeComponents();

appFrame.setSize(1200,1200);
appFrame.setResizable(false);
appFrame.setVisible(true);
appFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

public void arrangeComponents(){


jlbDregno = new JLabel("Department registration number");
jlbDoc_name = new JLabel(" Doctor Name");
jlbDesign = new JLabel("Designation");
jlbDept = new JLabel("Department");
jlbDoc_room = new JLabel("Doctor Room");
jlbSpec= new JLabel("Specialization");
jlbWork_hour = new JLabel("Working Hour");
jlbPhone = new JLabel("Phone");

jtfDregno = new JTextField(20);


jtfDoc_name = new JTextField(20);
jtfDesign = new JTextField(20);
jtfDept = new JTextField(20);
jtfDoc_room = new JTextField(20);
jtfSpec = new JTextField(20);
jtfWork_hour = new JTextField(20);
jtfPhone = new JTextField(20);

jbnDelete = new JButton("Delete");


jbnSearch = new JButton("Search");
jbnUpdate = new JButton("Update");
jbnback = new JButton("BACK");

/*add all initialized components to the container*/


GridBagConstraints gridBagConstraintsx01 = new GridBagConstraints();
gridBagConstraintsx01.gridx = 0;
gridBagConstraintsx01.gridy = 0;
gridBagConstraintsx01.insets = new Insets(5,5,5,5);
cPane.add(jlbDregno, gridBagConstraintsx01);

GridBagConstraints gridBagConstraintsx02 = new GridBagConstraints();


gridBagConstraintsx02.gridx = 1;
gridBagConstraintsx02.insets = new Insets(5,5,5,5);
gridBagConstraintsx02.gridy = 0;
gridBagConstraintsx02.gridwidth = 2;
gridBagConstraintsx02.fill = GridBagConstraints.BOTH;
cPane.add(jtfDregno, gridBagConstraintsx02);

GridBagConstraints gridBagConstraintsx03 = new GridBagConstraints();


gridBagConstraintsx03.gridx = 0;
gridBagConstraintsx03.insets = new Insets(5,5,5,5);
gridBagConstraintsx03.gridy = 1;
cPane.add(jlbDoc_name, gridBagConstraintsx03);

GridBagConstraints gridBagConstraintsx04 = new GridBagConstraints();


gridBagConstraintsx04.gridx = 1;
gridBagConstraintsx04.insets = new Insets(5,5,5,5);
gridBagConstraintsx04.gridy = 1;
gridBagConstraintsx04.gridwidth = 2;
gridBagConstraintsx04.fill = GridBagConstraints.BOTH;
cPane.add(jtfDoc_name, gridBagConstraintsx04);

GridBagConstraints gridBagConstraintsx05 = new GridBagConstraints();


gridBagConstraintsx05.gridx = 0;
gridBagConstraintsx05.insets = new Insets(5,5,5,5);
gridBagConstraintsx05.gridy = 2;
cPane.add(jlbDesign, gridBagConstraintsx05);

GridBagConstraints gridBagConstraintsx06 = new GridBagConstraints();


gridBagConstraintsx06.gridx = 1;
gridBagConstraintsx06.gridy = 2;
gridBagConstraintsx06.insets = new Insets(5,5,5,5);
gridBagConstraintsx06.gridwidth = 2;
gridBagConstraintsx06.fill = GridBagConstraints.BOTH;
cPane.add(jtfDesign, gridBagConstraintsx06);

GridBagConstraints gridBagConstraintsx07 = new GridBagConstraints();


gridBagConstraintsx07.gridx = 0;
gridBagConstraintsx07.insets = new Insets(5,5,5,5);
gridBagConstraintsx07.gridy = 3;
cPane.add(jlbDept, gridBagConstraintsx07);

GridBagConstraints gridBagConstraintsx08 = new GridBagConstraints();


gridBagConstraintsx08.gridx = 1;
gridBagConstraintsx08.gridy = 3;
gridBagConstraintsx08.gridwidth = 2;
gridBagConstraintsx08.insets = new Insets(5,5,5,5);
gridBagConstraintsx08.fill = GridBagConstraints.BOTH;
cPane.add(jtfDept, gridBagConstraintsx08);

GridBagConstraints gridBagConstraintsx09 = new GridBagConstraints();


gridBagConstraintsx09.gridx = 0;
gridBagConstraintsx09.gridy = 4;
gridBagConstraintsx09.insets = new Insets(5,5,5,5);
cPane.add(jlbDoc_room, gridBagConstraintsx09);

GridBagConstraints gridBagConstraintsx10 = new GridBagConstraints();


gridBagConstraintsx10.gridx = 1;
gridBagConstraintsx10.gridy = 4;
gridBagConstraintsx10.insets = new Insets(5,5,5,5);
gridBagConstraintsx10.gridwidth = 2;
gridBagConstraintsx10.fill = GridBagConstraints.BOTH;
cPane.add(jtfDoc_room, gridBagConstraintsx10);

GridBagConstraints gridBagConstraintsx11 = new GridBagConstraints();


gridBagConstraintsx11.gridx = 0;
gridBagConstraintsx11.gridy = 5;
gridBagConstraintsx11.insets = new Insets(5,5,5,5);
cPane.add(jlbSpec, gridBagConstraintsx11);

GridBagConstraints gridBagConstraintsx12 = new GridBagConstraints();


gridBagConstraintsx12.gridx = 1;
gridBagConstraintsx12.gridy = 5;
gridBagConstraintsx12.insets = new Insets(5,5,5,5);
gridBagConstraintsx12.gridwidth = 2;
gridBagConstraintsx12.fill = GridBagConstraints.BOTH;
cPane.add(jtfSpec, gridBagConstraintsx12);

GridBagConstraints gridBagConstraintsx13 = new GridBagConstraints();


gridBagConstraintsx13.gridx = 0;
gridBagConstraintsx13.gridy = 6;
gridBagConstraintsx13.insets = new Insets(5,5,5,5);
cPane.add(jlbWork_hour, gridBagConstraintsx13);

GridBagConstraints gridBagConstraintsx14 = new GridBagConstraints();


gridBagConstraintsx14.gridx = 1;
gridBagConstraintsx14.gridy = 6;
gridBagConstraintsx14.insets = new Insets(5,5,5,5);
gridBagConstraintsx14.gridwidth = 2;
gridBagConstraintsx14.fill = GridBagConstraints.BOTH;
cPane.add(jtfWork_hour, gridBagConstraintsx14);

GridBagConstraints gridBagConstraintsx15 = new GridBagConstraints();


gridBagConstraintsx15.gridx = 0;
gridBagConstraintsx15.gridy = 7;
gridBagConstraintsx15.insets = new Insets(5,5,5,5);
cPane.add(jlbPhone, gridBagConstraintsx15);

GridBagConstraints gridBagConstraintsx16 = new GridBagConstraints();


gridBagConstraintsx16.gridx = 1;
gridBagConstraintsx16.gridy = 7;
gridBagConstraintsx16.insets = new Insets(5,5,5,5);
gridBagConstraintsx16.gridwidth = 2;
gridBagConstraintsx16.fill = GridBagConstraints.BOTH;
cPane.add(jtfPhone, gridBagConstraintsx16);

GridBagConstraints gridBagConstraintsx17 = new GridBagConstraints();


gridBagConstraintsx17.gridx = 0;
gridBagConstraintsx17.gridy = 12;
gridBagConstraintsx17.insets = new Insets(5,5,5,5);
cPane.add(jbnDelete, gridBagConstraintsx17);

GridBagConstraints gridBagConstraintsx18 = new GridBagConstraints();


gridBagConstraintsx18.gridx = 1;
gridBagConstraintsx18.insets = new Insets(5,5,5,5);
gridBagConstraintsx18.gridy = 12;
cPane.add(jbnUpdate, gridBagConstraintsx18);

GridBagConstraints gridBagConstraintsx19 = new GridBagConstraints();


gridBagConstraintsx19.gridx = 2;
gridBagConstraintsx19.gridy = 12;
gridBagConstraintsx19.insets = new Insets(5,5,5,5);
cPane.add(jbnSearch, gridBagConstraintsx19);

GridBagConstraints gridBagConstraintsx20 = new GridBagConstraints();


gridBagConstraintsx20.gridx = 3;
gridBagConstraintsx20.insets = new Insets(5,5,5,5);
gridBagConstraintsx20.gridy = 12;
cPane.add(jbnback, gridBagConstraintsx20);

jbnDelete.addActionListener(this);
jbnSearch.addActionListener(this);
jbnUpdate.addActionListener(this);
jbnback.addActionListener(this);
}

public void actionPerformed (ActionEvent e){

if (e.getSource() == jbnDelete){
deletePerson();
clear();
}

else if (e.getSource() == jbnUpdate){


deletePerson();
savePerson();
clear();
}
else if (e.getSource() == jbnSearch){
searchPerson();
}
else if (e.getSource() == jbnback){
new mainpage();
}
}
// Save the Person into the Address Book
public void savePerson(){

dregno = jtfDregno.getText();
if(dregno.equals("")){
JOptionPane.showMessageDialog(null, "Please enter Department regno.");
}else{
//create a PersonInfo object and pass it to PersonDAO to save it
// PersonInfo person = new PersonInfo(name, address, phone, email);
// pDAO.savePerson(person);

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
try
{
String sql = "INSERT INTO doc_detail1 VALUES ('" +
jtfDregno.getText()+ "','" + jtfDoc_name.getText() + "','" + jtfDesign.getText() + "','" +
jtfDept.getText() + "','" + jtfDoc_room.getText() + "','" + jtfSpec.getText() + "','" +
jtfWork_hour.getText() + "','" + jtfPhone.getText() + "')";

//JTextField jtfName, jtfAddress, jtfPhone,


jtfEmail,jtfIpdno,jtfGender,jtfMarital,jtfFname,jtfDoa,jtfDocref,jtfTpo,jtfCons;;

PreparedStatement ps = con.prepareStatement(sql);

ps.executeUpdate();
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e.toString());
}

JOptionPane.showMessageDialog(null, "Record Saved");


} }

public void deletePerson(){


dregno= jtfDregno.getText();
dregno = dregno.toUpperCase();
if(dregno.equals("")){
JOptionPane.showMessageDialog(null,"Please enter doctor registration
number.");
}
else{
//remove Person of the given name from the Address Book database
int numberOfDeleted =removePerson(dregno);
JOptionPane.showMessageDialog(null, numberOfDeleted + " Record(s)
deleted.");
}

}
public int removePerson(String id)
{
int no = 0;

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try{
String sql = "DELETE FROM doc_detail1 WHERE dregno = '" + dregno +
"'";
System.out.println(id);
// Create a Pressared statement
//con=DriverManager.getConnection("jdbc:odbc:ho","","");
} catch(SQLException ex) {

PreparedStatement ps = con.prepareStatement(sql);
ps.executeUpdate();
no=1;
}
catch(Exception e){
System.out.println(e);
}

return no;
}
//Perform a Case-Insensitive Search to find the Person

void searchPerson()
{
String dregno,doc_name,design,dept,doc_room,spec,work_hour,phone;
dregno="";
doc_name="";
design="";
dept="";
doc_room="";
spec="";
work_hour="";
phone="";

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try {

String sql = "SELECT * FROM doc_detail1 WHERE dregno= '"+


jtfDregno.getText() +"'";

// Create a prepared statement


Statement s = con.createStatement();

ResultSet rs = s.executeQuery(sql);

if(rs.next())
{

dregno = rs.getString("dregno");
doc_name= rs.getString("Doc_name");
design = rs.getString("Design");
dept = rs.getString("Dept");
doc_room = rs.getString("doc_room");
spec= rs.getString("Spec");
work_hour = rs.getString("work_hour");
phone = rs.getString("phone");
//Create a PersonInfo object
//PersonInfo person = new
PersonInfo(pid,did,dname,address,fname,lline,mobile,category,exp,eid,tfrom,tto,rno,ipdcharge,opdc
harge);
//Add the person object to array list
//personsList.add(person);
jtfDregno.setText(dregno);
jtfDoc_name.setText(doc_name);
jtfDesign.setText(design);
jtfDept.setText(dept);
jtfDoc_room.setText(doc_room);
jtfSpec.setText(spec);
jtfWork_hour.setText(work_hour);
jtfPhone.setText(phone);
}
}
catch(Exception e){
System.out.println("D");
System.out.println(e);
}

//return personsList;

public void clear(){


jtfDregno.setText("");
jtfDoc_name.setText("");
jtfDesign.setText("");
jtfDept.setText("");
jtfDoc_room.setText("");
jtfSpec.setText("");
jtfWork_hour.setText("");
jtfPhone.setText("");
}}

Diet1.java

package patient;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
//import java.sql.ResultSet;
import java.sql.SQLException;
//import java.sql.Statement;
//import java.util.ArrayList;
//import java.sql.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

public class diet1 implements ActionListener


{

private Connection con;


JFrame appFrame;

JLabel jlbpid,jlbcmb, jlbhpd,jlbpm,jlbdate,jlbRemarks,jlbtotal;


JTextField jtfpid,jtfcmb, jtfhpd,jtfpm,jtfdate,jtfRemarks,jtftotal;
JButton jbnDelete, jbnUpdate, jbnSearch, jbnback;

String pid,cmb, hpd,pm,date,Remarks,total;

Container cPane;
public static void main(String args[]){
new diet1();
}

public diet1()
{
pid="";
cmb="";
hpd="";
pm="";
date="";
Remarks="";
total="";
createGUI();

public void createGUI(){

/*Create a frame, get its contentpane and set layout*/


appFrame = new JFrame("EDIT DIET");

cPane = appFrame.getContentPane();
cPane.setLayout(new GridBagLayout());

//Arrange components on contentPane and set Action Listeners to each JButton


arrangeComponents();

appFrame.setSize(1200,1200);
appFrame.setResizable(false);
appFrame.setVisible(true);
appFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

public void arrangeComponents(){


jlbpid = new JLabel("Pid");
jlbcmb = new JLabel("Quantity of cmb");
jlbhpd = new JLabel("Quantity of hpd");
jlbpm = new JLabel("Quantity of pm");
jlbdate = new JLabel("Date");
jlbRemarks= new JLabel("Remarks");
jlbtotal = new JLabel("Total Quantity");
jtfpid = new JTextField(20);
jtfcmb = new JTextField(20);
jtfhpd = new JTextField(20);
jtfpm = new JTextField(20);
jtfdate = new JTextField(20);
jtfRemarks = new JTextField(20);
jtftotal = new JTextField(20);

jbnDelete = new JButton("Delete");


jbnSearch = new JButton("Search");
jbnUpdate = new JButton("Update");
jbnback = new JButton("back");

/*add all initialized components to the container*/


GridBagConstraints gridBagConstraintsx01 = new GridBagConstraints();
gridBagConstraintsx01.gridx = 0;
gridBagConstraintsx01.gridy = 0;
gridBagConstraintsx01.insets = new Insets(5,5,5,5);
cPane.add(jlbpid, gridBagConstraintsx01);

GridBagConstraints gridBagConstraintsx02 = new GridBagConstraints();


gridBagConstraintsx02.gridx = 1;
gridBagConstraintsx02.insets = new Insets(5,5,5,5);
gridBagConstraintsx02.gridy = 0;
gridBagConstraintsx02.gridwidth = 2;
gridBagConstraintsx02.fill = GridBagConstraints.BOTH;
cPane.add(jtfpid, gridBagConstraintsx02);

GridBagConstraints gridBagConstraintsx03 = new GridBagConstraints();


gridBagConstraintsx03.gridx = 0;
gridBagConstraintsx03.insets = new Insets(5,5,5,5);
gridBagConstraintsx03.gridy = 1;
cPane.add(jlbcmb, gridBagConstraintsx03);

GridBagConstraints gridBagConstraintsx04 = new GridBagConstraints();


gridBagConstraintsx04.gridx = 1;
gridBagConstraintsx04.insets = new Insets(5,5,5,5);
gridBagConstraintsx04.gridy = 1;
gridBagConstraintsx04.gridwidth = 2;
gridBagConstraintsx04.fill = GridBagConstraints.BOTH;
cPane.add(jtfcmb, gridBagConstraintsx04);

GridBagConstraints gridBagConstraintsx05 = new GridBagConstraints();


gridBagConstraintsx05.gridx = 0;
gridBagConstraintsx05.insets = new Insets(5,5,5,5);
gridBagConstraintsx05.gridy = 2;
cPane.add(jlbhpd, gridBagConstraintsx05);

GridBagConstraints gridBagConstraintsx06 = new GridBagConstraints();


gridBagConstraintsx06.gridx = 1;
gridBagConstraintsx06.gridy = 2;
gridBagConstraintsx06.insets = new Insets(5,5,5,5);
gridBagConstraintsx06.gridwidth = 2;
gridBagConstraintsx06.fill = GridBagConstraints.BOTH;
cPane.add(jtfhpd, gridBagConstraintsx06);

GridBagConstraints gridBagConstraintsx07 = new GridBagConstraints();


gridBagConstraintsx07.gridx = 0;
gridBagConstraintsx07.insets = new Insets(5,5,5,5);
gridBagConstraintsx07.gridy = 3;
cPane.add(jlbpm, gridBagConstraintsx07);

GridBagConstraints gridBagConstraintsx08 = new GridBagConstraints();


gridBagConstraintsx08.gridx = 1;
gridBagConstraintsx08.gridy = 3;
gridBagConstraintsx08.gridwidth = 2;
gridBagConstraintsx08.insets = new Insets(5,5,5,5);
gridBagConstraintsx08.fill = GridBagConstraints.BOTH;
cPane.add(jtfpm, gridBagConstraintsx08);

GridBagConstraints gridBagConstraintsx09 = new GridBagConstraints();


gridBagConstraintsx09.gridx = 0;
gridBagConstraintsx09.gridy = 4;
gridBagConstraintsx09.insets = new Insets(5,5,5,5);
cPane.add(jlbdate, gridBagConstraintsx09);

GridBagConstraints gridBagConstraintsx10 = new GridBagConstraints();


gridBagConstraintsx10.gridx = 1;
gridBagConstraintsx10.gridy = 4;
gridBagConstraintsx10.insets = new Insets(5,5,5,5);
gridBagConstraintsx10.gridwidth = 2;
gridBagConstraintsx10.fill = GridBagConstraints.BOTH;
cPane.add(jtfdate, gridBagConstraintsx10);

GridBagConstraints gridBagConstraintsx11 = new GridBagConstraints();


gridBagConstraintsx11.gridx = 0;
gridBagConstraintsx11.gridy = 5;
gridBagConstraintsx11.insets = new Insets(5,5,5,5);
cPane.add(jlbRemarks, gridBagConstraintsx11);

GridBagConstraints gridBagConstraintsx12 = new GridBagConstraints();


gridBagConstraintsx12.gridx = 1;
gridBagConstraintsx12.gridy = 5;
gridBagConstraintsx12.insets = new Insets(5,5,5,5);
gridBagConstraintsx12.gridwidth = 2;
gridBagConstraintsx12.fill = GridBagConstraints.BOTH;
cPane.add(jtfRemarks, gridBagConstraintsx12);

GridBagConstraints gridBagConstraintsx13 = new GridBagConstraints();


gridBagConstraintsx13.gridx = 0;
gridBagConstraintsx13.gridy = 6;
gridBagConstraintsx13.insets = new Insets(5,5,5,5);
cPane.add(jlbtotal, gridBagConstraintsx13);

GridBagConstraints gridBagConstraintsx14 = new GridBagConstraints();


gridBagConstraintsx14.gridx = 1;
gridBagConstraintsx14.gridy = 6;
gridBagConstraintsx14.insets = new Insets(5,5,5,5);
gridBagConstraintsx14.gridwidth = 2;
gridBagConstraintsx14.fill = GridBagConstraints.BOTH;
cPane.add(jtftotal, gridBagConstraintsx14);

GridBagConstraints gridBagConstraintsx15 = new GridBagConstraints();


gridBagConstraintsx15.gridx = 1;
gridBagConstraintsx15.gridy = 7;
gridBagConstraintsx15.insets = new Insets(5,5,5,5);
cPane.add(jbnDelete, gridBagConstraintsx15);

GridBagConstraints gridBagConstraintsx16 = new GridBagConstraints();


gridBagConstraintsx16.gridx = 2;
gridBagConstraintsx16.insets = new Insets(5,5,5,5);
gridBagConstraintsx16.gridy = 7;
cPane.add(jbnUpdate, gridBagConstraintsx16);

GridBagConstraints gridBagConstraintsx17 = new GridBagConstraints();


gridBagConstraintsx17.gridx = 1;
gridBagConstraintsx17.gridy = 8;
gridBagConstraintsx17.insets = new Insets(5,5,5,5);
cPane.add(jbnSearch, gridBagConstraintsx17);

GridBagConstraints gridBagConstraintsx18 = new GridBagConstraints();


gridBagConstraintsx18.gridx = 2;
gridBagConstraintsx18.insets = new Insets(5,5,5,5);
gridBagConstraintsx18.gridy = 8;
cPane.add(jbnback, gridBagConstraintsx18);

jbnDelete.addActionListener(this);
jbnSearch.addActionListener(this);
jbnUpdate.addActionListener(this);
jbnback.addActionListener(this);
}

public void actionPerformed (ActionEvent e){

if (e.getSource() == jbnDelete){
deletePerson();
clear();
}

else if (e.getSource() == jbnUpdate){


deletePerson();
savePerson();
clear();
}

else if (e.getSource() == jbnSearch){


searchPerson();
}
else if (e.getSource() == jbnback){
new mainpage();
}}
// Save the Person into the Address Book
public void savePerson(){

pid = jtfpid.getText();
if(pid.equals("")){
JOptionPane.showMessageDialog(null, "Please enter Department regno.");
}else{
//create a PersonInfo object and pass it to PersonDAO to save it
// PersonInfo person = new PersonInfo(Remarksme, address, phone,
email);
// pDAO.savePerson(person);

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
} try
{
String sql = "INSERT INTO diet VALUES ('" +
jtfpid.getText()+ "','" + jtfcmb.getText() + "','" + jtfhpd.getText() + "','" + jtfpm.getText() + "','" +
jtfdate.getText() + "','" + jtfRemarks.getText() + "','" + jtftotal.getText() + "')";

//JTextField jtfRemarksme, jtfAddress, jtfPhone,


jtfEmail,jtfIpdno,jtfGender,jtfMarital,jtfFRemarksme,jtfDoa,jtfDocref,jtfTpo,jtfCons;;

PreparedStatement ps = con.prepareStatement(sql);

ps.executeUpdate();
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e.toString());
}

JOptionPane.showMessageDialog(null, "Record Saved");


}
}
public void deletePerson(){
pid= jtfpid.getText();
pid = pid.toUpperCase();
if(pid.equals("")){
JOptionPane.showMessageDialog(null,"Please enter doctor registration number.");
}
else{
//remove Person of the given Remarksme from the Address Book database
int numberOfDeleted =removePerson(pid);
JOptionPane.showMessageDialog(null, numberOfDeleted + " Record(s) deleted.");
}

}
public int removePerson(String id)
{
int no = 0;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try{
String sql = "DELETE FROM diet WHERE sago = '" + pid + "'";
System.out.println(id);
// Create a Pressared statement
//con=DriverMaRemarksger.getConnection("jdbc:odbc:ho","","");
} catch(SQLException ex) {

PreparedStatement ps = con.prepareStatement(sql);

ps.executeUpdate();
no=1;
}
catch(Exception e){
System.out.println(e);
}

return no;
}
//Perform a Case-Insensitive Search to find the Person

void searchPerson()
{
String pid,cmb, hpd,pm,date,Remarks,total;
pid="";
cmb="";
hpd="";
pm="";
date="";
Remarks="";
total="";

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try {

String sql = "SELECT * FROM diet WHERE sago= '"+ jtfpid.getText()


+"'";

// Create a prepared statement


Statement s = con.createStatement();

ResultSet rs = s.executeQuery(sql);

if(rs.next())
{

pid = rs.getString("sago");
cmb= rs.getString("qcmb");
hpd = rs.getString("hpd");
pm = rs.getString("qpm");
date = rs.getString("date");
Remarks= rs.getString("add");
total = rs.getString("tqty");
//Create a PersonInfo object
//PersonInfo person = new
PersonInfo(pid,did,dRemarksme,address,fRemarksme,lline,mobile,category,exp,eid,tfrom,tto,rno,ip
dcharge,opdcharge);

//Add the person object to array list


//personsList.add(person);
jtfpid.setText(pid);
jtfcmb.setText(cmb);
jtfhpd.setText(hpd);
jtfpm.setText(pm);
jtfdate.setText(date);
jtfRemarks.setText(Remarks);
jtftotal.setText(total);

}
}
catch(Exception e){
System.out.println("D");
System.out.println(e);
}

//return personsList;
}

public void clear(){

jtfpid.setText("");
jtfcmb.setText("");
jtfhpd.setText("");
jtfpm.setText("");
jtfdate.setText("");
jtfRemarks.setText("");
jtftotal.setText("");
}}

Department1.java

package patient;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
//import java.util.ArrayList;
//import java.sql.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

public class department1 implements ActionListener


{

private Connection con;


JFrame appFrame;

JLabel jlbDid, jlbDname;


JTextField jtfDid, jtfDname;

JButton jbnDelete, jbnUpdate, jbnSearch, jbnback;


String did,dname;
Container cPane;
public static void main(String args[]){
new department1();
}

public department1()
{
did="";

dname="";

createGUI();

public void createGUI(){

/*Create a frame, get its contentpane and set layout*/


appFrame = new JFrame(" EDIT DEPARTMENT");

cPane = appFrame.getContentPane();
cPane.setLayout(new GridBagLayout());

//Arrange components on contentPane and set Action Listeners to each JButton


arrangeComponents();

appFrame.setSize(1200,1200);
appFrame.setResizable(false);
appFrame.setVisible(true);
appFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

public void arrangeComponents(){


jlbDid = new JLabel("Department ID");

jlbDname = new JLabel("Department name");

jtfDid = new JTextField(20);

jtfDname = new JTextField(20);

jbnDelete = new JButton("Delete");


jbnSearch = new JButton("Search");
jbnUpdate = new JButton("Update");
jbnback = new JButton("back");

/*add all initialized components to the container*/


GridBagConstraints gridBagConstraintsx01 = new GridBagConstraints();
gridBagConstraintsx01.gridx = 0;
gridBagConstraintsx01.gridy = 0;
gridBagConstraintsx01.insets = new Insets(5,5,5,5);
cPane.add(jlbDid, gridBagConstraintsx01);

GridBagConstraints gridBagConstraintsx02 = new GridBagConstraints();


gridBagConstraintsx02.gridx = 1;
gridBagConstraintsx02.insets = new Insets(5,5,5,5);
gridBagConstraintsx02.gridy = 0;
gridBagConstraintsx02.gridwidth = 2;
gridBagConstraintsx02.fill = GridBagConstraints.BOTH;
cPane.add(jtfDid, gridBagConstraintsx02);

GridBagConstraints gridBagConstraintsx03 = new GridBagConstraints();


gridBagConstraintsx03.gridx = 0;
gridBagConstraintsx03.insets = new Insets(5,5,5,5);
gridBagConstraintsx03.gridy = 2;
cPane.add(jlbDname, gridBagConstraintsx03);

GridBagConstraints gridBagConstraintsx04 = new GridBagConstraints();


gridBagConstraintsx04.gridx = 1;
gridBagConstraintsx04.gridy = 2;
gridBagConstraintsx04.insets = new Insets(5,5,5,5);
gridBagConstraintsx04.gridwidth = 3;
gridBagConstraintsx04.fill = GridBagConstraints.BOTH;
cPane.add(jtfDname, gridBagConstraintsx04);

GridBagConstraints gridBagConstraintsx05 = new GridBagConstraints();


gridBagConstraintsx05.gridx = 1;
gridBagConstraintsx05.gridy = 3;
gridBagConstraintsx05.insets = new Insets(5,5,5,5);
cPane.add(jbnDelete, gridBagConstraintsx05);

GridBagConstraints gridBagConstraintsx06 = new GridBagConstraints();


gridBagConstraintsx06.gridx = 2;
gridBagConstraintsx06.insets = new Insets(5,5,5,5);
gridBagConstraintsx06.gridy = 3;
cPane.add(jbnUpdate, gridBagConstraintsx06);

GridBagConstraints gridBagConstraintsx07 = new GridBagConstraints();


gridBagConstraintsx07.gridx = 1;
gridBagConstraintsx07.insets = new Insets(5,5,5,5);
gridBagConstraintsx07.gridy = 4;
cPane.add(jbnSearch,gridBagConstraintsx07);

GridBagConstraints gridBagConstraintsx08 = new GridBagConstraints();


gridBagConstraintsx08.gridx = 2;
gridBagConstraintsx08.insets = new Insets(5,5,5,5);
gridBagConstraintsx08.gridy = 4;
cPane.add(jbnback, gridBagConstraintsx08);

jbnDelete.addActionListener(this);
jbnSearch.addActionListener(this);
jbnUpdate.addActionListener(this);
jbnback.addActionListener(this);
}

public void actionPerformed (ActionEvent e){


if (e.getSource() == jbnDelete){
deletePerson();
clear();
}

else if (e.getSource() == jbnUpdate){


deletePerson();
savePerson();
clear();
}

else if (e.getSource() == jbnSearch){


searchPerson();
}
else if (e.getSource() == jbnback){
new mainpage();
}

}
// Save the Person into the Address Book
public void savePerson(){

did = jtfDid.getText();

if(did.equals("")){
JOptionPane.showMessageDialog(null, "Please enter Doctor If.");
}else{
//create a PersonInfo object and pass it to PersonDAO to save it
// PersonInfo person = new PersonInfo(name, address, phone, email);
// pDAO.savePerson(person);

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
try
{
String sql = "INSERT INTO department1 VALUES ('" + jtfDid.getText()+ "','" + jtfDname.getText()
+ "')";

//JTextField jtfName, jtfAddress, jtfPhone,


jtfEmail,jtfIpdno,jtfGender,jtfMarital,jtfFname,jtfDoa,jtfDocref,jtfTpo,jtfCons;;
PreparedStatement ps = con.prepareStatement(sql);

ps.executeUpdate();
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e.toString());
}

JOptionPane.showMessageDialog(null, "Record Saved");


}}
public void deletePerson(){
did= jtfDid.getText();
did = did.toUpperCase();
if(did.equals("")){
JOptionPane.showMessageDialog(null,"Please enter doctor id to delete.");
}
else{
//remove Person of the given name from the Address Book database
int numberOfDeleted =removePerson(did);
JOptionPane.showMessageDialog(null, numberOfDeleted + " Record(s)
deleted.");
}}
public int removePerson(String id)
{
int no = 0;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try{
String sql = "DELETE FROM department1 WHERE did = '" + did + "'";
System.out.println(did);
// Create a Pressared statement
//con=DriverManager.getConnection("jdbc:odbc:ho","","");
} catch(SQLException ex) {

PreparedStatement ps = con.prepareStatement(sql);

ps.executeUpdate();
no=1;
}
catch(Exception e){
System.out.println(e);
}
return no;
}
//Perform a Case-Insensitive Search to find the Person
void searchPerson()
{
String did,dname;
did="";

dname="";

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try {

String sql = "SELECT * FROM department1 WHERE did= '"+ jtfDid.getText()


+"'";

// Create a prepared statement


Statement s = con.createStatement();

ResultSet rs = s.executeQuery(sql);

if(rs.next())
{

did = rs.getString("did");

dname = rs.getString("dname");
//Create a PersonInfo object
//PersonInfo person = new
PersonInfo(pid,did,dname,address,fname,lline,mobile,category,exp,eid,tfrom,tto,rno,ipdcharge,opdc
harge);

//Add the person object to array list


//personsList.add(person);
jtfDid.setText(did);

jtfDname.setText(dname);
}
}
catch(Exception e){
System.out.println("D");
System.out.println(e);
}

//return personsList;

}
public void clear(){
jtfDid.setText("");
jtfDname.setText("");
}}

Bloodbank.java

package patient;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
//import java.sql.ResultSet;
import java.sql.SQLException;
//import java.sql.Statement;
//import java.util.ArrayList;
//import java.sql.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

public class bloodbank1 implements ActionListener


{

private Connection con;


JFrame appFrame;

JLabel jlbbgroup,jlbdate, jlbpid,jlbamount;


JTextField jtfbgroup,jtfdate, jtfpid,jtfamount;;

String bgroup,date, pid,amount;

JButton jbnDelete, jbnUpdate, jbnSearch, jbnback;

Container cPane;
public static void main(String args[]){
new bloodbank1();
}

public bloodbank1()
{
bgroup="";
date="";
pid="";
amount="";
createGUI();

public void createGUI(){

/*Create a frame, get its contentpane and set layout*/


appFrame = new JFrame("EDIT BLOOD BANK");

cPane = appFrame.getContentPane();
cPane.setLayout(new GridBagLayout());

//Arrange components on contentPane and set Action Listeners to each JButton


arrangeComponents();

appFrame.setSize(1200,1200);
appFrame.setResizable(false);
appFrame.setVisible(true);
appFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

public void arrangeComponents(){


jlbbgroup = new JLabel("Bgroup");
jlbdate= new JLabel(" Date");
jlbpid = new JLabel("pid");
jlbamount = new JLabel("amount");

jtfbgroup = new JTextField(20);


jtfdate = new JTextField(20);
jtfpid = new JTextField(20);
jtfamount = new JTextField(20);

jbnDelete = new JButton("Delete");


jbnSearch = new JButton("Search");
jbnUpdate = new JButton("Update");
jbnback = new JButton("back");

/*add all initialized components to the container*/


GridBagConstraints gridBagConstraintsx01 = new GridBagConstraints();
gridBagConstraintsx01.gridx = 0;
gridBagConstraintsx01.gridy = 0;
gridBagConstraintsx01.insets = new Insets(5,5,5,5);
cPane.add(jlbbgroup, gridBagConstraintsx01);

GridBagConstraints gridBagConstraintsx02 = new GridBagConstraints();


gridBagConstraintsx02.gridx = 1;
gridBagConstraintsx02.insets = new Insets(5,5,5,5);
gridBagConstraintsx02.gridy = 0;
gridBagConstraintsx02.gridwidth = 2;
gridBagConstraintsx02.fill = GridBagConstraints.BOTH;
cPane.add(jtfbgroup, gridBagConstraintsx02);

GridBagConstraints gridBagConstraintsx03 = new GridBagConstraints();


gridBagConstraintsx03.gridx = 0;
gridBagConstraintsx03.insets = new Insets(5,5,5,5);
gridBagConstraintsx03.gridy = 1;
cPane.add(jlbdate, gridBagConstraintsx03);

GridBagConstraints gridBagConstraintsx04 = new GridBagConstraints();


gridBagConstraintsx04.gridx = 1;
gridBagConstraintsx04.insets = new Insets(5,5,5,5);
gridBagConstraintsx04.gridy = 1;
gridBagConstraintsx04.gridwidth = 2;
gridBagConstraintsx04.fill = GridBagConstraints.BOTH;
cPane.add(jtfdate, gridBagConstraintsx04);

GridBagConstraints gridBagConstraintsx05 = new GridBagConstraints();


gridBagConstraintsx05.gridx = 0;
gridBagConstraintsx05.insets = new Insets(5,5,5,5);
gridBagConstraintsx05.gridy = 2;
cPane.add(jlbpid, gridBagConstraintsx05);

GridBagConstraints gridBagConstraintsx06 = new GridBagConstraints();


gridBagConstraintsx06.gridx = 1;
gridBagConstraintsx06.gridy = 2;
gridBagConstraintsx06.insets = new Insets(5,5,5,5);
gridBagConstraintsx06.gridwidth = 2;
gridBagConstraintsx06.fill = GridBagConstraints.BOTH;
cPane.add(jtfpid, gridBagConstraintsx06);

GridBagConstraints gridBagConstraintsx07 = new GridBagConstraints();


gridBagConstraintsx07.gridx = 0;
gridBagConstraintsx07.insets = new Insets(5,5,5,5);
gridBagConstraintsx07.gridy = 3;
cPane.add(jlbamount, gridBagConstraintsx07);

GridBagConstraints gridBagConstraintsx08 = new GridBagConstraints();


gridBagConstraintsx08.gridx = 1;
gridBagConstraintsx08.gridy = 3;
gridBagConstraintsx08.gridwidth = 2;
gridBagConstraintsx08.insets = new Insets(5,5,5,5);
gridBagConstraintsx08.fill = GridBagConstraints.BOTH;
cPane.add(jtfamount, gridBagConstraintsx08);

GridBagConstraints gridBagConstraintsx09 = new GridBagConstraints();


gridBagConstraintsx09.gridx = 1;
gridBagConstraintsx09.gridy = 4;
gridBagConstraintsx09.insets = new Insets(5,5,5,5);
cPane.add(jbnDelete, gridBagConstraintsx09);

GridBagConstraints gridBagConstraintsx10 = new GridBagConstraints();


gridBagConstraintsx10.gridx = 2;
gridBagConstraintsx10.insets = new Insets(5,5,5,5);
gridBagConstraintsx10.gridy = 4;
cPane.add(jbnUpdate, gridBagConstraintsx10);

GridBagConstraints gridBagConstraintsx11 = new GridBagConstraints();


gridBagConstraintsx11.gridx = 1;
gridBagConstraintsx11.insets = new Insets(5,5,5,5);
gridBagConstraintsx11.gridy = 5;
cPane.add(jbnSearch,gridBagConstraintsx11);

GridBagConstraints gridBagConstraintsx12 = new GridBagConstraints();


gridBagConstraintsx12.gridx = 2;
gridBagConstraintsx12.insets = new Insets(5,5,5,5);
gridBagConstraintsx12.gridy = 5;
cPane.add(jbnback, gridBagConstraintsx12);

jbnDelete.addActionListener(this);
jbnSearch.addActionListener(this);
jbnUpdate.addActionListener(this);
jbnback.addActionListener(this);
}
public void actionPerformed (ActionEvent e){
if (e.getSource() == jbnDelete){
deletePerson();
clear();
}

else if (e.getSource() == jbnUpdate){


deletePerson();
savePerson();
clear();
}

else if (e.getSource() == jbnSearch){


searchPerson();
}
else if (e.getSource() == jbnback){
new mainpage();
}}
// Save the Person into the Address Book
public void savePerson(){

bgroup = jtfbgroup.getText();
String amount=jtfamount.getText();
int amt=Integer.parseInt(amount);
if(bgroup.equals("")){
JOptionPane.showMessageDialog(null, "Please enter Department
regno.");
}else{
//create a PersonInfo object and pass it to PersonDAO to save it
// PersonInfo person = new PersonInfo(name, address, phone,
email);
// pDAO.savePerson(person);
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {

con=DriverManager.getConnection("jdbc:odbc:bil","",""); }
catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try
{
String sql = "INSERT INTO bloodbank4
VALUES ('" + jtfbgroup.getText()+ "','" + jtfdate.getText() + "','" + jtfpid.getText() + "'," + amt +
")";

//JTextField jtfName, jtfAddress, jtfPhone,


jtfEmail,jtfIpdno,jtfGender,jtfMarital,jtfFname,jtfDoa,jtfDocref,jtfTpo,jtfCons;;

PreparedStatement ps =
con.prepareStatement(sql);

ps.executeUpdate();
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e.toString());
}

JOptionPane.showMessageDialog(null, "Record Saved");


}}
public void deletePerson(){
bgroup= jtfbgroup.getText();
bgroup = bgroup.toUpperCase();
if(bgroup.equals("")){
JOptionPane.showMessageDialog(null,"Please enter doctor registration number.");
}
else{
//remove Person of the given name from the Address Book database
int numberOfDeleted =removePerson(bgroup);
JOptionPane.showMessageDialog(null, numberOfDeleted + " Record(s) deleted.");
}}
public int removePerson(String id)
{
int no = 0;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

try{
String sql = "DELETE FROM bloodbank4 WHERE pid = '" +jtfpid.getText() +
"'";
System.out.println(id);
// Create a Pressared statement
//con=DriverManager.getConnection("jdbc:odbc:ho","","");
} catch(SQLException ex) {

PreparedStatement ps = con.prepareStatement(sql);

ps.executeUpdate();
no=1;
}
catch(Exception e){
System.out.println(e);
}

return no;
}
//Perform a Case-Insensitive Search to find the Person
void searchPerson()
{
String bgroup,date, pid,amount;
bgroup="";
date="";
pid="";
amount="";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con=DriverManager.getConnection("jdbc:odbc:bil","","");
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
try {

String sql = "SELECT * FROM bloodbank4 WHERE pid= '"+ jtfpid.getText()


+"'";

// Create a prepared statement


Statement s = con.createStatement();

ResultSet rs = s.executeQuery(sql);
if(rs.next())
{

bgroup = rs.getString("bgroup");
date= rs.getString("date");
pid= rs.getString("pid");
amount = rs.getString("amount");
//Create a PersonInfo object
//PersonInfo person = new
PersonInfo(pid,did,dname,address,fname,lline,mobile,category,exp,eid,tfrom,tto,rno,ipdcharge,opdc
harge);

//Add the person object to array list


//personsList.add(person);
jtfbgroup.setText(bgroup);
jtfdate.setText(date);
jtfpid.setText(pid);
jtfamount.setText(amount);
}
}
catch(Exception e){
System.out.println("D");
System.out.println(e);
}

//return personsList;
}
public void clear(){
jtfbgroup.setText("");
jtfdate.setText("");
jtfpid.setText("");
jtfamount.setText("");
}}
TESTING
• SOFTWARE TESTING
TESTING: What is it?
Once the source code has been generated, software must be tested to uncover as many errors as possible.
Our goal must be to design a series of test cases that have a high likelihood of finding errors. This is done
through software testing techniques. These techniques provide systematic guidance for designing that-
exercise the internal logic of software components and exercise the input and output domains of the
program to uncover errors in program function, behavior and performance.

Importance of testing:

Reviews and other software quality assurance activities can also uncover errors but they are not sufficient.
Every time the program is executed, the customer tests it. Therefore, you have to execute the program
before it gets to the customer with the specific intent of finding and removing errors. In order to find the
highest possible number of errors, tests must be conducted systematically and test cases must be designed
using disciplined techniques.

Testing: Who does it?

A software engineer performs all tests during early stages of testing. As the testing progresses, testing
specialists may also be involved.

Testing: Steps

Software is tested from two different perspectives:

• Program logic is exercised using “White Box Testing”.


• Software requirements are exercised using “Black Box Testing”.

In both the cases, the intent is to find the maximum number of errors with the minimum amount of effort
and time.
• TESTING METHODOLOGY

A methodology for testing integrates test case design techniques into a well-planned series of steps that
results in the successful construction of the software.

The first step in system testing is to prepare a plan that will test all the aspects of system, in a way that
promotes its credibility among potential users. A workable test plan is prepared in accordance with the
established specification. Procedure for using test data, personnel and training requirements after the test
plan were develops, and all tests can be planned and designed before any code is generated.

Except for small programs, system should not be tested as a single unit. Large systems are built out of
modules that in turn are composed of functions and procedures, the testing process should therefore
proceed in stages where testing is carried out incrementally in conjunction with the system implementation.
The testing process is an iterative one with information being feedback from later stage to earlier parts of
the process.
Therefore testing can be categorized into following forms:
• Unit testing
• Module testing
• System testing
• Alpha/ Beta testing
• White Box/ Black Box testing
UNIT TESTING:

The methodology of unit testing was followed in the manner that each and every piece of code was tested
as soon as it was written. The individual components were tested to ensure that they operate correctly and
independently. Let’s have a closer look at this kind of pattern:

Each component is tested independently without the other system components. It is the first level of testing
and the different modules are tested against the specifications.
Unit testing is essential for verification of the code product during the coding phase; and hence the goal is
to test the internal logic of the module. Unit testing focuses in the verification effort of the smallest unit of
software design module.

MODULE TESTING:

A module is a collection of dependent components such as procedures and functions. A module


encapsulates related components so that it can be tested without other system modules.
Module testing is a systematic technique for constructing the program structure while at the same time
conducting test to uncover errors associated with interfacing. The program is constructed and testing in
small segments where errors are easier to isolate and correct interfaces are more likely to be tested
completely.

SYSTEM TESTING:

Collections of modules make a sub-system and collection of sub-systems makes the entire system. This
phase involves testing of collection of sub-systems, which have been integrated into the entire system. Aim
is to find out errors, which normally result from unanticipated interaction between sub-systems and
components. It is also concerned with validating that the system meets its functional and non-functional
requirements.

Generally, it begins with low volumes of transactions based on live data. System testing is actually a series
of different tests whose primary purpose is to fully exercise the computer-based system. In system testing,
performance and acceptance standards are developed.

ALPHA/BETA TESTING:

Alpha Testing- in this of testing the system is tested with the user provided data. Customer tests the system
at developer site. Developer “looks over shoulder” and records errors & usage problems. Test is conducted
in a controlled environment.

Beta Testing:

This kind of testing involves delivering the system to a number of potential customers who give their
feedback regarding the software. The system is then modified with respect to the feedback given. Repairing
the system may introduce new bugs or errors in the system, thus testing has to be repeated after the system
has been modified. Beta testing is conducted at one or more customer’s site by the end user. Unlike in alpha
testing, the developer is generally not present.
WHITE BOX & BLACK BOX TESTING:

White Box Testing is concerned with the implementation of the program. The idea is to test
different programming and data structures used in the program. This test mainly focuses on the code rather
than on the specifications. The test cases must be designed in such a way that it is able to locate most of the
errors with minimum amount of time and efforts. White box testing is a design method that uses the control
structure of the procedural design to derive test cases.
Here, in the project few proto were developed and tested thoroughly. All the modules were designed only
using those protos.]

Using the White Box method, we derive the test case that:

• Guarantee that all independent paths within a module have been exercised at once.
• Exercise all logical decisions on the true and false sides.
• Execute all loops at their boundaries and within their operational bounds.
• Exercise internal data structure to ensure their validity.

Black Box testing method focuses on the functional requirements of the software. A set of input
conditions are derived that will fully exercise all functional requirements for a program. It is not an
alternative to white box but is a complementary approach that uncovers a different class of errors than
white box methods.

Black Box method attempts to find out errors relating to incorrect or missing functions, Interface errors,
errors in data structures, performance errors, initialization and termination errors. White box testing is
performed at earlier stages but black box testing is applied at the later stages of testing.

TESTING STRATEGIES FOLLOWED IN THE PROJECT:

We also began with unit testing procedures. In this we tested individual forms developed to meet different
requirements, to find and remove the errors. Following problems were encountered while making our
project:
• Syntax error caused due to misspelling or missing clause.
• Unrecognized command verb, phrase and keywords.
• Data types mismatched.
• Expected errors.
• Connectivity errors and logic errors.

These errors were removed using following techniques:

• Monitoring the compilation of the program.


• By appropriate statements in the program.
• By applying the right logic.

Finally the project is run to test the connectivity and integrity of different options given in the menu to
choices given by the user. This is to ensure that the system is responding well and giving best results as per
user expectations and requirements.
Snapshots & Test Cases:

Input Screen 1:
Test Case 1:

Input screen 2:
Test Case 2:

Input Screen 3:
Test Case 3:

Input Screen 4:
Test Case 4:

Input Screen 5:
Test Case 5:

Input Screen 6:
Test Case 6:

Input Screen 7:
Test Case 7:

Input Screen 8:
Test Case 8:

Input Screen 9:
Test Case 9:
Input Screen 10:

Test Case 10:

Input Screen 11:


Test Case 11:

Input Screen 12:


Test Case 12:

Input Screen 13:


Test Case 13:

Input Screen 14:


Test Case 14:

Input Screen 15:


Test Case 15:

Test Case 16:


CONCLUSION:

The PBS is designed to have computerized system management in hospitals. It helps in diagnosing disease,
prescribing the medicines, keeping proper records like registration of a new patient, availability of staff and
much other important functional utilization that demand for the accurate and sufficient records for proper
working. The project will result in improved decision making and also provides the authorities a view for
future requirements.
FUTURE SCOPE:

It refers to the changes which can be made to the project in relation with the future requirements.

• More information can be added like dead patient’s records.


• More departments can be added into the project.
• Billing through Medi-Claims and ATM cards.
• More security features can be added to prevent unauthorized access.
• Enabling various features to make it online so that a hospital with many branches across the globe
can access shared the information using internet.

Das könnte Ihnen auch gefallen