You are on page 1of 47

Bahria University,

Karachi Campus

Course: CSL-210
Object Oriented Programming Lab
Term: Spring 2020, Class: BSE- 2(B)

Project Report

Project Title:
GYM MANAGEMENT SYSTEM____

Submitted To:

Engr. Saniya Sarim

Signed: Remarks: Score:


[Project Report] [OOP Lab]

GYM MANAGEMENT
SYSTEM
BY
Usman Najeeb, Mustansar Gul, Muhammad Haris sarwar,
Hasnain Khalid

Page 4 of 50
[Project Report] [OOP Lab]

Table of Content

 Abstract ………………………………………………………. 06

 Project Overview …………………………………………….. 06

 Introduction ………………………………………………….. 07

 Background ………………………………………………….. 07

 Deccription …………………………………………….......... 07

 Functional or Specific Requirements ……………….. 09

 Code ………………………………...……………………… 10

 Database View ……………………………………………… 45

 Login Table…………….………………………….... 45

 Customer table ….……………….…………………. 45

 Equipment table….……………….………….……... 45

 Trianer Table….………………………….……….... 45

 Output …………………………………………………....... 46

 Conclusion …………………………………………………. 49

Abstract:

Page 5 of 50
[Project Report] [OOP Lab]
A system for managing a Gym. This system keeps track of employee salaries, inventory and
customer data along with billing. This is a fully equipped system that alone manages the entire functioning of a
hair salon. It maintains stock of inventory coming in. It also manages individual employee salary. The system is
even equipped to manage customer billing and data storage.

Project Overview:
Here’s a look at the benefits of a computerized gym management system:

 Appointments:
There’s no need to flip between pages, erasing and re-writing appointments or trying to decipher your
colleague’s handwriting.

Appointments systems are incredibly simple to use and you’ll have everything you need on one page to
keep your appointments organized and running smoothly. You can color code for even easier use and you
can add notes to specific appointments without running out of space.

 Client’s Records:
Handwritten client notes can be mislaid and make it easier for you to make mistakes. Computerized records
give you a detailed profile package for every client from past and present treatments to allergies and even how
they take their coffee.

 Gym equipments Control:


Running out of products is inconvenient and looks unprofessional. A stock control system is far quicker, less
complicated and more accurate than traditional stock taking methods. You’ll know exactly what stock you have
and which.

Introduction:

Page 6 of 49
[Project Report] [OOP Lab]
The gym management system focused on customer services that how it will be easy for the customer to just take
an appointment and then come so he do not worry about the time he just need to come and take the service this
is totally a digital method so you do not need to worry about the prices the prices are fix and we do not
overcharge you every employee have its id and also specialist in it work if he do work bad we also have an
option to delete the employee in our saloon the stocks are very good because the stock expiry date and no of
uses are all write comprised. We can add services update the services and many more things can done in this
Saloon Management System.

Background:
Being aware of the manual processes First it is very time consuming and this is also very bad for customer
relationship in previous we need to write in manually about the customer and employee but if the this will stole
then all the data leak. In some saloon the staff charge the customer very high because this is previous but we are
living in the latest century so the computerized thing is best for this. The Customer time also save by taking an
appointment some time when the customer come and need a service but saloon do not have products, stock but
in this system we do not worry about this all are done computerized so admin can easily check the stock and
add the stock.

Description:
The gym Management System aims at the Customer Services carried out in the Saloon by giving services to
Customer. There are two types of Services Appointment Services and Customer Intake.

In Appoint Services we can add Customer Name, Age, Contact no, Billing ID, especially Date and Time, also
have an option of in studio or not And the no of Services that customer want.

The other service is we can provide is Costumer intake Service. In Customer in take we can add customer
details like their Name, Age, Billing ID, Contact No and the no services they want like some customer want two
or more services.

These all work is done by Staff but admin can also access and preview the customer details.

In Admin aspect we need to login first we can add admin and also delete the previous admin. We can enter the
employee if the new staff comes in saloon that can be added by admin. Stock Update and Delete.

