You are on page 1of 49

PHARMACY MANAGEMENT SYSTEM

TABLE OF CONTENTS

1. OVERVIEW

1.1 Introduction

1.2. Overall Description

1.3. System features

1.4. Specification requirements


2. ADVANTAGES

3. SYSTEM IMPLEMENTATION

3.1 About the operating system

3.2 About the Language

4. SYSTEM CONFIGURATION

4.1 Hardware Requirements.

4.2 Software Requirements.

5. SOURCE CODE

6. SCREEN SHOTS

7.CONCLUSION

1. OVERVIEW:

1.1 PURPOSE:

This project is mainly


mainly to calculate the amount of medicines sold in the pharmacy on day to day
 basis and generate a bill.

for example: The data maybe added/updated/deleted into the database and retrieved while
generating the bill for the day.

1.2 INTENDED AUDIENCE:


2. ADVANTAGES

3. SYSTEM IMPLEMENTATION

3.1 About the operating system

3.2 About the Language

4. SYSTEM CONFIGURATION

4.1 Hardware Requirements.

4.2 Software Requirements.

5. SOURCE CODE

6. SCREEN SHOTS

7.CONCLUSION

1. OVERVIEW:

1.1 PURPOSE:

This project is mainly


mainly to calculate the amount of medicines sold in the pharmacy on day to day
 basis and generate a bill.

for example: The data maybe added/updated/deleted into the database and retrieved while
generating the bill for the day.

1.2 INTENDED AUDIENCE:


Staff in-charge of the pharmacy who do the sales may update the database and the staff that does
the stock inventory check and the accounting of the pharmacy will use the software.

1.3 PROJECT SCOPE:

This software is used to maintain a database in a pharmacy without manually having to keep
track of the inventory and sales. This reduces any humanized errors and thus generates a bill of 
the exact amount at the end of the day.

2. OVERALL DESCRIPTION:

2.1 PRODUCT PERSPECTIVE:

This software helps the pharmaceutical industry to maintain a database for the inventory and
 prevent any loss of information

2.2 PRODUCT FEATURES:

The software gives you the chance to add, delete, update the details of the medicines using the
medicine ID. During the bill generation you need only mention the medicine ID and the details
will automatically appear.

2.3 USER CLASSES AND CHARACTERISTICS:

The person who can update and retrieve details is the administrator (i.e. person assigned to this
 job).

2.4 OPERATING ENVIRONMENT:

The software uses windows 7 operating system. Java is used as a front end designing tool.

MS Access is used as the database.

Hardware requirements used are 13.370M, Processor 2.40 GHz, 320 GB hard disk and 34B
memory.

2.5 DESIGN AND IMPLEMENTATION CONSTRAINTS:

This software will be developed using JAVA and MS Access.

2.6 ASSUMPTION AND DEPENDENCIES:

The administrator should have authority to update and retrieve information. He must be present
during every sale. The software assumes that the ad ministrator does not make any errors while
entering the data.
3. SYSTEM FEATURES:

3.1 ADMINISTRATOR UPDATING MODULE:

In the module the administrator updates information about medicines to the database. The
administrator has rights to perform manipulation of information.

3.2 BILL GENERATION:

In this module, the administrator


administrator can generate the bill by specifying
specifying the medicine ID. This will
automatically provide the name, quantity and price at which it is sold.

4. SPECIFICATION REQUIREMENTS:

4.1 USER INTERFACE:

This application includes interfaces for medicine entry, interacting with the database GUI
standards, buttons and functions that will appear in every screen and so on.

4.2 HARDWARE INTERFACES:

Connectivity is established between MS Access and JAVA using JDBC. Processor I3 with
2.40GHz and memory 34B and hardware 320 GB is required.

4.3 SOFTWARE INTERFACES:

JAVA is used as programming language for writing


writing the code for the project, operating
operating system
windows 7 and MS Access is used as database.

4.4 COMMUNICATION:

Front end and back end are connected using JDBC connectivity.

ADVANTAGES:

 Scalability to add stores on the network on the same foundation/platform.

  No performance variations due to additional stores or increased transaction volumes.


Ability to manage peak loads considering a mix of 24 hours, extended hour and normal
hour operations.

 Quick response to user query/user inputs.

 Restricted access based on functionality and role.

 Flexibility to address specific requirements by setting rules and test /modify specific code
areas
 Ease of maintenance

 Ability to ensure quick root-outs of enhancements /upgrades.

SYSTEM IMPLEMENTATION

ABOUT OPERATING SYSTEM

Windows XP is a line of operating systems developed by Microsoft for 


