Professional Documents
Culture Documents
MANAGEMENT
This system is designed for the ease of shopkeeper and owner of the shop. So, we designed a very easy interface
which can user learn that what the buttons will perform when they are clicked. This interface can be used by
both the illiterate to computing and expert user.
Modules
LOGIN
MAINE
STOCK
SALE
DATABASE CONNECTION
SPLASH SCREEN
This is the first module to be
loaded and run. The purpose of
the module is to check the
connection with the database and
to use as an advertisement.
Snippet Code
for(int i=0;i<=100;i++)
{
try {
Thread.sleep(50);
} catch (InterruptedException ex) {
Logger.getLogger(splash.class.getName()).log(Level.SEVERE, null, ex);
}
Splash.loadingnum.setText(Integer.toString(i)+"%");
Splash.loadingbar.setValue(i);
switch(i){
case 10:
Splash.process.setText("loading dll...");
break;
case 20:
Splash.process.setText("connecting database...");
break;
case 30:
Splash.process.setText("Finalizing...");
break;
case 80:
Splash.process.setText("Opening Main Page...");
break;
}
if(i==100)
{
Login lg=new Login();
Splash.setVisible(false);
lg.setVisible(true);
}
}
LOGIN
This module is opened if the database connection is established else it will not be loaded. This
module is the access control to the
system. Basically, there are 2 types of
users in this system.
while (rs.next()) {
int id = rs.getInt(1);
Emp.empId = id;
String user1 = rs.getString(2);
Usern.username = user1;
count = count + 1;
}
String access = (txt_combo.getSelectedItem().toString());
if (access == "Admin") {
if (count == 1) {
JOptionPane.showMessageDialog(null, "Success");
MainForm j = new MainForm();
j.setVisible(true);
j.info_name.setText("Welcome Admin " + (Usern.username));
// j.user_info.setText("Welcome " + (Usern.username));
this.dispose();
Log_txt.setText("");
Log_Pass.setText("");
}
} else if (access == "Sales") {
if (count == 1) {
JOptionPane.showMessageDialog(null, "Sucess");
this.dispose();
} else if (count > 1) {
JOptionPane.showMessageDialog(null, "Duplicate Username or Password Access
denied");
} else {
JOptionPane.showMessageDialog(null, "Username and Password is not correct");
}
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Connection Lost");
this.dispose();
} finally {
try {
rs.close();
pst.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Connection Lost");
}
}
}
MAIN INTERFACE
This is the main interface module where all the other modules reside. This is a mdi form which act
as a container for the jinternal forms for stock, sale and settings.
STOCK MODULE
This form is used to enter items and search through the item and can be edited.
Snippet Code:
public ArrayList<Item> findItem(String ValToSearch)
{
ArrayList<Item> Itemlist=new ArrayList<Item>();
Statement st;
ResultSet rs;
try {
conn=Connect.connectDB();
st=conn.createStatement();
String searchQuery = "SELECT * FROM `item_details` WHERE CONCAT(`it_ID`,
`itName`) LIKE '%"+ValToSearch+"%'";
rs=st.executeQuery(searchQuery);
Item item;
while(rs.next())
{
item=new Item(
rs.getInt("it_ID"),
rs.getString("itName"),
rs.getString("descrip"),
rs.getInt("qty"),
rs.getString("exp_Date"),
Float.parseFloat(rs.getString("cost")),
Float.parseFloat(rs.getString("price")));
Itemlist.add(item);
}
} catch (SQLException ex) {
Logger.getLogger(Item_Recieve.class.getName()).log(Level.SEVERE, null, ex);
}
return Itemlist;
}
public void findItem()
{
ArrayList<Item> Items=findItem(txt_search.getText());
for(int i=0;i<Items.size();i++)
{
row[0]=Items.get(i).getID();
row[1]=Items.get(i).getName();
row[2]=Items.get(i).getDes();
row[3]=Items.get(i).getQty();
row[4]=Items.get(i).getExp();
row[5]=Items.get(i).getCost();
row[6]=Items.get(i).getPrice();
model.addRow(row);
}
Item_table1.setModel(model);
}
public void price()
{
float a=Float.parseFloat(txt_cost.getText());
int b=Integer.parseInt(txt_qty.getText());
txt_total.setText(String.valueOf(a*b));
SALES MODULE
This module will sell item(s) and balance can be calculated depending on the amount given by the
customer. Once Cash button is pressed the item id, and price will be saved in a Sales table in MySql
server.
Snippet Code:
int rowsc=tbl_sales.getRowCount();
try{
conn=Connect.connectDB();
}
}
CONNECTION MODULE
This module connects to MySql database in WAMP server. We have used jdbc to connect.
Code:
import java.sql.*;
Conclusion:
This program in java can be further refined using validation module and fixing some of the bugs,
making it more user friendly and adding other modules for accounting and report generation.