OOAD - Stock Maintenance Sytem
OOAD - Stock Maintenance Sytem
OOAD - Stock Maintenance Sytem
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:
SEQUENCE DIAGRAM:
ACTIVITY DIAGRAM:
COMPONENT DIAGRAM:
PACKAGE DIAGRAM
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.