Sie sind auf Seite 1von 120

1.

Introduction
1.1 Overview of Project
1.2 Objectives
1.3 Modules
1.4 Architecture and Design of the project

2. Literature Survey
2.1 Existing System
2.1.1 Drawbacks of Existing System
2.2 Proposed System
2.2.1 Merits of Proposed System
2.3 Overview of Language used
2.3.1 Introduction of Microsoft Visual Basic 6.0
2.3.1.1 The Programming Process
2.3.1.2 Understanding Program Maintenance
2.3.1.3 Visual Basic is a Smart Language
2.3.1.4 Tool Box Control
2.3.1.5 Adding Control
2.3.1.6 Removing Control
2.3.1.7 Intrinsic Control
2.3.1.8 Label Control
2.3.1.9 Command Bottom
2.3.1.10 Text Control
2.3.1.11 what does VB 6.0 has
2.3.1.12 Visual Basic with Databases
2.3.1.13 Active X Data Object Components
2.3.2 Introduction of MS Access 2003

3. Requirement Analysis
3.1 Role of SRS
3.2 Aim
3.3 Purpose
3.4 Scope
3.5 Application Requirements
3.6 Hardware Requirements
3.7 Functional Requirements
3.7.1 Administrator Functional Requirements
3.8 Non-Functional Requirements
3.8.1 Reliability
3.8.2 Usability
3.8.3 Maintainability
3.8.4 Performance

5
4. Design
4.1 Data Flow Diagram Notations
4.2 Context Diagram
4.3 Low Level DFD
4.3.1 Level1 DFD Admin
4.3.2 Level1 DFD User
4.4 High Level DFD
4.4.1 Level2 DFD User
4.4.2 Level2 DFD Admin
4.5 Entity-Relationship Diagram
4.6 Module Design
4.6.1
4.6.2
4.6.3
4.6.4
4.7 Database Design
4.7.1 Introduction to Database Design
4.7.2 Tables Created

5. Coding

6. Testing
6.1 Introduction to Testing
6.1.1 White Box Testing
6.1.2 Black Box Testing
6.1.3 Application Strategies
6.1.4 Unit Testing
6.1.5 Integration Testing
6.1.6 Validation Testing
6.1.7 System Testing
6.2 Multi-User System
6.3 Testing Results

7. Conclusion

8. Future Enhancement

9. Bibliography

10. User Manual


10.1 Screen Shots

6
Chapter 1

Introduction

We all know health is a wealth. We do not need a fancy car, big apartment, a
doctor degree without a health. Being healthy is a first thing we need to keep
in mind. Because most of time our attitude depends on how we feel. Being
healthy and fit gives us energy to do anything. So how do we stay fit? Be
7
active, eat green and hit a gym!

Physical fitness is very necessary for a healthy and tension free life. Physical
fitness includes diet, exercise and sleep. These three basic things have their
own importance in each individual's life and everyone should be sensible
with regard to these for a healthy life.

1.1 Overview of Project

Our proposed Smart Gym System is for those who runs a gym business. Before doing
anything we did a decent research on major difficulties for gym owners. We examined carefully
about how to make a huge registering system without failure as well as different functions for
different kind of user depending on their privilege.

Objectives
First thing we wanted to do in designing is avoid boring formal user interface. So we tried to
develop modern graphic user interface system. This application is for gym owners as well as for
their staffs to register new member, and take body measurements and see the reports of financial
and individual body progress. To use features of our application user has to enter password and
username. If you want to visit and make changes in admin panel you have to unlock the admin
panel by typing password in it. In the admin panel admin able to create username with password,
set privilege to groups which means which user can do what operations like see report, take
measurement etc. Also admin able to create groups and membership plans and apply it.

8
1.3 Modules:

Administrator Module

This module includes storing and retrieving the details of the data. The detail of the
entertainment which is stored is categorized into different types like:

Creating user
Admin can create an user along with password. Admin also able to put a user in a
particular groups.

Creating group
Create a group and set privilege for it. It includes read, read/write, read/write/delete
permissions.

Creating membership plan


Create a flexible membership plans for gym members. Plans can be various depending on
member needs.

User Module

Depends on the privilege users access to features of the application is granted.

1.4 Architecture and Design of the project

9
The application will be made of Desktop based distributed two-tier architecture to
support user entertainment at the same time.

10
DFD LEVEL-0: CONTEXT DIAGRAM :

11
12
Chapter 2

Literature Survey

Everything on the earth either living or non-living has an evolution cycle. Like scientist has
proved that human has completed an evolution cycle from ape to man. In same manner the
computer has an evolution cycle, as technology is improving the computers are becoming more
and more efficient. Similarly as the computer architecture is improving day by day, it also
requires upgrading the previous systems accordingly.

13
As we have developed this application for the first time. Similar applications of different
companies are present in the market and we tried to study those, a brief discussion was carried
out with the project guide to know more details about existing system. After discussion the
various deficiencies in the system was identified these points are noted down and discussed with
project guide again and decide where to make modification over existing system.

Since we are implementing our application in the new envoirnment and using the present
technologies so as to make it more efficient, there was a need to understand the applications
environment and also about the new technologies. And while implementing the application
various thing has been taken into consideration like application will also be usable for those end
users who dont understand english.

2.1 Existing System

An Existing system refers to the system that is being followed till now. Presently all the resume
Functionalities are done manually. This is making the person very difficult to keep track of the
client and the members in the job seeker.

2.1.1 Drawbacks of Existing System


a. Time consuming.
b. Updating and Retrieval tasks are very tedious.
c. Highly error prone.
d. Easy Customer service is difficult.
e. Lot of paper work results in lot of confusion.
f. No direct role for the higher officials.
To avoid all these limitations and make the system working more accurately it needs to be
computerized.

2.2 Proposed System

14
The online mobile shopping application is user-friendly application. Most of the information
about different brand of latest mobile to the customer who wants to know the details and want to
buy. It is very simple in design and to implement. The system requirements are very low.
System resources and the system will work in almost all configurations.

The main objectives of the proposed system can be enumerated as follows:


a. Customer can easily search different brand of mobile.
b. Customer can also search according to price.
c. User can register and buy that particular product.

2.2.1 Merits of Proposed System


The system is very simple in design and to implement. The system requires
Very low system resources and the system will work in almost all
Configurations
a. Security of data
b. Ensure data accuracy
c. Administrator controls the entire system
d. Reduce the damages of the machines
e. Minimize manual data entry
f. Greater efficiency
g. User friendly and interactive
h. Saves lot of time
i. Retrieval and Updating tasks can be performed much faster and easier

2.3 Overview of languages used

2.3.1 Introduction to MICROSOFT VISUAL BASIC 6.0

Visual Basic 6 is Microsoft's latest and greatest version of the Visual Basic programming
language. Although writing programs can be a tedious chore at times, Visual Basic reduces the

15
effort required on your part and makes programming enjoyable. Visual Basic makes many
aspects of programming as simple as dragging graphic objects onto the screen with your mouse.

Microsoft based Visual Basic on a programming language written for beginners called BASIC.

BASIC has been around for more than 35 years in one form or another. The original language
designers wanted to develop a programming language that beginners could use. With BASIC,
new programmers could become proficient right away.

BASIC stands for Beginner's All-purpose Symbolic Instruction Code. That's some abbreviation!

A programming language is a set of commands and command options, called arguments, that
you use to give instructions to the computer. Computers cannot (yet) understand human
languages because people deal well with ambiguous commands, and a computer cannot
understand such ambiguity. A programming language must be more precise than a spoken
language.

2.3.1.1 The Programming Process

Over time you'll find your own way of writing programs that works best for you. Nevertheless,
you'll generally follow these standard set of steps when creating your Visual Basic programs:

1. Decide what your application is to do by creating an overall design.

2. Create the visual portion of your application (the screens and menus that your users will
interact with).

3. Add Visual Basic programming language code to tie the visual elements together and to
automate the program.

4. Test your application to locate and remove any bugs you find.

5. Compile your tested application and distribute the compiled application to your users.

2.3.1.2 Understanding Program Maintenance

Bugs are not the only reason that you will work on a program after you think you're completely
done with it. Program maintenance is necessary because requirements change, companies
change, and laws change. You must also change the programs you write so that they remain

16
viable programs; you will need to update your program periodically to reflect changes that
impact the program. In addition, users will think of new things that they want the program to do.

Program maintenance is the term used for the updating of a program after the program is put into
use. This update may be a result of a user's request or a change in the way the program needs to
operate.

It is said that a program is written once and modified many times. The more program
maintenance you perform, the more likely that your program will be up-to-date and in use. You
may want to release new versions of your program so that users can, with a different version
number on the opening screen that you place there, keep track of the latest version installed on
their system.

2.3.1.3 Visual Basic Is a Smart Language

The main reason why Visual Basic is so popular and powerful is the same reason behind the
success of Windows. Microsoft took a complex technology (writing computer programs) and
made it easier to use through a graphical interface. Suppose you have to write a program for your
company. In a visual programming environment, you can quickly design the windows that the
user sees by drawing and arranging them just as you would lay out elements for a newspaper.

In a text-based programming system, you control the user interface through program language
commands. Common sense tells you that the visual programming method is easier for
newcomers to learn and requires less time to maintain. In this case, the old adage a picture is
worth a thousand words truly applies. However, do not let me give you the impression that
Visual Basic is just another pretty interface.

Another key concept of Visual Basic is the ability to create and use self-contained components,
or objects.

2.3.1.4 Tool Box Controls

The toolbox contains all the custom control needed for a visual basic application .several
advanced controls can be added to the project from the menu bar tool, Project Components.
Each control has its own properties, Events and methods. The properties of the controls can be
set either through code or in the properties window, user defined controls can also be created
and added to the tool box. Controls work with multimedia and internet too.

2.3.1.5 Adding controls

Controls can be added to a form in two ways:

*Double-click on a control in the toolbox and it appears on the form.


17
*Click on the control icon. Move the mouse over the form, click and draw the control to the
required size.

2.3.1.6 Removing controls

To remove a control from the form

*Select the control.

*Press the delete key.

Controls can be placed anywhere on the form. Their size can be changed by using the sizing
handle which appear when a control in selected.

2.3.1.7 Intrinsic controls

The default controls which are automatically displayed in a toolbox when a form is loaded are
known as intrinsic controls. The intrinsic controls in visual basic are very powerful, since objects
such as buttons, labels, text boxes, and combo or list boxes can be added to a form easily and
coded.

Some common intrinsic controls which are described below are:

1. Label

2. Command button

3. Text box

4. Frame

5. Option button

6. Check box

7. Picture box

8. Inage box

9. Timer

10. Combo box

11. List box

12. Horizontal & vertical scroll box

13. Shape and line


18
14. OLE

2.3.1.8 Label

Label control allows the user to display text on a form, which does not change. For example

Label1.caption=Name;

Generally labels are used to print captions for other controls. Text printed on labels cannot be
edited during runtime.

2.3.1.9 Command buttons

Commands buttons is one of the most powerful and frequently used controls in windows
application. It is used to invoke response from the user or to invoke special functions on the
form.

2.3.1.10 Textbox control

Textbox control is one of the most popular and versatile mechanism used to display and enters
text in a window user interface. It behaves like a mini text editor providing all the basic text
editing facilities.

Basic text properties

The basic properties of a textbox determine the appearance and functionality of a textbox
control. Some of them are as described below:

Enabled: Indicates whether the user can interact with the control or not.

Index: Determine the control array index.

Locked: Boolean. Indicates whether the user can type in the textbox or not.

Max Length: Indicates the maximum number of characters input in the textbox. Default values
are 0, which means any number of characters. The maximum of text can be typed in a textbox is
nearly 64 kb.

Max length property can be set to a specific value restricting the user to type only that many
character.

Multi Line: Specifies whether the textbox will hold a single line or multiple lines.

Password char: Specifies the masking character for text displayed in the textbox. Suppose the
password is set to *, the user than sees an asterisk in the place of every character typed in that
textbox.

19
Scrollbars: Indicates horizontal scrollbars, vertical scrollbars or both for the textbox. This
property is used with multiline property. Multiline textboxes can have horizontal, vertical or both
scroll bars. If a horizontal scrollbar is attached to a text box, the text will not wrap automatically.
The user must press enter to start new line.

Text: Specifies the text in the textbox.

Alignment: Alignment of text in a textbox can be Left-justified, centered or right-justified.

SelText: Returns the selected text. A selected text can be converted to uppercase by the
following code:

Text1. SelText= Ucase(Text1.SelText)

SelStart: Specifies the position of the first character of the selected text.

SetLength: Returns the length of the selected text. The most common use of these properties is

to select a piece of text at runtime to select the text in a textbox.

Text1.selstart=1

Text1.selLength=Len (Text1)

Click: Click event is called when the text box is clicked with the mouse.

Key press: Occurs every time a key is pressed and stores the ASCII code of the key pressed in
keyASCII(an integer type). This event can be used to restrict the user to type only certain
characters.

Controls are elements you can use when designing a user interface.

Visual Basic controls enable you to add features to your programs without you having to be
involved in the details of how these features work. For example, receiving input from a user of
your program is as simple as drawing a control that accepts input. This is a great advantage of
visual programming languagesyou can concentrate on what you want your program to do, not
how to get the programming language to do it.

2.3.1.11 What does VB 6.0 have.

Just about everything we could write about Visual Basic is, from language reference to ADO
database handling, from creating Web browsers to dragging and dropping data across
applications, from email applications to multimedia players, from creating ActiveX controls and
ActiveX

20
Documents to setup programs, its all here.

Heres some of what well see:

ActiveX controls

ActiveX documents

ADO, DAO, and RDO database applications

Multimedia AVI, MPG, WAV, and MID players

CD players that play CDs from the computers CD-ROM drive

Bitmapped menu items

Full Web browsers

Pie charts, line charts, bar charts, and others

Code clients that call methods in programs like Microsoft Excel

Code components (OLE automation servers)

Graphics animation

Applications that use the Windows Common Dialogs

Customized toolbars with embedded controls like combo boxes

Data entry forms

Database editing applications

Direct connections to the Windows API

Direct connections to code written in Visual C++

Drag/drop operations

Graphics applications that draw arcs, circles, rectangles, lines, and more

Email applications

Error handlers

Applications that use the printer

Word processor applications

21
File handlers for text and binary data

FTP applications

Dialog boxes

Windows Help files

MDI applications

Pop-up menus activated with right mouse clicks

Application deployment

HTTP applications

Image handling: blur, emboss, engrave, flip, sweep, stretch images, and more

OLE applications

Applications that use the Windows Registry

List views and tree views

Applications that create controls at runtime

Mouse capture

OLE drags (dragging data between applications)

Online user registration

Picture clip applications

Setup programs

Screen capture

Spreadsheets

Status bars and toolbars

Tab strips, progress bars, and others

2.3.1.12 Visual Basic with Databases


A database is a collection of information. This information is stored in a very structured
manner. By exploiting this known structure, we can access and modify the information quickly
and correctly.

22
For database management, Visual Basic application acts as a front-end to the database. This
means the Visual Basic application provides the interface between the user and the database.
This interface allows the user to tell the database what he or she needs and allows the database to
respond to the request displaying the requested information in some manner.

A Visual Basic application cannot directly interact with a database. There are two intermediate
components between the application and the database: the data control and the database
engine:
The data control is a Visual Basic object that connects the application to the database via
the database engine. It is the conduit between the application and the engine, passing information
back and forth between the two.

The database engine is the heart of a Visual Basic database management system. It is
the actual application that does the management. Having this engine saves programmers a lot of
work. The database engine native to Visual Basic is known as the Jet engine. It is the same
engine used by Microsoft Access for database management. Hence, it is primarily used to
work with Access databases, but it can also work with others.

2.3.1.13 ActiveX Data Object Components


The first step in editing an ADO database is to open that database, which is called a data source
in ADO terminology, by setting up a Connection object.

23
To use that and other ADO objects in code, use the Project|References item, select the
Microsoft ActiveX Data Objects Library item, and click on OK, adding the ADO Object Library
to your program.

Now create a new ADO Connection object with the Connection objects Open method:
Here are the arguments for this method:
Connection StringString containing connection information.
UserIDString containing a username to use when establishing the connection.
PasswordString containing a password to use when establishing the connection.
OpenOptionsif set to adConnectAsync, the connection will be opened asynchronously.

Here are the possible values for the Type argument:


dbOpenKeysetOpens a dynaset-type Recordset object, which is like an ODBC keyset
cursor.
dbOpenDynamicOpens a dynamic-type Recordset object, which lets the application see
changes made by other users.
dbOpenStaticOpens a static-type Recordset object.
dbOpenForwardOnlyOpens a forward-only-type Recordset object, where you can only use
MoveNext to move.

Here are the possible values for the LockType argument:


AdLockReadOnlyThe default; read-only.
adLockPessimisticPessimistic locking, record by record.
adLockOptimisticOptimistic locking, record by record.
adLockBatchOptimisticOptimistic batch updates.

Here are the possible values for the Options argument:


adCmdTextProvider should evaluate Source as a definition of a command.
adCmdTableADO should generate an SQL query to return all rows from the table named in
Source.
adCmdTableDirectProvider should return all rows from the table named in Source.
adCmdStoredProcProvider should evaluate Source as a stored procedure.
adCmdUnknownType of command in the Source argument is not known.
adCommandFileRecord set should be restored from the file named in Source.
adExecuteAsyncSource should be executed asynchronously.
adFetchAsyncAfter the initial quantity specified in the CacheSize property is fetched, any
remaining rows should be fetched asynchronously.

