Home Java Car Cleaning Inventory System in Java

Car Cleaning Inventory System in Java

10 min read
0
1
1,357

The Car Cleaning 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 the car cleaning management and transactions. To make a new transaction, Check the relevant checkboxes what are the cleaning do you need, qty and payment needs to be selected. If you like to learn of 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 “carcleaninventory “. 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/carcleaninventory","root","");
            //Connection Path where your database is located.
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        } catch (SQLException ex) {
           ex.printStackTrace();
        }
        
    }

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

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

The system shall be able to fill the relevant fields : car no, customer name,cleaning category type.

Add the Product details into the JTable

After fill the relevant fields by clicking the add button to see all Products details which will be shown in the table.

Paste this code inside the add button

        int sum = 0;
        if(chkdash.isSelected())
        {
            String dash = chkdash.getText();
            model = (DefaultTableModel)jTable1.getModel();
            model.addRow(new Object[]
            {
              dash,
              txtdash.getText()
            });  
        }
        if(chkuphot.isSelected())
        {
            String uphot = chkuphot.getText();
            model = (DefaultTableModel)jTable1.getModel();
            model.addRow(new Object[]
            {
              uphot,
              txtuphot.getText()
            });  
        }
           if(chkroof.isSelected())
        {
            String roof = chkroof.getText();
            model = (DefaultTableModel)jTable1.getModel();
            model.addRow(new Object[]
            {
              roof,
              txtroof.getText()
            });  
        }
           
           
             if(chkfloor.isSelected())
        {
            String floor = chkfloor.getText();
            model = (DefaultTableModel)jTable1.getModel();
            model.addRow(new Object[]
            {
              floor,
              txtfloor.getText()
            });  
        }
           
              if(chkseat.isSelected())
        {
            String seat = chkseat.getText();
            model = (DefaultTableModel)jTable1.getModel();
            model.addRow(new Object[]
            {
              seat,
              txtseat.getText()
            });  
        }
        
          if(chkfbody.isSelected())
        {
            String fbody = chkfbody.getText();
            model = (DefaultTableModel)jTable1.getModel();
            model.addRow(new Object[]
            {
              fbody,
              txtfbody.getText()
            });  
        }
        
          if(chkwind.isSelected())
        {
            String wind = chkwind.getText();
            model = (DefaultTableModel)jTable1.getModel();
            model.addRow(new Object[]
            {
              wind,
              txtwind.getText()
            });  
        }
          
          
          for(int i=0; i<jTable1.getRowCount(); i++)
          {
              sum = sum + Integer.parseInt(jTable1.getValueAt(i, 1).toString());
          }
        
        txttot.setText(String.valueOf(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,carno,total,pay,balance
car_products tables consist of following –  id clean_id,cleantype,price.

Create the Method Sales do the following codes inside the method

 public void sales()
    {
        String carno = txtno.getText();
        String total = txttot.getText();
        String pay = txtpay.getText();
        String bal = txtbal.getText();
        int lastinsertid =0;

        try {
             String query = "insert into carclean(carno,total,pay,balance)values(?,?,?,?)";
             pst = con.prepareStatement(query,Statement.RETURN_GENERATED_KEYS);
             pst.setString(1, carno);
             pst.setString(2, total);
             pst.setString(3, pay);
             pst.setString(4, bal);
             pst.executeUpdate();
             ResultSet generatekeyResult = pst.getGeneratedKeys();
             
             if(generatekeyResult.next())
             {
                 lastinsertid = generatekeyResult.getInt(1);
             }
             
             int rows = jTable1.getRowCount();
             
             String query1 = "insert into car_products(clean_id,cleantype,price)values(?,?,?)";
             
             pst1 = con.prepareStatement(query1);
             
             String cleanType = "";
             String price = "";
             int total1 = 0;
             for(int i=0; i<jTable1.getRowCount(); i++)
             {
                 cleanType = (String)jTable1.getValueAt(i, 0);
                 price = (String)jTable1.getValueAt(i, 1);
                 
                 pst1.setInt(1,lastinsertid);
                 pst1.setString(2,cleanType);
                 pst1.setString(3,price);
                 pst1.execute();
 
             }
             
             pst.addBatch();
             JOptionPane.showMessageDialog(this, "Record Adddedddd");

            try {
                 HashMap a = new HashMap();
                a.put("invo", lastinsertid);
                JasperDesign jdesign = JRXmlLoader.load("C:\\Users\\kobinath\\Documents\\NetBeansProjects\\Carclean\\src\\Carclean\\report1.jrxml");
                
                JasperReport jreport = JasperCompileManager.compileReport(jdesign);
                
                
                JasperPrint jprint = JasperFillManager.fillReport(jreport, a,con);
                
                
                //JasperViewer.viewReport(jprint);
                
              JasperPrintManager.printReport(jprint, false); //this code used to print for without show the print preview
                
                
            } catch (JRException ex) {
                Logger.getLogger(carclean.class.getName()).log(Level.SEVERE, null, ex);
            }
  
        } catch (SQLException ex) {
            Logger.getLogger(carclean.class.getName()).log(Level.SEVERE, null, ex);
        } 

    }

 

Call the Sales() method inside the Print Invoice button.After calculate, the total print receipt will be relased. This print receipt is design by Jsper Reporting.

Paste this code inside the Print Invoice button

      int pay = Integer.parseInt(txtpay.getText());
      int total = Integer.parseInt(txttot.getText());
      int bal = pay - total;
      txtbal.setText(String.valueOf(bal));
      sales();

Print Recipt

i have attached the video link below. which will do this tutorials step by step.this java projects with source codes will help you to learn java.

 

 

 

 

 

Load More Related Articles
Load More By admin
Load More In Java

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also

Build a Full-Stack Node.js MongoDB CRUD App with JWT Authentication

In this tutorial, we will teach the process of building a full-stack application using Nod…