OOAD - Stock Maintenance Sytem

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 21

Ex No: Stock Maintenance System

Date:
Aim:
To develop a Stock Maintenance System using ArgoUML Software and to implement
the software in Java.

Problem Statement:
A stock maintenance system is a software application that enables businesses to manage
their inventory efficiently. The current manual system is time-consuming and prone to errors,
resulting in inaccurate inventory counts and inefficient management of stocks. Therefore, there is
a need for a computerized system that can automate the inventory management process and
provide real-time data on stock levels, reducing the risk of stockouts and overstocks.

Scope:
The scope of the stock maintenance system includes the following functionalities:
● Adding new products to the inventory database
● Updating the stock levels when products are received or sold
● Generating reports on stock levels, sales, and purchase orders
● Alerting the management when stock levels fall below a predefined threshold
● Providing real-time data on stock levels and the availability of products to the sales team

Feasibility Study:
The feasibility study of the stock maintenance system considers the technical,
operational, and economic aspects of implementing the system.
Technical Feasibility:
The stock maintenance system requires the following hardware and software components:
A computer with a minimum of 4 GB RAM and a processor speed of 2.5 GHz
A database management system to store inventory data
An application server to run the inventory management software
An internet connection to enable real-time updates
Operational Feasibility:
The stock maintenance system is feasible from an operational perspective as it will
streamline inventory management and reduce the time and effort required for manual stock
tracking.

Economic Feasibility:
The stock maintenance system is economically feasible as it will result in cost savings
due to efficient inventory management, reduced stockouts, and improved sales performance. The
initial investment required for the system's development and implementation can be recovered
within a short period through these cost savings.
UML DIAGRAMS:

Sno UML DIAGRAMS


1 Use Case diagram
2 Class diagram
3 Sequence diagram
4 Collaboration
diagram
5 State Chart diagram
6 Activity diagram
7 Component diagram
8 Deployment diagram
9 Package diagram

USE CASE DIAGRAM:

Documentation of use case diagram:


The use case diagram provides a visual representation of the system's functionality
and its interaction with different actors. It helps in understanding the system's features and how
different actors interact with the system to perform their tasks. The use case diagram also helps
in identifying the system's requirements and how they relate to the actors and their tasks.
The admin represents the user who manages the system's settings, user accounts, and access
permissions. The database can store the product details, purchase details and sales details. The
vendor can add a new product to the system, update the product details. The customer can view
the product details, place an order for a product and check the status of their order.
CLASS DIAGRAM:

Documentation of class diagram:


The class diagram provides a visual representation of the system's classes, their
attributes, and their methods. It helps in understanding the system's data structure and the
functionality of each class. The Product Details class has methods for adding new products,
updating existing products, and deleting products. Purchase Details class has methods for adding
new purchase orders, updating existing purchase orders, and deleting purchase orders. Sales
Details class has methods for adding new sales orders, updating existing sales orders, and
deleting sales orders. Stock Details class has methods for updating the stock quantity when new
products are received, updating the stock quantity when products are sold, and generating alerts
when stock levels fall below the threshold.

SEQUENCE DIAGRAM:

Documentation of sequence diagram:


The sequence diagram provides a visual representation of the system's behavior and
how the different objects interact with each other to perform their tasks. It helps in understanding
the system's flow and how the objects communicate with each other to complete the tasks. The
sequence diagram also helps in identifying the system's performance issues and how they can be
resolved by optimizing the system's flow and communication between the objects.
COLLABORATION DIAGRAM
Documentation of collaboration diagram:
The collaboration diagram provides a visual representation of the objects in the
system and their interactions. It helps in understanding how the objects work together to achieve
the system's functionality. The customer object represents the customer who interacts with the
system to purchase products. The database object represents the database that stores the product
details, purchase details, sales details, and stock details. The vendor object represents the vendor
who supplies products to the system.

ACTIVITY DIAGRAM:

Documentation of activity diagram:


The activity diagram is a visual representation of the system's workflow, depicting the
activities and actions that occur within the system. The user enters their login credentials to
access the system. Once the user logs in, they can view the product details such as product name,
product description, and product quantity available. The user can add new products to the system
by providing the product details such as product name, product description, product category,
unit price, and quantity available. When the product quantity falls below the threshold, the
system generates a purchase order to the vendor to restock the product. The user can view the
sales details such as sales ID, customer ID, product ID, sales date, sales quantity, and sales
amount. The system updates the stock quantity when a product is sold.

STATE CHART DIAGRAM:

Documentation of state chart diagram:


A state chart diagram for the stock maintenance system can represent the states and
transitions of the system in a graphical format. The state chart diagram helps to understand the
different states of the objects in the system and the transitions between them. It provides a clear
view of the system's behavior and how it responds to different events. The state chart diagram
also helps in identifying the system's performance issues and how they can be resolved by
optimizing the system's flow and communication between the objects.

COMPONENT DIAGRAM:

Documentation of component diagram:


The Stock Maintenance System component represents the inventory management
software that is responsible for managing the inventory data and providing real-time updates to
the sales team, vendors, and admin. Customer component represents the customers of the
business. Database Details component represents the database management system that stores the
inventory data, customer data, and vendor data. Vendor component represents the vendors who
supply products to the business. Admin component represents the administrator of the system
who has the authority to manage user accounts, update product information, and generate reports.
DEPLOYMENT DIAGRAM
Documentation of deployment diagram:
The deployment diagram provides a visual representation of the system's hardware
and software components and their relationships. The stock maintenance system component
represents the system's software that runs on a physical server or a virtual machine. The customer
represents the hardware device that the customer uses to access the system. The database server
represents the physical server or virtual machine that hosts the database that stores the product
details, purchase details, sales details, and stock details.
The admin represents the hardware device that the admin uses to access the system.

PACKAGE DIAGRAM

Documentation of package diagram:


The package diagram provides a visual representation of the system's architecture
and its organization into packages. The UI layer package represents the user interface of the
system that interacts with the user. The Domain layer package represents the system's business
logic and domain objects. The Database package represents the database layer of the system.

Program:
main.java:
package stock;
public class main extends javax.swing.JFrame {
public main() {
initComponents();
} private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
vendor v = new vendor();
v.setVisible(true);
}private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
product p = new product();
p.setVisible(true);
} private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
purchase p = new purchase();
p.setVisible(true);
} private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
Sales p = new Sales();
p.setVisible(true); }
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break; } }
} java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new main().setVisible(true);
} }); }}

product.java:
package stock;
public class product extends javax.swing.JFrame {
public product() {
initComponents();
Connect();
load();
} Connection con;
PreparedStatement pst;
DefaultTableModel df;
public void Connect() {
try {
Class.forName("org.apache.derby.jdbc.ClientDriver");
con = DriverManager.getConnection("jdbc:derby://localhost:1527/stockmanagement;");
} }
public void load() {
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"));
v2.add(rs.getString("rlevel"));
} df.addRow(v2); } }
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try {
String pname = txtpname.getText();
String des = txtdes.getText();
String barcode = txtbarcode.getText();
String costprice = txtcprice.getText();
String retailprice = txtrprice.getText();
String qty = txtqty.getText();
String rlevel = txtlevel.getText();
pst = con.prepareStatement("insert into
product(pname,description,barcode,cprice,rprice,qty,rlevel)values(?,?,?,?,?,?,?)");
pst.setString(1, pname);
pst.setString(2, des);
pst.setString(3, barcode);
pst.setString(4, costprice);
pst.setString(5, retailprice);
pst.setString(6, qty);
pst.setString(7, rlevel);
pst.executeUpdate();
JOptionPane.showMessageDialog(this, "Product Addeddddd");
txtpname.setText("");
txtdes.setText("");
txtbarcode.setText("");
txtcprice.setText("");
txtrprice.setText("");
txtqty.setText("");
txtlevel.setText("");
txtpname.requestFocus();
} } private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false); }
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break; } }
} java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new product().setVisible(true);
} }); }}