2.3.2 Introduction of MS Access 2003

Generically, any database management system (DBMS) that can response to queries from client
machines formatted on the SQL language.

24
.

Chapter

25
Requirement Analysis

3.1 Role of SRS

Application Requirement Specification (SRS) is the starting point of the application


developing activity. As system grew more complex it became evident that the goal of the entire
system cannot be easily comprehended. Hence the need for the requirement phase arose. The
application project is initiated by the client needs. The SRS is the means of translating the ideas
of the minds of clients (the input) into a formal document. Application Requirement
Specification is the medium though which the client and user needs are accurately specified. It
forms the basis of application development.

3.2 Aim

a. This application is designed to maintain the database of job seeker and job providers.
b. The application must give universal access for the users of the system.
c. The application is user friendly and provides all the information required.
d. The application must work properly without problems on all targeted devices and network
support.

3.3 Purpose
26
The purpose of this document is to describe all external requirements of Mobile Management. It
also describes the interfaces for the system. The basic idea behind the project is to bridge the
communication gap between job seekers and the organization.

3.4 Scope

This document is the only one that describes the requirements of the system. It is meant for the
use by the developers, and will also be the basis for validating the final delivered system. Any
changes made to the requirements in the future will have to go through a formal change approval
process. The developer is responsible for asking for clarifications, where necessary, and will not
make any alterations without the permission of the client.

This project helps the job seeker to keep track of the Member and clients details.

3.5 Application Requirements

Operating system Windows XP, Windows 7

Front End Microsoft Visual Basic 6.0

Database Microsoft Access 2003

Connectivity ActiveX Data Object

Report Data Report

3.6 Hardware Requirements

RAM 512 MB or higher

27
Hard Disk 10GB or higher

Computer Processor Pentium IV

Clock Speed 700MHZ Processor

3.7 Functional Requirements

The main purpose of functional requirements is to define all activities or operations that
take place in the system. These are derived through interactions with the users of the system.
Since requirements specification is a comprehensive document and contains a lot of data, it has
been broken down into different stages in this report.

3.7.1 Administrator module functional requirements

Administrator has all the rights of maintaining all the records of Mobile Management.
Administrators will be responsible for editing and updating the information of the application.
Administrator will only have the rights to create users and give the permissions to the users.

3.7.2 Client module functional requirements

A client has all the privileges on job seeker and the job seeker details. Client cannot make any
changes in the new user creations.

3.8 Non-Functional Requirements

3.8.1 Reliability

Reliability is the correlation of an item, scale, or instrument with a hypothetical one, which truly
measures what it is supposed to. Since the true instrument is not available. The program
according to the requirement can perform the intended function.

b. Error-handling- exception occurring while accessing database need to be addressed.

28
3.8.2 Usability

Usability refers to the capability of the product to be understood, learned, and used and user
friendly to users, when used under specified conditions. This section should include all of those
requirements that affect usability.

3.8.3 Maintainability

Maintainability is the ease with which a program/specification can be corrected if an error occurs
desires a change in requirements. Specify attributes of application that relate to the ease of
maintenance of the application itself.

3.8.4 Performance

Performance is measured in terms of the output provided by the application. Requirement


specification plays an important part in the analysis of a system. Only when the requirement
specifications are properly given, it is possible to design a system, which will fit into required
environment.

The requirement specification for any system can be broadly stated as given below:

a. The system should be able to interface with the existing system.


b. The system should be accurate.
c. The system should be better than the existing system.
The existing system is completely dependent on the user to perform all the duties.

29
Chapter 4

Design
30
4.1 Data flow diagram notations
The dataflow diagram (DFD) is the one of the most important modeling tools. It
shows the use of the data pictorially. DFD represents the flow of data between different
transformations and process in the system. The dataflow shows logical flow of the data.
Different notations used in DFD are:
Functional Processing
It is represented by a diamond. This notation specifies the processing or main
transactions.

Data Flow
An arrow line represents it and name of the data is specified by the side of the
line as label. This arrow line is used to indicate data movement.

Source or Sink
It is represented by a rectangle .It is used for specifying from where data is
coming and where it will reach.

4.7.2 Tables Created

31
Table 1: login table
FIELD DATA
SIZE
NAME TYPE
long
userId number
integer
usernam
text 30
e
passwor
text 30
d
firstnam
text 30
e
lastnam
text 50
e
long
gid number
integer

Table 2: userGroup table

FIELD DATA
SIZE
NAME TYPE
long
groupId number
integer
groupName text 255
permissionS long
number
etId integer

Table 3: userPermission
DATA
FIELD NAME SIZE
TYPE
permissionId integer
canSeeMember integer
canAddMember integer
canEditMember integer
32
canDeleteMembe
integer
r
canTakeMeasure
integer
ment
canSeeReport integer
canSeeBodyProgr
integer
ess

Table 4: members table


FIELD DATA
SIZE
NAME TYPE
long
memberId
integer
firstname text 50
lastname text 50
gender text 10
long
number
integer
address text 255
Date/Tim
doj e
Date/Tim
dob e
profilePhoto
text
Url 255
dueDate text 255
Table 5: progressMember Table
FIELD DATA
SIZE
NAME TYPE
long
memberId
integer
height double
weight double
bmi double
biceps double
hips double
thigh double
neck double

33
forearms double
chest double
calves double
Date/Tim
mdate e
bodyfat double
waist double
wrist double

Table 6: paymentTransaction Table


FIELD DATA
SIZE
NAME TYPE
long
memberId
integer
Date/Tim
date
e
amt Currency

Table 7: gymDetail Table


DATATY
FIELD PE SIZE
gymNam
e text 255
gymAddr
ess text 255
gymLogo
Url text 255
gymPhon
e text 255

34
Coding

35
DialogLoading Form:
Option Explicit
Dim counter As Integer
Private Sub Form_Load()
Dim Action As AnimationActions
Action = gfaPlay
counter = 0
End Sub
Private Sub Timer1_Timer()
If counter >= 2 Then
frmMain.Show
Unload Me
Exit Sub
End If
counter = counter + 1
End Sub
DialogToAccessAdmin Form:
Option Explicit
Private Sub CancelButton_Click()
Unload Me
End Sub
Private Sub Form_Load()
If Me.Visible = True Then
txtPassword.SetFocus
Call CenterChild(frmMain, Me)
End If
End Sub
Private Sub OKButton_Click()
Call databaseconnection
rs.Open "select * from login", con, adOpenStatic
While Not rs.EOF
If rs.Fields(2) = txtPassword.Text Then
Call disconnectdatabase
frmAdmin.Show
Unload Me
Exit Sub
Else
rs.MoveNext
36
End If
Wend
Call disconnectdatabase
MsgBox "You are not granted to access", vbOKOnly + vbExclamation,
"Authentication"
txtPassword.Text = ""
txtPassword.SetFocus
End Sub
dialogToChangeWallpaper Form:
Option Explicit
Dim file As String
Private Sub CancelButton_Click()
Unload Me
End Sub
Private Sub cmdBwse_Click()
CommonDialog1.ShowOpen
Dim ext As String
ext = GetFileExtension(CommonDialog1.FileName)
If ext = "jpg" Or ext = "png" Or ext = "jpeg" Or ext = "bmp" Then
file = CommonDialog1.FileName
Image1.Picture = LoadPicture(file)
Else
MsgBox "Invalid image file!", vbOKOnly + vbExclamation, "Notification"
Exit Sub
End If
End Sub
Private Sub cmdSave_Click()
If file = "" Then
MsgBox "Choose the wallpaper to set!", vbOKOnly + vbExclamation, "Notification"
Exit Sub
End If
FileCopy file, App.Path & "\wallpaper.jpeg"
frmMain.Picture = LoadPicture(App.Path & "\wallpaper.jpeg")
Unload Me
frmMain.SetFocus
End Sub
Private Sub Form_Load()
file = ""
Me.Caption = ""
End Sub
frmAdmin Form:
Dim add As Integer
Dim userId As Integer
Dim planName As String
Dim permId As Integer
Dim file As String
Private Sub cmdDelete_Click()
'delete group sub
If qcombGroup.ListIndex = -1 Then
MsgBox "Select a group to delete!", vbOKOnly + vbExclamation, "Warning"
37
Exit Sub
End If
Dim arr() As String
arr = Split(qcombGroup.Text, " ")
Call databaseconnection
rs.Open "Select * from userGroup", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
Do Until rs.EOF
If rs.Fields(0) = Val(arr(1)) Then
rs.Delete
rs.Update
Exit Do
End If
rs.MoveNext
Loop
rs.Close
rs.Open "select * from userPermission", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
Do Until rs.EOF
If rs.Fields(0) = permId Then
rs.Delete
rs.Update
Exit Do
End If
rs.MoveNext
Loop
rs.Close
Call readGroup
MsgBox "Group deleted!", vbOKOnly + vbInformation, "Warning"
'Call disconnectdatabase
End Sub
Private Sub cmdSave_Click()
'check the empty fields
'check whether group id is exited or not
'add
If qmemberAdd.ListIndex = -1 And _
qmemberDelete.ListIndex = -1 And _
qmemberEdit.ListIndex = -1 And _
qmemberRead.ListIndex = -1 And _
qmeasureAdd.ListIndex = -1 And _
qreadReport.ListIndex = -1 And _
qreadProgress.ListIndex = -1 And _
qgroupId.Text = "" And _
qgroupName.Text = "" Then
MsgBox "Fields cannot be blank!", vbOKOnly + vbExclamation, "Warning"
Exit Sub
38
End If
Call databaseconnection
rs.Open "select * from userGroup"
If Not rs.EOF Then
rs.MoveLast
End If
rs.AddNew
rs.Fields(0) = Val(qgroupId.Text)
rs.Fields(1) = Trim(qgroupName.Text)
rs.Fields(2) = permId
rs.Update
rs.Close
rs.Open "select * from userPermission", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveLast
End If
rs.AddNew
rs.Fields(0) = permId
If qmemberRead.ListIndex = 0 Then
rs.Fields(1) = 1
Else
rs.Fields(1) = 0
End If
If qmemberAdd.ListIndex = 0 Then
rs.Fields(2) = 1
Else
rs.Fields(2) = 0
End If
If qmemberEdit.ListIndex = 0 Then
rs.Fields(3) = 1
Else
rs.Fields(3) = 0
End If
If qmemberDelete.ListIndex = 0 Then
rs.Fields(4) = 1
Else
rs.Fields(4) = 0
End If
If qmeasureAdd.ListIndex = 0 Then
rs.Fields(5) = 1
Else
rs.Fields(5) = 0
End If
If qreadReport.ListIndex = 0 Then
rs.Fields(6) = 1
Else
rs.Fields(6) = 0
End If
If qreadProgress.ListIndex = 0 Then
rs.Fields(7) = 1
39
Else
rs.Fields(8) = 0
End If
rs.Update
rs.Close
Call readGroup
Call clearGroup
End Sub
Private Sub cmdUpdate_Click()
'check the empty fields
'check the group id matches, if then add
If qmemberAdd.ListIndex = -1 And _
qmemberDelete.ListIndex = -1 And _
qmemberEdit.ListIndex = -1 And _
qmemberRead.ListIndex = -1 And _
qmeasureAdd.ListIndex = -1 And _
qreadReport.ListIndex = -1 And _
qreadProgress.ListIndex = -1 And _
qgroupId.Text = "" And _
qgroupName.Text = "" Then
MsgBox "Fields cannot be blank", vbOKOnly + vbExclamation, "Notification"
Exit Sub
End If
Call databaseconnection
rs.Open "select * from userGroup"
If Not rs.EOF Then
rs.MoveFirst
End If
Do While Not rs.EOF
If rs.Fields(0) = Val(qgroupId.Text) Then
rs.Fields(0) = Val(qgroupId.Text)
rs.Fields(1) = Trim(qgroupName.Text)
rs.Update
Exit Do
End If
rs.MoveNext
Loop
rs.Close
rs.Open "select * from userPermission", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveLast
End If
Do Until rs.EOF
If rs.Fields(0) = permId Then
If qmemberRead.ListIndex = 0 Then
rs.Fields(1) = 1
Else
rs.Fields(1) = 0
End If
If qmemberAdd.ListIndex = 0 Then
40
rs.Fields(2) = 1
Else
rs.Fields(2) = 0
End If
If qmemberEdit.ListIndex = 0 Then
rs.Fields(3) = 1
Else
rs.Fields(3) = 0
End If
If qmemberDelete.ListIndex = 0 Then
rs.Fields(4) = 1
Else
rs.Fields(4) = 0
End If
If qmeasureAdd.ListIndex = 0 Then
rs.Fields(5) = 1
Else
rs.Fields(5) = 0
End If
If qreadReport.ListIndex = 0 Then
rs.Fields(6) = 1
Else
rs.Fields(6) = 0
End If
If qreadProgress.ListIndex = 0 Then
rs.Fields(7) = 1
Else
rs.Fields(8) = 0
End If
rs.Update
Exit Do
End If
rs.MoveNext
Loop
rs.Close
Call readGroup
Call clearGroup
End Sub
Private Sub Form_Load()
Call databaseconnection
Call refreshLoginTable
Call refreshMembershipPlanTable
userId = -1
planName = ""
'Fill the table
'Call fillTable
'***Initializing comboBox
qmemberAdd.AddItem ("Allow")
qmemberAdd.AddItem ("Deny")
qmemberEdit.AddItem ("Allow")
41
qmemberEdit.AddItem ("Deny")
qmemberRead.AddItem ("Allow")
qmemberRead.AddItem ("Deny")
qmemberDelete.AddItem ("Allow")
qmemberDelete.AddItem ("Deny")
qmeasureAdd.AddItem ("Allow")
qmeasureAdd.AddItem ("Deny")
qreadProgress.AddItem ("Allow")
qreadProgress.AddItem ("Deny")
qreadReport.AddItem ("Allow")
qreadReport.AddItem ("Deny")
cmdSave.Enabled = False
Dim I As Integer
I=1
While I <= 24
mtxtDuration.AddItem I
I=I+1
Wend
'***Reading groups
Call readGroup
'***Fill lgroup
Call databaseconnection
rs.Open "select * from userGroup", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
While Not rs.EOF
lgroup.AddItem (rs.Fields(0))
rs.MoveNext
Wend
rs.Close
Call disconnectdatabase

Me.Caption = "Admin Panel"


add = 0
'Gym details loading
Call databaseconnection
rs.Open "select * from gymDetail", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
Do Until rs.EOF
gymName.Text = rs.Fields(0)
gymAddress.Text = rs.Fields(1)
If Not rs.Fields(2) = "" Then
file = rs.Fields(2)
Image1.Picture = LoadPicture(App.Path & rs.Fields(2))
Else
file = ""
End If
42
gymPhone.Text = rs.Fields(3)
rs.MoveNext
Loop
rs.Close
End Sub

Private Sub Form_Unload(Cancel As Integer)


If MsgBox("Do you want to exit Admin panel?", vbYesNo + vbQuestion,
"Notification") = vbYes Then
Unload Me
Else
Me.SetFocus
End If
End Sub
Private Sub gymCmdBrowse_Click()
logo.ShowOpen
Dim ext As String
ext = GetFileExtension(logo.FileName)
If ext = "jpg" Or ext = "png" Or ext = "jpeg" Or ext = "bmp" Then
file = logo.FileName
Image1.Picture = LoadPicture(file)
Else
MsgBox "Invalid image file", vbOKOnly + vbExclamation, "Notification"
Exit Sub
End If
End Sub
Private Sub gymCmdSave_Click()
If gymName.Text = "" And _
gymAddress.Text = "" And _
gymPhone.Text = "" And _
file = "" Then
MsgBox "All fields are mandatory!", vbOKOnly + vbExclamation, "Notification"
Exit Sub
End If
Call databaseconnection
rs.Open "select * from gymDetail", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
If rs.RecordCount = 0 Then
rs.AddNew
rs.Fields(0) = Trim(gymName.Text)
rs.Fields(1) = gymAddress.Text
rs.Fields(2) = file
rs.Fields(3) = Val(gymPhone.Text)
rs.Update
Else
Do Until rs.EOF
rs.Fields(0) = Trim(gymName.Text)
43
rs.Fields(1) = gymAddress.Text
If Not file = App.Path & "\gymLogo.jpeg" Then
FileCopy file, App.Path & "\gymLogo.jpeg"
End If
rs.Fields(2) = "\gymLogo.jpeg"
rs.Fields(3) = Val(gymPhone.Text)
rs.Update
rs.MoveNext
Loop
End If
rs.Close
MsgBox "Gym details saved!", vbOKOnly + vbInformation, "Notification"
End Sub
Private Sub gymPhone_KeyPress(KeyAscii As Integer)
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub lcmdAdd_Click()
If add = 0 Then
Call clearLoginFields
lusername.SetFocus
lid.Enabled = False
Call databaseconnection
rs.Open "select * from login", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveLast
End If
lid.Text = rs.Fields(0) + 1
rs.Close
Call disconnectdatabase
add = 1
lcmdAdd.Caption = "*Add"
Exit Sub
End If
If add = 1 Then
If lid.Text = "" And lusername.Text = "" And lpassword.Text = "" And
lfname.Text = "" And llname.Text = "" And lgroup.Text = "" Then
MsgBox "All fields are mandatory!", vbOKOnly + vbExclamation,
"Notification"
Exit Sub
End If
Call databaseconnection
rs.Open "select * from login", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
Do Until rs.EOF
If rs.Fields(1) = lusername.Text Then