use on general-purpose computer systems including home and business desktops, notebook 
 ,

computers, and media centers. The letters "XP" stand for experience. Windows XP is the
successor to both Windows 2000 and Windows Me, and is the first consumer-oriented operating
system produced by Microsoft to be built on the Windows NT kernel and architecture.
The most common editions of the operating system are Windows XP Home Edition, which is
targeted at home users, and Windows XP Professional, which has additional features such as
support for Windows Server domains and two physical processors, and is targeted at power users
and business clients. Windows XP Tablet PC Edition is designed to run the ink-aware Tablet PC
 platform. Two separate 64-bit versions of Windows XP were also released, Windows XP 64-bit
Edition for  IA-64 (Itanium) processors and Windows XP Professional x64 Edition for  x86-64
 processors.

Windows XP is known for its improved stability and efficiency over previous versions of 
Microsoft Windows. It presents a significantly redesigned graphical user interface, a change
Microsoft promoted as more user-friendly than previous versions of Windows. New software
management capabilities were introduced to avoid the "DLL hell" that

Plagued older consumer versions of Windows. It is also the first version of Windows to use
 product activation to combat software piracy, a restriction .

That did not sit well with some users and privacy advocates. Windows XP has also been
criticized by some users for security vulnerabilities, tight.Integration of applications such as
Internet Explorer and Windows Media Player, and for aspects of its user interface.

ABOUT THE LANGUAGE

Java is a programming language developed by Sun Microsystems and is based


on the concepts of C and C++. The syntax for Java is similar to C.

HISTORY OF JAVA

In November 1995, Sun Microsystems introduced a new programming


language to the world- Java. Until then the word “ Java” could only mean an island in Indonesia
or a particular blend of coffee.
Though its initial development began as early as 1991, it took some time for the final working
version to reach the market. The basic objective behind developing the language was to create
software that could be embedded in consumer electronic devices. Efforts were taken to produce a
 portable, platform in dependable language, and the result of this led to the birth of a new
language. James Gosling and a team of other programmers were the pioneers behind this
development. It was initially called “Oak ” but was later renamed to “ Java” . Slowly but
gradually it was found that Internet users had similar problems of portability and platform
independence and were looking for software that could address these issues. Java language was
found to be small, secure and portable. Thus Java, which was initially developed to cater. To
small-scale problems, was found capable of addressing large-scale problems across the Internet.

FEATURES OF JAVA

The Java Language is

• Simple

• Object Oriented

• Platform-Independent

• Robust

• Secure

• Distributed

• Multithreaded

 Simple
The designers of Java were trying to develop a language that a programmer could
learn quickly. They also wanted the language to be familiar to most programmers, for ease of 
migration. Hence the Java designers removed a number of complex features that existed in C and
C++. Java does not have features such as pointer manipulation, operator overloading etc. Java
does not use the ‘go to’ statement, or header filed. Constructs like ‘struct’ and ‘union’ have also
 been removed from Java.

 Platform-Independent 
Platform-independence refers to the ability of the program to migrate from one computer to
another without any Difficulty. Java is platform independent at the source level as well as at the
 binary level.

Java is strongly typed language. This means that you need to declare the type for any
variable. The java data types are consistent across all the development platforms. Java has its
own foundation class libraries. This allows the programmer to write code that can be mobbed
from one machine to another, with out having to rewrite it.

In short, platform independence at the source level allows the user to move the source
code from one system to another, compile the code, and run it clearly on the system.

Platform independence at the binary level allows the user to run the compiled binary file
on multiple platforms without recompiling the code.

 Robust 

Java is strictly a typed language. Hence it requires explicit method declaration.


Java checks your code at the time of compilation and also at the time of interpretation. Thus it
eliminates certain types of programming errors.

Java does not have pointers and pointer arithmetic. It checks all access to arrays and
strings at the runtime. It also checks the casts of o bjects from one type to another at runtime.

In traditional programming environments, the programmer had to manually allocate


memory. By the end of the program, the programmer had to explicitly free this memory.
Problems arose when the programmer forgot to de allocate the memory. In Java the programmer 
doesn’t need to bother about memory de allocation. It’s done automatically, as Java provides
Garbage collection for unused objects. Java’s exception handling feature simplifies the task of 
error handling and recovery.

 Secure:
Viruses are a great cause of worry in the world of computers. Prior to the advent
of Java, programmers had to first scan files, before downloading and executing them. Often this
 precaution was no guarantee against viruses. Also there were many malicious programs that
 programmers need to look out for.
These programs could search the contents of your local file system and retrieve sensitive data.

