JAVA Inventory System Source Code

Inventory Management System Source Code Using JAVA NetBeans And MySQL Database

Java inventory management system project

in this java project demo we will see how to use our java netbeans inventory management system with a mysql database.

goals of this project:
- give students / curious persons an example so they can learn from it.
helping people create their first project. 
sharing knowledge with others.

this project is not for:
- people who want to use it as their final year project.
- a real life store.

tools:
- java programming language.
- netbeans ide 8.2.
- mysql database.
- canva.com for images.
- flatuicolorpicker.com for colors.
- text file to generate order.

Watch This Full Demo



1 - Login Form

the login form allow the ADMIN and the other USERS to login into the application Home Form

java inventory system - login form

if the user enter wrong username or password a message will show up

java inventory system - login form error

and if everything is ok, when you click on the login button the main/home form will show up and the login form will close it self.


2 - Home Form

if the user type is ADMIN a "user" tab will be visible on the top menu

java inventory system - admin home form


if the user type is USER the "user" tab will be invisible

java inventory system - user home form


3 - Product Section


when you click on the Product tab, the MANAGE_PRODUCTS_FORM will show up



java inventory system - manage products



- on the form load all products will be displayed into a jtable.

- when you enter a value in the search box and click search button, only the products that contain this value will be shown in the jtable.



java inventory system - search products



if you click on the "Add New Product" button the Add_Product_Form will show up, this form allow you to enter the new product data and insert it into mysql database.


java inventory system - add new product

on the top form you can see a combobox categories, this combobox is populated from category table in the mysql database with the category name and id using HashMap.

and if you want to update a product just select the product you want to edit from the jtable and click on the "Edit Selected Product" and the Edit_Product_Form will show up with all the selected product data displayed on the form. 

java inventory system - edit selected product

when you want to delete a product just select the product you want to remove and click on the "Remove Selected Product" button.


NOTE: when you Edit or Remove a product click on the "Refresh" button to see the new results in the jtable.


4 - Category Section


now if you want to manage the categories you have to go to the category tab.
- when you click on the category tab the MANAGE_CATEGORIES_FORM will show up.

- you can insert a new category by just entering the name on the textfield and click the "Insert New Category" button.

- the MANAGE_CATEGORIES_FORM contain a jtable with all the categories name and id.

- if you select a category from the jtable : 1) the data of the selected category will be displayed on the textfields, 2) the products on the selected category will be displayed on a list. 

- also a navigation buttons for next and previous .



java inventory system - manage categories



- when you click on "show full  products list in this category" button a form with full products data in this category will show up.



java inventory system - show products in a category



5 - Customer Section


in this section you can:

- see all the customers in database displayed on jtable.

- get the selected customer data from jtable and set it into jtextfields on jtable click.

- insert a new customer.

- update the selected customer data.

- delete the selected customer.

- navigate using "Next" & "Previous".

- clear all jtextfields text using the "clear" buttons.

- display the selected customer orders count.

- display the selected customer total orders amount.

- display the selected customer last order date.



java inventory system - manage customers



6 - Order Section


when you click on the order tab MANAGE_ORDERS_FORM will show up, and this form contain:

- 1 jtable with all customers.

- 1 jtable for products ( show products depending on combobox category ).

- 1 jtable to display the products you want to add into the order .



java inventory system - manage orders



Watch A Full Order Section Demonstration


on the jtable for customers, if you select a row the customer id will be set into the jtextfield id.



now if you want to add products to the order follow those steps:

1 - select the category you want from the combobox.

2 - click on the product you want to add -> click on the ">>>" button enter the quantity you want, you can't enter 0 or let the box empty or enter a heigher quantity than the one available on the database.





java inventory system - quantity



java inventory system - quantity 0



java inventory system - unavailable quantity





and if everything is ok, the selected product will be add to the order jtable with the quantity you want.








now lets add more products to the order table



java inventory system - add products to order




- in the jtable you can see a column "Quantity X Price" where we calculate the total price for this product.
- on the bottom you can see the total amount of all products.


java inventory system - order buttons


- the "Remove Product" button allow you to select remove the selected product from the order jtable. - the "Clear" button allow you to remove all products from the order jtable.

