Gym management system free download

This is a simple open-source gym management system developed using java programming language and MySQL database. This gym management system based on basic three modules. Those are Member management, attendance management, payment management and package management.

Home Interface

This interface provides the path to move between all the modules.

Member Management

In this module include three functions. Those are

  • Add new members
  • Update exit members
  • delete exit members

Attendance Management.

Using this module admin can record attendance of the members. Here admin can record member id and how many times the member stayed in the gym.

Packages

Using this module admin create new packages and update exit packages.

Payment

using this module admin can handle payment with different packages.

Source code of gym management system.

Database connection

package Interface;

import java.sql.Connection;
import java.sql.DriverManager;
import javax.swing.JOptionPane;

/**
 *
 * @author ccs
 */
public class DBConnect {
    
     public static Connection connect()
    {
        Connection con=null;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            con=DriverManager.getConnection("jdbc:mysql://localhost:3306/database name?","userName","password");
           // JOptionPane.showConfirmDialog(null,"connect to data base");
            
        } catch (Exception e) {
            System.out.println("inter.DBConnect.connect()");
            JOptionPane.showMessageDialog(null, e);
        }
       return con;
    }
    
}

Member Module

    Connection conn=null;
    PreparedStatement pst=null;
    ResultSet rs=null;
    String sqr;
    private String parseSql;
    String mid;
    String name;
    String nic;
    String adress;
    String birthday;
    String contact;
    String gender;
    String other;
    
    public Member() {
        initComponents();
        conn=DBConnect.connect();
        autoId();
        tablelord();
    }
    
    private void autoId()
    {
        try {
             String sql="SELECT mid FROM member ORDER BY mid DESC LIMIT 1";
           // String q="SELECT returndate FROM borrowdetails where mid='"+ name +"'";
            pst=conn.prepareStatement(sql);
            rs=pst.executeQuery();
           if(rs.next())
           {
                String rnno=rs.getString("mid");
                int co=rnno.length();
               String txt= rnno.substring(0, 2);
               String num=rnno.substring(2, co);
               int n=Integer.parseInt(num);
               n++;
               String snum=Integer.toString(n);
               String ftxt=txt+snum;
               txtmid.setText(ftxt);
            
           }
           else
           {
               txtmid.setText("MI1000");
           }
           
                            
        } catch (Exception e) {
            JOptionPane.showMessageDialog(rootPane, e);
        }
       
    }
    
    private void tablelord()
    {
        try {
            String sql="SELECT `mid` as 'Member ID', `nic` as 'NIC', `name` as 'Name', `adress` as 'Address', `contact` as 'Contact Number', `birthday` as 'Birthday', `gender` as 'Gender', `other` as 'Other', date as 'Date' FROM `member`";
            pst=conn.prepareStatement(sql);
            rs=pst.executeQuery();
            tblmember.setModel(net.proteanit.sql.DbUtils.resultSetToTableModel(rs));
            
        } catch (Exception e) {
            JOptionPane.showConfirmDialog(rootPane, e);
        }
      
    }
    
    private void getData()
    {
    
        mid = txtmid.getText();
        nic = txtnic.getText();
        name = txtname.getText();
        adress = txtadress.getText();
        contact = txtcontac.getText();
        birthday = ((JTextField)bdate.getDateEditor().getUiComponent()).getText();
        gender = cmbgender.getSelectedItem().toString();
        other = txtother.getText();
    
    }
    
    private void clearData()
    {
    
        txtmid.setText("");
        txtnic.setText("");
        txtname.setText("");
        txtadress.setText("");
        txtcontac.setText("");
        ((JTextField)bdate.getDateEditor().getUiComponent()).setText("");
        cmbgender.setSelectedIndex(0);
        txtother.setText("");
    
    }