Java provides a controlled environment for the execution of the program. It never 
assumes that the code is safe for execution. And since java is more than a programming
language, it provides several layers of security control.

In the first layer, the data and methods are encapsulated in the class. They can be
accessed only through the interface that the class provides. Java does not allow any pointer 
arithmetic. Hence it does not allow direct access to the memory. It disallows array overflow,
 prevents reading memory out of bounds, and provides garbage collection. All these features help
minimize safety and portability problems.

In the second layer the compiler ensures that the code is safe and follows the protocols set by
Java before compiling the code.

The third layer is safety provided by the Interpreter. The verifier thoroughly screens the
 byte codes to ensure they obey the rules before executing them.

The fourth layer takes care of loading the classes. The class loader ensures that the class
doesn’t violate the access restrictions, before loading it to the system.

 Distributed 

Java can be used to develop applications that are portable across multiple
 platforms and operating systems. Java is designed to support network applications.

 Multithreaded 
Java programs use a process called ‘multithreading’ to perform many
tasks simultaneously. Java provides the master solution for synchronizing multiple processes.
The built in support for threads enables interactive applications on the internet to run
simultaneously
SYSTEM CONFIGURATION

HARDWARE REQUIREMENTS

Processor : Intel Pentium IV 2.4 GHZ or above

Clock speed : 500 MHZ

System bus : 32 bits


RAM : 256MB of RAM

HDD : 40 GB or higher  

Monitor : SVGA COLOR  

Keyboard : 108Keys

Mouse : 2 button mouse

SOFTWARE REQUIREMENTS

OS : MS WINDOWS XP SP2

Environment : Java Runtime Environment 1.5

Front end : Core Java JDK 1.6.0_17

Back end : Microsoft Access 2003

ABOUT MS-ACCESS

Access is a relational database program .Access is used to enter, edit, and analyze
analyze lists
lists of 
of 
data. Relational databases minimize redundant data

Advantages of Access


• Duplicate data is minimized

• Information is more accurate


• Data entry is faster and easier 


• Information can be viewed and sorted in multiple ways.


• Information is more secure


• Information can be shared among several users


• Information retrieval is faster and easier 

Tables used: MediInfo

MediInfo
MedicineID MediTitle Qty Price
1 Metacin 143 0.5
2 Crocin 194 25
3 Brufen 211 14
4 Domstal 69 15
5 Loparet 94 12
6 Otrivin 350 30

Source Code:

Billing.java

import java.awt.event.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.net.MalformedURLException;
import java.sql.*;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.UIManager;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.plaf.metal.MetalTheme;
import javax.swing.table.DefaultTableModel;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author home
*/
 public class Billing extends javax.swing.JFrame {

/**
* Creates new form Billing
*/
int index=0;
DefaultTableModel model;
String pri;
double amount=0.0;

Connection connect;
Statement st;
ResultSet rs;
public Billing() {

initConnect();
model=new DefaultTableModel();
initTable();

initComponents();

 jTable1.setModel(model);
StockCheck();

}
public void initTable(){
model.addColumn("Code");
model.addColumn("Medicine Name");
model.addColumn("Price");
model.addColumn("Quantity");
model.addColumn("Cost");
}
 public void initConnect() {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connect=DriverManager.getConnection("jdbc:odbc:Medi");
st=connect.createStatement();
} catch (SQLException ex) {
Logger.getLogger(Billing.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(Billing.class.getName()).log(Level.SEVERE, null, ex);
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
public void initial(){
int i=0;
jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
 jTextField2.setFocusable(false);
jTextField1.setFocusable(true);
jTextField2.setFocusable(true);

}
public void updatetable(double val,String code){
int v=(int)val;
try {
st.executeUpdate("UPDATE MediInfo SET Qty='"+v+"' WHERE
MedicineID='"+code+"'");

 jTextField1.setFocusable(false);
jTextField1.setFocusable(true);

} catch (SQLException ex) {


Logger.getLogger(Billing.class.getName()).log(Level.SEVERE, null, ex);
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-
BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jPanel3 = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
jPanel2 = new javax.swing.JPanel();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jPanel4 = new javax.swing.JPanel();
jLabel7 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem2 = new javax.swing.JMenuItem();
jMenuItem1 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Billing Vn.1 (BETA)");
setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage("Medic.jpg"));

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


jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);


jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 111,
Short.MAX_VALUE)
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 59,
Short.MAX_VALUE)
);
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("Amount");

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


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
 jPanel1Layout.createSequentialGroup()
.addContainerGap(23, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 151,
 javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
 jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE,
 javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);

jTable1.setModel(new javax.swing.table.DefaultTableModel());
jTable1.addInputMethodListener(new java.awt.event.InputMethodListener() {
public void caretPositionChanged(java.awt.event.InputMethodEvent evt) {
}
public void inputMethodTextChanged(java.awt.event.InputMethodEvent evt) {
jTable1InputMethodTextChanged(evt);
}
});
jScrollPane1.setViewportView(jTable1);

jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Billing"));

jTextField1.setAction(jTextField1.getAction());
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
}
});

