Home Java Textile Shop Inventory Using Java Mysql

Textile Shop Inventory Using Java Mysql

6 min read
0
0
1,140

this tutorial will teach you sales and inventory management system project in java mysql. The project is built to manage  sales and transactions. To make Textile Shop inventory java program. 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.

Create the Batch Table and Product Table

Batch No

The batch no is used to identify the shipping item.i described following table below. i explain clearly.

Batch Table

BatchIDBatchNameCreatedDate
1B0012020-4-6
2B0022020-5-10

Product Table

Product IDProduct NameBatch NoQtyPrice
1Tshirt1100250

Above table is explained. Batch table consist of 3 colums batchno,batchname,createddate.consider you have purchased the item for the first item B001 it means batch 1 second time purchased  batch changed as B002 it means batch 2.it is very easy to identify the shipping items.when you sell item if you  enter the relavent product id. it will display the batches you will able to select your relavent  batch for the item.

Establish the database connection

 Connection con;
        PreparedStatement pst;
        ResultSet rs;
        
        
        public void connect()
        {
        try {
            Class.forName("com.mysql.jdbc.Driver");
            con = DriverManager.getConnection("jdbc:mysql://localhost/etextileshop","root","");
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(batch.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(batch.class.getName()).log(Level.SEVERE, null, ex);
        }
        }

we have created the database name “etextileshop

Add Records

you can use the following code snippet to add the records in to database. paste the code inside the save button

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        try {
            String bname = txtbname.getText();
            SimpleDateFormat date_form = new SimpleDateFormat("yyyy-MM-dd");
            String date = date_form.format(txtbdate.getDate());  
            
            pst = con.prepareStatement("insert into batch(batchname,date)values(?,?)");
            pst.setString(1, bname);
            pst.setString(2, date);
            int k = pst.executeUpdate();
             
            if(k==1)
             {
                 JOptionPane.showMessageDialog(this, "Batch Adddeddd");
                 txtbname.setText("");
                 txtbname.requestFocus();
             }
             else
             {
                  JOptionPane.showMessageDialog(this, "Batch Faileddd");
             }  
        } catch (SQLException ex) {
            Logger.getLogger(batch.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

View Records

you can use the following code snippet to retrieve the data stored in the database and present it to users in a proper format. create a method batch_Load().paste the method inside the constructor of the class.when the form is loaded all the records will be shown on the jTable.

   public void batch_Load()
        {
        try {
            pst = con.prepareStatement("select * from batch");
            rs = pst.executeQuery();
            ResultSetMetaData rsd = rs.getMetaData();
            int c;
            
            c = rsd.getColumnCount();
            DefaultTableModel d = (DefaultTableModel)jTable1.getModel();
            d.setRowCount(0);
            
            while(rs.next())
            {
                  Vector v = new Vector();
                   for(int i=0; i<c; i++)
                   {
                       v.add(rs.getString("id"));
                       v.add(rs.getString("batchname"));
                       v.add(rs.getString("date")); 
                   }
                    d.addRow(v);
            }
    
        } catch (SQLException ex) {
            Logger.getLogger(batch.class.getName()).log(Level.SEVERE, null, ex);
        }
            
            
        }

Form Constructor

  public batch() {
        initComponents();
        connect();
        batch_Load();
    }

 

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.

 

 

 

 

 

 

 

    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

    Laravel 11 CRUD Mastering RESTful API MVC with Repository Pattern

    In this tutorial will teach Laravel 11 Api MVC with Repository Pattern Crud Application st…