private void jToggleButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton4ActionPerformed
       clearData();
       tablelord();
    }//GEN-LAST:event_jToggleButton4ActionPerformed

    private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton1ActionPerformed
        getData();
        try {
                String q= "INSERT INTO `member`(`mid`, `nic`, `name`, `adress`, `contact`, `birthday`, `gender`, `other`, `date`) VALUES ('"+mid+"','"+nic+"','"+name+"','"+adress+"','"+contact+"','"+birthday+"','"+gender+"','"+other+"','"+Home.getDate+"')";
                 pst=conn.prepareStatement(q);
                pst.execute(); 
                JOptionPane.showMessageDialog(rootPane,"Member added successfully");
                
                    } 
                catch (Exception e) 
                {
       
                 JOptionPane.showMessageDialog(rootPane,e);                    
                } 
        tablelord();
        clearData();
    }//GEN-LAST:event_jToggleButton1ActionPerformed

    private void delete()
    {
         int x=JOptionPane.showConfirmDialog(rootPane, "Do you realy want to delete");
        if(x==0)
        {
        try {
                String sql="DELETE FROM `member` WHERE mid='"+ txtmid.getText() +"'";
                pst=conn.prepareStatement(sql);
                pst.execute();
                
                tablelord();
                clearData();
            } catch (Exception e) {
            }
        }
    
    }
    
    private void jToggleButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton3ActionPerformed
        delete();
    }//GEN-LAST:event_jToggleButton3ActionPerformed

    private void jToggleButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton2ActionPerformed
        getData();
        try {
              String squpdate = "UPDATE `member` SET `nic`='"+nic+"',`name`='"+name+"',`adress`='"+adress+"',`contact`='"+contact+"',`birthday`='"+birthday+"',`gender`='"+gender+"',`other`='"+other+"' WHERE mid='"+mid+"'";
              pst=conn.prepareStatement(squpdate);
                pst.execute();  
                clearData();
                tablelord();
                
            } catch (Exception e) {
                JOptionPane.showMessageDialog(rootPane,e);              
            }  
    }//GEN-LAST:event_jToggleButton2ActionPerformed

    private void tblmemberMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblmemberMouseClicked
       DefaultTableModel tmodel=(DefaultTableModel)tblmember.getModel();
        int selectrowindex=tblmember.getSelectedRow();
        txtmid.setText(tmodel.getValueAt(selectrowindex, 0).toString());
        txtnic.setText(tmodel.getValueAt(selectrowindex, 1).toString());
        txtname.setText(tmodel.getValueAt(selectrowindex, 2).toString());
        txtadress.setText(tmodel.getValueAt(selectrowindex, 3).toString());
        txtcontac.setText(tmodel.getValueAt(selectrowindex, 4).toString());
        ((JTextField)bdate.getDateEditor().getUiComponent()).setText(tmodel.getValueAt(selectrowindex, 5).toString());
        cmbgender.setSelectedItem(tmodel.getValueAt(selectrowindex, 6).toString());
        txtother.setText(tmodel.getValueAt(selectrowindex, 7).toString());
    }//GEN-LAST:event_tblmemberMouseClicked

Package magement Module

 Connection conn=null;
    PreparedStatement pst=null;
    ResultSet rs=null;
    String sqr;
    private String parseSql;
    String pid;
    String name;
    String hour;
    String milk;
    String tablet;
    String expert;
    String body;
    
    public Package() {
        initComponents();
         conn=DBConnect.connect();
        tablelord();
    }
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
      getData();
        try {
                String q= "INSERT INTO `package`(`name`, `hours`, `milk`, `tablet`, `expert`, `body`) VALUES ('"+name+"','"+hour+"','"+milk+"','"+tablet+"','"+expert+"','"+body+"')";
                 pst=conn.prepareStatement(q);
                pst.execute(); 
                JOptionPane.showMessageDialog(rootPane,"Member added successfully");
                
                    } 
                catch (Exception e) 
                {
       
                 JOptionPane.showMessageDialog(rootPane,e);                    
                } 
        tablelord();
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
      
         int x=JOptionPane.showConfirmDialog(rootPane, "Do you realy want to delete");
        if(x==0)
        {
        try {
                String sql="DELETE FROM `package` WHERE name='"+ txtpackagename.getText() +"'";
                pst=conn.prepareStatement(sql);
                pst.execute();
                
                tablelord();
                clearData();
            } catch (Exception e) {
            }
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
       getData();
        try {
              String squpdate = "UPDATE `package` SET `hours`='"+hour+"',`milk`='"+milk+"',`tablet`='"+tablet+"',`expert`='"+expert+"',`body`='"+body+"' WHERE name = '"+txtpackagename.getText()+"'";
              pst=conn.prepareStatement(squpdate);
                pst.execute();  
                clearData();
                tablelord();
                
            } catch (Exception e) {
                JOptionPane.showMessageDialog(rootPane,e);              
            }  
    }//GEN-LAST:event_jButton1ActionPerformed

    private void tblpackageMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblpackageMouseClicked
       DefaultTableModel tmodel=(DefaultTableModel)tblpackage.getModel();
        int selectrowindex=tblpackage.getSelectedRow();
        txtpackagename.setText(tmodel.getValueAt(selectrowindex, 0).toString());
        txthour.setText(tmodel.getValueAt(selectrowindex, 1).toString());
        cmbmilk.setSelectedItem(tmodel.getValueAt(selectrowindex, 2).toString());
        cmbtablet.setSelectedItem(tmodel.getValueAt(selectrowindex, 3).toString());
        cmbadvice.setSelectedItem(tmodel.getValueAt(selectrowindex, 4).toString());
        cmbbodycheckup.setSelectedItem(tmodel.getValueAt(selectrowindex, 5).toString());

    }//GEN-LAST:event_tblpackageMouseClicked

    private void getData()
    {
    
        name = txtpackagename.getText();
        hour = txthour.getText();
       
        
        milk = cmbmilk.getSelectedItem().toString();
        tablet = cmbtablet.getSelectedItem().toString();
        expert = cmbadvice.getSelectedItem().toString();
        body = cmbbodycheckup.getSelectedItem().toString();
        
    
    }
    private void clear()
    {
    
        txtpackagename.setText("");
        txthour.setText("");
        cmbmilk.setSelectedIndex(0);
        cmbtablet.setSelectedIndex(0);
        cmbadvice.setSelectedIndex(0);
        cmbbodycheckup.setSelectedIndex(0);
    
    
    }
     private void tablelord()
    {
        try {
            String sql="SELECT `name` as 'Package Name', `hours` as 'Hours', `milk` as 'Milk', `tablet` as 'Tablet', `expert` as 'Expert Advice', `body` as 'Body Checkup' FROM `package`";
            pst=conn.prepareStatement(sql);
            rs=pst.executeQuery();
            tblpackage.setModel(net.proteanit.sql.DbUtils.resultSetToTableModel(rs));
            clear();
            
        } catch (Exception e) {
            JOptionPane.showConfirmDialog(rootPane, e);
        }
      
    }
    private void clearData()
    {
    
        txtpackagename.setText("");
        txthour.setText("");
  
        cmbmilk.setSelectedIndex(0);
        cmbadvice.setSelectedIndex(0);
        cmbbodycheckup.setSelectedIndex(0);
        cmbtablet.setSelectedIndex(0);

    
    }

