Java

Supermarket POS with Bill Print Using Java and Mysql

this Point of  sales System is developed using Java and mysql. The project is built to manage  sales and transactions. To make a new transaction, fields such as: product name, qty and payment 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.point of sale system using java netbeans IDE
which is the best editor for writing the code and design the UI easily.

why pos is important

Point of Sale systems are essential part of each industries for making sales and transaction very easily.

point of sales system features

1.manage the stocks.
2.manage the sales and transactions.
3.daily and weekly and monthly generating reports.
4.customer management.

that’s why importance of point of sale system in every business. attached the Screen Shot image below along with point of sale system java source code. i attached the video tutorials below. You will able to learn from it.

Paste this Code inside the keypress Event of the textbox. we created the textbox name txtpcode of this project.

private void txtpcodeKeyPressed(java.awt.event.KeyEvent evt) 
{                                    
        if(evt.getKeyCode() == KeyEvent.VK_ENTER)
        {
            String pcode = txtpcode.getText();   
            try {
                Class.forName("com.mysql.jdbc.Driver");
                con = DriverManager.getConnection("jdbc:mysql://localhost/salespos","root","");
                pst = con.prepareStatement("select * from product where id = ?");
                pst.setString(1, pcode);
                rs = pst.executeQuery();
                
                if(rs.next() == false)
                {     
                    JOptionPane.showMessageDialog(this, "Product Code Not Found");  
                }
                else
                {
                    String pname = rs.getString("prodname");
                     String price = rs.getString("price");
                     txtpname.setText(pname.trim());
                     txtprice.setText(price.trim());
                }
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(pos.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SQLException ex) {
                Logger.getLogger(pos.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

 

Add the Product details into the JTable

After receiving the product name and price where 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.

if the user can change the qty.amount should calculated according to the qty selected.

private void txtqtyStateChanged(javax.swing.event.ChangeEvent evt) {                                    
        int qty = Integer.parseInt(txtqty.getValue().toString());
        int price = Integer.parseInt(txtprice.getText());
        int tot = qty * price;
        
        txtamount.setText(String.valueOf(tot));
        
    }

Paste Code Inside the Add Button

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         

        DefaultTableModel model = new DefaultTableModel();
        model = (DefaultTableModel)jTable1.getModel();
        model.addRow(new Object[]
                
        {
            txtpcode.getText(),
            txtpname.getText(),
            txtqty.getValue().toString(),
            txtprice.getText(),
            txtamount.getText(),           
        });   
                
            int sum = 0;
                    
        for(int i = 0; i<jTable1.getRowCount(); i++)
        {
            sum = sum + Integer.parseInt(jTable1.getValueAt(i, 4).toString());
        }
        
        txtotal.setText(Integer.toString(sum));
           
          txtpcode.setText("");
           txtpname.setText("");
           txtprice.setText("");
           txtamount.setText("");
        txtpcode.requestFocus();
    }

Design the Bill

public void bill()
    {
        String total = txtotal.getText();
         String pay = txtpay.getText();
         String bal = txtbal.getText();
         
          DefaultTableModel model = new DefaultTableModel();
        
        model = (DefaultTableModel)jTable1.getModel();
         
         txtbill.setText(txtbill.getText() + "******************************************************\n");
         txtbill.setText(txtbill.getText() + "           POSBILL                                     \n");
         txtbill.setText(txtbill.getText() + "*******************************************************\n");
         
         //Heading
          txtbill.setText(txtbill.getText() + "Product" + "\t" + "Price" + "\t" + "Amount" + "\n"  );
          
          
          for(int i = 0; i < model.getRowCount(); i++)
          {
              
              String pname = (String)model.getValueAt(i, 1);
              String price = (String)model.getValueAt(i, 3);
              String amount = (String)model.getValueAt(i, 4); 
              
           txtbill.setText(txtbill.getText() + pname  + "\t" + price + "\t" + amount  + "\n"  );
    
          }
          
          txtbill.setText(txtbill.getText() + "\n");     
          
          txtbill.setText(txtbill.getText() + "\t" + "\t" + "Subtotal :" + total + "\n");
          txtbill.setText(txtbill.getText() + "\t" + "\t" + "Pay :" + pay + "\n");
          txtbill.setText(txtbill.getText() + "\t" + "\t" + "Balance :" + bal + "\n");
          txtbill.setText(txtbill.getText() + "\n");
          txtbill.setText(txtbill.getText() + "*******************************************************\n");
          txtbill.setText(txtbill.getText() + "           THANK YOU COME AGIN             \n");

        
    }

 

Paste the code inside the Bill button

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) 
   {                                         
       Balance();
       bill();

    }

Paste the code inside the Print Button

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        try 
        {
            txtbill.print();
        } 
        catch (PrinterException ex) {
            Logger.getLogger(pos.class.getName()).log(Level.SEVERE, null, ex);
        }  
    }

Related Posts

Point of sales System with Bill Print Using Java and Mysql
https://www.tutussfunny.com/point-of-sales-system-with-bill-print-using-java-and-mysql/

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

 

 

 

 

 

 

admin

Recent Posts

Fish Inventory Shop Management System in Angular

This article explain how to make a Fish Inventory Management App in Angular.this app explain…

5 days ago

Fish Inventory Management with React

Introduction to Fish Inventory Management In the aquaculture industry, managing fish inventory is crucial for…

7 days ago

Java GUI CRUD for Beginners

Introduction to Java GUI CRUD Java is a powerful programming language widely used for building…

7 days ago

Creating Beautiful Login Form Design Using React

Introduction to Login Form Design Designing an effective and beautiful login form is crucial for…

2 weeks ago

Creating Responsive Login Form with React

Introduction In today creating a responsive login form is essential for providing a seamless user…

2 weeks ago

Master React Inventory Management System Development

Introduction to Inventory Management Systems In today's fast-paced digital environment, businesses require efficient inventory management…

3 weeks ago