44
MsgBox "Username exists! Choose different!", vbOKOnly +
vbExclamation, "Warning"
Exit Sub
End If
rs.MoveNext
Loop
rs.MoveLast
rs.AddNew
rs.Fields(0) = lid.Text
rs.Fields(1) = lusername.Text
rs.Fields(2) = lpassword.Text
rs.Fields(3) = lfname.Text
rs.Fields(4) = llname.Text
rs.Fields(5) = lgroup.Text
rs.Update
rs.Close
Call disconnectdatabase
MsgBox "Record saved", vbOKOnly + vbInformation, "Notification"
lcmdAdd.Caption = "Add"
add = 0
Call clearLoginFields
Call refreshLoginTable
Exit Sub
End If
End Sub
Private Sub lcmdCancel_Click()
Unload Me
End Sub
Private Sub lcmdDelete_Click()
If userId = -1 Then
MsgBox "Select a user to delete!", vbOKOnly + vbExclamation, "Notification"
Exit Sub
End If
Call databaseconnection
rs.Open "Select * from login", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
Do Until rs.EOF
If rs.Fields(0) = userId Then
rs.Delete
MsgBox "User is deleted", vbOKOnly + vbInformation, "Notification"
Exit Do
End If
rs.MoveNext
Loop
rs.Close
Call refreshLoginTable
End Sub

45
Private Sub lcmdModify_Click()
If lid.Text = "" And lusername.Text = "" And lpassword.Text = "" And lfname.Text
= "" And llname.Text = "" And lgroup.Text = "" Then
MsgBox "All fields are mandatory!", vbOKOnly + vbExclamation,
"Notification"
Exit Sub
End If
Call databaseconnection
rs.Open "select * from login", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
Do Until rs.EOF
If rs.Fields(0) = lid.Text Then
rs.Fields(0) = lid.Text
rs.Fields(1) = lusername.Text
rs.Fields(2) = lpassword.Text
rs.Fields(3) = lfname.Text
rs.Fields(4) = llname.Text
rs.Fields(5) = lgroup.Text
rs.Update
rs.Close
Exit Do
End If
rs.MoveNext
Loop
Call disconnectdatabase
MsgBox "Record updated!", vbOKOnly + vbInformation, "Notification"
Call clearLoginFields
Call refreshLoginTable
End Sub
Private Sub lcmdRefresh_Click()
Call refreshLoginTable
End Sub
Private Sub loginTable_Click()
userId = loginTable.Columns(0)
lid.Text = loginTable.Columns(0)
lusername.Text = loginTable.Columns(1)
lpassword.Text = loginTable.Columns(2)
lfname.Text = loginTable.Columns(3)
llname.Text = loginTable.Columns(4)
Dim Index As Integer
Index = 0
For Index = 0 To lgroup.ListCount - 1
If UCase$(lgroup.ItemData(Index)) = UCase$(loginTable.Columns(5)) Then
lgroup.ListIndex = Index
Exit For
End If
Next
'group from comboBox
46
End Sub
Private Sub mcmdDelete_Click()
If planName = "" Then
MsgBox "Choose the plan to delete!", vbOKOnly + vbExclamation, "Notification"
Exit Sub
End If
Call databaseconnection
rs.Open "select * from membershipPlan", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
While Not rs.EOF
If rs.Fields(0) = planName Then
rs.Delete
rs.Update
rs.Close
planName = ""
Call disconnectdatabase
Call refreshMembershipPlanTable
mtxtplanname.Text = ""
mtxtfinalAMT.Caption = ""
mtxtdiscount.Text = ""
mtxtamount.Text = ""
Exit Sub
End If
rs.MoveNext
Wend
End Sub
Private Sub mcmdSave_Click()
If mtxtplanname.Text = "" And mtxtamount.Text = "" And mtxtdiscount.Text = ""
And mtxtDuration.Text = "Select" Then
MsgBox "Fill the blanks!", vbOKOnly + vbExclamation, "Notification"
Exit Sub
End If
Call databaseconnection
rs.Open "select * from membershipPlan", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveLast
End If
rs.AddNew
rs.Fields(0) = Trim(mtxtplanname.Text)
rs.Fields(1) = Val(mtxtDuration.Text)
rs.Fields(2) = Val(mtxtfinalAMT.Caption)
rs.Update
rs.Close
Call disconnectdatabase
Call refreshMembershipPlanTable
mtxtplanname.Text = ""
mtxtfinalAMT.Caption = ""
mtxtdiscount.Text = ""
47
mtxtamount.Text = ""
End Sub
Private Sub mcmdUpdate_Click()
If mtxtplanname.Text = "" And mtxtamount.Text = "" And mtxtdiscount.Text = ""
Then
MsgBox "Fill the blanks!", vbOKOnly + vbExclamation, "Notification"
Exit Sub
End If
If mtxtfinalAMT.Caption = "" Then
MsgBox "Final amount is not calculated!", vbOKOnly + vbExclamation, "Notification"
Exit Sub
End If
Call databaseconnection
Dim rsTemp As ADODB.Recordset
Set rsTemp = New ADODB.Recordset
rsTemp.Open "select * from membershipPlan", con, adOpenDynamic,
adLockOptimistic
If Not rsTemp.EOF Then
rsTemp.MoveFirst
End If
Do While Not rsTemp.EOF
If rsTemp.Fields(0) = mtxtplanname.Text Then
rsTemp.Fields(0) = mtxtplanname.Text
rsTemp.Fields(1) = Val(mtxtDuration.Text)
rsTemp.Fields(2) = Val(mtxtfinalAMT.Caption)
rsTemp.Update
mtxtplanname.Text = ""
mtxtfinalAMT.Caption = ""
mtxtdiscount.Text = ""
mtxtamount.Text = ""
Call refreshMembershipPlanTable
Exit Do
End If
rsTemp.MoveNext
Loop
'rsTemp.Close
End Sub
Private Sub membershipPlan_Click()
planName = Trim(membershipPlan.Columns(0))
mtxtplanname = planName
mtxtamount = membershipPlan.Columns(2)
mtxtDuration = membershipPlan.Columns(1)
End Sub

Private Sub mtxtamount_KeyPress(KeyAscii As Integer)


If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub mtxtdiscount_Change()
48
mtxtfinalAMT = mtxtamount - (Val(mtxtdiscount) * Val(mtxtamount)) / 100
End Sub
Private Sub mtxtdiscount_KeyPress(KeyAscii As Integer)
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub qcombGroup_Click()
Call clearGroup
Call databaseconnection
'add new group initialization
If qcombGroup.Text = "Add new group" Then
Call clearGroup
cmdSave.Enabled = True
cmdUpdate.Enabled = False
qgroupName.SetFocus
rs.Open "select * from userGroup", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveLast
End If
qgroupId.Text = rs.Fields(0) + 1
rs.Close
qgroupId.Enabled = False
cmdSave.Enabled = True
rs.Open "select * from userPermission", con, adOpenDynamic,
adLockOptimistic
If Not rs.EOF Then
rs.MoveLast
End If
permId = rs.Fields(0) + 1
rs.Close
Exit Sub
End If
cmdSave.Enabled = False
cmdUpdate.Enabled = True
qgroupId.Enabled = False

Dim tempArray() As String


tempArray = Split(qcombGroup.Text, " ")

rs.Open "select * from userGroup", con, adOpenDynamic, adLockOptimistic


If Not rs.EOF Then
rs.MoveFirst
End If
Do While Not rs.EOF
If rs.Fields(0) = Val(tempArray(0)) Then
permId = rs.Fields(2)
qgroupId.Text = rs.Fields(0)
qgroupName.Text = rs.Fields(1)
Exit Do
49
End If
rs.MoveNext
Loop
rs.Close
rs.Open "select * from userPermission", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
Do While Not rs.EOF
If rs.Fields(0) = permId Then
If rs.Fields(1) = 1 Then
qmemberRead.ListIndex = 0
Else
qmemberRead.ListIndex = 1
End If
If rs.Fields(2) = 1 Then
qmemberAdd.ListIndex = 0
Else
qmemberAdd.ListIndex = 1
End If
If rs.Fields(3) = 1 Then
qmemberEdit.ListIndex = 0
Else
qmemberEdit.ListIndex = 1
End If
If rs.Fields(4) = 1 Then
qmemberDelete.ListIndex = 0
Else
qmemberDelete.ListIndex = 1
End If
If rs.Fields(5) = 1 Then
qmeasureAdd.ListIndex = 0
Else
qmeasureAdd.ListIndex = 1
End If
If rs.Fields(6) = 1 Then
qreadReport.ListIndex = 0
Else
qreadReport.ListIndex = 1
End If
If rs.Fields(7) = 1 Then
qreadProgress.ListIndex = 0
Else
qreadProgress.ListIndex = 1
End If
Exit Do
End If
rs.MoveNext
Loop
rs.Close
50
Call disconnectdatabase
End Sub
Public Sub readGroup()
qcombGroup.clear
Call databaseconnection
rs.CursorLocation = adUseClient
rs.Open "select * from userGroup", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
While Not rs.EOF
qcombGroup.AddItem (rs.Fields(0) & " " & rs.Fields(1))
rs.MoveNext
Wend
Else
MsgBox "Record set is empty!", vbOKOnly + vbExclamation, "Warning"
End If

rs.Close
Call disconnectdatabase
qcombGroup.AddItem ("Add new group")
End Sub
Public Sub clearGroup()
qmemberAdd.Text = ""
qmemberEdit.Text = ""
qmemberRead.Text = ""
qmemberDelete.Text = ""
qmeasureAdd.Text = ""
qreadProgress.Text = ""
qreadReport.Text = ""
qgroupId.Text = ""
qgroupName.Text = ""

'cmdUpdate.Enabled = True
'cmdSave.Enabled = True
End Sub
Public Sub clearLoginFields()
lid.Text = ""
lusername.Text = ""
lpassword.Text = ""
lfname.Text = ""
llname.Text = ""
lgroup.Text = ""
End Sub
Public Sub refreshLoginTable()
loginTable.ClearFields
loginTableDC.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & App.Path & "\Data\sgsdata.mdb;Persist Security Info=False"
loginTableDC.CommandType = adCmdText
loginTableDC.RecordSource = "select * from login"
Set loginTable.DataSource = loginTableDC
51
loginTableDC.Refresh
loginTable.Refresh
End Sub
Public Sub refreshMembershipPlanTable()
membershipPlan.ClearFields
membershipPlanDC.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & App.Path & "\Data\sgsdata.mdb;Persist Security Info=False"
membershipPlanDC.CommandType = adCmdText
membershipPlanDC.RecordSource = "select * from membershipPlan"
Set membershipPlan.DataSource = membershipPlanDC
membershipPlanDC.Refresh
membershipPlan.Refresh
End Sub
frmIndividualReport Form:
Option Explicit
Dim mId As Integer

Private Sub cmdGenerate_Click()


If mId = -1 Then
MsgBox "Select a member!", vbOKOnly + vbExclamation, "Warning"
Exit Sub
End If
generateSelfReport (mId)
End Sub
Private Sub Form_Load()
mId = -1
lblBMIChange.Caption = ""
lblBodyFatChange.Caption = ""
lblDueDate.Caption = ""
lblLastMeasurementDate.Caption = ""
lblLastPaymentDate.Caption = ""
lblMemberNameGreeting.Caption = ""
lblSinceJoinedDate.Caption = ""
lblTotalAmtPaid.Caption = ""
lblWeightChange.Caption = ""
memberTableDC.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & App.Path & "\Data\sgsdata.mdb;Persist Security Info=False"
memberTableDC.CommandType = adCmdText
memberTableDC.RecordSource = "select memberId, firstname, lastname from
members"
Set memberTable.DataSource = memberTableDC
End Sub

Private Sub memberTable_Click()


mId = Val(memberTable.Columns(0))
End Sub
Public Function generateSelfReport(memberId As Integer)
Dim str As String
lblMemberNameGreeting.Caption = memberTable.Columns(0) & " " &
memberTable.Columns(1) & " " & memberTable.Columns(2)
52
str = getLastMeasurementDateOf(memberId)
If Not str = "" Then
lblLastMeasurementDate.Caption = "Last measurement date: " & str
Else
lblLastMeasurementDate.Caption = "Measurement History is empty"
End If
str = ""
lblBMIChange.Caption = "BMI change : " & getBMIchangeOf(memberId)
lblBodyFatChange.Caption = "Body Fat change : " &
getBodyFatChangeOf(memberId)
lblWeightChange.Caption = "Weight change : " & getWeightChangeOf(memberId)
str = getLastPaymentDateOf(memberId)
If Not str = "" Then
lblLastPaymentDate.Caption = "Last Payment Date : " & str
Else
lblLastPaymentDate.Caption = "Payment History is empty"
End If
str = ""

str = getTotalAmtPaidOf(memberId)
If Not str = "" Then
lblTotalAmtPaid.Caption = "Total amount paid : " & str
Else
lblTotalAmtPaid.Caption = "Payment History is empty"
End If
str = ""
lblSinceJoinedDate.Caption = sinceJoinedDateOf(memberId)
lblDueDate.Caption = "Due Date : " & getDueDateOf(memberId)
End Function
Private Sub txtSearch_Change()
If txtSearch.Text = "" Then
memberTable.ClearFields
memberTableDC.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & App.Path & "\Data\sgsdata.mdb;Persist Security Info=False"
memberTableDC.CommandType = adCmdText
memberTableDC.RecordSource = "select memberId, firstname, lastname from
members"
Set memberTable.DataSource = memberTableDC
memberTableDC.Refresh
memberTable.Refresh
Exit Sub
End If
If optRno.Value Then
memberTable.ClearFields
memberTableDC.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & App.Path & "\Data\sgsdata.mdb;Persist Security Info=False"
memberTableDC.CommandType = adCmdText
memberTableDC.RecordSource = "select memberId, firstname, lastname from
members where memberId like '" & Val(txtSearch.Text) & "%'"
Set memberTable.DataSource = memberTableDC
53
memberTableDC.Refresh
memberTable.Refresh
ElseIf optFname.Value Then
memberTable.ClearFields
memberTableDC.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & App.Path & "\Data\sgsdata.mdb;Persist Security Info=False"
memberTableDC.CommandType = adCmdText
memberTableDC.RecordSource = "select memberId, firstname, lastname from
members where firstname like '" & txtSearch.Text & "%'"
Set memberTable.DataSource = memberTableDC
memberTableDC.Refresh
memberTable.Refresh
End If
End Sub
Private Sub txtSearch_GotFocus()
If optRno.Value = False And optFname.Value = False Then
MsgBox "Choose the search option!", vbOKOnly + vbExclamation, "Warning"
Exit Sub
End If
txtSearch.Text = ""
End Sub

Private Sub txtSearch_KeyPress(KeyAscii As Integer)