purchase.java:
package stock;
public class purchase extends javax.swing.JFrame {
public purchase() {
initComponents();
Connect();
Vendor();
}
Connection con;
PreparedStatement pst;
PreparedStatement pst1;
PreparedStatement pst2;
DefaultTableModel df;
ResultSet rs;
public void Connect() {
try {
Class.forName("org.apache.derby.jdbc.ClientDriver");
con = DriverManager.getConnection("jdbc:derby://localhost:1527/stockmanagement;");}}
public void Vendor() {
try {
pst = con.prepareStatement("select Distinct name from vendor");
rs = pst.executeQuery();
txtvendor.removeAllItems();
while(rs.next()) {
txtvendor.addItem(rs.getString("name")); } } }
public void barcode() {
try {
String pcode = txtpcode.getText();
pst = con.prepareStatement("select * from product where barcode = ?");
pst.setString(1, pcode);
rs = pst.executeQuery();
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(); } } }
public void purchase() {
int price = Integer.parseInt(txtprice.getText());
int qty = Integer.parseInt(txtqty.getText());
int tot = price * qty;
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());
} txttcost.setText(String.valueOf(sum));
txtpcode.setText("");
txtpname.setText("");
txtprice.setText("");
txtqty.setText(""); }
public void add() {
try {
DateTimeFormatter dt = DateTimeFormatter.ofPattern("yyyy/MM/dd");
LocalDateTime now = LocalDateTime.now();
String date = dt.format(now);
String vendor = txtvendor.getSelectedItem().toString();
String subtotal = txttcost.getText();
String pay = txtpay.getText();
String bal = txtbal.getText();
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); }
String query2 = "insert into purchaseitem(purid,pid,rprice,qty,total)values(?,?,?,?,?) ";
pst1 = con.prepareStatement(query2);
String productid;
String price;
String qty;
int total = 0;
for(int i=0; i<jTable1.getRowCount(); i++) {
productid = (String)jTable1.getValueAt(i, 0);
price = (String)jTable1.getValueAt(i, 2);
qty = (String)jTable1.getValueAt(i, 3);
total = (int)jTable1.getValueAt(i, 4);
pst1.setInt(1, lastid);
pst1.setString(2, productid);
pst1.setString(3, price);
pst1.setString(4, qty);
pst1.setInt(5, total);
pst1.executeUpdate();
} String query3 = "update product set qty = qty+ ? where barcode = ?";
pst2 = con.prepareStatement(query3);
for(int i=0; i<jTable1.getRowCount(); i++) {
productid = (String)jTable1.getValueAt(i, 0);
qty = (String)jTable1.getValueAt(i, 3);
pst2.setString(1, qty);
pst2.setString(2, productid);
pst2.executeUpdate();
}JOptionPane.showMessageDialog(this, "Purchase Completedddddd!!!!!!!!!!!!!!!!!!!!");
} } private void txtpcodeKeyPressed(java.awt.event.KeyEvent evt) {
if(evt.getKeyCode() == KeyEvent.VK_ENTER) {
barcode();
} } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
purchase();
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
int pay = Integer.parseInt(txtpay.getText());
int subtotal = Integer.parseInt(txttcost.getText());
int bal = subtotal - pay;
txtbal.setText(String.valueOf(bal));
add();
}
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
} } } java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new purchase().setVisible(true);
} });
}}

sales.java:
package stock;
public class Sales extends javax.swing.JFrame {
public Sales() {
initComponents();
Connect();
} Connection con;
PreparedStatement pst;
PreparedStatement pst1;
PreparedStatement pst2;
DefaultTableModel df;
ResultSet rs;
public void Connect() {
try {
Class.forName("org.apache.derby.jdbc.ClientDriver");
con = DriverManager.getConnection("jdbc:derby://localhost:1527/stockmanagement;"); } }
public void barcode() {
try {
String pcode = txtpcode.getText();
pst = con.prepareStatement("select * from product where barcode = ?");
pst.setString(1, pcode);
rs = pst.executeQuery();
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(); } } }
public void Sales() {
try {
String pcode = txtpcode.getText();
pst = con.prepareStatement("select * from product where barcode = ?");
pst.setString(1, pcode);
rs = pst.executeQuery();
while(rs.next()) {
int currentqty;
currentqty = rs.getInt("qty");
int price = Integer.parseInt(txtprice.getText());
int qty = Integer.parseInt(txtqty.getText());
int tot = price * qty;
if(qty >= currentqty) {
JOptionPane.showMessageDialog(this, "Qty Not Enough!!!!!!!!!!");
} else {
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()); }
txttcost.setText(String.valueOf(sum));
txtpcode.setText("");
txtpname.setText("");
txtprice.setText("");
txtqty.setText(""); } }
public void add() {
try {
DateTimeFormatter dt = DateTimeFormatter.ofPattern("yyyy/MM/dd");
LocalDateTime now = LocalDateTime.now();
String date = dt.format(now);
String subtotal = txttcost.getText();
String pay = txtpay.getText();
String bal = txtbal.getText();
int lastid = 0;
String query1 = "insert into sales(date,subtotal,pay,bal)values(?,?,?,?)" ;
pst = con.prepareStatement(query1,Statement.RETURN_GENERATED_KEYS);
pst.setString(1, date);
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 query2 = "insert into sales_product(sales_id,pid,price,qty,total)values(?,?,?,?,?) ";
pst1 = con.prepareStatement(query2);
String productid;
String price;
String qty;
int total = 0;
for(int i=0; i<jTable1.getRowCount(); i++) {
productid = (String)jTable1.getValueAt(i, 0);
price = (String)jTable1.getValueAt(i, 2);
qty = (String)jTable1.getValueAt(i, 3);
total = (int)jTable1.getValueAt(i, 4);
pst1.setInt(1, lastid);
pst1.setString(2, productid);
pst1.setString(3, price);
pst1.setString(4, qty);
pst1.setInt(5, total);
pst1.executeUpdate(); }
String query3 = "update product set qty = qty- ? where barcode = ?";
pst2 = con.prepareStatement(query3);
for(int i=0; i<jTable1.getRowCount(); i++) {
productid = (String)jTable1.getValueAt(i, 0);
qty = (String)jTable1.getValueAt(i, 3);
pst2.setString(1, qty);
pst2.setString(2, productid);
pst2.executeUpdate(); }
JOptionPane.showMessageDialog(this, "Sales Completedddddd!!!!!!!!!!!!!!!!!!!!");
HashMap p = new HashMap();
p.put("invo", lastid);
try {
JasperDesign jdesign = JRXmlLoader.load("C:\\Users\\Documents\\NetBeansProjects \\
stockmanagement\\src\\stock\\report1.jrxml");
JasperReport jreport = JasperCompileManager.compileReport(jdesign);
JasperPrint jprint = JasperFillManager.fillReport(jreport, p,con);
JasperViewer.viewReport(jprint); } }
private void txtpcodeKeyPressed(java.awt.event.KeyEvent evt) {
if(evt.getKeyCode() == KeyEvent.VK_ENTER) {
barcode();
} } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Sales();
} private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
int pay = Integer.parseInt(txtpay.getText());
int subtotal = Integer.parseInt(txttcost.getText());
int bal = pay - subtotal;
txtbal.setText(String.valueOf(bal));
add(); }
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
} } } java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Sales().setVisible(true);
} }); }}