jTextField2.setAction(jTextField2.getAction());
jTextField2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField2ActionPerformed(evt);
}
});

jTextField3.setEditable(false);

jButton1.setAction(jButton1.getAction());
jButton1.setText("Add");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jButton2.setAction(jButton2.getAction());
jButton2.setMnemonic('N');
jButton2.setText("Cancel");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

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


jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel2.setText("Code");

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


jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel3.setText("Quantity");

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


jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel4.setText("Name");

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


jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(33, 33, 33)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.LEADING, false)
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE,
 javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 56,
Short.MAX_VALUE)
.addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE,
 javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.LEADING)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE,
111, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
111, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE,
111, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(0, 83, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
 jPanel2Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(37, 37, 37)
.addComponent(jButton2)))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(19, 19, 19)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addGap(11, 11, 11)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE,
 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE,
 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
 javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jButton1)
.addComponent(jButton2)))
);

jButton3.setAction(jButton3.getAction());
jButton3.setMnemonic('P');
jButton3.setText("Print");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});

jButton4.setAction(jButton4.getAction());
jButton4.setMnemonic('C');
jButton4.setText("Cancel/Close");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});

jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel7.setIcon(new
 javax.swing.ImageIcon("C:\\Users\\TOSHIBA\\Desktop\\Pharmacy\\medi.jpg")); // NOI18N
jLabel7.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0,
0)));
jLabel7.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);


jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING,
 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING,
 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
);

jLabel6.setFont(new java.awt.Font("mohammad bold art 1", 1, 24)); // NOI18N


jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel6.setText("Medicine Billing System");

jMenu1.setText("File");

jMenuItem2.setAction(jMenuItem2.getAction());
jMenuItem2.setText("Stock");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem2);

jMenuItem1.setAction(jMenuItem1.getAction());
jMenuItem1.setText("Exit");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem1);

jMenuBar1.add(jMenu1);

jMenu2.setText("About");
jMenuBar1.add(jMenu2);

setJMenuBar(jMenuBar1);

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


getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 647,
Short.MAX_VALUE)
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGap(0, 181, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(22, 22, 22))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addComponent(jButton3)
.addGap(35, 35, 35)
.addComponent(jButton4)
.addGap(291, 291, 291))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE,
 javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(37, 37, 37))))
.addGroup(layout.createSequentialGroup()
.addGap(181, 181, 181)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 346,
 javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 34,
 javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G, false)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE,
 javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
 javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 207,
 javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
 javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(30, 30, 30)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELI
 NE)
.addComponent(jButton4)
.addComponent(jButton3))
.addContainerGap(28, Short.MAX_VALUE))
);

pack();
}// </editor-fold>//GEN-END:initComponents