Page 7 of 49
[Project Report] [OOP Lab]
Employee Details Is very must when a new Employee come Admin can add Employee ID, Contact, First Name,
Last Name, Contact, Address, Salary And Their Gender Male/Female This will be save in our Database.

Admin can also delete the employee in this we need to add Employee ID, Contact, First Name, Last Name, and
Contact, Address and Salary and then simple press the delete button.

Admin Can also preview the staff detail in this admin simply need to add Customer name and their details
come.

If we need to change the Customer Address, Customer Contact or Salary Admin can also update the customer
details.

We can add new stock in stock table by entering Product ID, Product Name, ShelfLife, Manufacturer, Max
Uses, Quantity, Services Used In and Their Expiry Date.

Admin can delete the Stock too we need to add Product ID, Product Name, ShelfLife, Manufacturer, Max Uses,
Quantity, Services Used In and Their Expiry Date and then press the Delete Button.

Admin can view all the stock that is present in inventory.

Admin can also update the stock by entering The Product ID, Product Name, Quantity and Their Expiry Date.
Then press the update button.

Admin can also add the Services, Search the Services and Update the services.

In adding a new services panel admin just need to add Service ID , Service Name And their Services Charges
then Press the add button.

Admin Can also Search the services by entering service ID and then all the information about this service come.

Admin can update the service by entering service ID and Prep Charges.

Functional or Specific Requirements


Page 8 of 49
[Project Report] [OOP Lab]
This software is for managing computerized record of GYM. For this purpose the system should satisfy the
following requirement.

 Admin Aspects:

1) Add Admin
Add a new Admin.

2) Delete Admin
Delete the previous Admin.

3) Modify Stock
Addition, Deletion and also update the Stock.

4) Preview Customer
View the Customer Details.

 Staff end Aspects:

1) Making Appointments
Can make Appointments for Customers.

2) Add Customer Detail


Add Customer Details.

Code:
Page 9 of 49
[Project Report] [OOP Lab]

GYM
Signup:
package Gym;

import Gym_classes.Connection2DB;

public class Signup extends javax.swing.JFrame {

public Signup() {

initComponents();

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">

private void initComponents() {

jPanel1 = new javax.swing.JPanel();

jLabel2 = new javax.swing.JLabel();

jButton1 = new javax.swing.JButton();

jLabel3 = new javax.swing.JLabel();

jLabel5 = new javax.swing.JLabel();

id_txt = new javax.swing.JTextField();

pass_txt = new javax.swing.JTextField();

jButton2 = new javax.swing.JButton();

jLabel1 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jPanel1.setLayout(null);

jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

jLabel2.setText("Enter Username");

jPanel1.add(jLabel2);

jLabel2.setBounds(10, 100, 100, 14);

Page 10 of 49
[Project Report] [OOP Lab]
jButton1.setText("SignUp");

jButton1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

});

jPanel1.add(jButton1);

jButton1.setBounds(120, 150, 80, 23);

jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

jLabel3.setText("Enter Password");

jPanel1.add(jLabel3);

jLabel3.setBounds(10, 120, 87, 14);

jLabel5.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N

jLabel5.setText("ADMIN SIGNUP");

jPanel1.add(jLabel5);

jLabel5.setBounds(19, 0, 191, 28);

id_txt.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

id_txtActionPerformed(evt);

});

jPanel1.add(id_txt);

id_txt.setBounds(120, 90, 80, 20);

jPanel1.add(pass_txt);

pass_txt.setBounds(120, 120, 80, 20);

jButton2.setText("Back to Login");

jButton2.addActionListener(new java.awt.event.ActionListener() {

Page 11 of 49
[Project Report] [OOP Lab]
public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton2ActionPerformed(evt);

});

jPanel1.add(jButton2);

jButton2.setBounds(0, 240, 110, 23);

jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Gym/signup.png"))); // NOI18N

jPanel1.add(jLabel1);

jLabel1.setBounds(0, 30, 230, 230);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 228, Short.MAX_VALUE)

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE)

);

pack();

}// </editor-fold>

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

Connection2DB con=new Connection2DB();