If optRno Then
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 And KeyAscii <> 45 And
KeyAscii <> 47 Then
KeyAscii = 0
End If
End If
End Sub
frmInitialReport Form:
Option Explicit
Private Sub cmdProceed_Click()
If optIndividual.Value = False And optReport.Value = False Then
MsgBox "Select the report type!", vbOKOnly + vbExclamation, "Notification"
Exit Sub
ElseIf optIndividual.Value Then
frmIndividualReport.Show
Else
frmReport.Show
End If
Unload Me
End Sub
frmLogin Form:
Option Explicit
Public LoginSucceeded As Boolean
Private Sub cmdCancel_Click()
'set the global var to false
'to denote a failed login
LoginSucceeded = False
54
Me.Hide
End Sub
Private Sub cmdClose_Click()
If MsgBox("Are you really quit? ", vbYesNo, "Notification") = vbYes Then
Unload Me
End If
End Sub
Private Sub Form_Load()
txtUserName.BackColor = RGB(241, 241, 241)
txtPassword.BackColor = RGB(241, 241, 241)
'lblOk.MousePointer = 99
'lblOk.MouseIcon = LoadPicture(App.Path & "\hand.ico")
End Sub
Private Sub lblOk_Click()
If txtUserName.Text = "" And txtPassword.Text = "" Then
MsgBox "Enter the username and password!", vbOKOnly + vbExclamation, "Login"
txtUserName.Text = ""
txtPassword.Text = ""
ElseIf txtUserName.Text = "" Then
MsgBox "Enter the username", vbOKOnly + vbExclamation, "Login"
txtUserName.Text = ""
txtPassword.Text = ""
ElseIf txtPassword.Text = "" Then
MsgBox "Enter the password", vbOKOnly + vbExclamation, "Login"
txtUserName.Text = ""
txtPassword.Text = ""
Else
Call databaseconnection
rs.Open "select * from login", con, adOpenStatic
If rs.EOF = True Then
MsgBox "Login entry is empty!", vbOKOnly + vbCritical, "Error"
Exit Sub
Else
rs.MoveFirst
End If
While Not rs.EOF
If Trim(txtUserName.Text) = rs.Fields(1) And Trim(txtPassword.Text) =
rs.Fields(2) Then
barName = rs.Fields(3) & " " & rs.Fields(4)
Call disconnectdatabase
dialogLoading.Show
Unload Me
Exit Sub
Else
rs.MoveNext
End If
Wend
Call disconnectdatabase
MsgBox "Bad login", vbOKOnly + vbExclamation, "Login"
txtPassword.SetFocus
55
End If
End Sub
frmMain Form:
Private Declare Function GetMenu Lib "User32" (ByVal hWnd As Long) As Long
Private Declare Function GetSubMenu Lib "User32" (ByVal hMenu As Long, ByVal
nPos As Long) As Long
Private Declare Function SetMenuItemBitmaps Lib "User32" _
(ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, _
ByVal hBitmapUnchecked As Long, ByVal hBitmapChecked As Long) As Long
Private Declare Function LoadImage Lib "User32" Alias "LoadImageA" _
(ByVal hInst As Long, ByVal lpsz As String, ByVal un1 As Long, _
ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long
'Constant for SetMenuItemBitmaps
Private Const MF_BYPOSITION As Long = &H400&
'Constants for LoadImage
Private Const IMAGE_BITMAP As Long = &O0
Private Const LR_LOADFROMFILE As Long = 16
Private Const LR_CREATEDIBSECTION As Long = 8192
Private Sub addmember_Click()
frmMember.loadType = 0
frmMember.Show
End Sub
Private Sub adminpanel_Click()
dialogToAccessAdmin.Show
End Sub
Private Sub bodyprogress_Click()
frmSearch.loadBodyProgress = True
frmSearch.Show
End Sub
Private Sub calc_Click()
Shell "C:\WINDOWS\System32\calc.exe"
End Sub
Private Sub employees_Click(Index As Integer)
End Sub
Private Sub hideMetroGrid_Click()
frmMetroStyleMenu.Visible = False
End Sub
Private Sub logout_Click()
frmLogin.Show
Unload Me
End Sub
Private Sub MDIForm_Load()
Me.Caption = "Smart Gym System : " & barName
'frmSideBar.Show
'setting to fullscreen
dX = Me.Width
dY = Me.Height
setFullScreen Me
frmMetroStyleMenu.Show
Dim ext As String
56
ext = GetFileExtension(App.Path & "\wallpaper.jpeg")
If ext = "jpg" Or ext = "png" Or ext = "jpeg" Or ext = "bmp" Then
Me.Picture = LoadPicture(App.Path & "\wallpaper.jpeg")
Else
MsgBox "Invalid Image File!", vbOKOnly + vbExclamation, "Notification"
Exit Sub
End If

'add icons to the menu


Dim hMenu As Long
Dim hSubMenu As Long
Dim hMenuImg As Long
Dim sFileName As String
' Get the bitmap.
sFileName = App.Path & "\Icons\menuIcons\invisible.bmp"
hMenuImg = LoadImage(0, sFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE Or
LR_CREATEDIBSECTION)
' Get the menu item handle.
hMenu = GetMenu(Me.hWnd)
hSubMenu = GetSubMenu(hMenu, 0)
' Set the "mnuTwo" bitmap to the one that is loaded in memory.
Call SetMenuItemBitmaps(hSubMenu, 0, MF_BYPOSITION, hMenuImg, 0)
sFileName = App.Path & "\Icons\menuIcons\visible.bmp"
hMenuImg = LoadImage(0, sFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE
Or LR_CREATEDIBSECTION)
Call SetMenuItemBitmaps(hSubMenu, 1, MF_BYPOSITION, hMenuImg, 0)
sFileName = App.Path & "\Icons\menuIcons\AdminPanel.bmp"
hMenuImg = LoadImage(0, sFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE
Or LR_CREATEDIBSECTION)
Call SetMenuItemBitmaps(hSubMenu, 2, MF_BYPOSITION, hMenuImg, 0)
sFileName = App.Path & "\Icons\menuIcons\LogOut.bmp"
hMenuImg = LoadImage(0, sFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE
Or LR_CREATEDIBSECTION)
Call SetMenuItemBitmaps(hSubMenu, 3, MF_BYPOSITION, hMenuImg, 0)
sFileName = App.Path & "\Icons\menuIcons\Shutsystem.bmp"
hMenuImg = LoadImage(0, sFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE
Or LR_CREATEDIBSECTION)
Call SetMenuItemBitmaps(hSubMenu, 4, MF_BYPOSITION, hMenuImg, 0)
hMenu = GetMenu(Me.hWnd)
hSubMenu = GetSubMenu(hMenu, 1)
sFileName = App.Path & "\Icons\menuIcons\MemberList.bmp"
hMenuImg = LoadImage(0, sFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE
Or LR_CREATEDIBSECTION)
Call SetMenuItemBitmaps(hSubMenu, 0, MF_BYPOSITION, hMenuImg, 0)
sFileName = App.Path & "\Icons\menuIcons\MemberAdd.bmp"
hMenuImg = LoadImage(0, sFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE
Or LR_CREATEDIBSECTION)
Call SetMenuItemBitmaps(hSubMenu, 1, MF_BYPOSITION, hMenuImg, 0)
sFileName = App.Path & "\Icons\menuIcons\Measurement.bmp"

57
hMenuImg = LoadImage(0, sFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE
Or LR_CREATEDIBSECTION)
Call SetMenuItemBitmaps(hSubMenu, 2, MF_BYPOSITION, hMenuImg, 0)
sFileName = App.Path & "\Icons\menuIcons\Progress.bmp"
hMenuImg = LoadImage(0, sFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE
Or LR_CREATEDIBSECTION)
Call SetMenuItemBitmaps(hSubMenu, 3, MF_BYPOSITION, hMenuImg, 0)

sFileName = App.Path & "\Icons\menuIcons\MakePayment.bmp"


hMenuImg = LoadImage(0, sFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE
Or LR_CREATEDIBSECTION)
Call SetMenuItemBitmaps(hSubMenu, 4, MF_BYPOSITION, hMenuImg, 0)
hMenu = GetMenu(Me.hWnd)
hSubMenu = GetSubMenu(hMenu, 3)
sFileName = App.Path & "\Icons\menuIcons\Calculator.bmp"
hMenuImg = LoadImage(0, sFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE
Or LR_CREATEDIBSECTION)
Call SetMenuItemBitmaps(hSubMenu, 0, MF_BYPOSITION, hMenuImg, 0)
sFileName = App.Path & "\Icons\menuIcons\ChangeWall.bmp"
hMenuImg = LoadImage(0, sFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE
Or LR_CREATEDIBSECTION)
Call SetMenuItemBitmaps(hSubMenu, 1, MF_BYPOSITION, hMenuImg, 0)
End Sub
Private Sub MDIForm_Unload(Cancel As Integer)
If MsgBox("Are you really want to exit?", vbYesNo + vbQuestion, "Notification") =
vbYes Then
Unload Me
End If
End Sub

Private Sub measurement_Click()


frmSearch.loadMeasurement = True
frmSearch.Show
End Sub
Private Sub memberdetails_Click()
frmMemberlist.Show
End Sub
Private Sub metroGrid_Click()
If frmMetroStyleMenu.Visible = False Then
frmMetroStyleMenu.Visible = True
Exit Sub
End If
frmMetroStyleMenu.Show
End Sub
Private Sub payment_Click()
frmSearch.loadPayment = True
frmSearch.Show
End Sub
Private Sub reports_Click()
frmInitialReport.Show
58
End Sub

Private Sub setWallpaper_Click()


dialogToChangeWallpaper.Show
End Sub
Private Sub shutsystem_Click()
If MsgBox("Are you really want to exit?", vbYesNo + vbQuestion, "Notification") =
vbYes Then
Unload Me
End If
End Sub

frmMember Form:
Public loadType As Integer
Public payment As Boolean
Public memberId As Integer
Dim ibj As Object
Dim dtmTest As Date
Dim dateTimeNow As String
Dim dd As String
Dim tt As String
Dim photoUrl As String
Dim photoName As String
Dim isClicked As Boolean

Private Sub cmdBrowse_Click()


CommonDialog1.ShowOpen
pictureProfile.Picture = LoadPicture(CommonDialog1.FileName)
photoUrl = CommonDialog1.FileName
photoName = CommonDialog1.FileTitle
End Sub
Private Sub cmdCancel_Click()
If MsgBox("Exit?", vbYesNo + vbQuestion, "Notification") = vbYes Then
Call disconnectdatabase
Unload Me
End If
End Sub

Private Sub cmdClear_Click()


'Call clear
End Sub
Private Sub cmdProgress_Click()
End Sub
Private Sub cmdReport_Click()
If isClicked Then
cmdReport.Caption = "Show Report"
Me.Width = Line2.X2
isClicked = False
Else
cmdReport.Caption = "Hide Report"
59
Me.Width = 13920
isClicked = True
End If
End Sub
Private Sub cmdSave_Click()
If txtid.Text = "" And txtfname.Text = "" And txtlname.Text = "" And
txtgender.Text = "Select" And txtdob.Text = "" And txtnumber.Text = "" And
txtaddress.Text = "" Then
MsgBox "Fill the fields", vbOKOnly + vbExclamation, "Warning!"
End If
If loadType = 1 Then
'memberModify
rs.Open "select * from members"
If Not rs.EOF Then
rs.MoveFirst
End If
While Not rs.EOF
If rs.Fields(0) = txtid.Text Then
rs.Fields(0) = txtid.Text
rs.Fields(1) = txtfname.Text
rs.Fields(2) = txtlname.Text
rs.Fields(3) = txtgender.Text
rs.Fields(4) = txtnumber.Text
rs.Fields(5) = txtaddress.Text
rs.Fields(7) = txtdob.Value
'delete the previous photo
Kill App.Path & rs.Fields(8)
'new photo is copied here
If Not photoUrl = "" Then
FileCopy photoUrl, App.Path & "\ProfilePicture\" & photoName
End If
'set the photo to the database
rs.Fields(8) = "\ProfilePicture\" & photoName
Unload Me
Exit Sub
End If
rs.MoveNext
Wend
ElseIf loadType = 2 Then
'memberReadOnly
Else
'memberAdd
dd = Format$(Now, "mm/dd/yyyy")
tt = Format$(time, "hh:mm:ssAM/PM")
dateTimeNow = dd & " " & tt
rs.Open "select * from members"
If Not rs.EOF Then
rs.MoveLast
End If
rs.AddNew
60
rs.Fields(0) = txtid.Text
rs.Fields(1) = txtfname.Text
rs.Fields(2) = txtlname.Text
rs.Fields(3) = txtgender.Text
rs.Fields(4) = txtnumber.Text
rs.Fields(5) = txtaddress.Text
rs.Fields(6) = dateTimeNow
rs.Fields(7) = txtdob.Value
rs.Fields("dueDate") = dd
If Not photoUrl = "" Then
FileCopy photoUrl, App.Path & "\ProfilePicture\" & photoName
End If
rs.Fields(8) = "\ProfilePicture\" & photoName
rs.Update
rs.Close
MsgBox "Saved!", vbOKOnly + vbInformation, "Notification"
If MsgBox("Are you want to make payment?", vbYesNo, "Payment") = vbYes Then
frmPayment.txtid = txtid.Text
frmPayment.txtname = txtfname.Text & " " & txtlname.Text
frmPayment.Show
Unload Me
Else
Me.Refresh
Call clear
Unload Me
End If
End If
End Sub
Private Sub Form_Load()
Call databaseconnection
Call clear
txtgender.AddItem "Male"
txtgender.AddItem "Female"
txtid.Enabled = True
txtdueDate.Enabled = False
txtnumber.MaxLength = 12
cmdReport.Visible = False
cmdBrowse.Visible = True
cmdCancel.Visible = True
cmdClear.Visible = True
cmdSave.Visible = True
Me.Height = 6000
Me.Width = Line2.X2
If loadType = 1 Then
'#######memberModify
Me.Caption = "Edit member"
txtid.Enabled = False
txtdoj.Enabled = False
cmdSave.Caption = "Update"
Me.Height = 6000
61
Me.Width = Line2.X2
cmdReport.Visible = False
rs.Open "select * from members", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
While Not rs.EOF
If rs.Fields(0) = memberId Then
txtid.Text = rs.Fields(0)
txtfname.Text = rs.Fields(1)
txtlname.Text = rs.Fields(2)
txtgender.Text = rs.Fields(3)
txtnumber.Text = rs.Fields(4)
txtaddress.Text = rs.Fields(5)
txtdoj.Text = rs.Fields(6)
txtdob.Value = rs.Fields(7)
If FileExists(App.Path & rs.Fields(8)) Then
Image1.Picture = LoadPicture(App.Path & rs.Fields(8))
End If
txtdueDate.Text = rs.Fields(9)
rs.Close
Exit Sub
End If
rs.MoveNext
Wend
ElseIf loadType = 2 Then
'########memberReadOnly
Me.Caption = "Member in detail"
cmdClear.Visible = False
cmdCancel.Visible = False
cmdSave.Visible = False
cmdReport.Visible = True
cmdBrowse.Visible = False
txtaddress.Enabled = False
txtdob.Enabled = False
txtdoj.Enabled = False
txtfname.Enabled = False
txtgender.Enabled = False
txtid.Enabled = False
txtlname.Enabled = False
txtnumber.Enabled = False
Me.Height = 9210
Me.Width = Line2.X2
rs.Open "select * from members", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
Do While Not rs.EOF
If rs.Fields(0) = memberId Then
txtid.Text = rs.Fields(0)
62
txtfname.Text = rs.Fields(1)
txtlname.Text = rs.Fields(2)
txtgender.Text = rs.Fields(3)
txtdob.Value = rs.Fields(7)
txtnumber.Text = rs.Fields(4)
txtaddress.Text = rs.Fields(5)
txtdoj.Text = rs.Fields(6)
Dim fullPath As String
fullPath = App.Path & rs.Fields(8)
pictureProfile.Picture = LoadPicture(fullPath)

txtdueDate.Text = rs.Fields(9)
Exit Do
End If
rs.MoveNext
Loop
rs.Close
Dim rs2 As ADODB.Recordset
Set rs2 = New ADODB.Recordset
rs2.CursorLocation = adUseClient
rs2.Open "SELECT * FROM paymentTransaction WHERE memberId=" &
Val(txtid.Text), con, adOpenDynamic, adLockOptimistic
Set PaymentHistory.DataSource = rs2

Call generateSelfReport
Exit Sub
Else
'#######memberAdd
Me.Caption = "New member"
txtdoj.Enabled = False
Me.Height = Line1.Y2 + 400
dd = Format$(Now, "mm/dd/yyyy")
tt = Format$(time, "hh:mm:ssAM/PM")
dateTimeNow = dd & " " & tt
txtdoj.Text = dateTimeNow '***********Generating ID for the new
member*********************************
rs.Open "Select memberId from members", con, adOpenStatic, adLockOptimistic
If rs.EOF = True Then
txtid.Text = 1
Else
rs.MoveLast
txtid.Text = rs.Fields(0) + 1
End If
rs.Close
'****************************************************************************
End If
End Sub
Public Function clear()
txtid.Locked = True
txtid.Text = ""
63
txtfname.Text = ""
txtlname.Text = ""
txtgender.Text = "Select"
txtdob.Value = "1/1/2012"
txtnumber.Text = ""
txtaddress.Text = ""
End Function
Private Sub Form_Unload(Cancel As Integer)
If loadType = 0 Then
If MsgBox("Do you want to cancel?", vbOKOnly + vbQuestion, "Notification")
= vbYes Then
Unload Me
Call disconnectdatabase
Exit Sub
Else
Exit Sub
End If
End If
Unload Me
Call disconnectdatabase
End Sub
Public Function generateSelfReport()
Dim str As String
lblMemberNameGreeting.Caption = txtid.Text & " " & txtfname.Text & " " &
txtlname.Text
str = getLastMeasurementDateOf(Val(txtid.Text))
If Not str = "" Then
lblLastMeasurementDate.Caption = "Last measurement date: " & str
Else
lblLastMeasurementDate.Caption = "Measurement History is empty"
End If
str = ""
lblBMIChange.Caption = "BMI change : " & getBMIchangeOf(Val(txtid.Text))
lblBodyFatChange.Caption = "Body Fat change : " &
getBodyFatChangeOf(Val(txtid.Text))
lblWeightChange.Caption = "Weight change : " &
getWeightChangeOf(Val(txtid.Text))
str = getLastPaymentDateOf(Val(txtid.Text))
If Not str = "" Then
lblLastPaymentDate.Caption = "Last Payment Date : " & str
Else
lblLastPaymentDate.Caption = "Payment History is empty"
End If
str = ""
str = getTotalAmtPaidOf(Val(txtid.Text))
If Not str = "" Then
lblTotalAmtPaid.Caption = "Total amount paid : " & str
Else
lblTotalAmtPaid.Caption = "Payment History is empty"
End If
64
str = ""
lblSinceJoinedDate.Caption = sinceJoinedDateOf(Val(txtid.Text))
lblDueDate.Caption = "Due Date : " & getDueDateOf(Val(txtid.Text))
Dim rs3 As ADODB.Recordset
Set rs3 = New ADODB.Recordset
rs3.CursorLocation = adUseClient
rs3.Open "SELECT * FROM progressMember WHERE memberId=" & Val(txtid.Text),
con, adOpenDynamic, adLockOptimistic
Set measurementHistory.DataSource = rs3
End Function
Private Sub txtnumber_KeyPress(KeyAscii As Integer)
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
frmMemberlist Form:
Dim memberId As Integer
Dim oSelRows As SelBookmarks
Dim bookmark As Double
Private Sub cmdAddMember_Click()
frmMember.loadType = 0
frmMember.Show
End Sub
Private Sub cmdDeleteMember_Click()
If memberId = -1 Then
MsgBox "Select the member to delete!", vbOKOnly + vbExclamation,
"Notification"
Exit Sub
End If
If MsgBox("Are you really want to delete the user?", vbYesNo + vbQuestion,
"Notification") = vbYes Then
'delete
rs.Open "Select * from members", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
Do While Not rs.EOF
If rs.Fields(0) = memberId Then
rs.Delete
rs.Update
rs.Close
Exit Do
End If
rs.MoveNext
Loop
rs.Close
rs.Open "select * from progressMember", con, adOpenDynamic,
adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
65
End If
Do While Not rs.EOF
If rs.Fields(0) = memberId Then
rs.Delete
rs.Update
rs.Close
Exit Do
End If
rs.MoveNext
Loop
rs.Close
ElseIf answer = vbNo Then
frmMemberlist.SetFocus
End If

End Sub
Private Sub cmdMakePayment_Click()
If memberId = -1 Then
MsgBox "Select the member to make payment!", vbOKOnly + vbExclamation,
"Notification"
Exit Sub
End If
frmPayment.memberId = memberId
frmPayment.Show
memberId = -1
End Sub
Private Sub cmdModifyMember_Click()
If memberId = -1 Then
MsgBox "Select the member to modify!", vbOKOnly + vbExclamation,
"Notification"
Exit Sub
End If
frmMember.loadType = 1
frmMember.memberId = memberId
frmMember.Show
memberId = -1
End Sub
Private Sub cmdShowProfile_Click()
If memberId = -1 Then
MsgBox "Select the member to modify!", vbOKOnly + vbExclamation,
"Notification"
Exit Sub
End If
frmMember.loadType = 2
frmMember.memberId = memberId
frmMember.Show
memberId = -1
End Sub
Private Sub cmmdTakeMeasurement_Click()
frmMemberMeasurement.memberId = Val(DataGrid1.Columns(0))
66
frmMemberMeasurement.Show
End Sub
Private Sub DataGrid1_Click()
memberId = DataGrid1.Columns(0)
End Sub

Private Sub Form_Load()


memberId = -1
'MsgBox memberId
Me.Picture = Nothing
memberTableDC.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & App.Path & "\Data\sgsdata.mdb;Persist Security Info=False"
memberTableDC.CommandType = adCmdText
memberTableDC.RecordSource = "select * from members"
Set DataGrid1.DataSource = memberTableDC
End Sub
Private Sub searchField_Change()
If searchField.Text = "" Then
DataGrid1.ClearFields
memberTableDC.CommandType = adCmdText
memberTableDC.RecordSource = "Select * from members"
Set DataGrid1.DataSource = memberTableDC
memberTableDC.Refresh
DataGrid1.Refresh
Exit Sub
End If
If optRno Then
DataGrid1.ClearFields
memberTableDC.CommandType = adCmdText
memberTableDC.RecordSource = "Select * from members where memberId like
'" & Val(searchField.Text) & "%'"
Set DataGrid1.DataSource = memberTableDC
memberTableDC.Refresh
DataGrid1.Refresh
ElseIf optFname Then
DataGrid1.ClearFields
memberTableDC.CommandType = adCmdText
memberTableDC.RecordSource = "Select * from members where firstname like
'" & searchField.Text & "%'"
Set DataGrid1.DataSource = memberTableDC
memberTableDC.Refresh
DataGrid1.Refresh
End If
End Sub
Private Sub searchField_KeyPress(KeyAscii As Integer)
If optRno Then
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End If
67
End Sub
frmMemberMeasurement
Public memberId As Integer
Public memberGender As Boolean
Dim dateTimeNow As String
Dim dd As String
Dim tt As String
Private Sub c1height_KeyPress(KeyAscii As Integer)
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub c2weight_KeyPress(KeyAscii As Integer)
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub c3neck_KeyPress(KeyAscii As Integer)
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub c4hips_KeyPress(KeyAscii As Integer)
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub

Private Sub c5waist_Change()


If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub c6forearm_KeyPress(KeyAscii As Integer)
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub c7wrist_KeyPress(KeyAscii As Integer)
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub cmdCalculate_Click()
lblBMI.Caption = calculateBMIbyMetric(Val(c2weight.Text), Val(c1height.Text))
lblBodyFat.Caption = calculateBodyFat(memberGender, Val(c2weight.Text),
Val(c5waist.Text), Val(c7wrist.Text), Val(c4hips.Text), Val(c6forearm.Text)) & "%"
End Sub
Private Sub cmdCancel_Click()

68
If MsgBox("Measurement will be declined", vbYesNo + vbQuestion, "Notification")
= vbYes Then
Unload Me
End If
End Sub
Private Sub cmdSave_Click()
If c1height.Text = "" And _
c2weight.Text = "" And _
c3neck.Text = "" And _
c4hips.Text = "" And _
c5waist.Text = "" And _
c6forearm.Text = "" And _
c7wrist.Text = "" Then
MsgBox "Core Measurement fields are mandatory!", vbOKOnly +
vbExclamation, "Notification"
Exit Sub
End If
dd = Format$(Now, "mm/dd/yyyy")
tt = Format$(time, "hh:mm:ssAM/PM")
dateTimeNow = dd & " " & tt
Call databaseconnection
rs.Open "select * from progressMember", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveLast
End If
rs.AddNew
rs.Fields(0) = Val(lblmemberId.Caption)
rs.Fields(1) = Val(c1height.Text)
rs.Fields(2) = Val(c2weight.Text)
rs.Fields(3) = Val(lblBMI.Caption)
rs.Fields(4) = Val(d1bicep.Text)
rs.Fields(5) = Val(c4hips.Text)
rs.Fields(6) = Val(d2thigh.Text)
rs.Fields(7) = Val(c3neck.Text)
rs.Fields(8) = Val(c6forearm.Text)
rs.Fields(9) = Val(d3chest.Text)
rs.Fields(10) = Val(d4calves.Text)
rs.Fields(11) = dateTimeNow
Dim tempArray() As String
tempArray = Split(lblBodyFat.Caption, "%")
rs.Fields(12) = Val(tempArray(0))
rs.Fields(13) = Val(c5waist.Text)
rs.Fields(14) = Val(c7wrist.Text)
rs.Update
rs.Close
MsgBox "Measurement of " & memberId & " was successfully added", vbOKOnly
+ vbInformation, "Notification"
Unload Me
End Sub
Private Sub d1bicep_KeyPress(KeyAscii As Integer)
69
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub d2thigh_KeyPress(KeyAscii As Integer)
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub d3chest_KeyPress(KeyAscii As Integer)
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub d4calves_KeyPress(KeyAscii As Integer)
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub Form_Load()
optionCore.Value = True
corePanel.Enabled = True
detailedPanel.Enabled = False
detailedPanel.BackColor = &HE0E0E0
Me.Caption = "Measurement"
dd = Format$(Now, "mm/dd/yyyy")
tt = Format$(time, "hh:mm:ssAM/PM")
dateTimeNow = dd
lblDate.Caption = dateTimeNow
Call databaseconnection
rs.Open "select * from members", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
Do While Not rs.EOF
If rs.Fields(0) = memberId Then
lblmemberId.Caption = rs.Fields(0)
lblname.Caption = rs.Fields(1) & " " & rs.Fields(2)
If rs.Fields(3) = "Male" Then
memberGender = True
Else
memberGender = False
End If
Exit Do
End If
rs.MoveNext
Loop
rs.Close

End Sub
70
Private Sub Form_Unload(Cancel As Integer)
If MsgBox("Measurement will be declined", vbYesNo + vbQuestion, "Notification")
= vbYes Then
Unload Me
End If
End Sub
Private Sub optionCore_Click()
corePanel.Enabled = True
detailedPanel.Enabled = False
detailedPanel.BackColor = &HE0E0E0
End Sub

Private Sub optionDetailed_Click()


corePanel.Enabled = True
detailedPanel.Enabled = True
detailedPanel.BackColor = corePanel.BackColor
End Sub
frmMetroStyleMenu
Public memberId As Integer
Public memberGender As Boolean

Dim dateTimeNow As String


Dim dd As String
Dim tt As String
Private Sub c1height_KeyPress(KeyAscii As Integer)
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub c2weight_KeyPress(KeyAscii As Integer)
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub c3neck_KeyPress(KeyAscii As Integer)
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub

Private Sub c4hips_KeyPress(KeyAscii As Integer)


If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub c5waist_Change()
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
71
Private Sub c6forearm_KeyPress(KeyAscii As Integer)
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub c7wrist_KeyPress(KeyAscii As Integer)
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub cmdCalculate_Click()
lblBMI.Caption = calculateBMIbyMetric(Val(c2weight.Text), Val(c1height.Text))
lblBodyFat.Caption = calculateBodyFat(memberGender, Val(c2weight.Text),
Val(c5waist.Text), Val(c7wrist.Text), Val(c4hips.Text), Val(c6forearm.Text)) & "%"
End Sub
Private Sub cmdCancel_Click()
If MsgBox("Measurement will be declined", vbYesNo + vbQuestion, "Notification")
= vbYes Then
Unload Me
End If
End Sub
Private Sub cmdSave_Click()
If c1height.Text = "" And _
c2weight.Text = "" And _
c3neck.Text = "" And _
c4hips.Text = "" And _
c5waist.Text = "" And _
c6forearm.Text = "" And _
c7wrist.Text = "" Then
MsgBox "Core Measurement fields are mandatory!", vbOKOnly +
vbExclamation, "Notification"
Exit Sub
End If
dd = Format$(Now, "mm/dd/yyyy")
tt = Format$(time, "hh:mm:ssAM/PM")
dateTimeNow = dd & " " & tt
Call databaseconnection
rs.Open "select * from progressMember", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveLast
End If
rs.AddNew
rs.Fields(0) = Val(lblmemberId.Caption)
rs.Fields(1) = Val(c1height.Text)
rs.Fields(2) = Val(c2weight.Text)
rs.Fields(3) = Val(lblBMI.Caption)
rs.Fields(4) = Val(d1bicep.Text)
rs.Fields(5) = Val(c4hips.Text)
rs.Fields(6) = Val(d2thigh.Text)
rs.Fields(7) = Val(c3neck.Text)
72
rs.Fields(8) = Val(c6forearm.Text)
rs.Fields(9) = Val(d3chest.Text)
rs.Fields(10) = Val(d4calves.Text)
rs.Fields(11) = dateTimeNow
Dim tempArray() As String
tempArray = Split(lblBodyFat.Caption, "%")
rs.Fields(12) = Val(tempArray(0))
rs.Fields(13) = Val(c5waist.Text)
rs.Fields(14) = Val(c7wrist.Text)
rs.Update
rs.Close
MsgBox "Measurement of " & memberId & " was successfully added", vbOKOnly
+ vbInformation, "Notification"
Unload Me
End Sub
Private Sub d1bicep_KeyPress(KeyAscii As Integer)
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
Private Sub d2thigh_KeyPress(KeyAscii As Integer)
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub d3chest_KeyPress(KeyAscii As Integer)
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub d4calves_KeyPress(KeyAscii As Integer)
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub Form_Load()

optionCore.Value = True
corePanel.Enabled = True
detailedPanel.Enabled = False
detailedPanel.BackColor = &HE0E0E0
Me.Caption = "Measurement"
dd = Format$(Now, "mm/dd/yyyy")
tt = Format$(time, "hh:mm:ssAM/PM")
dateTimeNow = dd
lblDate.Caption = dateTimeNow
Call databaseconnection
rs.Open "select * from members", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
73
Do While Not rs.EOF
If rs.Fields(0) = memberId Then
lblmemberId.Caption = rs.Fields(0)
lblname.Caption = rs.Fields(1) & " " & rs.Fields(2)
If rs.Fields(3) = "Male" Then
memberGender = True
Else
memberGender = False
End If
Exit Do
End If
rs.MoveNext
Loop
rs.Close
End Sub
Private Sub Form_Unload(Cancel As Integer)
If MsgBox("Measurement will be declined", vbYesNo + vbQuestion, "Notification")
= vbYes Then
Unload Me
End If
End Sub
Private Sub optionCore_Click()
corePanel.Enabled = True
detailedPanel.Enabled = False
detailedPanel.BackColor = &HE0E0E0
End Sub
Private Sub optionDetailed_Click()
corePanel.Enabled = True
detailedPanel.Enabled = True

detailedPanel.BackColor = corePanel.BackColor
End Sub
frmPayment Form:
Public memberId As Integer
Dim duration As Integer
Option Explicit
Private Sub cmdCancel_Click()
Call disconnectdatabase
Unload Me
End Sub
Private Sub cmdPay_Click()
rs.Open "select * from paymentTransaction", con, adOpenDynamic,
adLockOptimistic
If Not rs.EOF Then
rs.MoveLast
End If
rs.AddNew
rs.Fields(0).Value = txtid.Text
rs.Fields(1).Value = Format$(Now, "mm/dd/yyyy") & " " & Format$(time,
"hh:mm:ssAM/PM")
74
rs.Fields(2).Value = Val(txtPayableAmt.Caption)
rs.Fields(3).Value = Val(lblBillno.Caption)
rs.Update
rs.Close

rs.Open "select * from members", con, adOpenDynamic, adLockOptimistic


If Not rs.EOF Then
rs.MoveFirst
End If
Do Until rs.EOF
If rs.Fields(0) = Val(txtid.Text) Then
Dim dueSTR As String
dueSTR = rs.Fields("dueDate").Value
rs.Fields("dueDate").Value = addMonth(dueSTR, duration)
rs.Update

If MsgBox("Payment Transaction done! " & vbCrLf & "Do you want to print the
receipt?", vbYesNo + vbQuestion, "Notification") = vbYes Then
'Receipt Print page generation
***************************************************
Dim rsTemp As ADODB.Recordset
Set rsTemp = New ADODB.Recordset
rsTemp.Open "select * from gymDetail", con, adOpenDynamic,
adLockOptimistic
If Not rsTemp.EOF Then
rsTemp.MoveFirst
End If
Dim zgname As String
Dim zaddress As String
Dim zphone As String
Dim zmname As String
Dim zpType As String
Dim zdueDate As String
Dim zdate As String

Dim zBillNo As Integer


Dim zId As Integer
Dim zAmt As Double
Do Until rsTemp.EOF
zgname = rsTemp.Fields(0)
zaddress = rsTemp.Fields(1)
zphone = rsTemp.Fields(3)
Exit Do
Loop
zmname = Trim(txtname.Text)
zpType = Trim(txtPaymentType.Text)
zdueDate = Trim(rs.Fields("dueDate"))
zBillNo = Val(lblBillno.Caption)
zId = Val(txtid.Text)
zAmt = Val(txtPayableAmt.Caption)
75
Call databaseconnection
Dim rsT As ADODB.Recordset
Set rsT = New ADODB.Recordset
rsT.Open "select * from gymDetail", con, adOpenDynamic, adLockOptimistic
Set ReceiptP.DataSource = rsT
ReceiptP.DataMember = rsT.DataMember
ReceiptP.Sections("Section0").Controls("lblGymName").Caption = zgname
ReceiptP.Sections("Section0").Controls("lblAddress").Caption = zaddress
ReceiptP.Sections("Section0").Controls("lblPhone").Caption = zphone
ReceiptP.Sections("Section1").Controls("lblBillNo").Caption = "Receipt No : "
& zBillNo
ReceiptP.Sections("Section2").Controls("lblMemberName").Caption =
zmname
ReceiptP.Sections("Section2").Controls("lblPlanName").Caption = zpType
ReceiptP.Sections("Section2").Controls("lblDueDate").Caption = zdueDate
ReceiptP.Sections("Section2").Controls("lblAmtPaid").Caption = zAmt
ReceiptP.Sections("Section2").Controls("lblMemberId").Caption = zId
ReceiptP.Sections("Section1").Controls("lblReceiptDate").Caption = "Receipt
Date : " & zdate
ReceiptP.Show
'ENDING RECEIPT GENERATION
******************************************************
End If
Exit Do
End If
rs.MoveNext
Loop
rs.Close
'Unload Me
End Sub

Private Sub Form_Load()


Call databaseconnection
'generating billno
rs.Open "select * from paymentTransaction ORDER BY billno", con, adOpenDynamic,
adLockOptimistic
If Not rs.EOF Then
rs.MoveLast
End If
If rs.RecordCount = 0 Then
lblBillno.Caption = "0"
Else
lblBillno.Caption = rs.Fields(3) + 1
End If
rs.Close
rs.Open "select * from membershipPlan", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
76
While Not rs.EOF
txtPaymentType.AddItem (rs.Fields(0).Value)
rs.MoveNext
Wend
txtPaymentType.Text = "Select"
rs.Close
rs.Open "Select * from members", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
While Not rs.EOF
If memberId = rs.Fields(0) Then
txtid.Text = rs.Fields(0)
txtname.Text = rs.Fields(1)
rs.Close
Exit Sub
End If
rs.MoveNext
Wend
rs.Close
'MsgBox "User could not found!", vbOKOnly + vbExclamation, "Notification"
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call disconnectdatabase
End Sub
Private Sub txtPaymentType_Click()
If txtPaymentType.Text = "..." Then
dialogToAccessAdmin.Show
Else
rs.Open "select * from membershipPlan", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
While Not rs.EOF
If txtPaymentType.Text = rs.Fields(0) Then
txtPayableAmt.Caption = rs.Fields(2)
duration = rs.Fields(1)
rs.Close
Exit Sub
End If
rs.MoveNext
Wend
rs.Close
End If
End Sub

frmProgress Form:
Public memberId As Integer
Public fname As String
Public lname As String
77
Private Sub Form_Load()
lblFname.Caption = fname
lblLname.Caption = lname
lblmemberId.Caption = memberId
tableDC.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
App.Path & "\Data\sgsdata.mdb;Persist Security Info=False"
tableDC.CommandType = adCmdText
tableDC.RecordSource = "select * from progressMember where memberId=" &
memberId
Set table.DataSource = tableDC
End Sub
frmReport Form:
Option Explicit
Dim billNo As Integer
Dim paymentQuery As String
Dim memberId As Integer
Dim memberId1 As Integer
Private Sub cmdPrint_Click()
If paymentQuery = "" Then
Exit Sub
End If
Dim sum As Double
Dim Count As Integer
Dim gName As String
Dim gAddress As String
Dim rec As ADODB.Recordset
Set rec = New ADODB.Recordset
rec.Open "select * from gymDetail", con, adOpenDynamic, adLockOptimistic
If Not rec.EOF Then
rec.MoveFirst
gName = rec.Fields(0)
gAddress = rec.Fields(1)
Else
gName = ""
gAddress = ""
End If
rec.Close
rec.Open paymentQuery, con, adOpenDynamic, adLockOptimistic
Count = 0
sum = 0
If Not rec.EOF Then
rec.MoveFirst
End If
Do Until rec.EOF
sum = sum + rec.Fields(2)
Count = Count + 1
rec.MoveNext
Loop
Set PaymentP.DataSource = rec
PaymentP.DataMember = rs.DataMember
78
PaymentP.Sections("Section4").Controls("lblGymName").Caption = gName
PaymentP.Sections("Section4").Controls("lblAddress").Caption = gAddress
PaymentP.Sections("Section5").Controls("lblRecordCount").Caption = "Total
Transaction : " & Count
PaymentP.Sections("Section2").Controls("lblRange").Caption = "Range : " &
dtFrom.Value & " - " & dtTo.Value
PaymentP.Sections("Section5").Controls("lblTotalTransaction").Caption = "Total : "
& sum & "rs"
PaymentP.Show
End Sub
Private Sub cmdPrintDue_Click()
Call databaseconnection
Dim gymName As String
Dim gymAddress As String
Dim countM As Integer
Dim recM As ADODB.Recordset
Set recM = New ADODB.Recordset
recM.Open "select * from gymDetail", con, adOpenDynamic, adLockOptimistic
If Not recM.EOF Then
recM.MoveFirst
gymName = recM.Fields(0)
gymAddress = recM.Fields(1)
Else
gymName = ""
gymAddress = ""
End If
recM.Close
countM = countOutdatedMembers
Set recM = getOutdatedMembers
Set DueMembersP.DataSource = recM
DueMembersP.DataMember = recM.DataMember
DueMembersP.Sections("Section4").Controls("lblGymName").Caption = gymName
DueMembersP.Sections("Section4").Controls("lblAddress").Caption = gymAddress
DueMembersP.Sections("Section3").Controls("lblCount").Caption = countM
DueMembersP.Show
End Sub
Private Sub cmdPrintReceipt_Click()
If billNo = -1 Then
MsgBox "Choose a bill to print!", vbOKOnly + vbExclamation, "Notification"
Exit Sub
End If
'Receipt Print page generation ***************************************************
Dim zgname As String
Dim zaddress As String
Dim zphone As String
Dim zmname As String
Dim zpType As String
Dim zdueDate As String
Dim zdate As String
Dim zBillNo As Integer
79
Dim zId As Integer
Dim zAmt As Double
Dim rsTemp As ADODB.Recordset
Set rsTemp = New ADODB.Recordset
rsTemp.Open "select * from gymDetail", con, adOpenDynamic,
adLockOptimistic
If Not rsTemp.EOF Then
rsTemp.MoveFirst
End If
Do Until rsTemp.EOF
zgname = rsTemp.Fields(0)
zaddress = rsTemp.Fields(1)
zphone = rsTemp.Fields(3)
Exit Do
Loop
rsTemp.Close
rsTemp.Open "select * from paymentTransaction where billno=" & billNo,
con, adOpenDynamic, adLockOptimistic
If Not rsTemp.RecordCount = 0 Then
If Not rsTemp.EOF Then
rsTemp.MoveFirst
End If
zBillNo = Val(rsTemp.Fields(3))
zdate = rsTemp.Fields(1)
zAmt = Val(rsTemp.Fields(2))
zId = Val(rsTemp.Fields(0))
Else
zBillNo = 0
zdate = ""
zAmt = 0
zId = 0
End If
rsTemp.Close
rsTemp.Open "Select * From members where memberId=" & zId, con,
adOpenDynamic, adLockOptimistic
If Not rsTemp.RecordCount = 0 Then
rsTemp.MoveFirst
zmname = rsTemp.Fields(1)
zdueDate = rsTemp.Fields("dueDate")
Else
zmname = ""
zdueDate = ""
End If
rsTemp.Close
rsTemp.Open "Select * from membershipPlan where amt=" & zAmt, con,
adOpenDynamic, adLockOptimistic
If Not rsTemp.RecordCount = 0 Then
zpType = rsTemp.Fields("planName")
Else
zpType = ""
80
End If
rsTemp.Close
Dim rsT As ADODB.Recordset
Set rsT = New ADODB.Recordset
rsT.Open "select * from gymDetail", con, adOpenDynamic, adLockOptimistic
Set ReceiptP.DataSource = rsT
ReceiptP.DataMember = rsT.DataMember
ReceiptP.Sections("Section0").Controls("lblGymName").Caption = zgname
ReceiptP.Sections("Section0").Controls("lblAddress").Caption = zaddress
ReceiptP.Sections("Section0").Controls("lblPhone").Caption = zphone
ReceiptP.Sections("Section1").Controls("lblBillNo").Caption = "Receipt No : "
& zBillNo
ReceiptP.Sections("Section2").Controls("lblMemberName").Caption =
zmname
ReceiptP.Sections("Section2").Controls("lblPlanName").Caption = zpType
ReceiptP.Sections("Section2").Controls("lblDueDate").Caption = zdueDate
ReceiptP.Sections("Section2").Controls("lblAmtPaid").Caption = zAmt
ReceiptP.Sections("Section2").Controls("lblMemberId").Caption = zId
ReceiptP.Sections("Section1").Controls("lblReceiptDate").Caption = "Receipt
Date : " & zdate
ReceiptP.Show
'ENDING RECEIPT GENERATION
******************************************************
End Sub
Private Sub cmdProfile_Click()
If memberId = -1 Then
MsgBox "Select a member ID to see the profile!", vbOKOnly + vbExclamation,
"Warning"
Exit Sub
End If
frmMember.loadType = 2
frmMember.memberId = memberId
frmMember.Show
End Sub
Private Sub cmdShowProfile_Click()
If memberId1 = -1 Then
MsgBox "Select a member ID to see the profile!", vbOKOnly + vbExclamation,
"Warning"
Exit Sub
End If

frmMember.loadType = 2
frmMember.memberId = memberId1
frmMember.Show
End Sub
Private Sub combIncome_Click()
Dim arr() As String
arr = Split(combIncome.Text, " ")
lblIncomeByRange.Caption = combIncome.Text & " Income : " &
getIncomeByRange(Val(arr(1)))
81
End Sub
Private Sub dtFrom_Change()
paymentTransaction.ClearFields
paymentTransactionDC.ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path &
"\Data\sgsdata.mdb;Persist Security Info=False"
paymentTransactionDC.CommandType = adCmdText
paymentTransactionDC.RecordSource = "SELECT * FROM paymentTransaction
where date between #" & dtFrom.Value & "# and #" & dtTo.Value & "#"
paymentQuery = "SELECT * FROM paymentTransaction where date between #" &
dtFrom.Value & "# and #" & dtTo.Value & "#"
Set paymentTransaction.DataSource = paymentTransactionDC
paymentTransactionDC.Refresh
paymentTransaction.Refresh
End Sub
Private Sub dtTo_Change()
paymentTransaction.ClearFields
paymentTransactionDC.ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path &
"\Data\sgsdata.mdb;Persist Security Info=False"
paymentTransactionDC.CommandType = adCmdText
paymentTransactionDC.RecordSource = "SELECT * FROM paymentTransaction
where date between #" & dtFrom.Value & "# and #" & dtTo.Value & "#"
paymentQuery = "SELECT * FROM paymentTransaction where date between #" &
dtFrom.Value & "# and #" & dtTo.Value & "#"
Set paymentTransaction.DataSource = paymentTransactionDC
paymentTransactionDC.Refresh
paymentTransaction.Refresh
End Sub
Private Sub Form_Load()
memberId = -1
memberId1 = -1
billNo = -1
paymentQuery = "select * from paymentTransaction"
combIncome.AddItem "Last 1 month"
combIncome.AddItem "Last 2 month"
combIncome.AddItem "Last 3 month"
combIncome.AddItem "Last 4 month"
combIncome.AddItem "Last 5 month"
combIncome.AddItem "Last 6 month"
combIncome.AddItem "Last 7 month"
combIncome.AddItem "Last 8 month"
combIncome.AddItem "Last 9 month"
combIncome.AddItem "Last 10 month"
combIncome.AddItem "Last 11 month"
combIncome.AddItem "Last 12 month"
combIncome.ListIndex = 0
Dim arr() As String
arr = Split(combIncome.Text, " ")
Dim cMembers As Integer
82
cMembers = countMembers
lblTotalMembers.Caption = "Total Members : " & cMembers
lblTotalIncome.Caption = "Total Income : " & getIncome & "rs"
lblIncomeByRange.Caption = "Last Month Income : " &
getIncomeByRange(Val(arr(1))) & "rs"
Dim male As Integer, female As Integer
Dim mperc As Double, fperc As Double
male = countMaleMembers
female = countFemaleMembers
mperc = male / cMembers * 100
fperc = female / cMembers * 100
lblgenderMcount.Caption = "Male " & male & " and " & mperc & "%"
lblgenderFcount.Caption = "Female " & female & " and " & fperc & "%"
paymentTransactionDC.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & App.Path & "\Data\sgsdata.mdb;Persist Security Info=False"
paymentTransactionDC.CommandType = adCmdText
paymentTransactionDC.RecordSource = "SELECT * FROM paymentTransaction"
Set paymentTransaction.DataSource = paymentTransactionDC
Set OutdatedMembers.DataSource = getOutdatedMembers

OutdatedMembers.Columns(0).Width = 400
OutdatedMembers.Columns(1).Width = 1000
OutdatedMembers.Columns(2).Width = 1700
paymentTransaction.Columns(1).Width = 2300
End Sub
Private Sub lblCountGenderMembers_Click()
End Sub
Private Sub paymentTransaction_Click()
billNo = paymentTransaction.Columns(3)
memberId = Val(paymentTransaction.Columns(1))
End Sub
Private Sub txtSearchByBillno_Change()
If txtSearchByBillno.Text = "" Then
paymentTransaction.ClearFields
paymentTransactionDC.ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path &
"\Data\sgsdata.mdb;Persist Security Info=False"
paymentTransactionDC.CommandType = adCmdText
paymentTransactionDC.RecordSource = "SELECT * FROM paymentTransaction"
paymentQuery = "SELECT * FROM paymentTransaction"
Set paymentTransaction.DataSource = paymentTransactionDC
paymentTransactionDC.Refresh
paymentTransaction.Refresh
Exit Sub
End If
paymentTransaction.ClearFields
paymentTransactionDC.ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path &
"\Data\sgsdata.mdb;Persist Security Info=False"
paymentTransactionDC.CommandType = adCmdText
83
paymentTransactionDC.RecordSource = "SELECT * FROM paymentTransaction
where billno like '" & Val(txtSearchByBillno.Text) & "%'"
paymentQuery = "SELECT * FROM paymentTransaction where billno like '" &
Val(txtSearchByBillno.Text) & "%'"
Set paymentTransaction.DataSource = paymentTransactionDC
paymentTransactionDC.Refresh
paymentTransaction.Refresh
End Sub
Private Sub txtSearchByBillno_KeyPress(KeyAscii As Integer)
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
frmSearch Form:
Public loadMeasurement As Boolean
Public loadSearchNprofile As Boolean
Public loadPayment As Boolean
Public loadBodyProgress As Boolean
Option Explicit
Private Sub cmdSelect_Click()
Dim memberId As Integer
Dim fname As String
Dim lname As String
Dim gender As Boolean
rs.Open "Select * from members", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
If optRollno Then
Do Until rs.EOF
If rs.Fields(0) = Val(combMember.Text) Then
memberId = rs.Fields(0)
fname = rs.Fields(1)
lname = rs.Fields(2)
If rs.Fields(3) = "Male" Then
gender = True
Else
gender = False
End If
Exit Do
End If
rs.MoveNext
Loop
ElseIf optFname Then
Do Until rs.EOF
If rs.Fields(1) = Trim(combMember.Text) Then
memberId = rs.Fields(0)
fname = rs.Fields(1)
lname = rs.Fields(2)
If rs.Fields(3) = "Male" Then
84
gender = True
Else
gender = False
End If
Exit Do
End If
rs.MoveNext
Loop
Else
Do Until rs.EOF
If rs.Fields(2) = Trim(combMember.Text) Then
memberId = rs.Fields(0)
fname = rs.Fields(1)
lname = rs.Fields(2)
If rs.Fields(3) = "Male" Then
gender = True
Else
gender = False
End If
Exit Do
End If
rs.MoveNext
Loop

End If
rs.Close
'fetching of user data finished
'*******************************************************************
If loadBodyProgress Then
frmProgress.memberId = memberId
frmProgress.fname = fname
frmProgress.lname = lname
frmProgress.Show
loadBodyProgress = False
Unload Me
ElseIf loadMeasurement Then
frmMemberMeasurement.memberId = memberId
frmMemberMeasurement.Show
loadMeasurement = False
Unload Me
ElseIf loadPayment Then
frmPayment.memberId = memberId
frmPayment.Show
loadPayment = False
Unload Me
ElseIf loadSearchNprofile Then
frmMember.loadType = 2
frmMember.memberId = memberId
frmMember.Show
loadSearchNprofile = False
85
Unload Me
Else
MsgBox "Profile has not loaded!", vbOKOnly + vbExclamation, "Notification"
End If
End Sub
Private Sub combMember_Change()
AutoTypeComboChange combMember
End Sub
Private Sub combMember_GotFocus()
gstrATCDBTableName = "members"
If optRollno.Value Then
gstrATCDBFieldName = "memberId"
ElseIf optFname.Value Then
gstrATCDBFieldName = "firstname"
Else
gstrATCDBFieldName = "lastname"
End If
gblnGetAllData = False
gblnDropDownOnFocus = IIf(True, True, False)
AutoTypeComboGotFocus combMember
End Sub
Private Sub combMember_KeyDown(KeyCode As Integer, Shift As Integer)
AutoTypeComboKeyDown combMember, KeyCode, Shift
End Sub
Private Sub combMember_KeyPress(KeyAscii As Integer)
If optRollno Then
If Not Chr(KeyAscii) Like "[0-9]" And KeyAscii <> 8 And KeyAscii <> 45 And
KeyAscii <> 47 Then
KeyAscii = 0
End If
End If
AutoTypeComboKeyPress Me, combMember, KeyAscii
End Sub
Private Sub combMember_LostFocus()
AutoTypeComboLostFocus combMember
End Sub
Private Sub Form_Load()
Call databaseconnection
Call combSearch
End Sub
CalculationModule Module:
Public Function calculateBMIbyEnglish(weight As Double, Height As Double)

Dim result As Double


result = (weight / (Height * Height)) * 703
calculateBMIbyEnglish = Round(result, 2)
End Function
Public Function calculateBMIbyMetric(weight As Double, Height As Double)
Dim result As Double
result = (weight / (Height * Height))
86
calculateBMIbyMetric = Round(result, 2)
End Function
Public Function calculateBodyFat(gender As Boolean, weight As Double, waist As
Double, wrist As Double, hips As Double, forearm As Double) As Double
Dim f1, f2, f3, f4, f5, lbm, bfw, result As Double
If gender Then
'male
f1 = (weight * 1.082) + 94.42
f2 = (waist * 4.15)
lbm = f1 - f2
bfw = weight - lbm
result = (bfw * 100) / weight
calculateBodyFat = Round(result, 2)
Else
'female

f1 = (weight * 0.732) + 8.987


f2 = wrist / 3.14
f3 = waist * 0.157
f4 = hips * 0.249
f5 = forearm * 0.434
lbm = f1 + f2 - f3 - f4 + f5
bfw = weight - lbm
result = (bfw * 100) / weight
calculateBodyFat = Round(result, 2)
End If
End Function

customDialogModule Module :
Public trigger As Boolean
Public answerYesNo As Boolean
Public counter As Long
Sub CenterChild(Parent As Form, Child As Form)
Dim iTop As Integer
Dim iLeft As Integer
If Parent.WindowState <> vbNormal Then
Exit Sub
Else
iTop = ((Parent.Height - Child.Height) \ 2)
'iLeft = ((Parent.Width - Child.Width) \ 2)
iLeft = ((Parent.ScaleWidth - Child.ScaleWidth) \ 2)
Child.Move iLeft, iTop
End If
End Sub
Public Function helpDlg(msg As String)
DialogHelp.lblBodyText = msg
DialogHelp.Show
End Function
Public Function notificationDlg(msg As String) As Boolean
DialogNotification.lblBodyText = msg
87
DialogNotification.Show
notificationDlg = answerYesNo
End Function
Function GetFileExtension(ByVal FileName As String) As String
Dim I As Long
For I = Len(FileName) To 1 Step -1
Select Case mId$(FileName, I, 1)
Case "."
GetFileExtension = mId$(FileName, I + 1)
Exit For
Case ":", "\"
Exit For
End Select
Next
End Function
databaseModule Module:
Public barName As String
Public databasePath As String
Public con As New ADODB.Connection
Public rs As New ADODB.Recordset
Public rsTemp As New ADODB.Recordset
Public gobjCmd As ADODB.Command
Public Sub databaseconnection()
If Not con.State = adStateOpen Then
con.Provider = "Microsoft.Jet.OLEDB.4.0"
con.Open App.Path & "\Data\sgsdata.mdb"
End If

End Sub
Public Sub disconnectdatabase()
If con.State = adStateOpen Then
con.Close
End If
End Sub
Function FileExists(FileName As String) As Boolean
On Error GoTo ErrorHandler
FileExists = (GetAttr(FileName) And vbDirectory) = 0
ErrorHandler:
FileExists = False
End Function
Public Sub combSearch()
Set gobjCmd = New ADODB.Command
Set gobjCmd.ActiveConnection = con
gobjCmd.CommandType = adCmdText
End Sub

dateTimeModule Module:
Public Function CurrentDate() As String
Dim sdate As Date
sdate = DateValue(Now)
88
CurrentDate = sdate
End Function
Public Function CurrentTime() As String
Dim time As Date
time = TimeValue(Now)
CurrentTime = time
End Function
Public Function CurrentDayToString() As String
Dim day As Date
day = DatePart("w", Now)
If day = 1 Then
CurrentDayToString = "Sunday"
ElseIf day = 2 Then
CurrentDayToString = "Monday"
ElseIf day = 3 Then
CurrentDayToString = "Tuesday"
ElseIf day = 4 Then
CurrentDayToString = "Wednesday"
ElseIf day = 5 Then
CurrentDayToString = "Thursday"
ElseIf day = 6 Then
CurrentDayToString = "Friday"
ElseIf day = 7 Then
CurrentDayToString = "Saturday"
End If
End Function
Public Function splitNgetDate(datestr As String) As String
Dim tempArray() As String
tempArray = Split(datestr, " ")
splitNgetDate = tempArray(0)
End Function
Public Function splitNgetTime(datestr As String) As String
Dim tempArray() As String
tempArray = Split(datestr, " ")
splitNgetTime = Trim(tempArray(1))
End Function
Public Function getDay(datestr As String) As Integer
'Returns trimmed day of dateSTR
Dim tempArray() As String
tempArray = Split(datestr, "/")
getDay = tempArray(1)
End Function
Public Function getMonth(datestr As String) As Integer
'returns trimmed month of dateSTR
Dim tempArray() As String
tempArray = Split(datestr, "/")
getMonth = tempArray(0)
End Function
Public Function getYear(datestr As String) As Integer
'returns trimmed year of dateSTR
89
Dim tempArray() As String
tempArray = Split(datestr, "/")
getYear = tempArray(2)
End Function

Public Function addMonth(baseDate As String, months As Integer) As String


Dim yyyy As Integer
Dim mm As Integer
Dim dd As Integer
yyyy = getYear(baseDate)
mm = getMonth(baseDate)
dd = getDay(baseDate)

mm = mm + months
If mm > 12 Then
yyyy = yyyy + (mm / 12)
mm = mm Mod 12
End If
addMonth = mm & "/" & dd & "/" & yyyy
End Function

fullScreenModule Module:
Dim isFullscreen As Boolean
Option Explicit
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public Const GWL_STYLE = (-16)
Public Const WS_CAPTION = &HC00000
Public Const WS_MAXIMIZEBOX = &H10000
Public Const WS_MINIMIZEBOX = &H20000
Public Const WS_SYSMENU = &H80000

'window position constants


Public Const SWP_SHOWWINDOW = &H40
Public Const SWP_HIDEWINDOW = &H80
Public Const SWP_FRAMECHANGED = &H20
Public Const SWP_NOACTIVATE = &H10
Public Const SWP_NOCOPYBITS = &H100
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOOWNERZORDER = &H200
Public Const SWP_NOREDRAW = &H8
Public Const SWP_NOREPOSITION = SWP_NOOWNERZORDER
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOZORDER = &H4
90
Public Const SWP_DRAWFRAME = SWP_FRAMECHANGED
Public Const HWND_NOTOPMOST = -2
Public Const SM_CXSCREEN = 0
Public Const SM_CYSCREEN = 1
Public Const HWND_TOP = 0
'API declarations
Public Declare Function GetWindowRect Lib "User32" (ByVal hWnd As Long, lpRect
As RECT) As Long
Public Declare Function SetWindowPos Lib "User32" (ByVal hWnd As Long, ByVal
hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal Cx As Long, ByVal
Cy As Long, ByVal wFlags As Long) As Long

Public Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA"


(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA"
(ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Declare Function GetSystemMetrics Lib "User32" (ByVal nIndex As Long) As
Long
Public dX As Long
Public dY As Long
Public dL As Long
Public dT As Long
Public Function setFullScreen(frm As Form)
Dim Cx As Long
Dim Cy As Long
Dim RetVal As Long
'Record the current size and position of the window
dX = frm.Width
dY = frm.Height
dL = frm.Left
dT = frm.Top
' Determine if screen is already maximized.
If frm.WindowState = vbMaximized Then
' Set window to normal size
frm.WindowState = vbNormal
End If
'Disable the view of the Title Bar
ShowTitleBar False, frm
' Get full screen width.
Cx = GetSystemMetrics(SM_CXSCREEN)
' Get full screen height.
Cy = GetSystemMetrics(SM_CYSCREEN)
' Call API to set new size of window.
RetVal = SetWindowPos(frm.hWnd, HWND_TOP, 0, 0, Cx, Cy,
SWP_SHOWWINDOW)
isFullscreen = True
End Function
Public Function unsetFullscreen(frm As Form)
'Enable the Title Bar Again
ShowTitleBar True, frm
91
'Restore the earlier window size and position
frm.WindowState = vbNormal
frm.Width = dX
frm.Height = dY
frm.Left = dL
frm.Top = dT
frm.Refresh
isFullscreen = False
End Function
Private Function ShowTitleBar(ByVal bState As Boolean, frm As Form)
Dim lStyle As Long
Dim tR As RECT
On Error Resume Next
'get the window's position
Call GetWindowRect(frm.hWnd, tR)
'should the titlebar style be not visible?
lStyle = GetWindowLong(frm.hWnd, GWL_STYLE)
If (bState) Then
'set the style's for the current window (if titlebar active)
frm.Caption = frm.Tag
If frm.ControlBox Then lStyle = lStyle Or WS_SYSMENU
If frm.MaxButton Then lStyle = lStyle Or WS_MAXIMIZEBOX
If frm.MinButton Then lStyle = lStyle Or WS_MINIMIZEBOX
If frm.Caption <> "" Then lStyle = lStyle Or WS_CAPTION
Else
'titlebar is invisible
'set the current caption to the forms tag
frm.Tag = frm.Caption
'remove the caption (otherwise the titlebar will not hide)
frm.Caption = vbNullString
lStyle = lStyle And Not WS_SYSMENU
lStyle = lStyle And Not WS_MAXIMIZEBOX
lStyle = lStyle And Not WS_MINIMIZEBOX
lStyle = lStyle And Not WS_CAPTION
End If
Call SetWindowLong(frm.hWnd, GWL_STYLE, lStyle)
'change the window style maintaining current sizes
Call SetWindowPos(frm.hWnd, 0, tR.Left, tR.Top, tR.Right - tR.Left, tR.Bottom -
tR.Top, SWP_NOREPOSITION Or SWP_NOZORDER Or SWP_FRAMECHANGED)
frm.Refresh
'fire resize code if any
Call Form_Resize
End Function
Private Sub Form_Resize()
End Sub

autoTypeCombo Module
Option Explicit
'*** NOTE: The calling form should use this set of events,
'*** replacing "Combo1" with the name of the combobox.
92
'Private Sub Combo1_GotFocus()
' AutoTypeComboGotFocus Combo1
'End Sub
'Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
' AutoTypeComboKeyDown Combo1, KeyCode, Shift
'End Sub
'Private Sub Combo1_KeyPress(KeyAscii As Integer)
' AutoTypeComboKeyPress Me, Combo1, KeyAscii
'End Sub
'Private Sub Combo1_Change()
' AutoTypeComboChange Combo1
'End Sub
'Private Sub Combo1_LostFocus()
' AutoTypeComboLostFocus Combo1
'End Sub
Public gstrATCDBTableName As String
Public gstrATCDBFieldName As String
Public gblnGetAllData As Boolean ' true = get all entries, false = go by 1st
letter
Public gblnDropDownOnFocus As Boolean
Private Const CB_FINDSTRING As Long = &H14C
Private Const CB_SHOWDROPDOWN As Long = &H14F
Private Const LB_FINDSTRING As Long = &H18F
Private Const CB_ERR As Long = (-1)
Private Const CB_GETITEMHEIGHT As Long = &H154
Private Const CB_SETDROPPEDWIDTH As Long = &H160

Private Type POINTAPI


X As Long
Y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal
hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function MoveWindow Lib "User32" (ByVal hWnd As Long, ByVal X
As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal
bRepaint As Long) As Long
Private Declare Function ScreenToClient Lib "User32" (ByVal hWnd As Long, lpPoint
As POINTAPI) As Long
Private Declare Function GetWindowRect Lib "User32" (ByVal hWnd As Long, lpRect
As RECT) As Long
Private gblnATCIgnoreTextChange As Boolean
Private gblnATCTextDeleted As Boolean
Private gintATCSelStart As Integer
93
Private gintATCSelLen As Integer
'---------------------------------------------------------------------------------
Public Sub AutoTypeComboGotFocus(pobjCombo As ComboBox)
'---------------------------------------------------------------------------------

' Select existing text on entry to the combo box


pobjCombo.SelStart = 0
pobjCombo.SelLength = Len(pobjCombo.Text)
' if currently populated, drop it down
If pobjCombo.ListCount > 0 And gblnDropDownOnFocus Then
SendMessage pobjCombo.hWnd, CB_SHOWDROPDOWN, 1, ByVal 0&
End If
End Sub
'---------------------------------------------------------------------------------
Public Sub AutoTypeComboKeyDown(pobjCombo As ComboBox, _
KeyCode As Integer, _
Shift As Integer)
'---------------------------------------------------------------------------------
' If the full text is selected and the user presses a letter or number,
' the selected text should be replaced
If pobjCombo.SelText = pobjCombo.Text _
And ((KeyCode >= vbKeyA And KeyCode <= vbKeyZ) Or _
(KeyCode >= vbKey0 And KeyCode <= vbKey9)) _
Then
pobjCombo.Text = ""
gblnATCTextDeleted = False
pobjCombo.Refresh
Exit Sub
End If
' If a user presses the "Delete" key, then the selected text
' is removed.
If KeyCode = vbKeyDelete And pobjCombo.SelText <> "" Then
' Make sure that the text is not automatically re-entered
' as soon as it is deleted
gblnATCIgnoreTextChange = True
gintATCSelStart = pobjCombo.SelStart + 1
gintATCSelLen = pobjCombo.SelLength
pobjCombo.SelText = ""
KeyCode = 0
gblnATCTextDeleted = True
Else
gblnATCTextDeleted = False
End If
End Sub
'---------------------------------------------------------------------------------
Public Sub AutoTypeComboKeyPress(pobjForm As Form, _
pobjCombo As ComboBox, _
KeyAscii As Integer)
'---------------------------------------------------------------------------------
' If a user presses the "Backspace" key, then the selected text
94
' is removed. Autosearch is not re-performed, as that would only
' put it straight back again.
Dim objCtl As Control
If Len(pobjCombo.Text) = 0 Then
gblnATCIgnoreTextChange = False
LoadCombo pobjCombo, IIf(gblnGetAllData, "", Chr$(KeyAscii))
If pobjCombo.ListCount > 0 Then
SetDropDownHeight pobjForm, pobjCombo, IIf(pobjCombo.ListCount < 8, _
pobjCombo.ListCount, 8)
End If
pobjForm.Refresh
On Error Resume Next
For Each objCtl In pobjForm.Controls
objCtl.Refresh
Next
End If
If pobjCombo.ListCount > 0 Then
SetDropDownWidth pobjCombo
SendMessage pobjCombo.hWnd, CB_SHOWDROPDOWN, 1, ByVal 0&
End If
If KeyAscii = 8 Then
gblnATCIgnoreTextChange = True
If Len(pobjCombo.SelText) > 0 Then
pobjCombo.SelText = ""
KeyAscii = 0
End If
End If
''if user presses enter, select the listindex
'If KeyAscii = 13 Then
' pobjCombo.ListIndex = SendMessage(pobjCombo.hwnd, _
' CB_FINDSTRING, _
' -1, _
' ByVal CStr(pobjCombo.Text))
'End If
End Sub
'---------------------------------------------------------------------------------
Public Sub AutoTypeComboChange(pobjCombo As ComboBox)
'---------------------------------------------------------------------------------

Dim I As Integer
Dim l As Long
Dim strNewText As String
' Check to see if a search is required.
If gblnATCTextDeleted Then Exit Sub
If Not gblnATCIgnoreTextChange And pobjCombo.ListCount > 0 Then
l = SendMessage(pobjCombo.hWnd, _
CB_FINDSTRING, _
-1, _
ByVal CStr(pobjCombo.Text))
strNewText = pobjCombo.list(l)
95
If Len(pobjCombo.Text) <> Len(strNewText) Then
' Partial match found
' Avoid recursively entering this event
gblnATCIgnoreTextChange = True
I = Len(pobjCombo.Text)
' Attach the full text from the list to what has already been entered.
' This technique preserves the case entered by the user.
pobjCombo.Text = pobjCombo.Text & mId$(strNewText, I + 1)
' Select the text that is auto-entered
pobjCombo.SelStart = I
pobjCombo.SelLength = Len(mId$(strNewText, I + 1))
End If
Else
' The IgnoreTextChange Flag is only effective for one Change event.
gblnATCIgnoreTextChange = False
End If
End Sub
'---------------------------------------------------------------------------------
Public Sub AutoTypeComboLostFocus(pobjCombo As ComboBox)
'---------------------------------------------------------------------------------

On Error Resume Next


If gblnATCTextDeleted Then
If Len(pobjCombo.Text) > 0 Then
pobjCombo.Text = Left$(pobjCombo.Text, gintATCSelStart - 1) & _
mId$(pobjCombo.Text, gintATCSelStart + gintATCSelLen)
pobjCombo.AddItem pobjCombo.Text
End If
End If
End Sub
'---------------------------------------------------------------------------------
Public Sub LoadCombo(pobjCombo As ComboBox, pstrLetter As String)
'---------------------------------------------------------------------------------
Dim objRstDropDownData As ADODB.Recordset
Dim strSQL As String
Dim strWhereClause As String
Dim strWhereOrAnd As String
If pstrLetter = "" Then
strWhereClause = ""
strWhereOrAnd = " WHERE "
Else
strWhereOrAnd = " AND "
If UCase$(pstrLetter) >= "A" And UCase$(pstrLetter) <= "Z" Then
strWhereClause = " WHERE " & gstrATCDBFieldName & " LIKE '" & pstrLetter
& "%'"
Else
strWhereClause = " WHERE " & gstrATCDBFieldName & " LIKE '[!A-Z]%'"
End If
End If
strSQL = ""
96
strSQL = strSQL & "SELECT " & gstrATCDBFieldName
strSQL = strSQL & " FROM " & gstrATCDBTableName
strSQL = strSQL & strWhereClause
strSQL = strSQL & strWhereOrAnd & gstrATCDBFieldName & " IS NOT NULL"
strSQL = strSQL & " AND TRIM(" & gstrATCDBFieldName & ") <> ''"
strSQL = strSQL & " ORDER BY " & gstrATCDBFieldName
gobjCmd.CommandText = strSQL
Set objRstDropDownData = gobjCmd.Execute
With pobjCombo
.clear
Do Until objRstDropDownData.EOF
.AddItem objRstDropDownData.Fields(gstrATCDBFieldName)
objRstDropDownData.MoveNext
Loop
End With

objRstDropDownData.Close
Set objRstDropDownData = Nothing
End Sub
'---------------------------------------------------------------------------------
Public Sub SetDropDownHeight(pobjForm As Form, _
pobjCombo As ComboBox, _
plngNumItemsToDisplay As Long)
'---------------------------------------------------------------------------------

Dim pt As POINTAPI
Dim rc As RECT
Dim lngSavedWidth As Long
Dim lngNewHeight As Long
Dim lngOldScaleMode As Long
Dim lngItemHeight As Long
lngSavedWidth = pobjCombo.Width
lngOldScaleMode = pobjForm.ScaleMode
pobjForm.ScaleMode = vbPixels
lngItemHeight = SendMessage(pobjCombo.hWnd, CB_GETITEMHEIGHT, 0, ByVal
0)
lngNewHeight = lngItemHeight * (plngNumItemsToDisplay + 2)

Call GetWindowRect(pobjCombo.hWnd, rc)


pt.X = rc.Left
pt.Y = rc.Top
Call ScreenToClient(pobjForm.hWnd, pt)
Call MoveWindow(pobjCombo.hWnd, pt.X, pt.Y, pobjCombo.Height, lngNewHeight,
True)
pobjForm.ScaleMode = lngOldScaleMode
pobjCombo.Width = lngSavedWidth
End Sub
'-----------------------------------------------------------------------------
Public Sub SetDropDownWidth(mCombo As ComboBox)
'-----------------------------------------------------------------------------
97
Dim RetVal As Long
Dim PixelWidth As Long
Dim MaxWidth As Long
Dim LoopCounter As Long
Dim lWidth As Long
For LoopCounter = 0 To mCombo.ListCount - 1
lWidth = mCombo.Parent.TextWidth(mCombo.list(LoopCounter))
If lWidth > MaxWidth Then
MaxWidth = lWidth
End If
Next LoopCounter
MaxWidth = MaxWidth + (23 * Screen.TwipsPerPixelX)
If MaxWidth > (mCombo.Width * 2) Then
MaxWidth = (mCombo.Width * 2)
ElseIf MaxWidth < mCombo.Width Then
MaxWidth = mCombo.Width
End If
PixelWidth = (MaxWidth \ Screen.TwipsPerPixelX)
RetVal = SendMessage(mCombo.hWnd, CB_SETDROPPEDWIDTH, PixelWidth, 0)
End Sub

ReportModule Module:
Public Function countMembers() As Integer
Dim counter As Integer
Call databaseconnection
rs.Open "select count(*) from members", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If

Dim n As Integer
n = Val(rs.Fields(0))
rs.Close
countMembers = n
Call disconnectdatabase
End Function
Public Function getOutdatedMembers() As ADODB.Recordset
Dim rsMember As ADODB.Recordset
Set rsMember = New ADODB.Recordset
rsMember.CursorLocation = adUseClient
rsMember.Fields.Append "ID", adBigInt, 20
rsMember.Fields.Append "Name", adVarChar, 100
rsMember.Fields.Append "DueDate", adDate, 100
rsMember.Fields.Append "Status", adVarChar, 100
rsMember.Open
Dim list() As String
Dim counter As Integer
counter = 0
Call databaseconnection
rs.Open "select * from members", con, adOpenDynamic
98
If Not rs.EOF Then
rs.MoveFirst
End If
Dim diff As Long
While Not rs.EOF
diff = DateDiff("d", Format$(rs.Fields("dueDate"), "mm/dd/yyyy"), Now)
If diff >= 0 Then
'Outdated
rsMember.AddNew
rsMember.Fields(0).Value = rs.Fields(0)
rsMember.Fields(1) = rs.Fields(1)
rsMember.Fields(2) = rs.Fields("dueDate")
rsMember.Fields(3) = "Outdated"
rsMember.Update
ElseIf diff >= -7 Then
rsMember.AddNew
rsMember.Fields(0).Value = rs.Fields(0)
rsMember.Fields(1) = rs.Fields(1)
rsMember.Fields(2) = rs.Fields("dueDate")
rsMember.Fields(3) = Abs(diff) & " to out"
rsMember.Update
End If
rs.MoveNext
Wend

rs.Close
Set getOutdatedMembers = rsMember
End Function
Public Function countOutdatedMembers() As Integer
Call databaseconnection
rs.Open "select * from members", con, adOpenDynamic
If Not rs.EOF Then
rs.MoveFirst
End If
Dim counter As Integer
While Not rs.EOF
diff = DateDiff("d", Format$(rs.Fields("dueDate"), "mm/dd/yyyy"), Now)
If diff >= 0 Then
counter = counter + 1
End If
rs.MoveNext
Wend
rs.Close
countOutdatedMembers = counter
End Function
Public Function getIncome() As Long
Call databaseconnection
Dim income As Long
income = 0

99
rs.Open "select * from paymentTransaction", con, adOpenDynamic,
adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
Do While Not rs.EOF
income = income + Val(rs.Fields(2))
rs.MoveNext
Loop
rs.Close
getIncome = income
End Function
Public Function getTotalAmtPaidOf(memberId As Integer) As String
Call databaseconnection
Dim income As Long
income = 0
rs.Open "select * from paymentTransaction where memberId=" & memberId, con,
adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
Do While Not rs.EOF
income = income + Val(rs.Fields(2))
rs.MoveNext
Loop
rs.Close
getTotalAmtPaidOf = income
End Function
Public Function getLastPaymentDateOf(memberId As Integer) As String
Call databaseconnection
Dim datestr As String
Dim cmdString As String
cmdString = "select * from paymentTransaction where memberId=" & memberId &
" ORDER BY date DESC"
rs.Open cmdString, con, adOpenDynamic, adLockOptimistic
If Not rs.RecordCount = 0 Then
If Not rs.EOF Then
rs.MoveFirst
End If
Do Until rs.EOF
datestr = rs.Fields(1)
Exit Do
Loop
End If
rs.Close
If Not datestr = "" Then
getLastPaymentDateOf = datestr
Else
getLastPaymentDateOf = ""
End If
100
End Function
Public Function sinceJoinedDateOf(memberId As Integer) As String
Call databaseconnection
Dim diffDays As Long
Dim diffMonths As Long
Dim since As String
rs.Open "select * from members", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
Do While Not rs.EOF
If rs.Fields(0) = memberId Then
since = splitNgetDate(rs.Fields("doj"))
diffDays = DateDiff("d", Format$(splitNgetDate(rs.Fields("doj")),
"mm/dd/yyyy"), Now)
diffMonts = DateDiff("m", Format$(splitNgetDate(rs.Fields("doj")),
"mm/dd/yyyy"), Now)
Exit Do
End If
rs.MoveNext
Loop
rs.Close
sinceJoinedDateOf = "Since " & since & ", " & Abs(diffMonts) & " months or " &
Abs(diffDays) & " days."
End Function

Public Function getLastMeasurementDateOf(memberId As Integer) As String


Call databaseconnection
Dim str As String
rs.Open "SELECT * FROM progressMember WHERE memberId=" & memberId & "
ORDER BY mdate DESC", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
Do Until rs.EOF
If Not rs.Fields("mdate") = "" Then
str = rs.Fields("mdate")
Else
str = ""
End If
Exit Do
Loop
rs.Close
getLastMeasurementDateOf = str
End Function
Public Function getOverallGrowthOf(memberId As Integer) As String
Call databaseconnection
'date is ordered and Last measurement date comes first
rs.Open "SELECT * FROM progressMember WHERE memberId=" & memberId & "
ORDER BY mdate DESC"
101
If Not rs.EOF Then
rs.MoveFirst
End If
getOverallGrowthOf = ""
End Function
Public Function getBMIchangeOf(memberId As Integer) As Double
Call databaseconnection
'date is ordered and Last measurement date comes first
rs.Open "SELECT TOP 2 * FROM progressMember WHERE memberId=" &
memberId & " ORDER BY mdate DESC"
If Not rs.EOF Then
rs.MoveFirst
End If
Dim last As Double
Dim prev As Double
If rs.RecordCount = 0 Then
last = Val(rs.Fields("bmi"))
rs.MoveNext
prev = Val(rs.Fields("bmi"))
Dim result As Double
result = ((last - prev) * 100) / prev
If result < 0 Then
getBMIchangeOf = Abs(result)
Else
getBMIchangeOf = (-1) * result
End If
Else
getBMIchangeOf = 0
End If
rs.Close
End Function

Public Function getBodyFatChangeOf(memberId As Integer) As Double


Call databaseconnection
'date is ordered and Last measurement date comes first
rs.Open "SELECT TOP 2 * FROM progressMember WHERE memberId=" &
memberId & " ORDER BY mdate DESC"
If Not rs.EOF Then
rs.MoveFirst
End If
Dim last As Double
Dim prev As Double
If rs.RecordCount = 0 Then
last = Val(rs.Fields("bodyfat"))
rs.MoveNext
prev = Val(rs.Fields("bodyfat"))
Dim result As Double
result = ((last - prev) * 100) / prev
If result < 0 Then
102
getBodyFatChangeOf = Abs(result)
Else
getBodyFatChangeOf = (-1) * result
End If
Else
getBodyFatChangeOf = 0
End If
rs.Close
End Function
Public Function getWeightChangeOf(memberId As Integer) As Double
Call databaseconnection
'date is ordered and Last measurement date comes first
rs.Open "SELECT TOP 2 * FROM progressMember WHERE memberId=" &
memberId & " ORDER BY mdate DESC"
If Not rs.EOF Then
rs.MoveFirst
End If

Dim last As Double


Dim prev As Double
If rs.RecordCount = 0 Then
last = Val(rs.Fields("weight"))
rs.MoveNext
prev = Val(rs.Fields("weight"))
Dim result As Double
result = ((last - prev) * 100) / prev
getWeightChangeOf = result
Else
getWeightChangeOf = 0
End If
rs.Close
End Function
Public Function getDueDateOf(memberId As Integer) As String
Call databaseconnection
Dim str As String
rs.Open "select * from members", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
Do Until rs.EOF
If rs.Fields(0) = memberId Then
str = rs.Fields("dueDate")
Exit Do
End If
rs.MoveNext
Loop
rs.Close
getDueDateOf = str
End Function

103
Public Function showReceipt(ByRef billNo As Integer, mId As Integer, mName As
String, planName As String, amt As Double, dueDate As String, gymName As String,
gymAddress As String, gymPhone As String) As Boolean
With ReceiptP
Call databaseconnection
Dim rsT As ADODB.Recordset
Set rsT = New ADODB.Recordset
rsT.Open "select * from members", con, adOpenDynamic, adLockOptimistic
Set .DataSource = rsT
.DataMember = rsT.DataMember
.Sections("Section0").Controls("lblGymName").Caption = gymName
.Sections("Section0").Controls("lblAddress").Caption = gymAddress
.Sections("Section0").Controls("lblPhone").Caption = gymPhone
.Sections("Section1").Controls("lblBillNo").Caption = "Receipt No : " & billNo
.Sections("Section2").Controls("lblMemberName").Caption = mName
.Sections("Section2").Controls("lblPlanName").Caption = planName
.Sections("Section2").Controls("lblDueDate").Caption = dueDate
.Sections("Section2").Controls("lblAmtPaid").Caption = amt
.Sections("Section3").Controls("lblMemberId").Caption = mId
.Show
End With
End Function
Public Function getIncomeByRange(last As Integer) As Double
Dim diff As Integer
Dim income As Double
Call databaseconnection
rs.Open "select * from paymentTransaction order by date", con, adOpenDynamic,
adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
End If
Do Until rs.EOF
diff = DateDiff("m", Format$(rs.Fields("date"), "mm/dd/yyyy"), Now)
If diff >= 0 And diff <= 3 Then
income = income + rs.Fields("amt")
End If
rs.MoveNext
Loop
rs.Close
getIncomeByRange = income
End Function

Public Function countMaleMembers() As Integer


Dim Count As Integer
Call databaseconnection
rs.Open "select count(*) from members where gender='Male'", con,
adOpenDynamic, adLockOptimistic
rs.MoveFirst
Count = rs.Fields(0)
rs.Close
104
countMaleMembers = Count
End Function
Public Function countFemaleMembers() As Integer
Dim Count As Integer
Call databaseconnection
rs.Open "select count(*) from members where gender='Female'", con,
adOpenDynamic, adLockOptimistic
rs.MoveFirst
Count = rs.Fields(0)
rs.Close
countFemaleMembers = Count
End Function

105
Testing

6.1 Introduction to Testing

Testing goes side by side with the implementation that is aimed at ensuring that the
system works accurately and efficiently before the live operation is performed .The common
view of testing held by the user is process of executing a program with explicit intention of
handling errors. The application which has been developed has to be tested to prove its validity.
Testing is considered to be the least creative phase of the whole cycle of system design. In the
106
real sense it is the phase, which helps to bring out the creativity of the other phases, and makes it
shine. The Mobile Management System was tested using the following two techniques of
application testing.

6.1.1 White Box Testing

a. By using this technique it was tested that all the individual logical paths were executed
at least once and every statement in the program was executed once during testing
b. All the logical decisions where tested on both their true and false sides
c. All the loops were tested with data in between the range and especially at the boundary
values.

6.1.2 Black Box Testing

a. By the use of this technique the missing functions were identified and placed in their
position.
b. The errors in the interfaces were identified and corrected.
c. The errors in the database access were indentified.
d. This technique was along used to identify the initialization and termination errors and
correct them.

6.1.3 Application Testing Strategies

Any application has to be tested with pre-planned strategies. As Roger Pressman states,
the preparation for testing should star as soon as the design of the system star. To carry out the
testing in an efficient manner certain amount of strategic planning has to be done. Any testing
strategy must incorporate test planning, test case design, test execution and the resultant data
collection evaluation.

Mobile Management was tested with the help of the following testing strategies:

6.1.4 Unit Testing

107
a. In the line of strategy the entire individuals function and modules were put to test
independently
b. By following this strategy all the errors in coding were identified and corrected.
c. This method was applied in combination with the White Box and Black Box testing
d. Technique to find errors in each module.
e. The effort of specific combination of data on system operation was tested.
f. The following were the testes carried out for Graphical User Interface (GUI).
g. It was seen that the pages opens properly based on related menu based commands.
h. It was tested whether all relevant menus, buttons, icons and other controls are available
and properly displayed.
i. Are the names of the menu functions self explanatory?
j. Are data input messages intelligible?

6.1.5 Integration Testing

This application testing strategy has two different approached namely the top down
approach in which the integration is carried out from the top level module to the bottom and the
bottom up approach in which the integration is carried out from the low level modules to the top.

The modules were tested using the bottom up approach by introducing stubs for the top level
functions.

This test was used to identify the errors in the interfaces, the error in passing the parameters
between the function and to correct them.

6.1.6 Validation Testing

The main aim of this testing is to verify that the application system does what it was
designed for. The system was tested to ensure that the purpose of automating the Asha clinic was
fulfilled.
Alpha testing was carried out to ensure the validity of the system

6.1.7 System Testing

108
The idea of applying this testing strategy was to put the system to a series of tests to ensure that it
performed well and exactly same under all condition.

The tests that the system was put were:

Recovery Testing
Performance Testing

The tests were made on each form for its correctness of accepting the data and storing the data
into the respective tables in the desired form of data type. The algorithms were tested with the
test data first and then with the real data. The tests were made for all types of constraints. The
tests were done in presence of the user so that he/she is familiar with the system that is going to
be introduced. During the testing each objective of the system was tested and found to be
working correctly.

6.2 MULTI-USER SYSTEM

Database Locking Schemes: Whenever more than one person is accessing a record/s some type
of process must be use to prevent the outer users from attempting to update the same record at
the same time. This process is a locking scheme. In its simplest form, a locking scheme allows
only one user at a time to update information in the database.

Chapter 7:

109
Conclusion

110
On the area of selling revolution, online selling has been an inevitable
component .Effecting computing capabilities are therefore utilized. The availability
of the required online selling at the press of a button is something favorable and
therefore computers are used for this purpose. Thus, one way of potential taping is
achieved.

The project Online Mobile Selling Management after being tested was found to be
achieving what is meant for. The system is found to be minimum error free ready for
implementation. Any work may not be always perfect. There may be any error or
shortcoming in this work. We have taken at care to ensure that the project works
perfectly.

The system has been designed in such a way that it can be modified with very little
effort to be achieving what a need arise in the future, as it follows the struts
framework. The system has been found to work efficiently and effectively. Due to its
higher user friendliness, other may use these document as a prototype for
developing similar application.

The development application is tested with sample data and outputs obtained in
according to the requirement. Through it could not be claimed that ours is an ideal
project, it will meet the primary requirement of the concern. Even though I have
tried my level best to make it a dream project, due to time constrains I could not
add more facilities to it. So the project has to be improved by having modifications
as and when the necessity arises in due course.

The project Smart Gym System is for computerizing the work in a College.
The application takes care of all the requirements of a job Department and is
capable to provide easy and effective storage of information related to
Department.

111
Chapter 8

FUTURE
Enhancement

112
FUTURE Enhancement
The project has been developed in a very short period of time and all efforts have
been taken so that this project is very efficient in its execution there still exists
some scope of improvement in our project. The following lists some of the
enhancement that can be added incorporate into the project.

Application of the project can be done more attractively .Database management


and stock maintenance module can be added which helps the administrator. This
project can also be modified into a client server application. More security measures
can be taken.

113
Chapter 9

Bibliography

114
Bibliography

Books
[A]Black book,2009

[B]VB Complete Reference,2009

Websites
[a]http://yahoo.com/

[e]http://www.google.com

115
CHAPTER 10

User
Manual
116
Screenshot
DialogToChangeWallpaper

DialogToAccessAdmin

DrDueMemberList

117
118
119
120
121
122
123
124

Das könnte Ihnen auch gefallen