Java

Fried Rice shop Inventory in Java Mysql

The Fried Rice shop Inventory Management System is developed by Java and MySQL.java best practice is must if you interested in java. The project is built to manage sales and transactions. To make a new transaction, fields such as: Fried Rice type, qty,price needs to be selected. If you like to learn point of sales systems step by step, this is the right place to learn from the beginning.

In this tutorial,you will learn  jasper reports step by step and designing the java print receipt.java coding practices is very important  for us to grow the knowledge in java day by day.how to be a good programmer in the future. Let go and learn the java mini projects step by step.i have attached the complete project video also how the flow works step by step below.

In order to create the system we have used NetBeans IDE and Mysql database as a backend.

Features of the Project

  • Point of Sales
  • Stock Management
  • Java Receipt

Learn how to make this System Step by step

The first step Create the database named with “friedriceshop“. then established the database connection to download the mysql connector in order to connect Java & mysql.if you don’t  have an idea about  download the mysql connector you can follow this link.

To connect the database please refer the following code. To create the method name connect (); paste the below code inside the Connect () method.

public void Connect() 
{ 
try
 { 
Class.forName("com.mysql.jdbc.Driver"); // Register the mysql driver 
con = DriverManager.getConnection("jdbc:mysql://localhost/friedriceshop","root",""); 
}
 catch (ClassNotFoundException ex)
 { 
ex.printStackTrace(); 
}
 catch (SQLException ex) 
{ 
ex.printStackTrace(); 
} 
}

After that call the method Connect() inside the constructor. When the programme is started to run, all the forms are loaded along with the connection method. Pasted the Connect() method inside the constructor.

 public friendrice()
    {
        initComponents();
        Connect();
    }

The system shall be able to select the relevant Rice type.

Add the Product details into the JTable

After selected the relevant rice type the user has the option to add the qty by clicking the add button to see all Products details which will be shown in the below table.

Paste this code inside the add button

int sum = 0;
 
        if(chktrice.isSelected())
        {
            String thai =  chktrice.getText();
            int  price = Integer.parseInt(txttrice.getText());
            int  qty = Integer.parseInt(strice.getValue().toString());
            int tot = price * qty;   
            model = (DefaultTableModel)jTable1.getModel();
            
            model.addRow(new Object[]          
            {
                thai,
                price,
                qty,
                tot 
            }        
             );    
        }
        if(chkbrice.isSelected())
        { 
            String basil =  chkbrice.getText();
            int  price = Integer.parseInt(txtbrice.getText());
            int  qty = Integer.parseInt(sbrice.getValue().toString());
            int tot = price * qty;
            model = (DefaultTableModel)jTable1.getModel();
            
            model.addRow(new Object[]          
            {
                basil,
                price,
                qty,
                tot
 
            }        
             );    
        }

           if(chkprice.isSelected())
        {

            String pine =  chkprice.getText();
            int  price = Integer.parseInt(txtprice.getText());
            int  qty = Integer.parseInt(sprice.getValue().toString());
            int tot = price * qty;
            
            model = (DefaultTableModel)jTable1.getModel();
            
            model.addRow(new Object[]          
            {
                pine,
                price,
                qty,
                tot 
            }        
             );    
        }

         if(chkcrice.isSelected())
        {
            String crice =  chkcrice.getText();
            int  price = Integer.parseInt(txtcrice.getText());
            int  qty = Integer.parseInt(scrice.getValue().toString());
            int tot = price * qty;
            
            model = (DefaultTableModel)jTable1.getModel();
            
            model.addRow(new Object[]          
            {
                crice,
                price,
                qty,
                tot
            }        
             );    
        }
          if(chkcorice.isSelected())
        {
            
            String comb =  chkcorice.getText();
            int  price = Integer.parseInt(txtcorice.getText());
            int  qty = Integer.parseInt(scorice.getValue().toString());
            int tot = price * qty;
            
            model = (DefaultTableModel)jTable1.getModel();
            
            model.addRow(new Object[]          
            {
                comb,
                price,
                qty,
                tot 
            }        
             );    
        }
        for(int i=0; i<jTable1.getRowCount(); i++)
        {
            sum = sum + Integer.parseInt(jTable1.getValueAt(i, 3).toString());  
        }
        
        txtsub.setText(Integer.toString(sum));

