Professional Documents
Culture Documents
PROBLEM STATEMENT
Aim:
To write a problem statement for Hospital Management System application.
Problem Statement:
This project is aimed to automate the hospital management system. The
purpose of the project entitled as HOSPITAL MANAGEMENT SYSTEM is to
computerize the Front Office Management of Hospital to develop software which is user
friendly, simple, fast, and cost effective. It deals with the collection of patients
information, diagnosis details, etc. Traditionally, it was done manually. The main
function of the system is to register and store patient details and doctor details and
retrieve these details as and when required, and also to manipulate these details
meaningfully. This function of Hospital Management Information System deals with
registering the new Patient by giving unique Identification Number to the Patient. This
number is unique throughout the System for identifying the patient. Simultaneous update
and changes are made to the databases. Identification number is also provided to doctor
to retrieve and to change doctor details. The software is used by administrator or
receptionist in the hospital. The software is secured by username and password, accessed
by administrator or receptionist of the hospital.
1. Login:
This module is used to login to the Hospital Management System.
2. Patient:
This module is for adding, querying, editing and deleting patient details in the
database.
3. Doctor:
This module is used to retrieve doctor details from the database and also for
adding new doctor details in the database.
4. Billing Details:
This module is to add billing details such as consultation fee, pharmacy bill, other
expense, ward rent and medical test.
Result:
Thus the problem statement for Career Guidance has been successfully defined.
1.2 Scope:
It can be used in any hospital or clinic for maintaining patient records and their
bill generation.
1.3 Definitions and Abbreviations:
Not applicable.
1.4 References:
Not applicable.
1.5 Overview:
The rest of the document describes the various system requirements, interfaces,
features and functionalities in detail.
2. Overall Description:
This section gives an overall description of the system under development,
including general factors that affect the product and its requirements.
Front-end client
application.
Back end
database.
Software mentioned in pt. (iv) above, will be required only for developing the
application. The final application will be packaged as an independent setup program,
which will be delivered to the department.
2.1.4 Memory Constraints
At least 1GB ram and 2.5GB space on hard disk will be required for running the
application.
2.2 Operations
This product release will not cover any automated housekeeping aspects of the
database. The DBA at the client side will be responsible for manually deleting old/nonrequired data. Database backup and recovery will also have to be handled by the DBA.
2.3 Site Adaptation Requirements
The terminals at client site will have to support the hardware and software interfaces
specified in the above sections.
2.4 Product Functions
A summary of the major functions that the software will perform:
(i)
(ii)
(iii)
(iv)
(v)
(vi)
(vii)
(viii)
(ix)
2.6 Constraints
(i)
(ii)
(iii)
(iv)
This screen is the home screen of the software, which contains buttons to navigate
to other screens. It is accessible only by the administrator.
Patient details panel will allow the administrator to retrieve the details of patient
from the database by submitting the patient id in the query box. It also allows the
administrator to edit the details of patients and to delete the records of patients. Various
fields available on the screen will be
(i)
(ii)
(iii)
(iv)
(v)
(vi)
(vii)
(i)
(ii)
(iii)
(iv)
(v)
(vi)
Doctor details panel will allow the administrator to retrieve the details of doctor
from the database by submitting the doctor id in the query box. It also allows the
administrator to edit the details of doctors and to delete the records of doctors. Various
fields available on the screen will be
(i)
(ii)
(iii)
(iv)
(v)
(vi)
(viii)
3.3.1 Security
The application will be password protected. Users will have to enter correct
username, password and role in order to access the application.
3.3.2 Maintainability
The application will be designed in a maintainable manner.
3.3.3 Portability
Application will work in any OS platform since it is java based. But oracle10g has
to be installed previously in the system.
Patient info:
Id
Name
Age
Gender
Problem
100
Ram
24
Male
Fever
Address
88,
Ward
6
mandaiyur,
Trichy.
101
kumar
45
Male
Dengue
32,
Airport,
Trichy.
Doctor info:
Id
Name
Age
Gender
Specialization
100
Raja
34
Male
general
Address
43,
mandaiyur,
Trichy.
101
Sekar
51
Male
Eye
23,
Mathur,
Trichy.
Bill info:
Id
Name
Fee
Pharma
Test
Other
Rent
total
100
Ram
150
190
100
20
1000
1460
101
kumar
220
1000
200
100
1000
2520
Logging info:
Username
Password
Admin
admin
Result:
Thus the SRS documentation for the Hospital Management System has been
analyzed and prepared.
2.
3.
4.
Actor:
Administrator:
Admin adds and updates the details of doctors, patients and patients bill records
in the database.
Database:
All the details of patients, doctors and logging are accessed by admin in the
database.
Result:
Thus the use case diagram for Hospital Management System has been designed.
CLASS DIAGRAM
Aim:
To design the class diagram for Hospital Management System.
Purpose:
Class diagrams are arguably the most used UML diagram type. It is the main
building block of any object oriented solution. It shows the classes in a system, attributes
and operations of each class and the relationship between each class. In most modelling
tools a class has three parts, name at the top, attributes in the middle and operations or
methods at the bottom. In large systems with many classes related classes are grouped
together to create class diagrams. Different relationships between diagrams are show by
different types of Arrows. Below is a image of a class diagram. It includes Attributes and
Operation.
Attributes:
Any class cannot make it process without addressing the states and behavior of
that object. It should have the attributes middle section of object (or class) box with lower
case letter for each name.
Operations:
Operations are located in third (bottom) class section. They must define in each
class box, because the object (class) did not know what should do and which other class
should interact. The operation tells object what is the message passed to the receiver
object, and the last one invoked that message to perform operation. .
Login: This class consists of username and password of admin as attributes and signin as
operation.
Main form: This class consists of options to switch over to other class and this is the
main class.
Doctor: This class consists of doctor details such as name, id, age, gender and
specialization along with add, edit, and delete operations.
Patient: This class contains add, edit, and delete operations along with attributes such as
name, id, age, gender, problem and ward no.
Billing details: This includes the consultation fee, ward rent and pharmacy bill. Bill
details are displayed along with patient records.
Query: This class is for querying doctor and patient details.
Result:
Thus the class diagram for Hospital Management System has been designed.
SEQUENCE DIAGRAM
Aim:
To develop a Sequence diagram for Hospital Management System
Purpose:
Sequence diagrams in UML shows how object interact with each other and the
order those interactions occur. Its important to note that they show the interactions for a
particular scenario. The processes are represented vertically and interactions are show as
arrows.
Sequence diagrams are an easy and intuitive way of describing the behaviour of
the system by viewing the interaction between the system and its environment. A
sequence diagram shows an interaction arranged in a time sequence.
It shows the objects participating in the interaction by their lifelines and the
messages they exchange, arranged in a time sequence. A sequence diagram has two
dimensions: the vertical dimension represents time, the horizontal dimension represents
different objects. The vertical line is called the objects lifeline. The lifeline represents
the objects existence during the interaction.
Result:
Thus the class diagram for Hospital Management System has been designed.
COLLABORATION DIAGRAM
Aim:
To design a collaboration diagram for Hospital Management System.
Purpose:
Collaboration diagram and sequence diagrams are alternate representations of an
interaction. A collaboration diagram is an interaction diagram that shows the order of
messages that implement an operation or a transaction. Collaboration diagram is an
interaction diagram that shows the order of messages that implement an operation or a
transaction. Collaboration diagram shows object s, their links and their messages. They
can also contain simple class instances and class utility instances. During, analysis
indicates the semantics of the primary and secondary interactions. Design, shows the
semantics of mechanisms in the logical design of system. Toggling between the sequence
and collaboration diagrams when we work in either a sequence or collaboration diagram,
it is possible to view the corresponding diagram by pressing F5 key
Result:
Thus the collaboration diagram for Hospital Management System has been
designed.
ACTIVITY DIAGRAM
Aim:
To design an activity diagram for Hospital Management System.
Purpose:
It shows organization and their dependence among the set of components. These
diagrams are particularly useful in connection with workflow and in describing
behaviours that has a lot of parallel processing. An activity is a state of doing something:
either a real-world process, or the execution of a software routine.
Activity:
An activity represents the performance of a task on duty. It may also represent the
execution of a statement in a procedure.
Decision:
A decision represents a condition on situation during the life of an object, which it
satisfies some condition or waits for an event.
Start state:
It represents the condition explicitly the beginning of a workflow on an activity.
Object flow:
An object on an activity diagram represents the relationship between activity and
object that creates or uses it.
Synchronization:
It enables us to see a simultaneous workflow in an activity.
End state:
An end state represents a final or terminal state on an activity diagram or state
chart diagram.
Result:
Thus the activity diagram for Hospital Management System has been designed.
Result:
Thus the state chart diagram for Hospital Management System has been designed.
IMPLEMENTATION DIAGRAMS
Aim:
To design the implementation diagrams for Hospital Management System
Purpose:
Implementation diagrams show the implementation phase of system development,
such as the source code structure and the run-time implementation structure. There are
two types of implementation diagrams:
1. Component Diagram
2. Deployment Diagram
Component Diagram:
Component diagrams model the physical components such as source code,
executable program, user interface in a design. A component diagram is a graph of the
designs components connected by dependency relationships.
Deployment Diagram:
Deployment diagrams show the configuration of run-time processing elements
and the software components, processes, and objects that live in them. It is a graph of
nodes, connected by communication association.
Component Diagram:
Deployment Diagram:
Result:
Thus implementation diagrams have been designed for Hospital Management
System.
FORWARD ENGINEERING
Aim:
To implement forward engineering for Hospital Management System using the
tools available in Star UML.
Forward Engineering:
The java classes can be generated by the engineering aspects like automatic code
conversion method of the StarUML. The class diagram developed in the software design
phase contains all the relevant classes and it defines the relationships between classes.
This class diagram is used to generate the code template for the system
To generate the Java stub code using StarUML:
Go to Tools on the main menu, expand Java, and select Generate Code.
From this dialog box, select the model, probably named Model1 and press
Next
Choose Select All to generate stub code for all the classes in the model/diagram
and then press Next
StarUML will now generate the codes stubs froms the diagram. Click Finish to
exit the dialog.
Input:
Output:
Login.java:
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Log In.java
// @ Date : 17-10-2012
// @ Author :
//
//
public class Log In extends Main Form, Main Form {
public Object username;
public Object password;
public void Signin() {
}
}
Mainform.java:
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Main Form.java
// @ Date : 17-10-2012
// @ Author :
//
//
public class Main Form extends Doctor, Patient {
public Object Menu Button;
public void Choose() {
}
}
Doctor.java:
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Doctor.java
// @ Date : 17-10-2012
// @ Author :
//
//
public class Doctor {
public Object Name;
public Object Id;
public Object Age;
public Object Specialisation;
public void Add() {
}
public void Edit() {
}
public void Delete() {
}
}
Patient.java:
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Patient.java
// @ Date : 17-10-2012
// @ Author :
//
//
public class Patient extends Billing Details {
public Object Name;
Result:
Thus the forward engineering was done successfully for the Hospital Management
System.
REVERSE ENGINEERING
Aim:
To create the reverse engineering for Hospital Management System using the
tools available in Star UML.
Reverse Engineering:
The star UML tool can be used to generate by reverse engineering .The class
diagram developed in the software design phase contains all the relevant classes and it
defines the relationships between classes. This class diagram is used to generate the code
template for the system.
To perform reverse engineering using StarUML:
From this dialog box, select the source code for reverse engineering.
Choose Add All to generate diagrams for all the template classes in the
model/diagram and then press Next
Select a valid output directory or select the package to contain the result of
reverse engineering.
In the Options Setup, Give the name of the diagram. Then press
(Run)R
StarUML will now generate class diagram from the code template.
Input:
Login.java:
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Log In.java
// @ Date : 17-10-2012
// @ Author :
//
//
public class Log In extends Main Form, Main Form {
public Object username;
public Object password;
public void Signin() {
}
}
Mainform.java:
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Main Form.java
// @ Date : 17-10-2012
// @ Author :
//
//
public class Main Form extends Doctor, Patient {
public Object Menu Button;
public void Choose() {
}
}
Doctor.java:
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Doctor.java
// @ Date : 17-10-2012
// @ Author :
//
//
public class Doctor {
public Object Name;
public Object Id;
public Object Age;
public Object Specialisation;
public void Add() {
}
public void Edit() {
}
public void Delete() {
}
}
Patient.java:
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Patient.java
// @ Date : 17-10-2012
// @ Author :
//
//
public class Patient extends Billing Details {
public Object Name;
public Object Id;
public Object Age;
public Object Problem;
public void Add() {
}
public void Edit() {
}
public void Delete() {
}
}
Query.java:
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Query,.java
// @ Date : 17-10-2012
// @ Author :
//
//
public class Query, {
public Object Id;
public void DisplayDoctor() {
}
public void DisplayPatient() {
}
}
Billingdetails.java:
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Billing Details.java
// @ Date : 17-10-2012
// @ Author :
//
//
public class Billing Details {
public Object Consultation Fee;
public Object Ward Rent;
public Object Pharmacy;
public void Display() {
}
}
Output:
Result:
Thus the reverse engineering was done successfully for the Hospital Management
System.
Level 0:
Level 1:
Level 2:
Result:
Thus the data flow diagram has been designed for Hospital Management System.
SOFTWARE TESTING
Aim:
To study various test approaches for testing a software.
What is testing?
Testing is the process of evaluating a system or its component(s) with the intent to
find that whether it satisfies the specified requirements or not. This activity results in the
actual, expected and difference between their results. In simple words testing is executing
a system in order to identify any gaps, errors or missing requirements in contrary to the
actual desire or requirements.
According to ANSI/IEEE 1059 standard, Testing can be defined as A process of
analyzing a software item to detect the differences between existing and required
conditions (that is defects/errors/bugs) and to evaluate the features of the software item.
Who does testing?
It depends on the process and the associated stakeholders of the project(s). In the
IT industry, large companies have a team with responsibilities to evaluate the developed
software in the context of the given requirements. Moreover, developers also conduct
testing which is called Unit Testing. In most cases, following professionals are involved
in testing of a system within their respective capacities:
Software Tester
Software Developer
Project Lead/Manager
End User
Different companies have difference designations for people who test the software on
the basis of their experience and knowledge such as Software Tester, Software Quality
Assurance Engineer, and QA Analyst etc. It is not possible to test the software at any
time during its cycle. The next two sections state when testing should be started and when
to end it during the SDLC.
Manual testing
This type includes the testing of the Software manually i.e. without using any
automated tool or any script. In this type the tester takes over the role of an end user and
test the Software to identify any un-expected behavior or bug. There are different stages
for manual testing like unit testing, Integration testing, System testing and User
Acceptance testing.
Testers use test plan, test cases or test scenarios to test the Software to ensure the
completeness of testing. Manual testing also includes exploratory testing as testers
explore the software to identify errors in it.
Automation testing
Automation testing which is also known as Test Automation is when the tester
writes scripts and uses another software to test the software. This process involves
automation of a manual process. Automation Testing is used to re-run the test scenarios
that were performed manually, quickly and repeatedly.
Apart from regression testing, Automation testing is also used to test the
application from load, performance and stress point of view. It increases the test
coverage; improve accuracy, saves time and money in comparison to manual testing.
Testing Methods
Black Box Testing
The technique of testing without having any knowledge of the interior workings
of the application is Black Box testing. The tester is oblivious to the system architecture
and does not have access to the source code. Typically, when performing a black box test,
a tester will interact with the system's user interface by providing inputs and examining
outputs without knowing how and where the inputs are worked upon.
White Box Testing
White box testing is the detailed investigation of internal logic and structure of the
code. White box testing is also called glass testing or open box testing. In order to
perform white box testing on an application, the tester needs to possess knowledge of the
internal working of the code. The tester needs to have a look inside the source code and
find out which unit/chunk of the code is behaving inappropriately.
Grey Box Testing
Grey Box testing is a technique to test the application with limited knowledge of
the internal workings of an application. In software testing, the term the more you know
the better carries a lot of weight when testing an application.
Mastering the domain of a system always gives the tester an edge over someone
with limited domain knowledge. Unlike black box testing, where the tester only tests the
application's user interface, in grey box testing, the tester has access to design documents
and the database. Having this knowledge, the tester is able to better prepare test data and
test scenarios when making the test plan.
Unit Testing
This type of testing is performed by the developers before the setup is handed
over to the testing team to formally execute the test cases. Unit testing is performed by
the respective developers on the individual units of source code assigned areas. The
developers use test data that is separate from the test data of the quality assurance team.
The goal of unit testing is to isolate each part of the program and show that individual
parts are correct in terms of requirements and functionality.
Integration Testing
The testing of combined parts of an application to determine if they function
correctly together is Integration testing. There are two methods of doing Integration
Testing Bottom-up Integration testing and Top down Integration testing.
S.N. Integration Testing Method
Bottom-up integration
1
This testing begins with unit testing, followed by tests of progressively higherlevel combinations of units called modules or builds.
Top-Down integration
This testing, the highest-level modules are tested first and progressively lowerlevel modules are tested after that.
In a comprehensive software development environment, bottom-up testing is
usually done first, followed by top-down testing. The process concludes with multiple
tests of the complete application, preferably in scenarios designed to mimic those it will
encounter in customers' computers, systems and network.
Test Results:
Result:
Thus various approaches on software testing has been studied.
DESIGN PROCESS
Aim:
To implement application using JDK as front end and Oracle as back end.
Login form:
Main form:
Patient form:
Doctor form:
Billing details:
CODINGS
Login form:
This form allows the administrator to entering into the application by providing
username and password. Default username and password is given to admin, later both can
be changed by the administrator. If a wrong entry has made, a message box will be
prompted to the user.
package hospital;
import java.awt.event.KeyEvent;
import java.sql.*;
public class Login extends javax.swing.JFrame {
Connection c;
Statement s;
ResultSet r;
public Login() {
try {
Driver
d
=
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
(Driver)
c=
DriverManager.getConnection("jdbc:oracle:thin:@//localhost:1521/orcl",
"scott", "tiger");
}catch(ClassNotFoundException | InstantiationException | IllegalAccessException |
SQLException e) {
System.out.println("Driver " + e.getMessage());
}
initComponents();
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try{
s=c.createStatement();
if(r.next()){
if(User.getText().equals(r.getString(1))&&Password.getText().equals(r.getString(
2)))
{
s=c.createStatement();
Username
or
if(r.next()){
if(User.getText().equals(r.getString(1))&&Password.getText().equals(r.getString(
2)))
{
Hos_main h=new Hos_main();
h.show();
this.hide();
}
else
{
javax.swing.JOptionPane.showMessageDialog(null,"Wrong
password");
User.setText("");
Password.setText("");
}
}
Username
or
Main Form:
In this form, the admin can switch over to other forms such as patient, doctor,
billing details and username & password changing forms. This form act as home screen
for the application
package hospital;
public class Hos_main extends javax.swing.JFrame {
public Hos_main() {
initComponents();
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
patient k=new patient();
k.show();
this.hide();
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
Doctor i=new Doctor();
i.show();
this.hide();
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
createuser u=new createuser();
u.show();
this.hide();// TODO add your handling code here:
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
Billing b= new Billing();
b.show();
this.hide();
}
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
Login g=new Login();
g.show();
this.hide();// TODO add your handling code here:
}
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Hos_main().setVisible(true);
}
});
}
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
(Driver)
con = DriverManager.getConnection("jdbc:oracle:thin:@//localhost:1521/orcl",
"scott", "tiger");
pst = con.prepareStatement("insert into pat_det values(?,?,?,?,?,?,?)");
//con.setAutoCommit(true);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
| SQLException e) {
System.out.println("Driver " + e.getMessage());
}
initComponents();
NEWQUERY.setVisible(false);
NAME2.disable();
AGE2.disable();
SEX2.disable();
PROBLEM2.disable();
ADDRESS2.disable();
WARD2.disable();
AGE2.setDisabledTextColor(Color.black);
NAME2.setDisabledTextColor(Color.black);
PROBLEM2.setDisabledTextColor(Color.black);
ADDRESS2.setDisabledTextColor(Color.black);
SEX2.setDisabledTextColor(Color.black);
WARD2.setDisabledTextColor(Color.black);
try {
st = con.createStatement();
rst = st.executeQuery("select max(id) from pat_det");
if (rst.next())
{
if(rst.getInt(1)==0)
ID3.setText(100+"");
else
ID3.setText((rst.getInt(1) + 1) + "");
}
else {
ID3.setText(100 + "");
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
"Entered
Wrong
data
pst.setString(6,ADDRESS3.getText());
pst.setInt(7,Integer.parseInt(WARD3.getText()));
pst.executeUpdate();
javax.swing.JOptionPane.showMessageDialog(null,
sucessfully");
"patient
details
added
from
pat_det
where
String name=rst1.getString("name");
System.out.print(name);
QUERY.disable();
NEWQUERY.setVisible(true);
NAME2.setText(rst1.getString(2));
AGE2.setText(rst1.getInt(3)+"");
SEX2.setText(rst1.getString(4));
PROBLEM2.setText(rst1.getString(5));
ADDRESS2.setText(rst1.getString(6));
WARD2.setText(Integer.parseInt(rst1.getString(7))+"");
}
else
{
javax.swing.JOptionPane.showMessageDialog(null, "Enter the valid ID sir");
QUERY.setText("");
}
}
}catch(SQLException | NumberFormatException e)
{
System.out.println(e.getMessage());
}
}
AGE2.setText("");
SEX2.setText("");
PROBLEM2.setText("");
ADDRESS2.setText("");
WARD2.setText("");
NEWQUERY.setVisible(false);
}
private void EDITActionPerformed(java.awt.event.ActionEvent evt) {
PROBLEM2.enable();
ADDRESS2.enable();
WARD2.enable();
}
{
st=con.createStatement();
st.executeUpdate("delete pat_det where id="+Integer.parseInt(QUERY.getText()));
javax.swing.JOptionPane.showMessageDialog(null, "ID deleted");
Hos_main j=new Hos_main();
j.show();
this.hide();
}catch(SQLException | NumberFormatException e)
{
System.out.println(e.getMessage());
}
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Hos_main j=new Hos_main();
j.show();
this.hide();
}
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new patient().setVisible(true);
}
});
}
Connection con;
Statement st;
ResultSet rst, rst1;
PreparedStatement pst;
public Doctor() {
try {
Driver
d
=
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
(Driver)
con=DriverManager.getConnection("jdbc:oracle:thin:@//localhost:1521/orcl",
"scott", "tiger");
pst = con.prepareStatement("insert into doc_det values(?,?,?,?,?,?)");
//con.setAutoCommit(true);
}
catch
(ClassNotFoundException
IllegalAccessException | SQLException e) {
InstantiationException
SPECIAL2.disable();
SPECIAL2.setDisabledTextColor(Color.black);
ADDRESS2.disable();
ADDRESS2.setDisabledTextColor(Color.black);
try {
st = con.createStatement();
rst = st.executeQuery("select max(id) from doc_det");
if (rst.next())
{
System.out.println(rst.getInt(1));
if(rst.getInt(1)==0)
ID3.setText(100+"");
else
ID3.setText((rst.getInt(1) + 1) + "");
}
else {
ID3.setText(100 + "");
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
doc_det
where
}
}
doc_det
where
if(rst1.next()) {
QUERY.disable();
QUERY.setDisabledTextColor(Color.black);
NEWQUERY.setVisible(true);
NAME2.setText(rst1.getString(2));
AGE2.setText(rst1.getInt(3)+"");
SEX2.setText(rst1.getString(4));
SPECIAL2.setText(rst1.getString(5));
ADDRESS2.setText(rst1.getString(6));
if(rst1.getString(2)==null){
javax.swing.JOptionPane.showMessageDialog(null,"Record not found!") ;
}
} else {
javax.swing.JOptionPane.showMessageDialog(null, "Enter the valid ID");
QUERY.setText("");
}
}
}catch(SQLException | NumberFormatException e) {
System.out.println(e.getMessage());
}
}
private void SAVE1ActionPerformed(java.awt.event.ActionEvent evt) {
try {
st=con.createStatement();
st.executeUpdate("update
doc_det
address='"+ADDRESS2.getText()+"',special='"+SPECIAL2.getText()+"'
id="+Integer.parseInt(QUERY.getText()));
set
where
}catch(SQLException | NumberFormatException e) {
System.out.println(e.getMessage());
}
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
Hos_main j=new Hos_main();
j.show();
this.hide();
}
} else {
if(AGE3.getText().length()>3)
javax.swing.JOptionPane.showMessageDialog(null, "Entered Wrong
data in AGE");
else {
pst.setInt(1,Integer.parseInt(ID3.getText()));
pst.setString(2,NAME3.getText());
pst.setInt(3, Integer.parseInt(AGE3.getText()));
pst.setString(4,SEX3.getText());
pst.setString(6,SPECIAL3.getText());
pst.setString(5,ADDRESS3.getText());
pst.executeUpdate();
javax.swing.JOptionPane.showMessageDialog(null,
sucessfully");
Hos_main i=new Hos_main();
i.show();
this.dispose();
}
}
}catch(SQLException | HeadlessException e) {
System.out.println(e.getMessage());
}
}
java.awt.EventQueue.invokeLater(new Runnable() {
"value
added
}
});
}
// Variables declaration - do not modify
private javax.swing.JTextArea ADDRESS2;
private javax.swing.JTextArea ADDRESS3;
private javax.swing.JTextField AGE2;
private javax.swing.JTextField AGE3;
private javax.swing.JButton DELETE;
private javax.swing.JPanel DETAILS;
private javax.swing.JButton EDIT;
private javax.swing.JTextField ID3;
private javax.swing.JTextField NAME2;
private javax.swing.JTextField NAME3;
private javax.swing.JPanel NEW;
private javax.swing.JButton NEWQUERY;
private javax.swing.JTextField QUERY;
private javax.swing.JButton QUERY1;
private javax.swing.JButton SAVE;
private javax.swing.JButton SAVE1;
private javax.swing.JTextField SEX2;
private javax.swing.JTextField SEX3;
private javax.swing.JTextField SPECIAL2;
private javax.swing.JTextField SPECIAL3;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
import java.sql.*;
public class Billing extends javax.swing.JFrame {
Connection con;
Statement st;
ResultSet rst, rst1,rs;
PreparedStatement pst;
/** Creates new form Billing */
public Billing() {
try {
Driver
d
=
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
(Driver)
con = DriverManager.getConnection("jdbc:oracle:thin:@//localhost:1521/orcl",
"scott", "tiger");
pst = con.prepareStatement("insert into bill_det values(?,?,?,?,?,?,?,?)");
//con.setAutoCommit(true);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
| SQLException e) {
System.out.println("Driver " + e.getMessage());
}
initComponents();
LFee.setVisible(false);
LName.setVisible(false) ;
LOther.setVisible(false);
LPharma.setVisible(false);
LRent.setVisible(false);
LTest.setVisible(false);
Fee.setVisible(false);
NAME.setVisible(false) ;
Other.setVisible(false);
Pharma.setVisible(false);
Rent.setVisible(false);
Test.setVisible(false);
jButton3.setVisible(false);
total.setVisible(false);
LTotal.setVisible(false);
TotalBill.setVisible(false);
edit.setVisible(false);
delete.setVisible(false);
newq.setVisible(false);
save.setVisible(false);
TotalBill.setDisabledTextColor(Color.black);
Fee.setDisabledTextColor(Color.black);
NAME.setDisabledTextColor(Color.black);
Other.setDisabledTextColor(Color.black);
Pharma.setDisabledTextColor(Color.black);
Rent.setDisabledTextColor(Color.black);
Test.setDisabledTextColor(Color.black);
}
{
st=con.createStatement();
rst1=st.executeQuery("select
*
id="+Integer.parseInt(QUERY.getText()));
from
pat_det
where
if(rst1.next())
{
st=con.createStatement();
rs=st.executeQuery("select
*
id="+Integer.parseInt(QUERY.getText()));
from
if(rs.next())
{
QUERY.disable();
NAME.setVisible(true);
LName.setVisible(true);
NAME.setText(rs.getString(2));
LFee.setVisible(true);
LOther.setVisible(true);
LPharma.setVisible(true);
LRent.setVisible(true);
LTest.setVisible(true);
Fee.setVisible(true);
Fee.setText(Integer.parseInt(rs.getString(3))+"");
Other.setVisible(true);
Other.setText(Integer.parseInt(rs.getString(6))+"");
Pharma.setVisible(true);
Pharma.setText(Integer.parseInt(rs.getString(4))+"");
Rent.setVisible(true);
bill_det
where
Rent.setText(Integer.parseInt(rs.getString(7))+"");
Test.setVisible(true);
Test.setText(Integer.parseInt(rs.getString(5))+"");
total.setVisible(true);
LTotal.setVisible(true);
TotalBill.setVisible(true);
TotalBill.setText(Integer.parseInt(rs.getString(8))+"");
edit.setVisible(true);
delete.setVisible(true);
newq.setVisible(true);
save.setVisible(false);
jButton3.setVisible(true);
Fee.disable();
NAME.disable() ;
Other.disable();
Pharma.disable();
Rent.disable();
Test.disable();
TotalBill.disable();
}
else{
QUERY.disable();
NAME.setVisible(true);
LName.setVisible(true);
NAME.setText(rst1.getString(2));
LFee.setVisible(true);
LOther.setVisible(true);
LPharma.setVisible(true);
LRent.setVisible(true);
LTest.setVisible(true);
Fee.setVisible(true);
Other.setVisible(true);
Pharma.setVisible(true);
Rent.setVisible(true);
Test.setVisible(true);
total.setVisible(true);
LTotal.setVisible(true);
TotalBill.setVisible(true);
Fee.setText(0+"");
Pharma.setText(0+"");
Test.setText(0+"");
Other.setText(0+"");
Rent.setText(0+"");
TotalBill.setText(0+"");
TotalBill.disable();
save.setVisible(true);
newq.setVisible(true);
}
}
else
{
javax.swing.JOptionPane.showMessageDialog(null, "Enter the valid ID sir");
QUERY.setText("");
}
}
}catch(SQLException | NumberFormatException e)
{
System.out.println(e.getMessage());
}
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
Hos_main h = new Hos_main();
h.show();
this.hide();// TODO add your handling code here:
}
try{
if(TotalBill.getText().isEmpty()||TotalBill.getText().length()<2){
javax.swing.JOptionPane.showMessageDialog(null, "Total Bill is not calculated
");
}
else{
pst.setInt(1,Integer.parseInt(QUERY.getText()));
pst.setString(2,NAME.getText());
pst.setInt(3,Integer.parseInt(Fee.getText()));
pst.setInt(4,Integer.parseInt(Pharma.getText()));
pst.setInt(5,Integer.parseInt(Test.getText()));
pst.setInt(6,Integer.parseInt(Other.getText()));
pst.setInt(7,Integer.parseInt(Rent.getText()));
pst.setInt(8,Integer.parseInt(TotalBill.getText()));
pst.executeUpdate();
javax.swing.JOptionPane.showMessageDialog(null, "Bill added sucessfully");
Hos_main i=new Hos_main();
i.show();
this.dispose();
}
}catch(SQLException | HeadlessException e)
{
System.out.println(e.getMessage());
}
}
private void editActionPerformed(java.awt.event.ActionEvent evt) {
Fee.enable();
NAME.enable() ;
Other.enable();
Pharma.enable();
Rent.enable();
Test.enable();
}
st=con.createStatement();
st.executeUpdate("delete
id="+Integer.parseInt(QUERY.getText()));
bill_det
where
LTotal.setVisible(false);
TotalBill.setVisible(false);
edit.setVisible(false);
delete.setVisible(false);
newq.setVisible(false);
QUERY.enable();
QUERY.setText("");:
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
ResultSet r;
PreparedStatement p;
public createuser() {
try {
Driver
d
=
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
(Driver)
c=
DriverManager.getConnection("jdbc:oracle:thin:@//localhost:1521/orcl", "scott",
"tiger");
p = c.prepareStatement("insert into log values(?,?)");
//con.setAutoCommit(true);
}
catch
(ClassNotFoundException
IllegalAccessException | SQLException e) {
InstantiationException
else{
s.executeUpdate("delete from log where name= '"+olduser.getText()+"'");
p.setString(1,newuser.getText());
p.setString(2, newpass.getText());
p.executeUpdate();
javax.swing.JOptionPane.showMessageDialog(null, "username and password
changed");
Login h=new Login();
h.show();
this.hide();
}
}catch(SQLException | NumberFormatException e){
System.out.print(e);
}
}
newpass.setVisible(true);
nuser.setVisible(true);
npass.setVisible(true);
Create.setVisible(true);
}
else
{
javax.swing.JOptionPane.showMessageDialog(null,"Wrong
password");
Username
olduser.setText("");
oldpass.setText("");
}
}
}catch (Exception e){
System.out.println(e.getMessage());
}
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Hos_main j=new Hos_main();
j.show();
this.hide();
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
or
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton Create;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JPasswordField newpass;
private javax.swing.JTextField newuser;
private javax.swing.JLabel npass;
private javax.swing.JLabel nuser;
private javax.swing.JPasswordField oldpass;
private javax.swing.JTextField olduser;
private javax.swing.JButton verify;
// End of variables declaration
}
Tables
The database table pat_det contains the patient details.
Id
Name
Age
Gender
Problem
100
Ram
24
Male
Fever
Address
Ward
88,
mandaiyur,
Trichy.
101
kumar
45
Male
Dengue
32,
Airport,
Trichy.
Name
Age
Gender
Specialization
100
Raja
34
Male
general
Address
43,
mandaiyur,
Trichy.
101
Sekar
51
Male
Eye
23,
Mathur,
Trichy.
Name
Fee
Pharma
Test
Other
Rent
total
100
Ram
150
190
100
20
1000
1460
101
kumar
220
1000
200
100
1000
2520
The database table log contains the username and password of admin.
Username
Password
Admin
admin
Result:
Thus the design process has been implemented successfully.