private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_jTextField1ActionPerformed
// TODO add your handling code here:
// if()
int i=0;
if(jTextField1.getText().equals(""))
JOptionPane.showMessageDialog(rootPane, "Sorry.. Please enter the Code & Other 
details.");
else{

try {
rs=st.executeQuery("SELECT MediTitle FROM MediInfo WHERE
MedicineID='"+Integer.parseInt(jTextField1.getText()) +"'");
while(rs.next()){
jTextField3.setText(""+rs.getString(1));
i++;
}
jTextField1.setFocusable(false);
jTextField1.setFocusable(true);

} catch (SQLException ex) {


Logger.getLogger(Billing.class.getName()).log(Level.SEVERE, null, ex);
}
if(i==0)
JOptionPane.showMessageDialog(rootPane, "No Medicine Found !!");
}
}//GEN-LAST:event_jTextField1ActionPerformed

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


FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
String cod = null,nm = null,qt = null,qty=null;
int i;
if(jTextField1.getText().equals("")&&jTextField2.getText().equals(""))
JOptionPane.showMessageDialog(rootPane, "Sorry.. Please enter the Code & Other 
details.");
else{
try {

rs=st.executeQuery("SELECT * FROM MediInfo WHERE


MedicineID='"+Integer.parseInt(jTextField1.getText()) +"'");
while(rs.next()){
cod=rs.getString(1);
nm=rs.getString(2);
qty=rs.getString(3);
qt=jTextField2.getText();
pri=rs.getString(4);

}
//jTextField2.setFocusable(true);
} catch (SQLException ex) {
Logger.getLogger(Billing.class.getName()).log(Level.SEVERE, null, ex);
}
int reply=JOptionPane.showConfirmDialog(rootPane, "Do you wanna Add ?");
insertRow(reply,cod,nm,pri,qt,qty);

}
}//GEN-LAST:event_jButton1ActionPerformed

public void insertRow(int reply,String cod,String nm,String pri,String qt,String qty){


if(reply==JOptionPane.YES_OPTION){
double price=Double.parseDouble(pri);
double cost=price*Integer.parseInt(qt);
DecimalFormat df=new DecimalFormat("00.0");
String formate = df.format(cost);
cost = Double.parseDouble(formate) ;
boolean bool=CheckStock(qty,qt);
if(bool){
model.insertRow(index,new Object[]{cod,nm,pri,qt,cost});
amount+=cost;

 jLabel5.setText(""+amount);
index++;
//updatetable(Double.parseDouble(qty)-Double.parseDouble(qt),cod);
}
else
JOptionPane.showMessageDialog(rootPane, "Stock Available is "+qty);
initial();
}
}
public boolean CheckStock(String qt,String qty){
if(Double.parseDouble(qt)>Double.parseDouble(qty))
return true;
else
return false;
}
private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
FIRST:event_jTextField2ActionPerformed
// TODO add your handling code here:
jButton1ActionPerformed(evt);
}//GEN-LAST:event_jTextField2ActionPerformed

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


FIRST:event_jButton4ActionPerformed
// TODO add your handling code here:

new Billing().setVisible(true);
this.dispose();
}//GEN-LAST:event_jButton4ActionPerformed

private void jTable1InputMethodTextChanged(java.awt.event.InputMethodEvent evt)


{//GEN-FIRST:event_jTable1InputMethodTextChanged
// TODO add your handling code here:

}//GEN-LAST:event_jTable1InputMethodTextChanged

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


FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
initial();
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
FIRST:event_jButton3ActionPerformed
// TODO add your handling code here:
int i=0;
int reply=JOptionPane.showConfirmDialog(rootPane, "Are you sure to print the
recceipt ?");
if(reply==JOptionPane.YES_OPTION){
updateData();
StockCheck();
initial();
while(i<model.getRowCount())
{
model.removeRow(0);
i++;
}
jLabel5.setText("");
JOptionPane.showMessageDialog(rootPane, "Bill is generated.. Thank You!!");
}
}//GEN-LAST:event_jButton3ActionPerformed