Calculating the Total and balance

After that  create the method Sales().we have to create two different tables to store data into the database.we also have to create the following tables from database.
carclean tables consist of following colums – id,subtotal,pay,balance.
car_products tables consist of following – id,sales_id,ricetype,price,qty,total.

  public void sales()
    {
        String subtot = txtsub.getText();
        String pay = txtpay.getText();
        String bal = txtbal.getText();
        int lastinsertid = 0;
        try {
 
            String query = "insert into sales(subtotal,pay,balance)values(?,?,?)";
            
            pst1 = con.prepareStatement(query,Statement.RETURN_GENERATED_KEYS);
            
            pst1.setString(1, subtot);
            pst1.setString(2, pay);
            pst1.setString(3, bal); 
            pst1.executeUpdate();
            
            ResultSet generatekey = pst1.getGeneratedKeys();
            
            if(generatekey.next())
            {
                lastinsertid = generatekey.getInt(1);
            }
            
            
            int rows = jTable1.getRowCount();
            String query1 = "insert into sales_product(sales_id,ricetype,price,qty,total)values(?,?,?,?,?)";
            pst2 = con.prepareStatement(query1);
            
            String ricetype = "";
            int price =0 ;
            int qty = 0;
            int tot = 0;
            
            for(int i=0; i<jTable1.getRowCount(); i++)
            {
                 ricetype = (String)jTable1.getValueAt(i, 0);
                 price = (int)jTable1.getValueAt(i, 1);
                  qty = (int)jTable1.getValueAt(i, 2);
                   tot = (int)jTable1.getValueAt(i, 3);
                   
                   
                   pst2.setInt(1, lastinsertid);
                   pst2.setString(2, ricetype);
                   pst2.setInt(3, price);
                   pst2.setInt(4, qty);
                   pst2.setInt(5, tot);
                   pst2.executeUpdate();  
            }
            JOptionPane.showMessageDialog(this, "Sales Completeddddd");
 
            HashMap a = new HashMap();
            a.put("invo",lastinsertid);

            try {
                JasperDesign jdesign = JRXmlLoader.load("C:\\Users\\kobinath\\Documents\\NetBeansProjects\\FriendRiceShop\\src\\friedrice\\report1.jrxml");
                JasperReport jreport = JasperCompileManager.compileReport(jdesign);
                
                JasperPrint jprint = JasperFillManager.fillReport(jreport, a, con);
                 
                JasperViewer.viewReport(jprint);
                
                
             //  JasperPrintManager.printReport(jprint, false); 
                
            } catch (JRException ex) {
                Logger.getLogger(friendrice.class.getName()).log(Level.SEVERE, null, ex);
            }   
            
            
        } catch (SQLException ex) {
            Logger.getLogger(friendrice.class.getName()).log(Level.SEVERE, null, ex);
        }
 
    }

Call the Sales() method inside the Print Invoice button. after calculating the total print receipt will be released. This print receipt is design by Jsper Reporting.

Paste this code inside the Print Invoice button

 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
 
        int sub,pay,bal;
         sub = Integer.parseInt(txtsub.getText());
         pay = Integer.parseInt(txtpay.getText());
         
         bal = pay - sub;
         
         txtbal.setText(String.valueOf(bal));
  
        sales();
    }

Print Recipt

i have attached the video link below. which will do this tutorials step by step.

 

 

admin

Recent Posts

Employee Working Hours Calculation System using C#.net

Initialize the employee number, Hourswork,and Hoursrate to calculate a grosswage use the following condition. if…

1 day ago

Java Payroll System Calculate Employee Overtime

Act as a Java developer to create a program that calculates the gross wage for…

3 days ago

Employee Working Hours Calculation System using Java

Initialize the employee number, Hourswork,and Hoursrate to calculate a grosswage use the following condition. if…

4 days ago

Laravel 11 School Management System

In this tutorial, we will teach you how to create a simple school management system…

1 week ago

How to Make Admin Panel Using React MUI

I have design the Admin Basic templete using React MUI Design Admin Dashboard and Login.Here…

3 weeks ago

Install Laravel Breeze for Authentication Using Laravel 11

In this tutorial ,i am to going teach the Laravel Breeze.Laravel Breeze provides a simple…

3 weeks ago