Payment Management Module

  Connection conn=null;
    PreparedStatement pst=null;
    ResultSet rs=null;
    String sqr;
    private String parseSql;
    String mid;
    String month;
    String pack;
    String amount;
    
    
    public Payment() {
        initComponents();
        conn=DBConnect.connect();
        tablelord();
        comboLoad();
    }

    
     private void tablelord()
    {
       // getData();
        try {
            String sql="SELECT `mid` as 'Member ID', `month` as 'Month', `package` as 'Package', `amount` as 'Amount', `date` as 'Date' FROM `payment`";
            pst=conn.prepareStatement(sql);
            rs=pst.executeQuery();
            tblpayment.setModel(net.proteanit.sql.DbUtils.resultSetToTableModel(rs));
            clear();
            
        } catch (Exception e) {
            JOptionPane.showConfirmDialog(rootPane, e);
        }
      
    }
    
     private void getData()
     {
     mid = txtmid.getText();
     month= cmbmonth.getSelectedItem().toString();
     pack = cmbpackage.getSelectedItem().toString();
     amount = txtamount.getText();
     
     }
     
     private void clear()
     {
     txtmid.setText("");
     txtamount.setText("");
     cmbmonth.setSelectedIndex(0);
     cmbpackage.setSelectedIndex(0);
     
     
     }
 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
       
         getData();
        try {
                String q= "INSERT INTO `payment`( `mid`, `month`, `package`, `amount`, `date`) VALUES ('"+mid+"','"+month+"','"+pack+"','"+amount+"','"+Home.getDate+"')";
                 pst=conn.prepareStatement(q);
                pst.execute(); 
                JOptionPane.showMessageDialog(rootPane,"Payment Recorded successfully");
                
                    } 
                catch (Exception e) 
                {
       
                 JOptionPane.showMessageDialog(rootPane,e);                    
                } 
        tablelord();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
       try {
            String sql="SELECT `mid` as 'Member ID', `month` as 'Month', `package` as 'Package', `amount` as 'Amount', `date` as 'Date' FROM `payment` where mid='"+txtmidsearch.getText()+"' and month = '"+cmbmonthsearch.getSelectedItem().toString()+"'";
            pst=conn.prepareStatement(sql);
            rs=pst.executeQuery();
            tblpayment.setModel(net.proteanit.sql.DbUtils.resultSetToTableModel(rs));
            clear();
            
        } catch (Exception e) {
            JOptionPane.showConfirmDialog(rootPane, e);
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void comboLoad()
    {
    
        try {
            
            String sql="SELECT `name` FROM `package`";
            pst=conn.prepareStatement(sql);
            rs=pst.executeQuery();
            while(rs.next())
            {
            
                cmbpackage.addItem(rs.getString("name"));
                
            
            }
            
        } catch (Exception e) {
        }
            
    
    }

What are the languages, technologies and platform used to develop this system?

  • Java programming language
  • Mysql database (wamp server)
  • Netbeans IDE

How to use this
You can download the complete project file and database using the below link.

The goals of providing this project:

  • To provide an example for students to develop their own projects.
  • helping people create their projects.
  • sharing knowledge and codes for educational purpose.

This project is not for:

  • You cannot use this project or project source codes for commercial purposes
  • You cannot re-upload this project or project source code to web internet or any kind of space.

Copyright © codeguid

Do you need help to remotely set up my any project on your machine or customize any project with your requirement please contact  syntech1994@gmail.com

Download Source codes

386 Downloads

Don’t Forget Subscribe Us

3 Comments

Leave a Reply

Your email address will not be published.


*