if all is good, click the "Insert Order" button to add the new order with the details into the database.

if you want to show all the orders click on the "Show All Orders" button and All_Orders_Form will show up with all the orders displayed on a jtable.

java inventory system - show all orders


when you click on "Print Selected Order" the selected order will be printed into a text file.

java inventory system - print order


7 - User Section

and the last one is the user tab ( for admin only ), so when you click on it the  MANAGE_USERS_FORM will show up with all the users displayed on a jtable.
if you select a user from the jtable all the data will be set into textfields so you can delete it or edit the informations.
- and to add a new user enter the user informations click on the "Insert" button.
java inventory system - manage users

if you want the source code click on the download button below





disclaimer: you will get the source code + the database script
                    and to make it work in your machine is your responsibility
                    and to debug any error/exception is your responsibility
                    this project is for the students who want to see an example and read                                      the code not to get and run


More Java Projects:

Java - Login And Register Form With MySQL DataBase

How To Make SignUp And SignIn Form In Java Using NetBeans With MySQL DataBase

Java - Login And Register Form With MySQL DataBase


in a previous Java tutorial we did a login and register form design ( video link: https://youtu.be/XAowXcmQ-kA ), 
and in this one will see how to connect the login and signup form with a mysql database

to do that you need to download mysql connector, watch tutorial from here: https://www.youtube.com/watch?v=zM7oe2_S-jY
and add it to your project

we will ceate a class (MyConnection) to connect our login and register forms with mysql database

in the register form wi will create a function (checkUsername) to check if the username you want to register is already exists in the database table

what we will check when the user click on the register button:
- if the username jtextfield is empty
- if the password jtextfield is empty
- if the retype_password text is equal to the password text
- if the username already exists in the database using the "checkUsername" function
- if the jdatechooser is empty

in the login fom it's simple;
the user enter his login and password and click on the login button,

and all we have to do is to check if a user with this username and password already exists on the database, and if the user don't exists show a warning message , else show a new form with the user username displayed on a jlabel.



Project Source Code:


------------ Create A Class "MyConnection" To Connect Our Forms With Database

import java.sql.Connection;
import java.sql.DriverManager;


/**
 *
 * @author 1BestCsharp
 */
public class MyConnection {
    
    
    // create a function to connect with mysql database
    
    public static Connection getConnection(){
     
        Connection con = null;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            con = DriverManager.getConnection("jdbc:mysql://localhost/java_login_register", "root", "");
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
        
        return con;
    }
    
}    



------------ On The Register Form ------------

// function to check if the username already exist in database table
    public boolean checkUsername(String username)
    {
        PreparedStatement ps;
        ResultSet rs;
        boolean checkUser = false;
        String query = "SELECT * FROM `the_app_users` WHERE `u_uname` =?";
        
        try {
            ps = MyConnection.getConnection().prepareStatement(query);
            ps.setString(1, username);
            
            rs = ps.executeQuery();
            
            if(rs.next())
            {
                checkUser = true;
            }
        } catch (SQLException ex) {
            Logger.getLogger(RegisterForm.class.getName()).log(Level.SEVERE, null, ex);
        }
         return checkUser;
    }




// on the register button click
private void jButton_Register_ActionPerformed(java.awt.event.ActionEvent evt) {                                                  
        String fname = jTextField_FN.getText();
        String lname = jTextField_LN.getText();
        String uname = jTextField_UN.getText();
        String pass = String.valueOf(jPasswordField_PASS.getPassword());
        String re_pass = String.valueOf(jPasswordField_REPASS.getPassword());
        String bdate = null;
        String address = jTextArea_ADDRESS.getText();
                
        if(uname.equals(""))
        {
            JOptionPane.showMessageDialog(null, "Add A Username");
        }
        
        else if(pass.equals(""))
        {
            JOptionPane.showMessageDialog(null, "Add A Password");
        }
        else if(!pass.equals(re_pass))
        {
            JOptionPane.showMessageDialog(null, "Retype The Password Again");
        }
        
        else if(checkUsername(uname))
        {
            JOptionPane.showMessageDialog(null, "This Username Already Exist");
        }
        
        else{
        
        if(jDateChooser_BDATE.getDate() != null)
        {
            SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
            bdate = dateformat.format(jDateChooser_BDATE.getDate());
        }
            
        PreparedStatement ps;
        String query = "INSERT INTO `the_app_users`(`u_fname`, `u_lname`, `u_uname`, `u_pass`, `u_bdate`, `u_address`) VALUES (?,?,?,?,?,?)";
        
        try {
            ps = MyConnection.getConnection().prepareStatement(query);
            
            ps.setString(1, fname);
            ps.setString(2, lname);
            ps.setString(3, uname);
            ps.setString(4, pass);
            
            if(bdate != null)
            {
             ps.setString(5, bdate);
            }else{
                ps.setNull(5, 0);
            }
            ps.setString(6, address);
            
            if(ps.executeUpdate() > 0)
            {
                JOptionPane.showMessageDialog(null, "New User Add");
            }
            
        } catch (SQLException ex) {
            Logger.getLogger(RegisterForm.class.getName()).log(Level.SEVERE, null, ex);
        }
        }
    }                                                 

    

------------ On The Login Form ------------


// on the login button click
private void jButton_LOGINActionPerformed(java.awt.event.ActionEvent evt) {                                 
        PreparedStatement ps;
        ResultSet rs;
        String uname = jTextField1.getText();
        String pass = String.valueOf(jPasswordField1.getPassword());
        
        String query = "SELECT * FROM `the_app_users` WHERE `u_uname` =? AND `u_pass` =?";
        
        try {
            ps = MyConnection.getConnection().prepareStatement(query);
            
            ps.setString(1, uname);
            ps.setString(2, pass);
            
            rs = ps.executeQuery();
            
            if(rs.next())
            {
                    HOME_JFrame mf = new HOME_JFrame();
                    mf.setVisible(true);
                    mf.pack();
                    mf.setLocationRelativeTo(null);
                    mf.setExtendedState(JFrame.MAXIMIZED_BOTH);
                    mf.jLabel1.setText("Welcome < "+uname+" >");
                    
                    this.dispose();
            }
            else{
                    JOptionPane.showMessageDialog(null, "Incorrect Username Or Password", "Login Failed", 2);
                }
            
        } catch (SQLException ex) {
            Logger.getLogger(LoginForm.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        
    }                                             




download the source code



////// OUTPUT : 


java register form - add username
java register form - add username
it's the same for password and retype password

java register form - username already exists
java register form - username already exists
java login form - login failed
java login form - login failed
java login form - login success
java login form - login success -> show new form




VB.NET Inventory System Source Code

Inventory Management System Source Code Using VB.NET And MySQL Database

vb.net inventory management system project

in this vb.net project demo we will see how to use our visual basic .net inventory management system with a mysql database.

goals of this project:
- give students / curious persons an example so they can learn from.
helping people create their first project. 
sharing knowledge with others.

this project is not for:
- people who want to use it as their final year project.
- a real life store.

tools:
- visual basic .net programming language.
- visual studio express 2013.
- mysql database
- canva.com for images
- flatuicolorpicker.com for colors
- iTextSharp (PDF library)

Watch This Full Demo



1 - Login Form

the login form allow the ADMIN and the other USERS to login into the application main form

vb.net inventory system - login form

if the user enter wrong username or password a message will show up

vb.net inventory system - login form error

as you can see there is a checkbox that allow you to show and hide the password

vb.net inventory system - login form show pass

so, if everything is ok when you click on the login button the main/home form will show up and the login form will close it self.


2 - Home Form

if the user type is ADMIN a "user" tab will be visible on the top menu

vb.net inventory system - home form

if the user type is USER the "user" tab will be invisible

vb.net inventory system - user home form


3 - Product Section


when you click on the Product tab, the MANAGE_PRODUCT_FORM will show up



vb.net inventory system - manage products



- on the form load all products will be displayed into a datagridview.

- when you enter a value in the search box and click search button, only the products that contain this value will be shown in the datagridview.



vb.net inventory system - search products



if you click on the "New Product" button the ADD_NEW_PRODUCT_FORM will show up, this form allow to enter the new product data and insert it into mysql database.


vb.net inventory system - add new product

on the top form you can see a combobox categories, this combobox is populated from category table in the mysql database.
if you want to add a new category without leaving the current form you can easly click on the "Add New Category" button and small form will show up and you can add a new category.

vb.net inventory system - add product category

and if you want to update a product just select the product you want to edit from the datagridview and click on the "Update Product" and the UPDATE_PRODUCT_FORM will show up with all the selected product data displayed on the form.

- NOTE: the number "11" you see on the right of  the combobox category is a label with the id of the product you want to edit, you can make this label invisible if you want. 

vb.net inventory system - update selected product

when you want to delete a product just select the product you want to remove and click on the "Remove Product" button.

vb.net inventory system - delete selected product


4 - Category Section


now if you want to manage the categories you have to go to the category tab.

- you can insert a new category by just entering the name on the textbox and clicking insert.

- when you click on the category tab the MANAGE_CATEGORIES_FORM will show up.

- the MANAGE_CATEGORIES_FORM contain a datagridview with all the categories name and id.

- if you select a category from the datagridview : 1) the data of the selected one will be displayed on the textboxes, 2) the products on the selected category will be displayed on a listbox. 

- also a navigation buttons for next and previous + a reset button to clear the textboxes text.



vb.net inventory system - manage categories



if you double click on a datagridview row, a list of products will show up on a new form



vb.net inventory system - show products in a category



5 - Customer Section


in this section you can:

- see all the customers on database displayed in datagridview.

- get the selected customer data from datagridview and set it into tetboxes on datagridview click.

- insert a new customer.

- update the selected customer data.

- delete the selected customer.

- navigate using "Next" & "Previous".

- clear all textboxes text using the "Reset" buttons.

- display the selected customer orders count.

- display the selected customer total orders amount.

- display the selected customer last order date.



vb.net inventory system - manage customers



6 - Order Section


when you click on the order tab MANAGE_ORDERS_FORM will show up, and this form contain:

- 1 datagridview with all customers.

- 1 datagridview for products ( show products depending on combobox category ).

- 1 datagridview to display the products you want to add into the order .



vb.net inventory system - manage orders



on the datagridview for customers, if you select a row the customer id will be set into the textbox id,

and if you double click a form will show up with the selected customer orders, and when you select an order you can see all products on this order in a listbox.



vb.net inventory system - customer orders



if you want to add a new customer click on "Add New Customer" button and enter the customer data



vb.net inventory system - add customer



now if you want to add products to the order follow those steps:

1 - select the category you want from the combobox.

2 - double click on the product you want, the QUANTITY_FORM will show up and you can enter the quantity you want, you can't enter 0 or let the box empty or enter a heigher quantity than the one available on the database.


vb.net inventory system - quantity
quantity form
vb.net inventory system - 0 quantity
quantity = 0
vb.net inventory system - unavailable quantity
unavailable quantity



and if everything is ok, the selected product will be add to the order datagridview with the quantity you want.


add product to order with valid quantity

now lets add more products to the order




- in the datagridview you can see a column "Quantity X Price" where we calculate the total price for this product.
- the checkbox "Select All" allow you to select all the products in the datagridview and if you want to delete them click on the "Delete Selected Products".
- on the bottom you can see the total amount of all products.

if all is good, click the "Insert Order" button to add the new order with the details into the database.

vb.net inventory system - insert order


if you want to show all the orders click on the "Show All Orders" button and ALL_ORDERS_FORM will show up with all the orders displayed on a datagridview.

vb.net inventory system - show all orders

when you click on "Print Selected Order" the selected order will be printed into a pdf file using iTextSharp (PDF library)

vb.net inventory system - printed order


7 - User Section

and the last one is the user tab, so when you click on it the MANAGE_USERS_FORM will show up
with all the users displayed on a datagridview.

vb.net inventory system - manage users

if you select a user from the datagridview all the data will be set into textboxes so you can delete it or edit his informations.

vb.net inventory system - select user

and to add a new user click on the "Create New User" button so the ADD_NEW_USER_FORM will show up, and all you have to do is enter the user informations and click add.

vb.net inventory system - add new user


if you want the source code click on the download button below





disclaimer: you will get the source code + the database script
                    and to make it work in your machine is your responsibility
                    and to debug any error/exception is your responsibility
                    this project is for the students who want to see an example and read                                      the code not to get and run