Professional Documents
Culture Documents
PROJECT REPORT
ON
SESSION 2019-22
1
DECLARATION
We Paras Mittal and Tushar Verma hereby declare that the project report title “Stock Management
System” is an original work carried out by me under the supervision of Mr. Sanjaykant Tyagi. I
further declare that this work has not been submitted to any other Institute/University for the award of
the degree of Bachelor of Computer Applications.
2
Date: 30th April 2013
FORWARDING LETTER
This is to certify that the project entitled “Stock Management System”, which is being submitted for
the partial fulfillment for the award of Degree of Bachelor of Computer Applications from Ch.
Charan Singh U n i v e r s i t y , M e e r u t i s a n a u t h e n t i c w o r k c a r r i e d out by Mr. Paras
Mittal(University Roll No.190855106146) and Tushar Verma(190855106199) under the guidance of
Project Guide Mr.Sanjaykant Tyagi.
The matter embodied in this project work has not been submitted earlier for the award of degree or
diploma.
3
ACKNOWLEDGEMENT
Finally, I(Paras Mittal) would like to thank God, for letting me through all the difficulties. I have
experienced your guidance day by day. You are the one who let me finish my Project. I will keep on
trusting you for my future.
Paras Mittal
(190855106146)
Tushar Verma
(190855106199)
4
Preface
5
INDEX
Bibliography…………………………………………………………………………….....83
6
CHAPTER.1 INTRODUCTION
Introduction
The project Stock Management System is a complete desktop based application designed on
java using Netbeans Software. The main aim of the project is to develop Stock Management System
Model software in which all the information regarding the stock of the organization will be presented.
It is an Intranet based desktop application which has admits component to manage the stock and
maintenance of the stock system. This desktop application is based on the management of stock of an
organization. The application contains vendors details, sales details, Purchase details and the
remaining stock that are presented in the organization. There is a provision of updating the stock also.
This application also provides the remaining balance of the stock as well as the details of the balance
of transaction. The new product can also be added here. In this project the calculator is also given to
cross check the calculation, google is also in the additional services. Here the login page is created in
order to protect the management of the stock of organization in order to prevent it from the threads
and misuse of the stock.
Objectives
Primary objective:-
The primary objectives of the project is to know the fundamentals of Java programming and
SQL using Netbeans and MySQL.
Secondary objective:-
The secondary objectives of this project are mentioned below:
► To develop an application that deals with the day to day requirement of any production
organization To develop the easy management of the stock.
► To handle the stock details like sales details, purchase details and balance stock details.
► To provide details information about the stock balance.
► To make the stock manageable and simplify the use of stock in the organization.
► To keep details of vendors.
7
1.1 Scope of the System
After analyzing many existing SMS we have now the obvious vision of the project to be
developed. Before we started to build the application we had many challenges,
8
1.3 Project Description
1.3.1About Existing System:-
“Stock Management System” is one can go into almost required solution regarding the stock. This
software package provides guidance for all the stock management purpose, as a perfect guide, the
current demand for such software became needful. This project will provide for computerization of a
small enterprise whose main goal is to keep track on their stock process and wants to change from
paper based data to computerized data. In this System, on starting it the login page will be displayed,
which can only be accessed by the Owner. Six options are provided, one is for vendor information,
second is for purchase details, third is for sales details, fourth for product details, fifth is for additional
services where notepad, calculator and google is given , at last but not the least is logout option.
For stock management processes, you need robust functionality for managing your
logistics facilities. Support for stock management helps you record and track materials on the basis of
both quantity and value.
Additional benefits of stock management include improved cash flow, visibility, and decision
making.
A crucial phase in the system life cycle is the successful implementation of the new system
design. Implementation includes all those activities that take place to convert from the old system to
tee new one. The new system may be completely new, replacing an existing system. In either case,
proper implementation becomes necessary so that a reliable system based on the requirements of the
organization can be provided. Successful implementation may not guarantee improvement in the
organization using the new system, but improper installation will prevent it. It has been observed that
even the best system can’t show good result if the analysts managing the implementation do not
9
attend to every important details. This is an area where the systems analysts need to work with utmost
care. This system will be implemented using java Netbeans as front end and MYSQL as back end.
For the successful implementation of a system, the training of the users of the system plays
an important role. Because even well designed system can succeed or fail because of the way they are
operated and used. Therefore, the quality of the training received by the personnel involved with the
system in various capacities helps or hinders and may even prevent the successful implementation of
management information system. Those who are directly or indirectly related with the system
development work must know in detail what their roles will be, how they can ace efficient use of the
system and what the system will or will not do for them. Therefore both system operators and users
need training.
Advantages
1. Avoidance of stock-outs and excess stock .
2. Helps save time and money .
3. Fast accessible.
4. Having knowledge of vendors .
5. Easy to maintain .
Limitations
1. This application is not suitable for those organization where there is large quantity.
2. Single admin panel is only made.
3. It is not suitable for large organization.
10
CHAPTER.2 PROJECT CATEGORY & ENVIRONEMENT
Today computer has become the backbone of nearly every occupation. In every industry or company
or any institution, the several employees have to maintain a number of records in various part of the
organization. In a market, there is a need to maintain record about employees, edibles, assets & many
more.
To do this work manually requires a lot of manpower and consumes too much time. Moreover one is
never sure about the efficiency & accuracy of work being done and records being maintained. A bad
part of this style of working is that, if a person concerned for a particular job, say maintaining
customer record, is on leave, some of the process gets standstill, which depends on the records kept
by that employee. That is, where automation comes in to help and allows simple, smooth and most
efficient, secure and easy to handle functionality.
This system will reduce the workload of the employee and time of processing of data from one unit to
another.It also provides the facility to prevent the unauthorized data access of other persons by
categorized the user as normal user and administrator. Only administrator can delete & even modify
the records.
SQL is used as front end language for handling the database using MySQL software.
11
2.4 Software and Hardware Requirements
Software Requirements:
12
CHAPTER.3 PROJECT DEVELOPMENT STAGES
We all know the importance of computerization. The world is moving ahead at lightning speed and
everyone is running short of time. One always wants to get the information and perform a task
he/she/they desire(s) within a short period of time and too with amount of efficiency and accuracy.
The application areas for the computerization have been selected on the basis of following factors:
3. Facilitating desired information display, very quickly, by retrieving information from users.
6. Updating and deletion of such a huge amount of data will become easier.
Types of feasibility
1. Technical Feasibility
2. Operational Feasibility
3. Economic Feasibility
13
This is concerned with specifying equipment and software that will
successfully satisfy the user requirement. Technical needs of the system include:-
In examining technical feasibility, configuration of the system is given more importance than the
actual make of hardware .Configuration should give the complete picture about the system’s
requirements: how many workstations are required , how these units are interconnected so that they
could operate and communicate smoothly. What speeds of input and output should be achieved at
particular quality of printing.
The computers are easily available in almost all the places, even in villages. The hardware needed to
carry out this project with 64 MB of RAM and 2 GB HDD.
The software needed to carry out this project include Visual Basic 6.0 as front end and oracle 8 as
back end .So the technology required to carry out the project is easily available and affordable, hence
this project is technically feasible
Due to all these reasons implementation of such system becomes not only feasible but reputed to the
organization..
3.2.2OPERATIONAL FEASIBILITY
This is mainly related to human organization and political aspects. The points to be considered are:-
What new skills will be required? Do the existing staff members have these skills? If not, they be
trained in due course of time.
14
This feasibility study is carried out by a small group of people who are familiar with the information
system techniques who understand the parts of business that are relevant to the project and are skilled
in the system analysis and design process. This project is not developed just for fun. They are
developed on demand of the organization for which the system is being developed. Therefore the
chances of resistance from the company Staff is almost nil. Any disturbance to the organization if
occurs will be advantageous to the organization. Also the time required to carry out a transaction will
be required to a large extent, which will make the students and others happy and cheerful. The
operators now will be able to service more students and staff members than before in same time period.
There is no need to recruit new staff to corporate the system .The existing staff of the company can be
trained to interact with the system, which is a GUI, based software and is easy to use. Hence the project
is Operationally feasible.
3.2.3.ECONOMIC FEASIBILITY
Economic analysis is the most frequently used technique for evaluating the effectiveness of a proposed system.
More commonly known as cost-benefit analysis; the procedure is to determine the benefits and savings that are
expected from a proposed system and compare them with costs. If benefits outweigh costs, a decision is
taken to design and implement the system.
15
3.3DFD
A data flow diagram is a graphical representation of the "flow" of data through an
information system, modelling its process aspects.
16
E-R Diagram:-
ER Diagram stands for Entity Relationship Diagram, also known as ERD is a diagram that displays
the relationship of entity sets stored in a database.
17
CHAPTER.4 PROJECT FORMS
18
• purchase :- Has 6 attributes(id, date, vendor, subtotal, pay, bal)
19
Modules and Coding
1.Vendor:
package stock;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.*;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
20
public void load(){
int a;
try {
pst = con.prepareStatement("Select * from vendor ");
ResultSet rs = pst.executeQuery();
ResultSetMetaData rd = rs.getMetaData();
a=rd.getColumnCount();
df = (DefaultTableModel)jTable1.getModel();
df.setRowCount(0);
while(rs.next())
{
Vector v2 = new Vector();
for(int i=1;i<=a ;i++)
{
v2.add(rs.getString("id"));
v2.add(rs.getString("name"));
v2.add(rs.getString("phone"));
v2.add(rs.getString("email"));
v2.add(rs.getString("address"));
}
df.addRow(v2);
} } catch (SQLException ex) {
java.util.logging.Logger.getLogger(vendor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); }
}
@SuppressWarnings("unchecked")
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
txtvendor = new javax.swing.JTextField();
txtPhone = new javax.swing.JTextField();
txtemail = new javax.swing.JTextField();
txtaddress = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jLabel5 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
jButton5 = new javax.swing.JButton();
jLabel6 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
21
getContentPane().setLayout(null);
jPanel1.setBorder(new
javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel1.setText("Vendor Name");
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel2.setText("Phone");
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel3.setText(" Email");
jLabel4.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel4.setText("Address");
txtvendor.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtvendorActionPerformed(evt);} });
txtaddress.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtaddressActionPerformed(evt); } });
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(34, 34, 34)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4))
.addGap(35, 35, 35)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtaddress, javax.swing.GroupLayout.PREFERRED_SIZE, 132,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtemail, javax.swing.GroupLayout.PREFERRED_SIZE, 132,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtPhone, javax.swing.GroupLayout.PREFERRED_SIZE, 132,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtvendor, javax.swing.GroupLayout.PREFERRED_SIZE, 132,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(64, Short.MAX_VALUE)));
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(35, 35, 35)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel1)
22
.addComponent(txtvendor, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(23, 23, 23)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel2)
.addComponent(txtPhone, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(27, 27, 27)
.addComponent(jLabel3))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(txtemail, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(23, 23, 23)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel4)
.addComponent(txtaddress, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(32, Short.MAX_VALUE))
);
getContentPane().add(jPanel1);
jPanel1.setBounds(10, 108, 352, 221);
jButton1.setIcon(new
javax.swing.ImageIcon("C:\\Users\\Guide\\Documents\\NetBeansProjects\\stockmanagement\\src\\icon\\add.png"
)); // NOI18N
jButton1.setText(" Add");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt); } });
getContentPane().add(jButton1);
jButton1.setBounds(10, 335, 105, 39);
jButton2.setIcon(new
javax.swing.ImageIcon("C:\\Users\\Guide\\Documents\\NetBeansProjects\\stockmanagement\\src\\icon\\update.p
ng")); // NOI18N
jButton2.setText("Update");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt); }});
getContentPane().add(jButton2);
jButton2.setBounds(125, 335, 103, 39);
jButton3.setIcon(new
javax.swing.ImageIcon("C:\\Users\\Guide\\Documents\\NetBeansProjects\\stockmanagement\\src\\icon\\delete.pn
g")); // NOI18N
jButton3.setText("Delete");
23
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt); } });
getContentPane().add(jButton3);
jButton3.setBounds(256, 335, 104, 39);
jButton4.setIcon(new
javax.swing.ImageIcon("C:\\Users\\Guide\\Documents\\NetBeansProjects\\stockmanagement\\src\\icon\\clear.png
")); // NOI18N
jButton4.setText("Cancel");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt); } });
getContentPane().add(jButton4);
jButton4.setBounds(386, 335, 102, 39);
24
private void txtvendorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
FIRST:event_txtvendorActionPerformed}
private void txtaddressActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
FIRST:event_txtaddressActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txtaddressActionPerformed
25
txtemail.setText(df.getValueAt(selected, 3).toString());
txtaddress.setText(df.getValueAt(selected, 4).toString());
jButton1.setEnabled(false); }//GEN-LAST:event_jTable1MouseClicked
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
FIRST:event_jButton2ActionPerformed
df = (DefaultTableModel)jTable1.getModel();
int selected = jTable1.getSelectedRow();
int id = Integer.parseInt(df.getValueAt(selected, 0).toString());
String vname = txtvendor.getText();
String phone = txtPhone.getText();
String email = txtemail.getText();
String address = txtaddress.getText();
try { pst = con.prepareStatement("update vendor set name=?,phone=?,email=?,address=? where
id=?");
pst.setString(1, vname);
pst.setString(2, phone);
pst.setString(3, email);
pst.setString(4, address);
pst.setInt(5, id);
pst.executeUpdate();
JOptionPane.showMessageDialog(this,"Vendor Updatedddddd");
txtvendor.setText("");
txtPhone.setText("");
txtemail.setText("");
txtaddress.setText("");
txtvendor.requestFocus();
load();
jButton1.setEnabled(true);
try {
pst = con.prepareStatement("delete from vendor where id=?");
pst.setInt(1, id);
pst.executeUpdate();
JOptionPane.showMessageDialog(this,"Vendor Deleteddddd");
26
txtvendor.setText("");
txtPhone.setText("");
txtemail.setText("");
txtaddress.setText("");
txtvendor.requestFocus();
load();
jButton1.setEnabled(true);
} catch (SQLException ex) {
java.util.logging.Logger.getLogger(vendor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} }//GEN-LAST:event_jButton3ActionPerformed
27
private javax.swing.JTextField txtaddress;
private javax.swing.JTextField txtemail;
private javax.swing.JTextField txtvendor;}
2.Login
package stock;
import javax.swing.JOptionPane;
public Login() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("LOGIN");
setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
getContentPane().setLayout(null);
28
jButton2.setBackground(new java.awt.Color(255, 102, 102));
jButton2.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jButton2.setIcon(new
javax.swing.ImageIcon("C:\\Users\\Guide\\Documents\\NetBeansProjects\\stockmanagement\\src\\icon\\icons8-
close-16.png")); // NOI18N
jButton2.setText("Cancel");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
getContentPane().add(jButton2);
jButton2.setBounds(510, 230, 120, 30);
jLabel5.setIcon(new
javax.swing.ImageIcon("C:\\Users\\Guide\\Documents\\NetBeansProjects\\stockmanagement\\src\\icon\\login-
icon.png")); // NOI18N
getContentPane().add(jLabel5);
jLabel5.setBounds(10, 0, 320, 360);
29
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents
uname = txtName.getText();
password = txtPass.getText();
this.setVisible(false);
}//GEN-LAST:event_jButton2ActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
30
if ("FlatLaf Light".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
}
//</editor-fold>
3.Product:
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
*/
package stock;
31
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
/**
*
* @author Guide
*/
public class product extends javax.swing.JFrame {
/**
* Creates new form product
*/
public product() {
initComponents();
Connect();
load();
}
Connection con;
PreparedStatement pst;
DefaultTableModel df;
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/stockmanagement","root","IITm@tech0");
//.createStatement();
32
int a;
try {
pst = con.prepareStatement("Select * from product ");
ResultSet rs = pst.executeQuery();
ResultSetMetaData rd = rs.getMetaData();
a=rd.getColumnCount();
df = (DefaultTableModel)jTable1.getModel();
df.setRowCount(0);
while(rs.next())
{
Vector v2 = new Vector();
for(int i=1;i<=a ;i++)
{
v2.add(rs.getString("id"));
v2.add(rs.getString("pname"));
v2.add(rs.getString("description"));
v2.add(rs.getString("barcode"));
v2.add(rs.getString("cprice"));
v2.add(rs.getString("rprice"));
v2.add(rs.getString("qty"));
}
df.addRow(v2);
}
} catch (SQLException ex) {
java.util.logging.Logger.getLogger(vendor.class.getName()).log(java.util.logging.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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
33
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
txtpname = new javax.swing.JTextField();
txtdes = new javax.swing.JTextField();
txtbarcode = new javax.swing.JTextField();
txtcprice = new javax.swing.JTextField();
txtrprice = new javax.swing.JTextField();
txtqty = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
jLabel9 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
getContentPane().setLayout(null);
jPanel1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
34
jLabel7.setText("Qty");
txtpname.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtpnameActionPerformed(evt);
}
});
35
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(38, 38, 38)
.addComponent(txtpname, javax.swing.GroupLayout.PREFERRED_SIZE, 189,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(24, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(33, 33, 33)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel2)
.addComponent(txtpname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(25, 25, 25)
.addComponent(jLabel3))
.addComponent(txtdes, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(23, 23, 23)
.addComponent(jLabel4))
.addComponent(txtbarcode, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(26, 26, 26)
.addComponent(jLabel5))
.addComponent(txtcprice, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(26, 26, 26)
.addComponent(jLabel6))
.addComponent(txtrprice, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
36
.addGap(26, 26, 26)
.addComponent(jLabel7))
.addComponent(txtqty, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(60, Short.MAX_VALUE))
);
getContentPane().add(jPanel1);
jPanel1.setBounds(20, 80, 375, 320);
jButton1.setIcon(new
javax.swing.ImageIcon("C:\\Users\\Guide\\Documents\\NetBeansProjects\\stockmanagement\\src\\icon\\add.png"
)); // NOI18N
jButton1.setText("Add");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1);
jButton1.setBounds(19, 427, 85, 37);
jButton2.setIcon(new
javax.swing.ImageIcon("C:\\Users\\Guide\\Documents\\NetBeansProjects\\stockmanagement\\src\\icon\\update.p
ng")); // NOI18N
jButton2.setText("Update");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
getContentPane().add(jButton2);
jButton2.setBounds(112, 427, 110, 37);
jButton3.setIcon(new
javax.swing.ImageIcon("C:\\Users\\Guide\\Documents\\NetBeansProjects\\stockmanagement\\src\\icon\\delete.pn
g")); // NOI18N
jButton3.setText("Delete");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
getContentPane().add(jButton3);
jButton3.setBounds(239, 427, 100, 37);
37
jButton4.setIcon(new
javax.swing.ImageIcon("C:\\Users\\Guide\\Documents\\NetBeansProjects\\stockmanagement\\src\\icon\\clear.png
")); // NOI18N
jButton4.setText("Clear");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
getContentPane().add(jButton4);
jButton4.setBounds(348, 427, 96, 37);
jButton5.setIcon(new
javax.swing.ImageIcon("C:\\Users\\Guide\\Documents\\NetBeansProjects\\stockmanagement\\src\\icon\\icons8-
close-16.png")); // NOI18N
jButton5.setText("Close");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});
getContentPane().add(jButton5);
jButton5.setBounds(471, 427, 92, 37);
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"ProductID", "ProductName", "Description", "Barcode", "CostPrice", "RetailPrice", "Qty"
}
));
jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jTable1MouseClicked(evt);
}
});
jScrollPane1.setViewportView(jTable1);
getContentPane().add(jScrollPane1);
jScrollPane1.setBounds(404, 73, 604, 327);
38
setSize(new java.awt.Dimension(1050, 525));
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents
try {
pst = con.prepareStatement("update product set
pname=?,description=?,barcode=?,cprice=?,rprice=?,qty=? where id=?");
pst.setString(1, pname);
pst.setString(2, des);
pst.setString(3, barc);
pst.setString(4, cprice);
pst.setString(5, rprice);
pst.setString(6, qty);
pst.setInt(7, id);
pst.executeUpdate();
JOptionPane.showMessageDialog(this,"Product Updatedddddd");
txtpname.setText("");
txtdes.setText("");
txtbarcode.setText("");
txtcprice.setText("");
txtrprice.setText("");
txtqty.setText("");
txtpname.requestFocus();
load();
39
jButton1.setEnabled(true);
}//GEN-LAST:event_jButton2ActionPerformed
txtpname.setText("");
txtdes.setText("");
txtbarcode.setText("");
txtcprice.setText("");
txtrprice.setText("");
txtqty.setText("");
txtpname.requestFocus();
load();
} catch (SQLException ex) {
java.util.logging.Logger.getLogger(vendor.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
40
} // TODO add your handling code here:
}//GEN-LAST:event_jButton1ActionPerformed
jButton1.setEnabled(true);
}//GEN-LAST:event_jButton4ActionPerformed
try {
pst = con.prepareStatement("delete from product where id=?");
pst.setInt(1, id);
pst.executeUpdate();
JOptionPane.showMessageDialog(this,"Product Deleteddddd");
txtpname.setText("");
txtdes.setText("");
txtbarcode.setText("");
txtcprice.setText("");
txtrprice.setText("");
txtqty.setText("");
txtpname.requestFocus();
load();
jButton1.setEnabled(true);
41
} catch (SQLException ex) {
java.util.logging.Logger.getLogger(vendor.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
}
}//GEN-LAST:event_jButton3ActionPerformed
txtpname.setText(df.getValueAt(selected, 1).toString());
txtdes.setText(df.getValueAt(selected, 2).toString());
txtbarcode.setText(df.getValueAt(selected, 3).toString());
txtcprice.setText(df.getValueAt(selected, 4).toString());
txtrprice.setText(df.getValueAt(selected, 5).toString());
txtqty.setText(df.getValueAt(selected, 6).toString());
jButton1.setEnabled(false); }//GEN-LAST:event_jTable1MouseClicked
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("FlatLaf Light".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(product.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (InstantiationException ex) {
42
java.util.logging.Logger.getLogger(product.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(product.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(product.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
}
//</editor-fold>
43
4.Purchase
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
*/
package stock;
//import com.mysql.cj.xdevapi.Statement;
import java.awt.event.KeyEvent;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.table.DefaultTableModel;
import java.sql.ResultSet;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import javax.swing.JOptionPane;
import java.io.*;
import java.time.LocalDate;
import static java.time.LocalDateTime.now;
import java.time.ZonedDateTime;
/**
*
* @author Guide
*/
public class Purchase extends javax.swing.JFrame {
/**
* Creates new form Purchase
*/
public Purchase() {
initComponents();
Connect();
vendor();
}
Connection con;
PreparedStatement pst;
PreparedStatement pst1;
PreparedStatement pst2;
44
DefaultTableModel df;
ResultSet rs;
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/stockmanagement","root","IITm@tech0");
//.createStatement();
txtvendor.removeAllItems();
while(rs.next())
{
txtvendor.addItem(rs.getString("name"));
}
45
if(rs.next() == false)
{
JOptionPane.showMessageDialog(this,"BarCode Not Found");
txtpcode.setText("");
}
else
{
String pname = rs.getString("pname");
String price = rs.getString("rprice");
txtpname.setText(pname.trim());
txtprice.setText(price.trim());
txtqty.requestFocus();
}
df = (DefaultTableModel)jTable1.getModel();
df.addRow(new Object[]
{
txtpcode.getText(),
txtpname.getText(),
txtprice.getText(),
txtqty.getText(),
tot
});
int sum = 0;
for(int i=0;i<jTable1.getRowCount();i++)
{
sum=sum+Integer.parseInt(jTable1.getValueAt(i,4).toString());
46
}
txttcost.setText(String.valueOf(sum));
txtpcode.setText("");
txtpname.setText("");
txtprice.setText("");
txtqty.setText("");
}
int lastid=0;
String query1 = "Insert into purchase(date,vendor,subtotal,pay,bal) values(?,?,?,?,?)";
pst = con.prepareStatement(query1,Statement.RETURN_GENERATED_KEYS);
pst.setString(1, date);
pst.setString(2, vendor);
pst.setString(3, subtotal);
pst.setString(4, pay);
pst.setString(5, bal);
pst.executeUpdate();
rs=pst.getGeneratedKeys();
if(rs.next())
{
lastid = rs.getInt(1);
}
47
String productid;
String price;
String qty;
int total = 0;
pst1.setInt(1,lastid);
pst1.setString(2,productid);
pst1.setString(3,price);
pst1.setString(4,qty);
pst1.setInt(5,total);
pst1.executeUpdate();
pst2.setString(1,qty);
pst2.setString(2,productid);
pst2.executeUpdate();
}
48
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
getContentPane().setLayout(null);
49
jLabel1.setBounds(100, 40, 260, 96);
jPanel1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
jButton1.setText("Add");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Product Code", "Product Name", "Price", "Qty", "Total"
}
));
jScrollPane1.setViewportView(jTable1);
50
jLabel7.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel7.setText("Qty");
jButton2.setIcon(new
javax.swing.ImageIcon("C:\\Users\\Guide\\Documents\\NetBeansProjects\\stockmanagement\\src\\icon\\add.png"
)); // NOI18N
jButton2.setText("Add");
jButton2.addActionListener(new java.awt.event.ActionListener() {
51
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setIcon(new
javax.swing.ImageIcon("C:\\Users\\Guide\\Documents\\NetBeansProjects\\stockmanagement\\src\\icon\\icons8-
close-16.png")); // NOI18N
jButton3.setText("Close");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
52
.addComponent(txtqty, javax.swing.GroupLayout.PREFERRED_SIZE, 112,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(40, 40, 40)))
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 88,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(138, 138, 138))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 126,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(42, 42, 42)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 110,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 576,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(70, 70, 70)
.addComponent(jLabel8))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(52, 52, 52)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtpay, javax.swing.GroupLayout.PREFERRED_SIZE, 116,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txttcost, javax.swing.GroupLayout.PREFERRED_SIZE, 116,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtbal, javax.swing.GroupLayout.PREFERRED_SIZE, 116,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel9)
.addComponent(jLabel10))))))
.addGap(20, 20, 20))))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(23, 23, 23)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
53
.addComponent(jLabel4)
.addComponent(jLabel5)
.addComponent(jLabel7))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtpcode, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtpname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtprice, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtqty, 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,
jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 33,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(26, 26, 26)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txttcost, javax.swing.GroupLayout.PREFERRED_SIZE, 27,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel9)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtpay, javax.swing.GroupLayout.PREFERRED_SIZE, 27,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel10)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtbal, javax.swing.GroupLayout.PREFERRED_SIZE, 27,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0,
Short.MAX_VALUE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton3)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(20, 20, 20))
);
54
getContentPane().add(jPanel1);
jPanel1.setBounds(80, 140, 821, 347);
txtvendor.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtvendorActionPerformed(evt);
}
});
getContentPane().add(txtvendor);
txtvendor.setBounds(700, 90, 103, 29);
jLabel6.setIcon(new
javax.swing.ImageIcon("C:\\Users\\Guide\\Documents\\NetBeansProjects\\stockmanagement\\src\\icon\\purchase
_screen.png")); // NOI18N
getContentPane().add(jLabel6);
jLabel6.setBounds(-120, 0, 1120, 870);
55
int pay = Integer.parseInt(txtpay.getText());
int subtotal = Integer.parseInt(txttcost.getText());
txtbal.setText(String.valueOf(bal));
add();
}//GEN-LAST:event_jButton2ActionPerformed
if(evt.getKeyCode() == KeyEvent.VK_ENTER)
{
barcode();
}
}//GEN-LAST:event_txtpcodeKeyPressed
}//GEN-LAST:event_jButton1ActionPerformed
/**
56
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("FlatLaf Light".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Purchase.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Purchase.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Purchase.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Purchase.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
}
//</editor-fold>
57
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.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
private javax.swing.JTextField txtbal;
private javax.swing.JTextField txtpay;
private javax.swing.JTextField txtpcode;
private javax.swing.JTextField txtpname;
private javax.swing.JTextField txtprice;
private javax.swing.JTextField txtqty;
private javax.swing.JTextField txttcost;
private javax.swing.JComboBox<String> txtvendor;
// End of variables declaration//GEN-END:variables
}
5.Main
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
*/
package stock;
import java.awt.Desktop;
import java.awt.Graphics;
import java.io.IOException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Guide
*/
public class main extends javax.swing.JFrame {
/**
* Creates new form main
*/
public main() {/*
JLabel b;
58
setSize(1200,700);
setLayout(null);
ImageIcon img=new
ImageIcon("C:\\Users\\Guide\\Documents\\NetBeansProjects\\stockmanagement\\src\\icon\\stock.png");
b=new JLabel("",img,JLabel.CENTER);
b.setBounds(0,0,1200,700);
add(b);*/
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jCheckBoxMenuItem1.setSelected(true);
jCheckBoxMenuItem1.setText("jCheckBoxMenuItem1");
jMenu1.setText("jMenu1");
jMenu2.setText("jMenu2");
59
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("STOCK MANAGEMENT");
setBackground(new java.awt.Color(204, 255, 255));
setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
getContentPane().setLayout(null);
60
});
getContentPane().add(jButton3);
jButton3.setBounds(70, 183, 310, 80);
jMenu4.setIcon(new
javax.swing.ImageIcon("C:\\Users\\Guide\\Documents\\NetBeansProjects\\stockmanagement\\src\\icon\\services.
png")); // NOI18N
jMenu4.setText("Additional Services");
61
jMenuItem1.setIcon(new
javax.swing.ImageIcon("C:\\Users\\Guide\\Documents\\NetBeansProjects\\stockmanagement\\src\\icon\\notepad.
png")); // NOI18N
jMenuItem1.setText("Notepad");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem1);
jMenuItem2.setIcon(new
javax.swing.ImageIcon("C:\\Users\\Guide\\Documents\\NetBeansProjects\\stockmanagement\\src\\icon\\calculato
r.png")); // NOI18N
jMenuItem2.setText(" Calculator");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem2);
jMenuItem3.setIcon(new
javax.swing.ImageIcon("C:\\Users\\Guide\\Documents\\NetBeansProjects\\stockmanagement\\src\\icon\\google.p
ng")); // NOI18N
jMenuItem3.setText("Google");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem3);
jMenuBar1.add(jMenu4);
setJMenuBar(jMenuBar1);
62
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
FIRST:event_jButton1ActionPerformed
vendor v = new vendor();
v.setVisible(true);
}//GEN-LAST:event_jButton1ActionPerformed
}//GEN-LAST:event_jButton3ActionPerformed
63
}catch(Exception e){ }
}//GEN-LAST:event_jMenuItem3ActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("FlatLaf Light".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
64
private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1;
private javax.swing.JLabel jLabel2;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu4;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JPopupMenu jPopupMenu1;
// End of variables declaration//GEN-END:variables
}
6.Sales
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
*/
package stock;
import java.awt.event.KeyEvent;
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.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
/**
*
* @author Guide
*/
public class Sales extends javax.swing.JFrame {
/**
* Creates new form Sales
*/
public Sales() {
initComponents();
65
Connect();
}
Connection con;
PreparedStatement pst;
PreparedStatement pst1;
PreparedStatement pst2;
DefaultTableModel df;
ResultSet rs;
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/stockmanagement","root","IITm@tech0");
//.createStatement();
if(rs.next() == false)
{
JOptionPane.showMessageDialog(this,"BarCode Not Found");
txtpcode.setText("");
}
else
{
String pname = rs.getString("pname");
String price = rs.getString("rprice");
66
txtpname.setText(pname.trim());
txtprice.setText(price.trim());
txtqty.requestFocus();
}
try {
String pcode =txtpcode.getText();
while(rs.next())
{
int currentqty;
currentqty = rs.getInt("qty");
else
{
df = (DefaultTableModel)jTable1.getModel();
df.addRow(new Object[]
{
txtpcode.getText(),
txtpname.getText(),
67
txtprice.getText(),
txtqty.getText(),
tot
});
int sum = 0;
for(int i=0;i<jTable1.getRowCount();i++)
{
sum=sum+Integer.parseInt(jTable1.getValueAt(i,4).toString());
}
txttcost.setText(String.valueOf(sum));
txtpcode.setText("");
txtpname.setText("");
txtprice.setText("");
txtqty.setText("");
} catch (SQLException ex) {
Logger.getLogger(Sales.class.getName()).log(Level.SEVERE, null, ex);
}
}
68
pst.setString(2, subtotal);
pst.setString(3, pay);
pst.setString(4, bal);
pst.executeUpdate();
rs=pst.getGeneratedKeys();
if(rs.next())
{
lastid = rs.getInt(1);
}
String productid;
String price;
String qty;
int total = 0;
pst1.setInt(1,lastid);
pst1.setString(2,productid);
pst1.setString(3,price);
pst1.setString(4,qty);
pst1.setInt(5,total);
pst1.executeUpdate();
pst2.setString(1,qty);
69
pst2.setString(2,productid);
pst2.executeUpdate();
}
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
getContentPane().setLayout(null);
70
jLabel1.setBounds(80, 10, 150, 40);
jPanel1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Product Code", "Product Name", "Price", "Qty", "Total"
}
));
71
jScrollPane1.setViewportView(jTable1);
72
jButton2.setText("Add");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
73
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addComponent(jLabel7)
.addGap(107, 107, 107))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addComponent(txtqty, javax.swing.GroupLayout.PREFERRED_SIZE, 112,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(40, 40, 40)))
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 88,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(138, 138, 138))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 576,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 126,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(46, 46, 46)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 110,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(70, 70, 70)
.addComponent(jLabel8))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(52, 52, 52)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtpay, javax.swing.GroupLayout.PREFERRED_SIZE, 116,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txttcost, javax.swing.GroupLayout.PREFERRED_SIZE, 116,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtbal, javax.swing.GroupLayout.PREFERRED_SIZE, 116,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel9)
.addComponent(jLabel10))))))
.addGap(20, 20, 20))))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
74
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(23, 23, 23)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jLabel4)
.addComponent(jLabel5)
.addComponent(jLabel7))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtpcode, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtpname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtprice, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtqty, 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,
jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 33,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(26, 26, 26)))
.addComponent(jLabel8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(txttcost, javax.swing.GroupLayout.PREFERRED_SIZE, 27,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel9)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtpay, javax.swing.GroupLayout.PREFERRED_SIZE, 27,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel10)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtbal, javax.swing.GroupLayout.PREFERRED_SIZE, 27,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 67,
Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton3)
75
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(44, 44, 44))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 182,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
);
getContentPane().add(jPanel1);
jPanel1.setBounds(80, 70, 834, 420);
jLabel3.setIcon(new
javax.swing.ImageIcon("C:\\Users\\Guide\\Documents\\NetBeansProjects\\stockmanagement\\src\\icon\\sales
screen.png")); // NOI18N
getContentPane().add(jLabel3);
jLabel3.setBounds(-50, -150, 1010, 850);
if(evt.getKeyCode() == KeyEvent.VK_ENTER)
{
barcode();
}
}//GEN-LAST:event_txtpcodeKeyPressed
76
// TODO add your handling code here:
}//GEN-LAST:event_txtqtyActionPerformed
txtbal.setText(String.valueOf(bal));
add();
}//GEN-LAST:event_jButton2ActionPerformed
77
java.util.logging.Logger.getLogger(Sales.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Sales.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Sales.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Sales().setVisible(true); } }); }
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
private javax.swing.JTextField txtbal;
private javax.swing.JTextField txtpay;
private javax.swing.JTextField txtpcode;
private javax.swing.JTextField txtpname;
private javax.swing.JTextField txtprice;
private javax.swing.JTextField txtqty;
private javax.swing.JTextField txttcost;
}
78
Output Screens
Outputs of all modules are given below sequencially :-
1.Login
2.Main
79
3.Vendor
4.Purchase
80
5.Product
6.Sales
81
CHAPTER.5 CONCLUSION
To conclude,
1. Stock Management System is a simple desktop based application basically suitable for small
organization.
2. It has every basic items which are used for the small organization.
3. Here, we can update, insert and delete the item as per the requirement.
4. Through it has some limitations, we strongly believes that the implementation of this system will
surely benefit the organization.
82
Bibliography
Following books and eBook are used to complete this project reports.
I. Mastering JAVA Neat Beans
a. Author Tata McGraw-Hill’s
b. Publisher Black Book Publication
II. Oracle The Complete Reference
a. Author Robert Koch
b. Publication Tata McGraw-Hill
III. SQL, PL/SQL The Programming Language of Oracle
a. Author Ivan Bayross
b. Publication BPB Publication
IV. Software Engineering Apractitioner’s Approach
a. Author Roger S. Pressman
b. Publication Tata McGraw-Hill
V. Fundamentals of Software Engineering
a. Author Carlo Ghezzi, Mehdi Jazayeri, DinoMandrioli
b. Publisher Prentice Hall of India
83