vendor.java:
package stock;
public class vendor extends javax.swing.JFrame {
public vendor() {
initComponents();
Connect();
load();
} Connection con;
PreparedStatement pst;
DefaultTableModel df;
public void Connect() {
try {
Class.forName("org.apache.derby.jdbc.ClientDriver");
con = DriverManager.getConnection("jdbc:derby://localhost:1527/stockmanagement;");} }
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); }
} } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try {
String vname = txtvendor.getText();
String phone = txtphone.getText();
String email = txtemail.getText();
String address = txtaddress.getText();
pst = con.prepareStatement("insert into
vendor(name,phone,email,address)values(?,?,?,?)");
pst.setString(1, vname);
pst.setString(2, phone);
pst.setString(3, email);
pst.setString(4, address);
pst.executeUpdate();
JOptionPane.showMessageDialog(this, "Vendor Addeddddd");
txtvendor.setText("");
txtphone.setText("");
txtemail.setText("");
txtaddress.setText("");
txtvendor.requestFocus();
load();
} } private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {
df = (DefaultTableModel)jTable1.getModel();
int selected = jTable1.getSelectedRow();
int id = Integer.parseInt(df.getValueAt(selected, 0).toString());
txtvendor.setText(df.getValueAt(selected, 1).toString());
txtphone.setText(df.getValueAt(selected,2).toString());
txtemail.setText(df.getValueAt(selected, 3).toString());
txtaddress.setText(df.getValueAt(selected, 4).toString());
jButton1.setEnabled(false);
} private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
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 Updated");
txtvendor.setText("");
txtphone.setText("");
txtemail.setText("");
txtaddress.setText("");
txtvendor.requestFocus();
load();
jButton1.setEnabled(true);
} } private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
df = (DefaultTableModel)jTable1.getModel();
int selected = jTable1.getSelectedRow();
int id = Integer.parseInt(df.getValueAt(selected, 0).toString());
try {
pst = con.prepareStatement("delete from vendor where id = ?");
pst.setInt(1, id);
pst.executeUpdate();
JOptionPane.showMessageDialog(this, "Vendor Deleteedddd");
txtvendor.setText("");
txtphone.setText("");
txtemail.setText("");
txtaddress.setText("");
txtvendor.requestFocus();
load();
jButton1.setEnabled(true);
} } private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
txtvendor.setText("");
txtphone.setText("");
txtemail.setText("");
txtaddress.setText("");
txtvendor.requestFocus();
load();
jButton1.setEnabled(true); }
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false); }
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break; } } }
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new vendor().setVisible(true);
} }); }}

Output:
Main page:

Vendor page:
Product page:

Purchase page:

Sales page:
Result:
Thus a Stock Maintenance System is developed using ArgoUML Software and the
software is implemented in Java.

You might also like