AJP
AJP
We have created an system using java. In Which the food beverages are added ,
deleted , updated, Refresh And sell. We are using product id for saving different id for
different product . And Flavour is used for saving different product name like mango, Apple.
& cost per unit is used for number of product items, & Units in stock is used for it will be
displayed how many number of product are there. The Refresh button is used for whenever
we deleted, updated or added any info then we click on refresh button its saves all changes.
The add button is used for added all information about product id, Delete button is used for
deleted a particular record. The update button is used for we updated a particular stock its
updated all info automatically
1|P age
INTRODUCTION
We have created an system using java. In Which the food beverages are added ,
deleted , updated, Refresh And sell. We are using product id for saving different id for
different product . And Flavour is used for saving different product name like mango, Apple.
& cost per unit is used for number of product items, & Units in stock is used for it will be
displayed how many number of product are there. The Refresh button is used for whenever
we deleted, updated or added any info then we click on refresh button its saves all changes.
The add button is used for added all information about product id, Delete button is used for
deleted a particular record. The update button is used for we updated a particular stock its
updated all info automatically. And sell button is used for sell the product. Show all button is
used for show all info about added records, deleted records, updated records, selled records
successfully. Its improve customer services and resolve the problem quickly
2|P age
SYSTEM REQUIREMENTS
Hardware Requirement :-
Software Requirement :-
3|P age
CODE
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JFrame;
import javax.swing.*;
Frame f1,f2;
JFrame frame,frame2;
Choice c1;
TextField t1,t2,t3,t4,t5,t6,t7,t8;
Dialog d1;
//ResultSet rs;
Label l1,l2,l3,l4,l5,l6,l7,l8;
JLabel l9;
BeverageInventoryManagement()
4|P age
l9.setBounds(100,50,200,100);
d1.setLayout(null);
b.setBounds(150,200,20,20);
d1.setVisible(false);
});
d1.add(l9);
d1.add(b);
d1.setBounds(600,300,350,300);
frame.setTitle("Current Stock");
frame.setSize(500, 300);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame2.setTitle("Sales Log");
frame2.setSize(500, 300);
frame2.setLocationRelativeTo(null);
frame2.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f1=new Frame("");
5|P age
f1.setLayout(null);
f1.setBounds(50,50,800,800);
f1.setBackground(clr1);
c1=new Choice();
c1.add("Select Genre");
c1.setBounds(50,100,150,50);
c1.addItemListener(this);
b1=new Button("Refresh");
b1.setBounds(50,500,150,50);
b2=new Button("Delete");
b2.setBounds(250,500,150,50);
b3=new Button("Add");
b3.setBounds(450,500,150,50);
b7=new Button("Update");
b7.setBounds(50,600,150,50);
b8 = new Button("Sell");
b8.setBounds(250,600,150,50);
b9 = new Button("Exit");
b9.setBounds(250,700,150,50);
b10.setBounds(450,600,150,50);
b11.setBounds(50,700,150,50);
6|P age
b12.setBounds(450,700,150,50);
t1.setBounds(400,100,100,30);
t1.setBackground(clr2);
t2.setBounds(400,200,100,30);
t2.setBackground(clr2);
t3.setBounds(400,300,100,30);
t3.setBackground(clr2);
t7=new TextField();
t7.setBounds(400,400,100,30);
t7.setBackground(clr2);
l5.setBounds(250,100,150,50);
l6=new Label("Flavour");
l6.setBounds(250,200,150,50);
l7.setBounds(250,300,150,50);
l8.setBounds(250,400,150,50);
f2.setLayout(null);
f2.setBounds(50,50,700,600);
7|P age
l1=new Label("Enter Id");
l1.setBounds(50,50,100,50);
l2.setBounds(50,150,100,50);
l3.setBounds(50,250,100,50);
l4.setBounds(50,350,100,50);
t4=new TextField();
t4.setBounds(200,50,100,50);
t5=new TextField();
t5.setBounds(200,150,100,50);
t6=new TextField();
t6.setBounds(200,250,100,50);
t8=new TextField();
t8.setBounds(200,350,100,50);
b4=new Button("Save");
b4.setBounds(50,500,100,50);
b5=new Button("Exit");
b5.setBounds(200,500,100,50);
b6=new Button("Clear");
b6.setBounds(350,500,100,50);
b1.addActionListener(this);
b2.addActionListener(this);
8|P age
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
b7.addActionListener(this);
b8.addActionListener(this);
b9.addActionListener(this);
b10.addActionListener(this);
b11.addActionListener(this);
b12.addActionListener(this);
f1.add(t1);
f1.add(t2);
f1.add(t3);
f1.add(t7);
f1.add(c1);
f1.add(b1);
f1.add(b2);
f1.add(b3);
f1.add(b7);
f1.add(b8);
f1.add(b9);
f1.add(b10);
f1.add(b11);
f1.add(b12);
9|P age
f1.add(l5);
f1.add(l6);
f1.add(l7);
f1.add(l8);
f2.add(t4);
f2.add(t5);
f2.add(t6);
f2.add(t8);
f2.add(l1);
f2.add(l2);
f2.add(l3);
f2.add(l4);
f2.add(b4);
f2.add(b5);
f2.add(b6);
f1.setVisible(true);
Load();
try
if (ae.getSource()==b1)
Load();
10 | P a g e
else if(ae.getSource()==b2)
mydelete();
10
else if(ae.getSource()==b3)
add();
else if(ae.getSource()==b7)
updateValue();
else if(ae.getSource()==b8)
sellprocedure();
else if(ae.getSource()==b4)
modify();
else if(ae.getSource()==b10)
frame.setVisible(true);
11 | P a g e
else if(ae.getSource()==b11)
frame2.setVisible(true);
else if(ae.getSource()==b12)
d1.setVisible(true);
else if(ae.getSource()==b9)
f1.dispose();
else if(ae.getSource()==b5)
f2.dispose();
else if(ae.getSource()==b6)
t4.setText("");
t5.setText("");
t6.setText("");
catch (Exception e)
12 | P a g e
System.out.print(""+e);
int no1;
no1=Integer.parseInt(c1.getSelectedItem());
try
Class.forName("com.mysql.cj.jdbc.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","","");
Statement st=con.createStatement();
ResultSet rs;
String str;
rs=st.executeQuery(str);
rs.next();
t1.setText(rs.getInt(1)+"");
t2.setText(rs.getString(2));
t3.setText(rs.getInt(3)+"");
t7.setText(rs.getInt(4)+"");
rs.close();
con.close();
13 | P a g e
catch (Exception e)
System.out.print(""+e);
void Load()
try
c1.removeAll();
c1.add("Select Id");
Class.forName("com.mysql.cj.jdbc.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","");
Statement st=con.createStatement();
ResultSet rs;
String str;
rs=st.executeQuery(str);
while(rs.next())
c1.add(+rs.getInt(1)+"");
13
rs.close();
14 | P a g e
con.close();
catch (Exception e)
System.out.print(""+e);
void mydelete()
int no1;
no1=Integer.parseInt(c1.getSelectedItem());
try
Class.forName("com.mysql.cj.jdbc.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","");
Statement st=con.createStatement();
ResultSet rs;
String str;
st.executeUpdate(str);
rs=st.executeQuery(str);
rs.close();
con.close();
15 | P a g e
catch(Exception e)
System.out.print(""+e);
void updateValue()
String name;
int cost,id;
try{
id=Integer.parseInt(t1.getText());
name=t2.getText();
cost=Integer.parseInt(t3.getText());
Class.forName("com.mysql.cj.jdbc.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","");
Statement st=con.createStatement();
ResultSet rs;
String str;
st.executeUpdate(str);
catch (Exception e)
System.out.println("\n\t"+e);
16 | P a g e
}
void sellprocedure()
try{
Class.forName("com.mysql.cj.jdbc.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","");
st.execute();
catch (Exception e)
System.out.println("\n\t"+e);
void add()
f2.setVisible(true);
void modify()
int id,cost,units;
String name;
try
17 | P a g e
{
id=Integer.parseInt(t4.getText());
name=t5.getText();
cost=Integer.parseInt(t6.getText());
units=Integer.parseInt(t8.getText());
Class.forName("com.mysql.cj.jdbc.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","");
Statement st=con.createStatement();
ResultSet rs;
String str;
st.executeUpdate(str);
rs=st.executeQuery(str);
/*while(rs.next())
}*/
rs.close();
con.close();
Load();
18 | P a g e
catch (Exception e)
System.out.println("\n\t"+e);
new BeverageInventoryManagement();
import javax.swing.*;
import java.awt.*;
import javax.swing.table.DefaultTableModel;
import java.sql.*;
public CurrentStock() {
cnt.setLayout(new FlowLayout(FlowLayout.LEFT));
model.addColumn("Id");
model.addColumn("Name");
model.addColumn("Cost");
model.addColumn("Units");
try {
19 | P a g e
Class.forName("com.mysql.cj.jdbc.Driver");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","");
ResultSet Rs = pstm.executeQuery();
while(Rs.next()){
model.addRow(new Object[]{Rs.getInt(1),
Rs.getString(2),Rs.getInt(3),Rs.getInt(4)});
} catch (Exception e) {
System.out.println(e.getMessage());
cnt.add(pg);
this.pack();
20 | P a g e
Output
21 | P a g e
Conclusion
We have created an Beverage Inventory Management system using java. In Which the food
beverages are added , deleted , updated, Refresh And sell. We are using product id for saving different
id for different product . And Flavour is used for saving different product name like mango, Apple. &
cost per unit is used for number of product items, & Units in stock is used for it will be displayed how
many number of product are there. The Refresh button is used for whenever we deleted, updated or
added any info then we click on refresh button its saves all changes. The add button is used for added
all information about product id, Delete button is used for deleted a particular record. The update
button is used for we updated a particular stock its updated all info automatically. And sell button is
used for sell the product. Show all button is used for show all info about added records, deleted
records, updated records, selled records successfully. Its improve customer services and resolve the
problem quickly
22 | P a g e
References
)1) www.javatpoint.com
2) www.google.com
3) www.edureka.com
4) www.udemy.com
23 | P a g e