private void StockCheck(){

ArrayList req=new ArrayList();


try {

rs=st.executeQuery("SELECT MedicineID,Qty FROM MediInfo");


while(rs.next()){
if(Double.parseDouble(rs.getString(2))<20)
req.add(rs.getString(1));

}
if(!req.isEmpty()){
int rep=JOptionPane.showConfirmDialog(rootPane,
"<html><b>ALERT</b></html>\n Stock is Less\n Do u want to Check out
the Stock ?\n");
if(rep==JOptionPane.YES_OPTION){
MetalTheme myXPStyleTheme = new XPStyleTheme();
MetalLookAndFeel.setCurrentTheme(myXPStyleTheme);
try
{
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
}
catch (Exception err)
{
System.out.println("Error loading myXPStyleTheme:" + err.toString());
}
PMSSwing c = new PMSSwing(1);
c.RetrieveData();
}
}
//jTextField2.setFocusable(true);
} catch (SQLException ex) {
Logger.getLogger(Billing.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
FIRST:event_jMenuItem1ActionPerformed
// TODO add your handling code here:
System.exit(0);
}//GEN-LAST:event_jMenuItem1ActionPerformed

private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_jMenuItem2ActionPerformed
// TODO add your handling code here:
MetalTheme myXPStyleTheme = new XPStyleTheme();
MetalLookAndFeel.setCurrentTheme(myXPStyleTheme);
try
{
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
}
catch (Exception err)
{
System.out.println("Error loading myXPStyleTheme:" + err.toString());
}

PMSSwing c = new PMSSwing(1);


c.RetrieveData();
}//GEN-LAST:event_jMenuItem2ActionPerformed
 public void updateData(){
int i=0;
double update;
String cod,qty,QtyData=null;
while(i<jTable1.getModel().getRowCount()){
cod=(String) jTable1.getModel().getValueAt(i, 0);
qty=(String) jTable1.getModel().getValueAt(i, 3);

try {

rs=st.executeQuery("SELECT Qty FROM MediInfo WHERE


MedicineID='"+cod+"'");
while(rs.next()){
QtyData=rs.getString(1);

}
update=Double.parseDouble(QtyData)-Double.parseDouble(qty);
updatetable(update, cod);

//jTextField2.setFocusable(true);
} catch (SQLException ex) {
Logger.getLogger(Billing.class.getName()).log(Level.SEVERE, null, ex);
}
i++;
}}

try {
for (javax.swing.UIManager.LookAndFeelInfo info :
 javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Billing.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Billing.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Billing.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Billing.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
}
//</editor-fold>

/*
* Create and display the form
*/
java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {


new Billing().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
// End of variables declaration//GEN-END:variables
}

Add ,modify and remove data :

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.table.*;
import javax.swing.plaf.metal.*;
//import javax.swing.border.*;

//DataBase Packages

//import java.net.*;
//import java.io.*;
import java.sql.*;

//Main Class

class PMSSwing extends JFrame implements ActionListener 


{
private Statement st;
private Connection con;

//List of Labels

private JLabel lblOldMedicineID;


private JLabel lblMedicineID;
private JLabel lblMediTitle;
private JLabel lblQty;
private JLabel lblPrice;

//List of TextFields

private JTextField txtOldMedicineID;


private JTextField txtMedicineID;
private JTextField txtMediTitle;
private JTextField txtQty;
private JTextField txtPrice;

//List of Buttons

private JButton btnSaveAdd;


private JButton btnSaveEdit;
private JButton btnSaveDelete;
private JButton btnAdd;
private JButton btnEdit;
private JButton btnDelete;
private JButton btnExit;
private JButton btnRefresh;
private JButton btnCancel;

//List of Panel

private JPanel btnpanel;


private JPanel panel;
private JTable table;

//Table

private DefaultTableModel tmodel;


//Container 

private Container cpane;

Splash FormSplash = new Splash();


Thread ThFormSplash = new Thread(FormSplash);

PMSSwing()
{
}

PMSSwing(int choice)
{
switch(choice)
{
case 1:
//Initial Window

setTitle("PHARMACY MANAGEMENT SYSTEM");


setBounds(275, 250, 450, 230);
setResizable(false);
setIconImage (getToolkit().getImage ("Images/SuperDisk.gif"));

loadSplashScreen();

FormSplash.dispose();

//cotainer 

cpane = getContentPane();

//components

tmodel = new DefaultTableModel();


table = new JTable(tmodel);
SetColHeader();

btnpanel = new JPanel(new GridLayout(1, 5, 5, 0));


btnAdd = new JButton ("Add");
btnEdit = new JButton ("Edit");
btnDelete = new JButton ("Delete");
btnRefresh = new JButton ("Refresh");
btnExit = new JButton ("Exit");
btnAdd.addActionListener(this);
btnEdit.addActionListener(this);
btnDelete.addActionListener(this);
btnRefresh.addActionListener(this);
btnExit.addActionListener(this);

btnpanel.add(btnAdd);
btnpanel.add(btnEdit);
btnpanel.add(btnDelete);
btnpanel.add(btnRefresh);
btnpanel.add(btnExit);

cpane.add(new JScrollPane(table));

cpane.add(btnpanel, BorderLayout.SOUTH);
break;
case 2:
//Appending Window

setTitle("Addition of data...");
setBounds(275, 275, 400, 200);
setResizable(false);

//cotainer 

cpane = getContentPane();
cpane.setLayout(new FlowLayout());

//Components

panel = new JPanel(new GridLayout(8, 1, 5, 0));


setBackground(Color.BLUE);

lblMedicineID = new JLabel(" MediID ");


lblMediTitle = new JLabel(" MediTitle ");
lblQty = new JLabel(" Qty ");
lblPrice = new JLabel(" Price ");

txtMedicineID = new JTextField(15);


txtMediTitle = new JTextField(15);
txtQty = new JTextField(15);
txtPrice = new JTextField(15);

panel.add(lblMedicineID);
panel.add(txtMedicineID);
panel.add(lblMediTitle);
panel.add(txtMediTitle);
panel.add(lblQty);
panel.add(txtQty);
panel.add(lblPrice);
panel.add(txtPrice);

btnpanel = new JPanel(new GridLayout(2, 1, 10, 5));


btnSaveAdd = new JButton ("Save");
btnCancel = new JButton ("Cancel");

btnSaveAdd.addActionListener(this);
btnCancel.addActionListener(this);

btnpanel.add(btnSaveAdd);
btnpanel.add(btnCancel);
cpane.setBackground(Color.YELLOW);

cpane.add(panel);
cpane.add(btnpanel, BorderLayout.EAST);
break;
case 3:
//Editing window

setTitle("Updation of data...");
setBounds(350, 350, 400, 250);
setResizable(false);

//cotainer 

cpane = getContentPane();
cpane.setLayout(new FlowLayout());

//Components

panel = new JPanel(new GridLayout(10, 1, 5, 0));


lblOldMedicineID = new JLabel(" OldMedicineID ");
txtOldMedicineID = new JTextField(15);

lblMedicineID = new JLabel(" NewMediID ");


lblMediTitle = new JLabel(" MediTitle ");
lblQty = new JLabel(" Qty ");
lblPrice = new JLabel(" Price ");

txtMedicineID = new JTextField(15);


txtMediTitle = new JTextField(15);
txtQty = new JTextField(15);
txtPrice = new JTextField(15);

panel.add(lblOldMedicineID);
panel.add(txtOldMedicineID);
panel.add(lblMedicineID);
panel.add(txtMedicineID);
panel.add(lblMediTitle);
panel.add(txtMediTitle);
panel.add(lblQty);
panel.add(txtQty);
panel.add(lblPrice);
panel.add(txtPrice);

btnpanel = new JPanel(new GridLayout(2, 1, 10, 5));


btnSaveEdit = new JButton ("Save");
btnCancel = new JButton ("Cancel");

btnSaveEdit.addActionListener(this);
btnCancel.addActionListener(this);

btnpanel.add(btnSaveEdit);
btnpanel.add(btnCancel);

cpane.add(panel);
cpane.setBackground(Color.BLUE);

cpane.add(btnpanel, BorderLayout.EAST);
break;
case 4:
//Deleting window

setTitle("Removal of data...");
setBounds(300, 300, 300, 125);
setResizable(false);

//cotainer 

cpane = getContentPane();
cpane.setLayout(new FlowLayout());

//Components

panel = new JPanel(new GridLayout(2, 1, 5, 0));


lblMedicineID = new JLabel("MedicineID to be deleted: ");
txtMedicineID = new JTextField(15);

panel.add(lblMedicineID);
panel.add(txtMedicineID);

btnpanel = new JPanel(new GridLayout(2, 1, 10, 5));


btnSaveDelete = new JButton ("Delete");
btnCancel = new JButton ("Cancel");

btnSaveDelete.addActionListener(this);
btnCancel.addActionListener(this);

btnpanel.add(btnSaveDelete);
btnpanel.add(btnCancel);

cpane.add(panel);
cpane.setBackground(Color.RED);

cpane.add(btnpanel, BorderLayout.EAST);
break;
}
//Window Properties

setDefaultCloseOperation(HIDE_ON_CLOSE);
setVisible(true);

//conection to DataBase

ConnectToDatabase();
}

public void actionPerformed (ActionEvent ae)


{
if (ae.getSource() == btnAdd)
{
new PMSSwing(2);
}
else if (ae.getSource() == btnEdit)
{
new PMSSwing(3);
}
else if (ae.getSource() == btnDelete)
{
new PMSSwing(4);
}
else if (ae.getSource() == btnExit)
{
this.dispose();

}
else if (ae.getSource() == btnCancel)
{
setVisible(false);
}
else if(ae.getSource() == btnSaveAdd)
{
AddData(txtMedicineID.getText(), txtMediTitle.getText(), txtQty.getText(),
txtPrice.getText());
txtMedicineID.setText("");
txtMediTitle.setText("");
txtQty.setText("");
txtPrice.setText("");
}
else if(ae.getSource() == btnSaveEdit)
{
EditData(txtMedicineID.getText(), txtMediTitle.getText(),
txtQty.getText(),txtPrice.getText(), txtOldMedicineID.getText());
txtOldMedicineID.setText("");
txtMedicineID.setText("");
txtMediTitle.setText("");
txtQty.setText("");
txtPrice.setText("");
}
else if(ae.getSource() == btnSaveDelete)
{
DeleteData(txtMedicineID.getText());
txtMedicineID.setText("");
}
else if(ae.getSource() == btnRefresh)
{
RetrieveData();
}
}

protected void loadSplashScreen()


{
//Start the thread
ThFormSplash.start();
while(!FormSplash.isShowing())
{
try
{
//Display the FormSplash for 10 seconds
Thread.sleep(750);
}
catch(InterruptedException e)
{
}
}
}

public static void main(String arg[])


{

//System.out.println("Error Loading Theme:" + e.toString());


//If Failed to load the liquid them then load my own XPStyleTheme
MetalTheme myXPStyleTheme = new XPStyleTheme();
MetalLookAndFeel.setCurrentTheme(myXPStyleTheme);
try
{
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
}
catch (Exception err)
{
System.out.println("Error loading myXPStyleTheme:" + err.toString());
}

PMSSwing c = new PMSSwing(1);


c.RetrieveData();
}

private void SetColHeader()


{
tmodel.addColumn("MedicineID");
tmodel.addColumn("MediTitle");
tmodel.addColumn("Qty");
tmodel.addColumn("Price");

private void ConnectToDatabase ()


{
try
{
String dsn = "Medi";

//load driver 
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//make connection
con = DriverManager.getConnection("jdbc:odbc:Medi");

//create statement
st = con.createStatement();
}
catch (Exception e) {System.out.println(e);}
}

private void AddData (String code, String title, String hour, String price)
{
try
{
//prepare statement
String qry = "Insert into MediInfo values (?, ?, ?, ?)";
System.out.println(code + "\t"+title+ "\t"+hour+ "\t"+price);
//System.out.println("Read only "+con.isReadOnly());
//System.out.println("Closed "+con.isClosed());

PreparedStatement ps = con.prepareStatement(qry);

ps.setString(1, code);
ps.setString(2, title);
ps.setString(3, hour);
ps.setString(4,price);

ps.executeUpdate();
}
catch(Exception e) {System.out.println(e + "\t" + e.getMessage()); }
}

private void EditData (String code, String title, String hour, String price, String cond)
{
try
{
//prepare statement
String qry = "Update MediInfo set MedicineID = ?, MediTitle = ?, Qty = ?, Price = ? where
MedicineID = ?";
PreparedStatement ps = con.prepareStatement(qry);

ps.setString(1, code);
ps.setString(2, title);
ps.setString(3, hour);
ps.setString(4, price);
ps.setString(5, cond);

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

private void DeleteData (String cond)


{
try
{
//prepare statement
String qry = "Delete from MediInfo where MedicineID = ?";
PreparedStatement ps = con.prepareStatement(qry);

ps.setString(1, cond);

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

public void RetrieveData ()


{
try
{
int row = tmodel.getRowCount();
while(row > 0)
{
row--;
tmodel.removeRow(row);
}

//execute query
ResultSet rs = st.executeQuery("Select * from MediInfo");

//get metadata
ResultSetMetaData md = rs.getMetaData();
int colcount = md.getColumnCount();

Object[] data = new Object[colcount];


//extracting data

while (rs.next())
{
for (int i=1; i<=colcount; i++)
{
data[i-1] = rs.getString(i);
}
tmodel.addRow(data);
}
}
catch(Exception e) {System.out.println(e); }
}
}

Loading the content :

import javax.swing.*;
import java.awt.*;
import javax.swing.border.LineBorder;

 public class Splash extends JWindow implements Runnable


{
 public void run()
{
JLabel SplashLabel = new JLabel(new ImageIcon("Start.jpg"));
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
Color cl = new Color (0, 0, 0);
SplashLabel.setBorder (new LineBorder (cl, 1));

getContentPane().add(SplashLabel,BorderLayout.CENTER);

setSize(850,300);
setLocation(200,100);
show();
}
}

Display :

import javax.swing.plaf.*;
import javax.swing.plaf.metal.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
 public class XPStyleTheme extends DefaultMetalTheme {

public String getName() { return "XP Style Theme"; }

private final ColorUIResource primary1 = new ColorUIResource( 119, 119, 187); //Frame
Border Color 
private final ColorUIResource primary2 = new ColorUIResource( 153, 153, 204);
//Barckground Color 
private final ColorUIResource primary3 = new ColorUIResource(225, 225, 25 5); // Title
Color 

private final ColorUIResource secondary1 = new ColorUIResource( 172, 168, 153); //


Shadow color 
private final ColorUIResource secondary2 = new ColorUIResource(172, 168, 153); //Dark 
Shadow color 113, 111, 100
private final ColorUIResource secondary3 = new ColorUIResource(236, 233,216); //Face
Color 

protected ColorUIResource getPrimary1() { return primary1; }


protected ColorUIResource getPrimary2() { return primary2; }
protected ColorUIResource getPrimary3() { return primary3; }

protected ColorUIResource getSecondary1() { return secondary1; }


protected ColorUIResource getSecondary2() { return secondary2; }
protected ColorUIResource getSecondary3() { return secondary3; }

}
Screen shots:
Addition of data :
Updation of data:
Removal of Data:
Entries of all data :
After adding items :
After updating :
After Deletion :

You might also like