con.Signup(id_txt.getText(),pass_txt.getText());

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

// TODO add your handling code here:

Page 12 of 49
[Project Report] [OOP Lab]
}

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

Logins log=new Logins();

log.setVisible(true);

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

/* Set the Nimbus look and feel */

//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">

/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.

* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html

*/

try {

for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {

if ("Nimbus".equals(info.getName())) {

javax.swing.UIManager.setLookAndFeel(info.getClassName());

break;

} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(Signup.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(Signup.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(Signup.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

Page 13 of 49
[Project Report] [OOP Lab]
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(Signup.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

//</editor-fold>

/* Create and display the form */

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new Signup().setVisible(true);

});

// Variables declaration - do not modify

private javax.swing.JTextField id_txt;

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel3;

private javax.swing.JLabel jLabel5;

private javax.swing.JPanel jPanel1;

private javax.swing.JTextField pass_txt;

// End of variables declaration

Logins:
package Gym;

Page 14 of 49
[Project Report] [OOP Lab]
import Gym_classes.Connection2DB;

public class Logins extends javax.swing.JFrame {

/**

* Creates new form Logins

*/

public Logins() {

initComponents();

setExtendedState(MAXIMIZED_BOTH);

/**

* This method is called from within the constructor to initialize the form.

* WARNING: Do NOT modify this code. The content of this method is always

* regenerated by the Form Editor.

*/

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">

private void initComponents() {

Login_btn = new javax.swing.JButton();

User_txt = new javax.swing.JTextField();

UserName_lbl = new javax.swing.JLabel();

Pass_lbl = new javax.swing.JLabel();

Pass_txt = new javax.swing.JPasswordField();

jLabel1 = new javax.swing.JLabel();

jButton1 = new javax.swing.JButton();

jLabel2 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

Page 15 of 49
[Project Report] [OOP Lab]
getContentPane().setLayout(null);

Login_btn.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

Login_btn.setText("LogIn");

Login_btn.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

Login_btnActionPerformed(evt);

});

getContentPane().add(Login_btn);

Login_btn.setBounds(210, 230, 80, 25);

getContentPane().add(User_txt);

User_txt.setBounds(200, 150, 97, 30);

UserName_lbl.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

UserName_lbl.setForeground(new java.awt.Color(51, 51, 255));

UserName_lbl.setText("User name");

getContentPane().add(UserName_lbl);

UserName_lbl.setBounds(60, 150, 73, 17);

Pass_lbl.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

Pass_lbl.setForeground(new java.awt.Color(51, 51, 255));

Pass_lbl.setText("Password");

getContentPane().add(Pass_lbl);

Pass_lbl.setBounds(60, 190, 67, 17);

getContentPane().add(Pass_txt);

Pass_txt.setBounds(200, 190, 97, 30);

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N

jLabel1.setForeground(new java.awt.Color(51, 51, 255));

Page 16 of 49
[Project Report] [OOP Lab]
jLabel1.setText("GYM Log In");

getContentPane().add(jLabel1);

jLabel1.setBounds(160, 0, 150, 70);

jButton1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N

jButton1.setText("SignUp");

jButton1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

});

getContentPane().add(jButton1);

jButton1.setBounds(210, 270, 80, 23);

jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Gym/Login.jpg"))); // NOI18N

getContentPane().add(jLabel2);

jLabel2.setBounds(0, -20, 480, 420);

pack();

}// </editor-fold>

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

// TODO add your handling code here:

Connection2DB con= new Connection2DB();

String mypass=String.valueOf(Pass_txt.getPassword());

if (con.matchPassword(User_txt.getText(), mypass)) {

HomePage home=new HomePage();

home.setVisible(true);

} else {

System.out.println("not matched");

Page 17 of 49
[Project Report] [OOP Lab]
}

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

Signup sign=new Signup();

sign.setVisible(true);

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

/* Set the Nimbus look and feel */

//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">

/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.

* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html

*/

try {

for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {

if ("Nimbus".equals(info.getName())) {

javax.swing.UIManager.setLookAndFeel(info.getClassName());

break;

} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(Logins.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(Logins.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(Logins.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

Page 18 of 49
[Project Report] [OOP Lab]
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(Logins.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

//</editor-fold>

/* Create and display the form */

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new Logins().setVisible(true);

});

// Variables declaration - do not modify

private javax.swing.JButton Login_btn;

private javax.swing.JLabel Pass_lbl;

private javax.swing.JPasswordField Pass_txt;

private javax.swing.JLabel UserName_lbl;

private javax.swing.JTextField User_txt;

private javax.swing.JButton jButton1;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel2;

// End of variables declaration

Homepage:
package Gym;

Page 19 of 49
[Project Report] [OOP Lab]

public class HomePage extends javax.swing.JFrame {

/**

* Creates new form HomePage

*/

public HomePage() {

initComponents();

setExtendedState(MAXIMIZED_BOTH);

/**

* This method is called from within the constructor to initialize the form.

* WARNING: Do NOT modify this code. The content of this method is always

* regenerated by the Form Editor.

*/

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">

private void initComponents() {

Customer_btn = new javax.swing.JButton();

trainer_btn = new javax.swing.JButton();

qequip_btn = new javax.swing.JButton();

jLabel2 = new javax.swing.JLabel();

jButton1 = new javax.swing.JButton();

jLabel1 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

getContentPane().setLayout(null);

Customer_btn.setBackground(new java.awt.Color(255, 255, 255));

Page 20 of 49
[Project Report] [OOP Lab]
Customer_btn.setText("CUSTOMER");

Customer_btn.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

Customer_btnActionPerformed(evt);

});

getContentPane().add(Customer_btn);

Customer_btn.setBounds(330, 160, 100, 30);

trainer_btn.setBackground(new java.awt.Color(255, 255, 255));

trainer_btn.setText(" TRAINER");

trainer_btn.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

trainer_btnActionPerformed(evt);

});

getContentPane().add(trainer_btn);

trainer_btn.setBounds(330, 190, 100, 30);

qequip_btn.setBackground(new java.awt.Color(255, 255, 255));

qequip_btn.setText("EQUIPMENT");

qequip_btn.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

qequip_btnActionPerformed(evt);

});

getContentPane().add(qequip_btn);

qequip_btn.setBounds(330, 220, 100, 30);

jLabel2.setFont(new java.awt.Font("Tahoma", 1, 48)); // NOI18N

Page 21 of 49
[Project Report] [OOP Lab]
jLabel2.setForeground(new java.awt.Color(255, 255, 255));

jLabel2.setText("GYM MANAGEMENT SYTEM");

getContentPane().add(jLabel2);

jLabel2.setBounds(70, 10, 690, 70);

jButton1.setBackground(new java.awt.Color(255, 255, 255));

jButton1.setText("BACK");

jButton1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

});

getContentPane().add(jButton1);

jButton1.setBounds(330, 270, 100, 20);

jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Gym/bg4.jpg"))); // NOI18N

getContentPane().add(jLabel1);

jLabel1.setBounds(4, 4, 820, 490);

pack();

}// </editor-fold>

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

Equipment e=new Equipment();

e.setVisible(true);

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

Customer c=new Customer();

c.setVisible(true);

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

Page 22 of 49
[Project Report] [OOP Lab]
Trainer t=new Trainer();

t.setVisible(true);

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

Logins l=new Logins();

l.setVisible(true);

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

/* Set the Nimbus look and feel */

//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">

/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.

* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html

*/

try {

for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {

if ("Nimbus".equals(info.getName())) {

javax.swing.UIManager.setLookAndFeel(info.getClassName());

break;

} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(HomePage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(HomePage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

Page 23 of 49
[Project Report] [OOP Lab]
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(HomePage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(HomePage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

//</editor-fold>

/* Create and display the form */

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new HomePage().setVisible(true);

});

// Variables declaration - do not modify

private javax.swing.JButton Customer_btn;

private javax.swing.JButton jButton1;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel2;

private javax.swing.JButton qequip_btn;

private javax.swing.JButton trainer_btn;

// End of variables declaration

GYM CLASSES
Connection2DB:

Page 24 of 49
[Project Report] [OOP Lab]
package Gym_classes;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.Statement;

import javax.swing.JOptionPane;

public class Connection2DB {

//Settingup Connection

public Connection setConnection(){

String dataSourceName="database/Database2.accdb";

String dir = System.getProperty("user.dir"); //project directory

String url = "jdbc:ucanaccess://"+dir+"/" + dataSourceName;

Connection con=null;

try {

con = DriverManager.getConnection(url);

catch(Exception sqlEx){

System.out.println(sqlEx);

return con;

public boolean matchPassword(String user, String pass){

boolean successful =false;

Page 25 of 49
[Project Report] [OOP Lab]
try {

Connection con=setConnection();

Statement st = con.createStatement();

String sql = "select * from Login_Table where Username = '"+user+"'";

ResultSet rs = st.executeQuery(sql);

while(rs.next()){

String userName = rs.getString("Username");

String password = rs.getString("Password");

if(user.equals(userName) && pass.equals(password))

successful = true;

else

successful = false;

con.close();

catch(Exception sqlEx){

System.out.println(sqlEx);

return successful;

// SIGNUP

public void Signup(String username,String pass) {

PreparedStatement pst = null;

try {

Connection con=setConnection();

String sql = "Insert into Login_Table(Username,Password) values(?,?)";

pst = con.prepareStatement(sql);

Page 26 of 49
[Project Report] [OOP Lab]
pst.setString(1,username);

pst.setString(2, pass);

pst.execute();

JOptionPane.showMessageDialog(null, "saved");

} catch (Exception e) {

JOptionPane.showMessageDialog(null, e);

Customer-c:
package Gym_classes;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import javax.swing.JOptionPane;

import javax.swing.JTable;

import net.proteanit.sql.DbUtils;

public class Customer_c extends Person {

//Fields Declaration

Connection2DB conn = new Connection2DB();

Connection con = conn.setConnection();

private String fees;

private String trainer;

private String MemberShip;

private String MemberShipExp;

Page 27 of 49
[Project Report] [OOP Lab]
//Constructor to initialize fields

public Customer_c(String fees, String trainer, String name, String NIC, String Age, String Address, String Gender,
String mobile_num, String time,String jdate,String expdate) {

super( name, NIC, Age, Address, Gender, mobile_num, time);

this.fees = fees;

this.trainer = trainer;

this.MemberShip = jdate;

this.MemberShipExp = expdate;

public Customer_c() {

//Getters for attributes

public String getFees() {

return fees;

public String getTrainer() {

return trainer;

public String getMemberShip() {

return MemberShip;

public String getMemberShipExp() {

return MemberShipExp;

// ADD METHOD

public void add() {

PreparedStatement pst = null;

try {

Page 28 of 49
[Project Report] [OOP Lab]
String sql = "Insert into
CustomerTable(Name,NIC,Age,Address,Gender,MobileNo,Fees,Trainer,Timing,MemberShip_Date,MemberShip_Exp)
values (?,?,?,?,?,?,?,?,?,?,?)";

pst = con.prepareStatement(sql);

pst.setString(1, getName());

pst.setString(2, getNIC());

pst.setString(3, getAge());

pst.setString(4, getAddress());

pst.setString(5, getGender());

pst.setString(6, getMobile_num());

pst.setString(7, getFees());

pst.setString(8, getTrainer());

pst.setString(9, getTime());

pst.setString(10,getMemberShip());

pst.setString(11, getMemberShipExp());

pst.execute();

JOptionPane.showMessageDialog(null, "saved");

} catch (Exception e) {

JOptionPane.showMessageDialog(null, e);

//DELETE METHOD

public boolean del(String id) {

boolean del = false;

try {

String sql = "delete from CustomerTable where ID=?";

PreparedStatement pst = con.prepareStatement(sql);

pst.setString(1, id);

Page 29 of 49
[Project Report] [OOP Lab]
pst.execute();

JOptionPane.showMessageDialog(null, "DLETED");

del = true;

} catch (Exception e) {

JOptionPane.showMessageDialog(null, e);

return del;

// SEARCH METHOD

public boolean search(JTable table, String search, String select) {

boolean found = false;

ResultSet rs = null;

try {

PreparedStatement pst = null;

String sql = "select * from CustomerTable where " + select + "=?";

pst = con.prepareStatement(sql);

pst.setString(1, search);

rs = pst.executeQuery();

table.setModel(DbUtils.resultSetToTableModel(rs));// nahi pata mere khayal may table ko values show kra rha hai

found = true;

} catch (Exception e) {

JOptionPane.showMessageDialog(null, e);

return found;

//UPDATE METHOD

public boolean update(String id, String name, String nic, String age, String address, String gender, String mobno, String
fees, String timing, String trainer) {

Page 30 of 49
[Project Report] [OOP Lab]
boolean update = false;

try {

String sql = "update CustomerTable set Name='" + name + "',NIC='" + nic + "',Age='" + age + "',Address='" +
address + "',Gender='" + gender + "',MobileNo='" + mobno + "',Fees='" + fees + "',Timing='" + timing + "',Trainer='" +
trainer + "' where id='" + id + "'";

PreparedStatement pst = con.prepareStatement(sql);

pst.execute();

update = true;

JOptionPane.showMessageDialog(null, "Updated");

} catch (Exception e) {

JOptionPane.showMessageDialog(null, e);

return update;

//SHOW METHOD

public void showDetail(JTable table) {

try {

String sql = "select * from CustomerTable ";

PreparedStatement pst = con.prepareStatement(sql);

ResultSet rs = pst.executeQuery();

table.setModel(DbUtils.resultSetToTableModel(rs));

} catch (Exception e) {

JOptionPane.showMessageDialog(null, e);

public String trainer(){

String name=null;

Page 31 of 49
[Project Report] [OOP Lab]
try {

String sql="select Name from TrainerTable ";

PreparedStatement pst=con.prepareStatement(sql);

ResultSet rs=pst.executeQuery();

while(rs.next()){

name=rs.getString("Name");

} catch (Exception e) {

JOptionPane.showMessageDialog(null,e);

return name;

Equipment-c:
package Gym_classes;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import javax.swing.JOptionPane;

import javax.swing.JTable;

import net.proteanit.sql.DbUtils;

public class Equipment_c {

Connection2DB conn = new Connection2DB();

Connection con = conn.setConnection();

private String ID;

Page 32 of 49
[Project Report] [OOP Lab]
private String name;

private String Quantity;

private String perprice;

private String totalprice;

private String date;

public Equipment_c() {

public Equipment_c( String name, String Quantity, String perprice, String totalprice, String date) {

this.name = name;

this.Quantity = Quantity;

this.perprice = perprice;

this.totalprice = totalprice;

this.date = date;

public String getID() {

return ID;

public String getName() {

return name;

public String getQuantity() {

return Quantity;

public String getPerprice() {

return perprice;

public String getTotalprice() {

Page 33 of 49
[Project Report] [OOP Lab]
return totalprice;

public String getDate() {

return date;

//ADD METHOD

public void add() {

PreparedStatement pst = null;

try {

String sql = "Insert into EquipmentTable(Name,Quantity,PricePerQuantity,TotalPrice,Date) values (?,?,?,?,?)";

pst = con.prepareStatement(sql);

pst.setString(1, getName());

pst.setString(2, getQuantity());

pst.setString(3, getPerprice());

pst.setString(4, getTotalprice());

pst.setString(5, getDate());

pst.execute();

JOptionPane.showMessageDialog(null, "saved");

} catch (Exception e) {

JOptionPane.showMessageDialog(null, e);

//DELETE METHOD

public boolean del(String id) {

boolean del = false;

Page 34 of 49
[Project Report] [OOP Lab]
PreparedStatement pst = null;

try {

String sql = "delete from EquipmentTable where ID=?";

pst = con.prepareStatement(sql);

pst.setString(1, id);

pst.execute();

JOptionPane.showMessageDialog(null, "DLETED");

del = true;

} catch (Exception e) {

return del;

// SEARCH METHOD

public boolean search(JTable table, String search, String select) {

boolean found = false;

ResultSet rs = null;

try {

PreparedStatement pst = null;

String sql = "select * from EquipmentTable where " + select + "=?";

pst = con.prepareStatement(sql);

pst.setString(1, search);

rs = pst.executeQuery();

table.setModel(DbUtils.resultSetToTableModel(rs));// nahi pata mere khayal may table ko values show kra rha hai

found = true;

} catch (Exception e) {

JOptionPane.showMessageDialog(null, e);

Page 35 of 49
[Project Report] [OOP Lab]
}

return found;

//UPDATE METHOD

public boolean update(String id, String name, String quantity, String PriceperQuantity, String totalPrice, String date) {

boolean update = false;

try {

String sql = "update EquipmentTable set Name='" + name + "',Quantity='" + quantity + "',PricePerQuantity='" +
PriceperQuantity + "',TotalPrice='" + totalPrice + "',Date='" + date + "' where id='" + id + "'";

PreparedStatement pst = con.prepareStatement(sql);

pst.execute();

update = true;

JOptionPane.showMessageDialog(null, "Updated");

} catch (Exception e) {

JOptionPane.showMessageDialog(null, e);

return update;

//SHOWDETAILS METHOD

public void showDetail(JTable table) {

try {

String sql = "select * from EquipmentTable ";

PreparedStatement pst = con.prepareStatement(sql);

ResultSet rs = pst.executeQuery();

table.setModel(DbUtils.resultSetToTableModel(rs));

} catch (Exception e) {

Page 36 of 49
[Project Report] [OOP Lab]
JOptionPane.showMessageDialog(null, e);

//Calculation method

public String cal(int quantity, int PerpriceQ) {

int result = quantity * PerpriceQ;

String Result = Integer.toString(result);

return Result;

Trainer-c:
package Gym_classes;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import javax.swing.JOptionPane;

import javax.swing.JTable;

import net.proteanit.sql.DbUtils;

public class Trainer_c extends Person {

Connection2DB conn = new Connection2DB();

Connection con = conn.setConnection();

private String Salary;

public Trainer_c() {

Page 37 of 49
[Project Report] [OOP Lab]
public Trainer_c( String name, String NIC, String Age, String Address, String Gender, String mobile_num, String
Salary, String time) {

super( name, NIC, Age, Address, Gender, mobile_num, time);

this.Salary = Salary;

public String getSalary() {

return Salary;

// ADD METHOD

public void add() {

PreparedStatement pst = null;

try {

String sql = "Insert into TrainerTable(Name,NIC,Age,Address,Gender,Mobileno,Salary,Timing) values


(?,?,?,?,?,?,?,?)";

pst = con.prepareStatement(sql);

pst.setString(1, getName());

pst.setString(2, getNIC());

pst.setString(3, getAge());

pst.setString(4, getAddress());

pst.setString(5, getGender());

pst.setString(6, getMobile_num());

pst.setString(7, getSalary());

pst.setString(8, getTime());

pst.execute();

JOptionPane.showMessageDialog(null, "saved");

} catch (Exception e) {

JOptionPane.showMessageDialog(null, e);

Page 38 of 49
[Project Report] [OOP Lab]
}

//DELETE METHOD

public boolean del(String id) {

boolean del = false;

try {

String sql = "delete from TrainerTable where ID=?";

PreparedStatement pst = con.prepareStatement(sql);

pst.setString(1, id);

pst.execute();

JOptionPane.showMessageDialog(null, "DLETED");

del = true;

} catch (Exception e) {

return del;

// SEARCH METHOD

public boolean search(JTable table, String search, String select) {

boolean found = false;

ResultSet rs = null;

try {

PreparedStatement pst = null;

String sql = "select * from TrainerTable where " + select + "=?";

pst = con.prepareStatement(sql);

pst.setString(1, search);

Page 39 of 49
[Project Report] [OOP Lab]
rs = pst.executeQuery();

table.setModel(DbUtils.resultSetToTableModel(rs));

found = true;

} catch (Exception e) {

JOptionPane.showMessageDialog(null, e);

return found;

//UPDATE METHOD

public boolean update(String id, String name, String nic, String age, String address, String gender, String mobno, String
Salary, String timing) {

boolean update = false;

try {

String sql = "update TrainerTable set Name='" + name + "',NIC='" + nic + "',Age='" + age + "',Address='" +
address + "',Gender='" + gender + "',MobileNo='" + mobno + "',Salary='" + Salary + "',Timing='" + timing + "' where
id='" + id + "'";

PreparedStatement pst = con.prepareStatement(sql);

pst.execute();

update = true;

JOptionPane.showMessageDialog(null, "Updated");

} catch (Exception e) {

JOptionPane.showMessageDialog(null, e);

return update;

public void showDetail(JTable table) {

try {
Page 40 of 49
[Project Report] [OOP Lab]
String sql = "select * from TrainerTable ";

PreparedStatement pst = con.prepareStatement(sql);

ResultSet rs = pst.executeQuery();

table.setModel(DbUtils.resultSetToTableModel(rs));

} catch (Exception e) {

JOptionPane.showMessageDialog(null, e);

Person:
package Gym_classes;

import javax.swing.JTable;

import net.proteanit.sql.DbUtils;

public abstract class Person {

private String name,NIC,Age,Address,Gender,mobile_num,time;

public Person(String name, String NIC, String Age, String Address, String Gender, String mobile_num, String time) {

this.name = name;

this.NIC = NIC;

this.Age = Age;

this.Address = Address;

this.Gender = Gender;

this.mobile_num = mobile_num;

this.time=time;

public Person() {

Page 41 of 49
[Project Report] [OOP Lab]
public String getName() {

return name;

public String getNIC() {

return NIC;

public String getAge() {

return Age;

public String getAddress() {

return Address;

public String getGender() {

return Gender;

public String getMobile_num() {

return mobile_num;

public String getTime() {

return time;

public abstract void add();

public abstract boolean search(JTable table,String select,String name);

public abstract boolean del(String id);

Receipt:
package Gym_classes;

Page 42 of 49
[Project Report] [OOP Lab]

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import javax.swing.JOptionPane;

import javax.swing.JTextField;

public class Receipt {

JTextField id;

JTextField name;

JTextField fees;

JTextField trainer;

Connection2DB conn = new Connection2DB();

Connection con = conn.setConnection();

public Receipt(JTextField id, JTextField name, JTextField fees, JTextField trainer) {

this.id = id;

this.name = name;

this.fees =fees;

this.trainer = trainer;

public void bill(String ID)

ResultSet rs;

try{ PreparedStatement pst =null;

String sql="select [ID],[Name],[Fees],[Trainer] from CustomerTable where ID='"+ID+"'";

Page 43 of 49
[Project Report] [OOP Lab]
pst=con.prepareStatement(sql);

rs=pst.executeQuery();

while(rs.next()){

String add1=rs.getString("Name");

name.setText(add1);

String add2=rs.getString("Fees");

fees.setText(add2);

String add3=rs.getString("Trainer");

trainer.setText(add3);

catch (Exception e){

JOptionPane.showMessageDialog(null, e);

Database View:

Page 44 of 49
[Project Report] [OOP Lab]

Login Table

Customer Table:

Equipment Table:

Trainer Table:

Output:

Page 45 of 49
[Project Report] [OOP Lab]

Page 46 of 49
[Project Report] [OOP Lab]

Page 47 of 49
[Project Report] [OOP Lab]

Page 48 of 49
[Project Report] [OOP Lab]

Conclusion:
Our intention to build a gym management system turned into an extreme level of curiosity when we were given
confidence by our teachers in creating such a system which could really solve real world problems and we had a
very common problem spotted in our minds regarding the topic of our project, it was really amazing to drive
solutions for a real world problem so that it can be easily tackled.

References
https://www.academia.edu/RegisterToDownload#Institution

https://www.academia.edu/26750275/Project_report_on_gym_management_system_proje
ct

https://www.w3schools.com/

Page 49 of 49

You might also like