You are on page 1of 282

CAPE COMPUTER SCIENCE

SCHOOL-BASED ASSESSMENT

Group members:
1) Cajaun Campbell
2) Dejorn Byfield
3) Patrick Marsden
4) David Wong
5) Dominic Wiggan

Teacher: Mr. P. Gordon

Examination Year: 2023

Territory: Jamaica

School: Ardenne High School


Table of Contents

Table of Contents Page

Problem Statement……………………………………………………………….3

Pseudocode.………………………………………………………………………5

C-Program……………………………………………………………………...139

Test Plan………………………………………………………………………..269

Test Data………………………………………………………………………..

Page | 2
Problem Statement
White Rose Interiors Limited is a manufacturing company that offers a wide range of

services such as: Custom blinds, carpet cleaning, sofa cleaning, pest control and more. They are

located at The Trade Centre Complex 30-32 Red Hills Rd, Kingston 19 Unit #32. White Rose

Interiors Limited has been in business for over the past thirty years in Jamaica and currently

operate under two branches, in the parishes of Kingston and St. James. Their mission is to be the

premier company in the manufacturing of quality blinds to companies, institutions and

households through the effective combination of teamwork, innovation and motivated staff for

the sustained viability and profitability of the company.

Problem

Customer and Service information are manual written and stored in filing cabinets:

1) The company deals with a large number of customers weekly. To record all jobs

manually is very time consuming and tedious.

2) Job sheets and worksheets can get misplaced easily and information can be lost.

3) If natural disasters were to occur, the information being stored manually would be

irretrievable.

4) It is very costly to continually purchase stationery, cabinets and other materials to keep

all the files updated and organized.

5) It takes up a vast quantity of space in the office to store all the files.

6) It is difficult to keep track of previous customers over previous periods.

Page | 3
Solution

1) Create a program that stores the record of all jobs done. Including the date of the job and

the description. The program will require a username and password to access it. Different

users will have different controls to the program.

2) Store all the data on a database that can be accessed with a username and password by

both employees and an administrator.

3) The data will be backed up on a MySQL server on a computer system

4) The data would be stored in a database where it easily be store, retrieved, organize and

manipulated by employees and an administrator.

5) The program will be able to keep track of customer Information (e.g., name, email,

number and address). You will be able to retrieve information on when a operation was

done for a customer.

Page | 4
Pseudocode
Pseudocode

//Structure that has members to use in worksheet reference

Record worksheet

Begin

Declare

name as string

namePerson as string

address as string

telephone as string

date as string

email as string

jobNumber as string

contactPerson as string

records as integer

id as integer

randomNumber as integer

End worksheet

Record worksheet wk

//Structure that has members to use in jobsheet reference

Record jobsheet

Page | 5
Begin

Declare

name as string

telephone as string

address as string

date as string

contactPerson as string

services as string

subService as string

subServiceQuery as string

subServiceArray as string

records as integer

id as integer

subServiceAmount as integer

serviceType as integer

End jobsheet

Record jobsheet jb

//Structure that has members to use in gathering the inputs from users in regards to different

databases

Record databaseInputs

Begin

Page | 6
Declare

databaseInput as integer

databaseInputTable as integer

databaseInputName as string

End databaseInputs

Record databaseInputs DBI

//Structure that has a member to use in creating a name for the databases

Record databaseName

Begin

Declare

name as string

nameInput as string

End databaseName

Record databaseName db

//Structure that has members to use in creating a database table

Record databaseTables

Begin

Declare

name as string

Page | 7
datatype as string

columnName as string

columnDataType as string

columnDataString as string

alterTableQuery as string

query as string

columnNameForQuery as string

columnNameNew as string

columns as integer

columnDataSize as integer

columnDataInt as integer

columnDataStringChar as integer

columnNumber as integer

End databaseTables

Record databaseTables dbt

//Structure that has members to use in creating user fields in a database table

Record userInformation

Begin

Declare

userFirstName as string

userSurname as string

Page | 8
userDOB as string

userEmail as string

userID as integer

numberOfUsers as integer

End userInformation

Record userInformation userInfo

//Structure that has members that holds login information for users

Record userCredentails

Begin

Declare

userName as string

password as string

menuInput as integer

End userCredentials

Record userCredentails user

//Structure that has members to use in the admin option selection menu

Record adminControls

Begin

Declare

adminInput as integer

adminInputDB as integer

Page | 9
adminInputUsers as integer

adminInputUsersDatabase as integer

adminInputUsersTable as integer

End adminControls

Record adminControls admin

// Structure that has controls to use in switch statements for users

Record userControls

Begin

Declare

userInput as integer

userInputDB as integer

userDBName as string

userdbtName as string

End userControls

Record userControls u

// Hierarchy of functions

FUNCTION startupMenu

FUNCTION mainMenu

FUNCTION menu

FUNCTION insertTableValuesJobsheet2

FUNCTION welcomeScreen

Page | 10
FUNCTION loginScreen

FUNCTION adminWelcomeScreen

FUNCTION createDatabaseName

// Function that checks to see which type of user is logged in to then decide which

// user function to call because of an error

FUNCTION decisionError

Begin

if user.userName == "admin" then

Sleep(3000)

FUNCTION adminWelcomeScreen

else if user.userName == user.userName then

Sleep(3000)

FUNCTION welcomeScreen

Endif

End

// Function that checks to see which type of user is logged in

FUNCTION decision

Begin

Print user.userName

if user.userName == "admin" then

FUNCTION adminWelcomeScreen

Page | 11
else if user.userName == user.userName then

FUNCTION welcomeScreen

Endif

End

// Function that checks the data entered by a user for a decision

FUNCTION decisionData

Begin

Print " "

Print " "

Print "Enter 'Return' to go to back : "

Read dbt.name

if dbt.name == Return then

FUNCTION decision

Endif

End

// Function that checks to see if a user entered a key to return to a

// previous page

FUNCTION decisionPrompt

Begin

Print " "

Print "Press any key to go back "

Page | 12
Function getcharacter

FUNCTION decision

End

//A function that checks to see if a mySQL query was executed with errors

FUNCTION finish_with_error(MYSQL * con)

Begin

Print mysql_error(con)

FUNCTION decisionError

End

//A function that prompts the user to enter a name to create a database

FUNCTION createDatabaseName

Begin

Print "Enter a name for the Database, Enter 'Return' to go to back: "

Read db.name

if db.name == 'Return' then

FUNCTION decision

Endif

End

//A function that creates a database using a name provided by the user

FUNCTION createDatabase

Page | 13
Begin

MYSQL* con = mysql_init(NULL)

if (con == NULL) then

Begin

fprintf(stderr, "%s\n", mysql_error(con));

exit(1)

Endif

if (mysql_real_connect(con, "localhost", "root", "root",

NULL, 0, NULL, 0) == NULL)

Begin

fprintf(stderr, "%s\n", mysql_error(con))

mysql_close(con)

exit(1)

Endif

Declare

Begin

query[255]

End

sprintf(query, "CREATE DATABASE `%s` ", db.name)

Page | 14
if (mysql_query(con, query)) then

Begin

fprintf(stderr, "%s\n", mysql_error(con))

Function decisionError

Endif

mysql_close(con)

End

//A function that deletes a database that was provided by the user

Function deleteDatabase

Begin

MYSQL* con = mysql_init(NULL)

if (con == NULL) then

Begin

fprintf(stderr, "%s\n", mysql_error(con));

exit(1)

Endif

if (mysql_real_connect(con, "localhost", "root", "root",

NULL, 0, NULL, 0) == NULL) then

Page | 15
Begin

fprintf(stderr, "%s\n", mysql_error(con))

mysql_close(con)

exit(1)

Endif

Declare

Begin

query[255]

End

sprintf(query, "DROP DATABASE %s", dBI.databaseInputName)

if (mysql_query(con, query)) then

Begin

fprintf(stderr, "%s\n", mysql_error(con))

Function decisionError

Endif

mysql_close(con)

End

Page | 16
//A function that prompts the user to enter the name of a database that will be used in mySQL

queries

Function selectDatabase

Begin

print"Select the name of the database to use, Enter 'Return' to go to the previous page: "

Read dBI.databaseInputName

if (dBI.databaseInputName == Return) then

Begin

Function decision

Endif

End

//A function that shows the list of available databases for the admin

Function showDatabases

Begin

MYSQL* con = mysql_init(NULL)

if (con == NULL) then

Begin

fprintf(stderr, "%s\n", mysql_error(con))

exit(1)

Endif

Page | 17
if (mysql_real_connect(con, "localhost", "root", "root",

NULL, 0, NULL, 0) == NULL) then

Begin

fprintf(stderr, mysql_error(con))

mysql_close(con)

exit(1)

Endif

Declare

Begin

query[255]

End

sprintf(query, "SHOW SCHEMAS")

if (mysql_query(con, query)) then

Begin

fprintf(stderr, mysql_error(con))

Function decisionError

Endif

MYSQL_RES* result = mysql_store_result(con)

Page | 18
int num_fields = mysql_num_fields(result)

MYSQL_ROW row

print "List of Databases"

print" "

while (row = mysql_fetch_row(result)) do

Begin

print" "

for i to num_fields do

Begin

print row[i] ? row[i] : "NULL"

Endfor

print " "

Endwhile

print " "

mysql_free_result(result)

mysql_close(con)

End

Page | 19
//A function that prompts the user to enter a name to create a database table

FUNCTION createDatabaseTableName

Begin

Print "Enter a name for the table: "

Read dbt.name

if dbt.name == 'Return' then

FUNCTION decision

Endif

End

//A function that returns the list of available databases specifically for users, after hiding the

default mySQL databases

Function showDatabasesForUsers() {

Begin

MYSQL* con = mysql_init(NULL)

if (con == NULL) then

Begin

fprintf(stderr, "%s\n", mysql_error(con))

exit(1)

Endif

Page | 20
if (mysql_real_connect(con, "localhost", "root", "root",

NULL, 0, NULL, 0) == NULL) then

Begin

fprintf(stderr, "%s\n", mysql_error(con))

mysql_close(con)

exit(1)

Endif

Declare

Begin

query[255]

End

sprintf(query, "SELECT `schema_name` from INFORMATION_SCHEMA.SCHEMATA

WHERE `schema_name` NOT IN('information_schema', 'mysql', 'performance_schema', 'sys',

'%s')", u.userDBName)

if (mysql_query(con, query)) then

Begin

fprintf(stderr, "%s\n", mysql_error(con))

Function decisionError

Endif

Page | 21
MYSQL_RES* result = mysql_store_result(con)

int num_fields = mysql_num_fields(result)

MYSQL_ROW row

if (result == NULL) then

Begin

finish_with_error(con)

Endif

print"List of Databases"

print" "

while ((row = mysql_fetch_row(result))) do

Begin

print" "

for i to num_fields do

Begin

print row[i] ? row[i] : "NULL"

End

print" "

Page | 22
Endwhile

print" "

mysql_free_result(result)

mysql_close(con)

End

//A function that returns the list of available tables in a database

FUNCTION showDatabaseTables

Begin

MYSQL* con = mysql_init(NULL)

if (con == NULL) then

Begin

fprintf(stderr, "%s\n", mysql_error(con));

exit(1)

Endif

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL) then

Begin

Page | 23
fprintf(stderr, "%s\n", mysql_error(con))

mysql_close(con)

exit(1)

Endif

Declare

Begin

query as string

End

sprintf(query, "SHOW TABLES")

if (mysql_query(con, query)) then

Begin

fprintf(stderr, "%s\n", mysql_error(con))

Function decisionError

Endif

MYSQL_RES* result = mysql_store_result(con)

int num_fields = mysql_num_fields(result)

MYSQL_ROW row

Page | 24
print "List of Tables"

print " "

while ((row = mysql_fetch_row(result)))

Begin

print " "

for i to num_fields do

print row[i] ? row[i] : "NULL"

printf" "

Endwhile

printf " "

mysql_free_result(result)

mysql_close(con)

End

//A function that prompts the user to enter the name of a database table that will be used in

mySQL queries

Function selectDatabaseTables

Begin

Page | 25
print"Select the name of the Worksheet to use, Enter 'Return' to go to the previous page: "

Read dbt.name

if (dbt.name == "Return") then

Begin

Function decision

Endif

End

//A function that deletes a database table that was provided by the user

FUNCTION deleteDatabaseTables

Begin

MYSQL* con = mysql_init(NULL)

if (con == NULL) then

Print mysql_error(con)

exit(1)

Endif

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL) then

finish_with_error(con)

Endif

Page | 26
Declare

Begin

query as string

End

Print(query, "DROP TABLE " dbt.name)

if (mysql_query(con, query)) then

Print mysql_error(con)

FUNCTION decisionError

Endif

mysql_close(con)

End

//A function that shows the data of a database table that was provided by the user

FUNCTION showDatabaseTableData

Begin

MYSQL* con = mysql_init(NULL)

if (con == NULL) then

Print mysql_error(con)

exit(1)

Page | 27
Endif

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL) then

finish_with_error(con)

Endif

Declare

Begin

query as string

End

Print query, "SELECT * FROM" dbt.name

if (mysql_query(con), query)) then

Print mysql_error(con)

FUNCTION decisionError

Endif

MYSQL_RES* result = mysql_store_result(con)

if (result == NULL) then

Page | 28
finish_with_error(con)

Endif

int num_fields = mysql_num_fields(result)

MYSQL_ROW row

MYSQL_FIELD* field

while ((row = mysql_fetch_row(result))) do

for 1 to num_field do

if (i == 0) then

while (field = mysql_fetch_field(result)) do

Print field->name

Endwhile

Print " "

Endif

Print row[i] ? row[i] : "NULL"

Endfor

Endwhile

Page | 29
Print " "

mysql_free_result(result)

mysql_close(con)

End

//A function that creates a database table using a name provided by the user

Function createTables

Begin

MYSQL* con = mysql_init(NULL)

if (con == NULL) then

Begin

Print mysql_error(con)

exit(1)

Endif

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL) then

begin

finish_with_error(con)

Page | 30
Endif

Declare

Begin

query as string

End

sprintf(query, "CREATE TABLE %s (%s %s PRIMARY KEY)", dbt.name, dbt.columnName,

dbt.dataType)

if (mysql_query(con, query)) then

begin

fprintf(stderr, "%s\n", mysql_error(con))

Function decisionError

endif

mysql_close(con)

End

//A function that returns the names of the columns from a database table

Function showColumns

Begin

Page | 31
MYSQL* con = mysql_init(NULL)

if (con == NULL) then

begin

Print mysql_error(con)

exit(1)

Endif

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL) then

begin

finish_with_error(con)

Endif

Declare

Begin

query as string

End

sprintf(query, "SELECT column_name from information_schema.columns where

table_schema = database() and table_name = '%s'", dbt.name)

if (mysql_query(con, query))

Page | 32
begin

fprintf(stderr, "%s\n", mysql_error(con))

decisionError()

endif

MYSQL_RES* result = mysql_store_result(con)

if (result == NULL)

begin

finish_with_error(con)

endif

int num_fields = mysql_num_fields(result)

MYSQL_ROW row

MYSQL_FIELD* field

while ((row = mysql_fetch_row(result))) do

begin

for i to num_fields do

begin

if (i == 0)

Page | 33
begin

while (field = mysql_fetch_field(result)) do

begin

print "field->name"

endwhile

print " "

endif

print row[i] ? row[i] : "NULL"

endfor

endwhile

print" "

mysql_free_result(result)

mysql_close(con)

Page | 34
end

//A function that creates a database table with column names and data types

FUNCTION createTablesInputWorksheet

Begin

MYSQL* con = mysql_init(NULL)

if (con == NULL) then

begin

Print mysql_error(con)

exit(1)

Endif

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL) then

begin

finish_with_error(con)

Endif

print"Create the table by entering a name, Enter 'Return' to go to back: "

Read dbt.name

if (dbt.name == "Return") then

Page | 35
begin

function decision

endif

function system("cls")

print"+-----------------------------------------+"

print"| Alert |"

print"+-----------------------------------------+"

print"| To create a worksheet enter 8 columns |"

print"+-----------------------------------------+"

print" "

print ""

print"Continue creating the table by entering the number of columns: "

Read dbt.columns

print "Create a primary key column by entering 'ID': "

Read dbt.columnName

print"Set the datatype of the column by entering 'INT': "

Read dbt.columnDataType

if (dbt.columnDataType == "int" OR dbt.columnDataType == "INT") then

begin

sprintf(dbt.dataType, "INT")

function createTables()

else if (dbt.columnDataType == "varchar" OR dbt.columnDataType == "VARCHAR") then

sprintf(dbt.dataType, "VARCHAR(%i)", MAX)

Page | 36
function createTables

else if (dbt.columnDataType == "date" OR dbt.columnDataType == "DATE") then

sprintf(dbt.dataType, "DATE")

function createTables()

endif

mysql_close(con)

End

//A function that allows the user to add database tables

FUNCTION addTables

Begin

MYSQL* con = mysql_init(NULL)

if (con == NULL) then

Print mysql_error(con)

exit(1)

Endif

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL) then

Page | 37
finish_with_error(con)

Endif

Declare

Begin

query as string

End

sprintf(query, "ADD %s %s", dbt.columnName, dbt.columnDataType)

if (mysql_query(con, query)) then

begin

fprintf(stderr, "%s\n", mysql_error(con))

function decisionError

endif

mysql_close(con)

end

//A function that is called to

FUNCTION insertTableColumns2

Begin

MYSQL* con = mysql_init(NULL)

Page | 38
if (con == NULL) then

Print mysql_error(con)

exit(1)

Endif

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL) then

finish_with_error(con)

Endif

Declare

Begin

query as string

End

sprintf(query, "ALTER TABLE %s ADD COLUMN %s %s", dbt.name, dbt.columnName,

dbt.dataType)

if (mysql_query(con, query)) then

begin

fprintf(stderr, "%s\n", mysql_error(con))

decisionError()

endif

Page | 39
mysql_close(con)

End

//A function that allows the user to make modifications to a database table

FUNCTION alterTables

Begin

MYSQL* con = mysql_init(NULL)

if (con == NULL) then

Print mysql_error(con)

exit(1)

Endif

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL) then

finish_with_error(con)

Endif

Page | 40
Declare

Begin

query as string

End

print"Enter the change to make to the table's column ADD, MODIFY, DROP, RENAME,

Enter 'Return' to go to the previous page: "

Read dbt.alterTableQuery

if (dbt.alterTableQuery == "Return") then

begin

function decision

endif

else if (dbt.alterTableQuery == "add" OR dbt.alterTableQuery == "ADD") then

begin

function system("cls")

function showColumns

print " "

print "Enter the name of the column: "

Read dbt.columnName

print"Enter the Data type of the column INT() , VARCHAR() , DATE , DECIMAL: "

Read dbt.columnDataType

if (dbt.columnDataType == "INT") then

begin

Page | 41
sprintf(dbt.dataType, "INT")

else if (dbt.columnDataType == "varchar" OR dbt.columnDataType == "VARCHAR")

then

sprintf(dbt.dataType, "VARCHAR(%i)", MAX)

else if (dbt.columnDataType == "DATE" OR dbt.columnDataType == "date") then

sprintf(dbt.dataType, "DATE")

else then

print"Incorrect data type entered"

Function decisionError()

endif

sprintf(query, "ALTER TABLE %s ADD %s %s", dbt.name, dbt.columnName,

dbt.dataType)

if (mysql_query(con, query)) then

begin

fprintf(stderr, "%s\n", mysql_error(con))

function decisionError

endif

else if (dbt.alterTableQuery == "drop") OR dbt.alterTableQuery == "DROP")then

begin

function system("cls")

function showColumns

Page | 42
print " "

print "Enter the name of the column: "

Read dbt.columnName

sprintf(query, "ALTER TABLE %s DROP COLUMN %s", dbt.name, dbt.columnName)

if (mysql_query(con, query)) then

Begin

fprintf(stderr, "%s\n", mysql_error(con));

decisionError();

Endif

else if (dbt.alterTableQuery == "modify" OR dbt.alterTableQuery == "MODIFY") then

function system("cls")

function showColumns

print" "

print "Enter the name of the column: "

Read dbt.columnName

print "Enter the Data type of the column INT() , VARCHAR() , DATE , DECIMAL: "

Read dbt.columnDataType

if (dbt.columnDataType == "int" OR dbt.columnDataType, "INT") then

begin

sprintf(dbt.dataType, "INT")

else if (dbt.columnDataType == "varchar") OR dbt.columnDataType == "VARCHAR")

then

Page | 43
begin

sprintf(dbt.dataType, "VARCHAR(%i)", MAX)

else if (dbt.columnDataType == "date") OR dbt.columnDataType == "DATE") then

begin

sprintf(dbt.dataType, "DATE")

sprintf(query, "ALTER TABLE %s MODIFY %s %s", dbt.name, dbt.columnName,

dbt.dataType)

if (mysql_query(con, query)) then

begin

fprintf(stderr, "%s\n", mysql_error(con))

function decisionError

endif

else if (dbt.alterTableQuery == "rename") OR dbt.alterTableQuery == "RENAME") then

begin

function system("cls")

function showColumns

print" "

print"Enter the name of the old column: "

Read dbt.columnName

Page | 44
print "Enter the name to change the column to: "

Readdbt.columnNameNew

sprintf(query, "ALTER TABLE %s RENAME COLUMN %s to %s", dbt.name,

dbt.columnName, dbt.columnNameNew)

if (mysql_query(con, query)) then

begin

fprintf(stderr, "%s\n", mysql_error(con))

function decisionError

endif

endif

mysql_close(con)

End

// Funcction that generates an email script to send a confirmation

// message to an email entered by a user

FUNCTION userEmail

Begin

FILE* email

Page | 45
Declare

script as string

command as string

end

sprintf(script,

"$from = 'whiteroseprogramcredentials@gmail.com'\n"

"$to = '%s'\n"

"$subject = 'Welcome to White Rose Interiors Database Program'\n"

"$body = 'Your credentials are as follows: \n Username: %i\n Password: %s'\n"

"$smtpServer = 'smtp.gmail.com'\n"

"$port = 587\n"

"$username = 'whiteroseprogramcredentials@gmail.com'\n"

"$password = 'oduqxmklfciozdpm'\n"

"$mailMessage = New-Object System.Net.Mail.MailMessage $from, $to, $subject,

$body\n"

"$mailMessage.From = New-Object System.Net.Mail.MailAddress($from, 'White Rose

Interiors Admin')\n"

"$smtpClient = New-Object System.Net.Mail.SmtpClient $smtpServer\n"

"$smtpClient.Port = $port\n"

"$smtpClient.EnableSsl = $true\n"

"$smtpClient.Credentials = New-Object System.Net.NetworkCredential($username,

$password)\n"

Page | 46
"$smtpClient.Send($mailMessage)\n", userInfo.userEmail, userInfo.userID, user.password)

sprintf(command, "%s", script); //Store the completed script into a variable

email = fopen("emailscript.ps1", "w")

if (email == NULL) then

begin

printf("Couldn't create script file")

exit(1)

endif

fprintf(email, "%s", command)

fclose(email)

function system("powershell.exe

C:\\Users\\Dell\\Desktop\\CSUnit1SBA\\CSUnit1SBA\\emailscript.ps1")

End

// Function that gives a guide to the administrator when creating

// columsn for the database table worksheet

FUNCTION insertTableColumnsWorksheet

Page | 47
Begin

MYSQL* con = mysql_init(NULL)

if (con == NULL) then

Print mysql_error(con)

exit(1)

Endif

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL) then

finish_with_error(con)

Endif

print"+-------------------------------------------+"

print"| Alert |"

print"+-------------------------------------------+"

print"| Create the remaining columns of the table |"

print"| in the following order: |"

print"+-------------------------------------------+"

print"| Name: Varchar |"

print"+-------------------------------------------+"

print"| Address: Varchar |"

Page | 48
print"+-------------------------------------------+"

print"| Telephone: Varchar |"

print"+-------------------------------------------+"

print"| Date: Date |"

print"+-------------------------------------------+"

print"| Email: Varchar |"

print"+-------------------------------------------+"

print"| JobNumber: Int |"

print"+-------------------------------------------+"

print"| ContactPerson: Varchar |"

print"+-------------------------------------------+"

print" "

print" "

for i to dbt.columns - 1 do

print"Create the column by entering a name, Enter 'Return' to go to the previous page: "

Read dbt.columnName

if (dbt.columnName == "Return" then

begin

function adminWelcomeScreen

endif

print"Enter the Data type of the column INT , VARCHAR , DATE , DECIMAL: "

Read dbt.columnDataType

Page | 49
if (dbt.columnDataType == "int" OR dbt.columnDataType == "INT") then

begin

sprintf(dbt.dataType, "INT")

function insertTableColumns2

endif

else if (dbt.columnDataType == "varchar" OR dbt.columnDataType == "VARCHAR") then

begin

sprintf(dbt.dataType, "VARCHAR(%i)", MAX)

function insertTableColumns2

else if (dbt.columnDataType == "date" OR dbt.columnDataType == "DATE") then

begin

sprintf(dbt.dataType, "DATE")

function insertTableColumns2

end

else then

begin

printf("Incorrect data type entered")

function decisionError

endif

endfor

Page | 50
mysql_close(con)

end

//A function that gathers input from the user regarding the database table values to be passed into

a worksheet

Function insertTableValues

begin

print"Enter the amount of records you want to insert: "

Read wk.records

for i to wk.records do

begin

print"Enter the name of the person: "

Read wk.namePerson

print"Enter the address of the person: "

Read wk.address

print"Enter the telephone number of the person: "

Read wk.telephone

print "Enter the date YYYY-MM-DD: "

Read wk.date

print "Enter the email of the person: "

Page | 51
Read wk.email

print "Enter the Job Number of the person: "

Read wk.jobNumber

print "Enter the Contact Person: "

Read wk.contactPerson

endfor

end

//A function that gathers input from the user regarding the database table values to be passed into

a worksheet

Function insertTableValues2

begin

MYSQL* con = mysql_init(NULL)

if (con == NULL) then

Print mysql_error(con)

exit(1)

Endif

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL) then

Page | 52
finish_with_error(con)

Endif

Declare

Begin

query as string

End

print"Enter the amount of records you want to insert: "

Read wk.records

function time_t t1

function srand((unsigned)time(&t1))

for i to wk.records do

begin

print" Enter the name of the person: "

Read wk.namePerson

print" Enter the address of the person: "

Read wk.address

print" Enter the telephone number of the person: "

Read wk.telephone

print" Enter the date YYYY-MM-DD: "

Page | 53
Read wk.date

print" Enter the email of the person: "

Read wk.email

print "Enter the Job Number of the person: "

Read wk.jobNumber

print "Enter the Contact Person: "

Read wk.contactPerson

wk.id = rand() % MAX

sprintf(query, "INSERT INTO %s VALUES(%i,'%s', '%s', '%s', '%s', '%s', '%s', '%s')",

dbt.name, wk.id, wk.namePerson, wk.address, wk.telephone, wk.date, wk.email, wk.jobNumber,

wk.contactPerson)

if (mysql_query(con, query))

begin

fprintf(stderr, "%s\n", mysql_error(con))

function decisionError

endif

endfor

mysql_close(con)

end

Page | 54
//A function that gathers input from the user regarding the database table values to be passed into

the user table that will hold the login credentials

Function insertTableValuesUsers

Begin

MYSQL* con = mysql_init(NULL)

if (con == NULL) then

Print mysql_error(con)

exit(1)

Endif

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL) then

finish_with_error(con)

Endif

Declare

Begin

query as string

End

Page | 55
print"Enter the amount of records you want to insert: "

Read userInfo.numberOfUsers

function time_t t1

function srand((unsigned)time(&t1))

for i to userInfo.numberOfUsers do

print "Enter your first name: "

Read userInfo.userFirstName

print "Enter your last name: "

Read userInfo.userSurname);

print"Enter your Date of birth YYYY-MM-DD: "

Read userInfo.userDOB

print "Enter your email: "

Read userInfo.userEmail

print "Enter a password: "

Read user.password

userInfo.userID = rand() % MAX

sprintf(query, "INSERT INTO %s VALUES(%i, '%s', '%s', '%s', '%s', '%s')" dbt.name,

userInfo.userID, userInfo.userFirstName, userInfo.userSurname, userInfo.userEmail,

userInfo.userDOB, user.password

if (mysql_query(con, query)) then

begin

fprintf(stderr, "%s\n", mysql_error(con))

Page | 56
function decisionError

endif

endfor

mysql_close(con)

end

// Function that inserts the records in a database table created

// for users when signing into the program

function insertTableValuesUsersSignIn

Begin

MYSQL* con = mysql_init(NULL)

if (con == NULL) then

Print mysql_error(con)

exit(1)

Endif

if (mysql_real_connect(con, "localhost", "root", "root",

u.userDBName, 0, NULL, 0) == NULL) then

finish_with_error(con)

Endif

Page | 57
Declare

Begin

query as string

End

function time_t t1

function srand((unsigned)time(&t1))

print "Enter your first name: "

Read userInfo.userFirstName

print "Enter your last name: "

Read userInfo.userSurname

print "Enter your Date of birth YYYY-MM-DD: "

Read userInfo.userDOB

print "Enter your email: "

Read userInfo.userEmail

print "Enter a password: "

Read user.password

userInfo.userID = rand() % MAX

sprintf(query, "INSERT INTO %s VALUES(%i, '%s', '%s', '%s', '%s', '%s')", u.userdbtName,

userInfo.userID, userInfo.userFirstName, userInfo.userSurname, userInfo.userEmail,

userInfo.userDOB, user.password

Page | 58
if (mysql_query(con, query))

begin

fprintf(stderr, "%s\n", mysql_error(con))

function decisionError

endif

mysql_close(con)

end

// Function that gives guide to administrators when creating a database

// table

Function createTablesInputUsers

begin

MYSQL* con = mysql_init(NULL)

if (con == NULL) then

Print mysql_error(con)

exit(1)

Endif

if (mysql_real_connect(con, "localhost", "root", "root",

Page | 59
dBI.databaseInputName, 0, NULL, 0) == NULL) then

finish_with_error(con)

Endif

printCreate the table by entering a name, Enter 'Return' to go to back: "

Read dbt.name

if (dbt.name == "Return" then

begin

function decision

endif

function system("cls")

print"+-----------------------------------------+"

print"| Alert |"

print"+-----------------------------------------+"

print"| To create a table enter 6 columns |"

print"+-----------------------------------------+"

print" "

print" "

print "Continue creating the table by entering the number of columns: "

Read dbt.columns

print "Create a primary key column by entering 'ID': "

Read dbt.columnName

Page | 60
print "Set the datatype of the column by entering 'INT': "

Read dbt.columnDataType

if (dbt.columnDataType == "int" OR dbt.columnDataType == "INT" then

begin

sprintf(dbt.dataType, "INT")

function createTables

else if (dbt.columnDataType == "varchar") OR dbt.columnDataType == "VARCHAR" then

begin

sprintf(dbt.dataType, "VARCHAR(%i)", MAX)

function createTables

else if (dbt.columnDataType == "date") OR dbt.columnDataType == "DATE") then

begin

sprintf(dbt.dataType, "DATE")

function createTables

endif

mysql_close(con)

end

// Function that gives guide to administrators when creating a database

// table columns for users

Function insertTableColumnsUsers

begin

Page | 61
MYSQL* con = mysql_init(NULL)

if (con == NULL) then

Print mysql_error(con)

exit(1)

Endif

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL) then

finish_with_error(con)

Endif

function system("cls")

print"+-------------------------------------------+"

print"| Alert |"

print"+-------------------------------------------+"

print"| Create the remaining columns of the table |"

print"| in the following order: |"

print"+-------------------------------------------+"

print"| First Name: Varchar |"

print"+-------------------------------------------+"

print"| Surname: Varchar |"

Page | 62
print"+-------------------------------------------+"

print"| Email: Varchar |"

print"+-------------------------------------------+"

print"| Date of Birth: Date |"

print"+-------------------------------------------+"

print"| Password: Varchar |"

print"+-------------------------------------------+"

print" ")

print" ")

for i to dbt.columns - 1 do

print"Create the column by entering a name, Enter 'Return' to go to the previous page: "

Read dbt.columnName

if (dbt.columnName == "Return") then

begin

function adminWelcomeScreen

endif

print "Enter the Data type of the column INT , VARCHAR , DATE , DECIMAL: "

Read dbt.columnDataType

if (dbt.columnDataType == "int" OR dbt.columnDataType == "INT") then

sprintf(dbt.dataType, "INT")

function insertTableColumns2

Page | 63
else if (dbt.columnDataType == "varchar") OR dbt.columnDataType == "VARCHAR"

then

sprintf(dbt.dataType, "VARCHAR(%i)", MAX)

function insertTableColumns2

else if (dbt.columnDataType == "date" OR dbt.columnDataType == "DATE") then

sprintf(dbt.dataType, "DATE")

function insertTableColumns2

else then

begin

print "Incorrect data type entered"

function decisionError

endif

endfor

mysql_close(con)

end

//A function that searches the user login table and selects the password based on the ID number

provided

//it then stores the password inside of a variable that is authenticated with the password provided

//by the user

Function userAuthentication

begin

Page | 64
MYSQL* con = mysql_init(NULL)

if (con == NULL) then

Print mysql_error(con)

exit(1)

Endif

if (mysql_real_connect(con, "localhost", "root", "root",

u.userDBName, 0, NULL, 0) == NULL) then

finish_with_error(con)

Endif

Declare

Begin

query as string

End

sprintf(query, "SELECT PASSWORD FROM %s WHERE ID = %s", u.userdbtName,

user.userName)

if (mysql_query(con, query)) then

begin

Page | 65
fprintf(stderr, "%s\n", mysql_error(con))

function decisionError

endif

MYSQL_RES* result = mysql_store_result(con)

int num_fields = mysql_num_fields(result)

MYSQL_ROW row

while ((row = mysql_fetch_row(result))) do

begin

for i to num_fields do

begin

res = row[i] ? row[i] : "NULL"

endfor

print " "

endwhile

print" "

if (user.userName == "admin") then

Page | 66
begin

function adminWelcomeScreen

else if (user.password == res) then

begin

function welcomeScreen

else

begin

print "Incorrect Username or password"

function Sleep(3000)

function loginScreen

endif

mysql_free_result(result)

mysql_close(con)

end

//A function that gather the information that will be used to update the records in a database table

Function updateTableValuesQuery

begin

print" "

Page | 67
print "Enter the name of the Column in updating the records: "

Read dbt.columnName

function system("cls")

function showDatabaseTableData

print " "

print "Enter the ID of the record: "

Read wk.id

print "Enter the new record value: "

Read dbt.query

end

//A function that updates records in a database table

Function updateTableValues

begin

MYSQL* con = mysql_init(NULL)

if (con == NULL) then

Print mysql_error(con)

exit(1)

Endif

Page | 68
if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL) then

finish_with_error(con)

Endif

Declare

Begin

query as string

End

if (dbt.columnName == "JobNumber") then

begin

sprintf(query, "UPDATE %s SET %s = %i WHERE ID = %i", dbt.name, dbt.columnName,

dbt.query, wk.id)

else then

sprintf(query, "UPDATE %s SET %s = '%s' WHERE ID = %i", dbt.name,

dbt.columnName, dbt.query, wk.id)

endif

if (mysql_query(con, query))

Page | 69
begin

fprintf(stderr, "%s\n", mysql_error(con))

function decisionError

endif

mysql_close(con)

end

//A function that gathers the input from the user to use in deleting values from a database table

Function deleteTableValuesQuery

begin

print"Enter the name of the Column to use for deletion: "

Read dbt.columnName

function system("cls")

function showDatabaseTableData

print " "

print "Enter the record value to delete: "

Read dbt.query)

end

Page | 70
//A function that deletes records in a database table

Function deleteTableValues

Begin

MYSQL* con = mysql_init(NULL)

if (con == NULL) then

Print mysql_error(con)

exit(1)

Endif

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL) then

finish_with_error(con)

Endif

Declare

Begin

query as string

End

if (dbt.columnName == "JobNumber") then

Page | 71
begin

sprintf(query, "DELETE FROM %s WHERE %s = %s", dbt.name, dbt.columnName,

dbt.query)

endif

else then

begin

sprintf(query, "DELETE FROM %s WHERE %s = '%s'", dbt.name, dbt.columnName,

dbt.query)

endif

if (mysql_query(con, query))

begin

fprintf(stderr, "%s\n", mysql_error(con))

function decisionError

endif

mysql_close(con)

end

// Function that gives a guide to the administrator when creating

// records for the database table jobsheet

Function createTablesInputJobsheet

begin

Page | 72
MYSQL* con = mysql_init(NULL)

if (con == NULL) then

Print mysql_error(con)

exit(1)

Endif

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL) then

finish_with_error(con)

Endif

print"Create the table by entering a name, Enter 'Return' to go to back: "

Read dbt.name

if (dbt.name == "Return") then

begin

function decision

endif

function system("cls")

print"+-----------------------------------------+"

Page | 73
print"| Alert |"

print"+-----------------------------------------+"

print"| To create a jobsheet enter 7 columns |"

print"+-----------------------------------------+"

print" "

print" "

print"Continue creating the table by entering the number of columns: "

Read dbt.columns

print "Create a primary key column by entering 'ID': "

Read dbt.columnName

print "Set the datatype of the column by entering 'INT': "

Read dbt.columnDataType

if (dbt.columnDataType == "int") OR dbt.columnDataType == "INT") then

begin

sprintf(dbt.dataType, "INT")

function createTables

else if (strcmp(dbt.columnDataType == "varchar" OR dbt.columnDataType ==

"VARCHAR") then

sprintf(dbt.dataType, "VARCHAR(%i)", MAX)

function createTables

else if ( dbt.columnDataType == "date" OR dbt.columnDataType == "DATE") then

sprintf(dbt.dataType, "DATE")

function createTables

Page | 74
endif

mysql_close(con)

end

// Function that gives a guide to the administrator when creating

// columns for the database table jobsheet

Function insertTableColumnsJobsheet

begin

MYSQL* con = mysql_init(NULL)

if (con == NULL) then

Print mysql_error(con)

exit(1)

Endif

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL) then

finish_with_error(con)

Endif

Page | 75
Declare

Begin

query as string

End

function system("cls")

print"+-------------------------------------------+"

print"| Alert |"

print"+-------------------------------------------+"

print"| Create the remaining columns of the table |"

print"| in the following order: |"

print"+-------------------------------------------+"

print"| Name: Varchar |"

print"+-------------------------------------------+"

print"| Telephone: Varchar |"

print"+-------------------------------------------+"

print"| Address: Varchar |"

print"+-------------------------------------------+"

print"| Date: Date |"

print"+-------------------------------------------+"

print"| Contact Person: Varchar |"

Page | 76
print"+-------------------------------------------+"

print"| Services: Varchar |"

print"+-------------------------------------------+"

print" "

print" "

for i to dbt.columns - 1 do

print"Create the column by entering a name, Enter 'Return' to go to the previous page: "

Read dbt.columnName

if (dbt.columnName == "Return") then

begin

function adminWelcomeScreen

endif

print "Enter the Data type of the column INT , VARCHAR , DATE , DECIMAL: "

Read dbt.columnDataType

if ( dbt.columnDataType == "int") OR dbt.columnDataType == "INT") then

begin

sprintf(dbt.dataType, "INT")

function insertTableColumns2

else if (dbt.columnDataType == "varchar" OR dbt.columnDataType == "VARCHAR" then

begin

Page | 77
sprintf(dbt.dataType, "VARCHAR(%i)", MAX)

function insertTableColumns2

else if (dbt.columnDataType == "date" OR dbt.columnDataType == "DATE") then

begin

sprintf(dbt.dataType, "DATE")

function insertTableColumns2

else then

begin

print"Incorrect data type entered"

function decisionError

endif

print " "

endfor

mysql_close(con)

end

//A function that creates a files that will store the services provided in a jobsheet

FUNCTION servicesFileCreation()

Begin

FILE* filePointer

Page | 78
filePointer = fopen("services.txt", "w")

if (filePointer == NULL) then

begin

Print "Error!"

exit(1)

Endif

if (jb.subServiceAmount < 2) then

begin

Fprint (filePointer, " ", jb.subService)

else

begin

Fprint (filePointer, " ,", jb.subService)

Endif

fclose(filePointer)

End

//A function that appEnds to a file that will store the services provided in a jobsheet

FUNCTION servicesFileAppEnd()

Page | 79
Begin

FILE* filePointer

filePointer = fopen("services.txt", "a")

if (filePointer == NULL) then

begin

Print("Error!")

exit(1)

Endif

if (jb.subServiceAmount < 2) then

begin

Fprint (filePointer, " " , jb.subService)

else then

begin

Fprint (filePointer, " " ," ", jb.subService)

Endif

fclose(filePointer)

End

Page | 80
//A function that stores the services provided

FUNCTION servicesFileStorage()

Begin

FILE* filePointer

filePointer = fopen("services.txt", "r")

if (filePointer == NULL) then

begin

Print ("Error!")

exit(1)

Endif

fRead(filePointer, " ", jb.services)

fclose(filePointer)

End

// A function that stores the subservices for a installation

// job in a jobsheet

Page | 81
Function installationCase

begin

for i to i do

begin

print"+----------------------+"

print"| Carpet |"

print"+----------------------+"

print"| Drapery |"

print"+----------------------+"

print"| Blinds/Roller Shades |"

print"+----------------------+"

print"Enter Sub-Service : "

Read jb.subService

function system("cls")

function servicesFileCreation

endfor

for j to jb.subServiceAmount - 1 do

begin

print"+----------------------+"

print"| Carpet |"

print"+----------------------+"

print"| Drapery |"

Page | 82
print"+----------------------+"

print"| Blinds/Roller Shades |"

print"+----------------------+"

print"Enter Sub-Service : "

Read jb.subService

function system("cls")

function servicesFileAppend

function servicesFileStorage

sprintf(jb.servicesQuery, "Installation of %s ", jb.services)

endfor

end

//A function that presents the different types of jobsheet sub-services for the repair service

Function repairCase

begin

for i to 1 do

begin

print"+----------------------+"

print"| Carpet |"

print"+----------------------+"

print"| Drapery |"

Page | 83
print"+----------------------+"

print"| Blinds/Roller Shades |"

print"+----------------------+"

print"Enter Sub-Service : "

Read jb.subService

function system("cls")

function servicesFileCreation

endfor

for j to jb.subServiceAmount - 1 do

begin

print"+----------------------+"

print"| Carpet |"

print"+----------------------+"

print"| Drapery |"

print"+----------------------+"

print"| Blinds/Roller Shades |"

print"+----------------------+"

print"Enter Sub-Service : "

Read jb.subService

function system("cls")

function servicesFileAppend

function servicesFileStorage

sprintf(jb.servicesQuery, "Repair of %s ", jb.services)

Page | 84
endfor

end

//A function that presents the different types of jobsheet sub-services for the pest control service

Function pestControlCase

begin

for i to 1 do

begin

print"+----------------------+"

print"| Spraying |"

print"+----------------------+"

print"| Bait/Paste |"

print"+----------------------+"

print"| Termite Treatment |"

print"+----------------------+"

printf("Enter Sub-Service : "

Read jb.subService

function system("cls")

function servicesFileCreation

endfor

for i to jb.subServiceAmount - 1 do

Page | 85
begin

print"+-------------------+"

print"| Spraying |"

print"+-------------------+"

print"| Bait/Paste |"

print"+-------------------+"

print"| Termite Treatment |"

print"+-------------------+"

print"Enter Sub-Service : "

Read jb.subService

function system("cls")

function servicesFileAppend

function servicesFileStorage

sprintf(jb.servicesQuery, "Pest Control of %s", jb.services)

endfor

end

//A function that presents the different types of jobsheet sub-services for the sanitation service

Function sanitationCase

begin

Page | 86
for j to 1 do

begin

print"+----------------------+"

print"| Rug |"

print"+----------------------+"

print"| Carpet |"

print"+----------------------+"

print"| Drapery |"

print"+----------------------+"

print"| Blinds/Roller Shades |"

print"+----------------------+"

print"| Deep Clean |"

print"+----------------------+"

print"| Windows |"

print"+----------------------+"

print"| Vehicle Interior |"

print"+----------------------+"

print"| Tile Stipping |"

print"+----------------------+"

print"| Sofa/Settee |"

print"+----------------------+"

print"| Sanitization |"

print"+----------------------+"

Page | 87
print"| Partitions |"

print"+----------------------+"

print"| Office Chairs |"

print"+----------------------+"

print"| Dining Chairs |"

print"+----------------------+"

print"| Mattress |"

print"+----------------------+"

print"Enter Sub-Service : "

Read jb.subService

function system("cls"

functionservicesFileCreation

endfor

for j to jb.subServiceAmount - 1 do

print"+----------------------+"

print"| Rug |"

print"+----------------------+"

print"| Carpet |"

print"+----------------------+"

print"| Drapery |"

print"+----------------------+"

print"| Blinds/Roller Shades |"

Page | 88
print"+----------------------+"

print"| Deep Clean |"

print"+----------------------+"

print"| Windows |"

print"+----------------------+"

print"| Vehicle Interior |"

print"+----------------------+"

print"| Tile Stipping |"

print"+----------------------+"

print"| Sofa/Settee |"

print"+----------------------+"

print"| Sanitization |"

print"+----------------------+"

print"| Partitions |"

print"+----------------------+"

print"| Office Chairs |"

print"+----------------------+"

print"| Dining Chairs |"

print"+----------------------+"

print"| Mattress |"

print"+----------------------+"

print"Enter Sub-Service : "

Read jb.subService

Page | 89
function system("cls")

function servicesFileAppend

function servicesFileStorage

sprintf(jb.servicesQuery, "Cleaning/Sanitization of %s", jb.services)

endfor

end

//A function that gathers information that will be stored in a jobsheet

Function insertTableValuesJobsheet

begin

MYSQL* con = mysql_init(NULL)

if (con == NULL) then

Print mysql_error(con)

exit(1)

Endif

if (mysql_real_connect(con, "localhost", "root", "root",

Page | 90
dBI.databaseInputName, 0, NULL, 0) == NULL) then

finish_with_error(con)

Endif

Declare

Begin

query as string

End

print"Enter the amount of records you want to insert: "

Read jb.records

function time_t t1

function srand((unsigned)time(&t1))

for i to jb.records do

print"Enter the name of the person: "

Read jb.name

print "Enter the telephone number of the person: "

Read jb.telephone

print"Enter the address of the person: "

Read jb.address

print"Enter the date YYYY-MM-DD: "

Page | 91
Read jb.date

print"Enter the Contact Person: "

Read jb.contactPerson

jb.id = rand() % MAX

function system("cls")

print"+-------------------------+"

print"| 1)Installation |"

print"+-------------------------+"

print"| 2)Repair |"

print"+-------------------------+"

print"| 3)Pest Control |"

print"+-------------------------+"

print"| 4)Cleaning/Sanitization |"

print"+-------------------------+"

print"Enter the type of Service: "

Read jb.serviceType

function insertTableValuesJobsheet2

sprintf(query, "INSERT INTO %s VALUES(%i, '%s', '%s', '%s', '%s', '%s', '%s')",

dbt.name, jb.id, jb.name, jb.telephone, jb.address, jb.date, jb.contactPerson, jb.servicesQuery)

if (mysql_query(con, query)) then

begin

fprintf(stderr, "%s\n", mysql_error(con))

function decisionError

Page | 92
endif

endfor

mysql_close(con)

end

//A function that prompts the user for the number of subservices, then calles the respective

function based on the service type

Function insertTableValuesJobsheet2

begin

print"Enter the amount of Sub-Services: "

Read jb.subServiceAmount

if (jb.serviceType == 1) then

begin

function installationCase

else if (jb.serviceType == 2) then

begin

function repairCase

else if (jb.serviceType == 3) then

Page | 93
begin

function pestControlCase

else if (jb.serviceType == 4) then

begin

function sanitationCase

else then

begin

print"Incorrect input entered"

function decisionError

endif

end

//A function that creates a files that will store the user database name provided by the admin

Function userDatabaseNameFileCreation

begin

FILE* filePointer

filePointer = fopen("userdatabasename.txt", "w")

Page | 94
if (filePointer == NULL) then

begin

printf("Error!")

exit(1)

endif

fprintf(filePointer, "%s", db.name)

fclose(filePointer)

end

//A function that stores the userdatabase name

Function userDatabaseNameFileStorage

begin

FILE* filePointer

filePointer = fopen("userdatabasename.txt", "r")

if (filePointer == NULL) then

begin

Page | 95
printf("Error!")

exit(1)

endif

fscanf(filePointer, "%s", u.userDBName)

fclose(filePointer)

end

//A function that creates a files that will store the user database table name provided by the

admin

Function userTableNameFileCreation

begin

FILE* filePointer

filePointer = fopen("usertablename.txt", "w")

if (filePointer == NULL) then

begin

printf("Error!")

exit(1)

endif

Page | 96
fprintf(filePointer, "%s", dbt.name)

fclose(filePointer)

end

//A function that stores the userdatabase table name

Function userTableNameFileStorage

begin

FILE* filePointer

filePointer = fopen("usertablename.txt", "r")

if (filePointer == NULL) then

begin

printf("Error!")

exit(1)

endif

fscanf(filePointer, "%s", u.userdbtName)

fclose(filePointer)

end

Page | 97
//A function that authenticates the password provided by the user and calls the specific function

Function loginScreen

MYSQL* con = mysql_init(NULL)

if (con == NULL) then

begin

fprintf(stderr, "%s\n", mysql_error(con))

exit(1)

endif

if (mysql_real_connect(con, "localhost", "root", "root",

NULL, 0, NULL, 0) == NULL) then

begin

fprintf(stderr, "%s\n", mysql_error(con))

mysql_close(con)

exit(1)

endif

function system("cls")

function menu

print"Username: "

Page | 98
Read user.userName

print " "

print "Password: "

Read user.password

if (user.userName == "admin" then

function adminWelcomeScreen

else then

begin

function userDatabaseNameFileStorage

function userTableNameFileStorage

function userAuthentication

endif

end

// Function that allows users to signup to use the program

// and store their information in the user database table

Function signupScreen

begin

function system("cls")

function userDatabaseNameFileStorage

function userTableNameFileStorage

Page | 99
function insertTableValuesUsersSignIn

function userEmail

print" "

print"Your credentials have been sent to %s", userInfo.userEmail

print" "

print "Press any key to go back "

function getcharacter

function mainMenu

end

// A function that presents the different options for the admin

Function adminWelcomeScreenOption2

begin

print"+----------------------+"

print"| 1)Create a Worksheet |"

print"+----------------------+"

print"| 2)Edit a Worksheet |"

print"+----------------------+"

print"| 3)Delete a Worksheet |"

print"+----------------------+"

print"| 4)Previous Page |"

print"+----------------------+"

Page | 100
end

//A function that presents the different options for the admin

Function adminWelcomeScreenOption3

begin

print"+---------------------+"

print"| 1)Create a Jobsheet |"

print"+---------------------+"

print"| 2)Edit a Jobsheet |"

print"+---------------------+"

print"| 3)Delete a Jobsheet |"

print"+---------------------+"

print"| 4)Previous Page |"

print"+---------------------+"

end

//A function that presents the different options for the user

Function userEditWorksheetScreenOptions

begin

print"+-------------------+"

print"| 1)Add records |"

Page | 101
print"+-------------------+"

print"| 2)Delete records |"

print"+-------------------+"

print"| 3)Update records |"

print"+-------------------+"

print"| 4)Show Table Data |"

print"+-------------------+"

print"| 5)Previous Page |"

print"+-------------------+"

end

//A function that presents the different options for the user

Function userWelcomeScreenOptions

begin

function time_t t

function time(&t)

print"Welcome %s\n", user.userName

print"Login time: %s\n", ctime(&t)

print"+--------------+"

print"| 1)Worksheets |"

print"+--------------+"

Page | 102
print"| 2)Jobsheets |"

print"+--------------+"

print"| 3)Log Out |"

print"+--------------+"

end

//A function that presents the different options for the admin

Function adminWelcomeScreenOption1

begin

function system("cls"

print"+---------------------+"

print"| 1)Create a Database |"

print"+---------------------+"

print"| 2)Delete Database |"

print"+---------------------+"

print"| 3)View Databases |"

print"+---------------------+"

print"| 4)Previous Page |"

print"+---------------------+"

end

Page | 103
//A function that presents the different options for the admin

Function adminWelcomeScreenOptions

begin

function time_t t

function time(&t)

print"Welcome %s\n", user.userName

print"Login time: %s\n", ctime(&t)

print"+--------------+"

print"| 1)Databases |"

print"+--------------+"

print"| 2)Worksheets |"

print"+--------------+"

print"| 3)Jobsheets |"

print"+--------------+"

print"| 4)Users |"

print"+--------------+"

print"| 5)Log Out |"

print"+--------------+"

Page | 104
end

//A function that presents the different options for the admin

Function adminEditWorksheetScreenOptions

begin

print"+-------------------+"

print"| 1)Add records |"

print"+-------------------+"

print"| 2)Delete records |"

print"+-------------------+"

print"| 3)Update records |"

print"+-------------------+"

print"| 4)Show colums |"

print"+-------------------+"

print"| 5)Alter Columns |"

print"+-------------------+"

print"| 6)Show Table Data |"

print"+-------------------+"

print"| 7)Previous Page |"

print"+-------------------+"

Page | 105
end

FUNCTION welcomeScreen

begin

function system("cls")

function menu

function userWelcomeScreenOptions

print" "

print "Enter your input here: "

Read u.userInput

switch (u.userInput)

begin

case(1):

function system("cls")

function userEditWorksheetScreenOptions

print " "

print "Enter your input here: "

Read u.userInputDB

switch (u.userInputDB)

begin

case(1):

function system("cls")

Page | 106
function showDatabasesForUsers

function selectDatabase

function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function insertTableValues2

print"The records have been added to the worksheet"

function decisionPrompt

case(2):

function system("cls")

function showDatabasesForUsers

function selectDatabase

function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function showColumns

function deleteTableValuesQuery

function deleteTableValues

print"The records have been successfully deleted"

function decisionPrompt

case(3):

Page | 107
function system("cls")

function showDatabasesForUsers

function selectDatabase

function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function showColumns

function updateTableValuesQuery

function updateTableValues

print"The records have been successfully updated"

function decisionPrompt

case(4):

function system("cls")

function showDatabasesForUsers

function selectDatabase

function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function showDatabaseTableData

function decisionPrompt

case(5):

Page | 108
function system("cls")

function welcomeScreen(

default:

print"Wrong Input, try again"

function system("cls")

function welcomeScreen

end

case(2):

function system("cls")

function userEditWorksheetScreenOptions

print" "

print"Enter your input here: "

Read u.userInputDB

switch (u.userInputDB)

begin

case(1):

function system("cls")

function showDatabasesForUsers

function selectDatabase

function system("cls")

function showDatabaseTables

Page | 109
function selectDatabaseTables

function system("cls")

function insertTableValuesJobsheet

print "The records have been added to the jobsheet"

function decisionPrompt

case(2):

function system("cls")

function showDatabasesForUsers

function selectDatabase

function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function showColumns

function deleteTableValuesQuery

function deleteTableValues

print "The records have been successfully deleted"

function decisionPrompt

case(3):

function system("cls")

function showDatabasesForUsers

function selectDatabase

function system("cls")

Page | 110
function showDatabaseTables

function selectDatabaseTables

function system("cls")

function showColumns

function updateTableValuesQuery

function updateTableValues

print"The records have been successfully updated"

function decisionPrompt

case(4):

function system("cls")

function showDatabasesForUsers

function selectDatabase

functionsystem("cls")

function showDatabaseTables

functionselectDatabaseTables

function system("cls")

function showDatabaseTableData

function decisionPrompt

case(5):

function system("cls")

function welcomeScreen

default:

Page | 111
print"Wrong Input, try again"

function decisionPrompt

end

case(3):

function system("cls")

function mainMenu

default:

print"Wrong Input, try again")

function decisionPrompt

end

end

function adminWelcomeScreen

begin

function system("cls")

function menu

function adminWelcomeScreenOptions

print " "

print "Enter your input here: "

Page | 112
Read admin.adminInput

switch (admin.adminInput)

begin

case(1):

function system("cls")

function adminWelcomeScreenOption1

print " "

print"Enter your input here: "

Read dBI.databaseInput

switch (dBI.databaseInput)

begin

case(1):

function system("cls")

function createDatabaseName

function createDatabase

print"The database %s has been created \n", db.name

function system("cls")

function decisionPrompt

case(2):

function system("cls")

function showDatabases

function selectDatabase

function deleteDatabase

Page | 113
print"The database %s has been deleted ", dBI.databaseInputName

function decisionPrompt

case(3):

function system("cls")

function showDatabases

function decisionPrompt

case(4):

function system("cls")

function adminWelcomeScreen

default:

print"Wrong Input, try again")

function decisionPrompt

end

case(2):

function system("cls")

function adminWelcomeScreenOption2

print" "

print"Enter your input here: "

Read admin.adminInputDB

switch (admin.adminInputDB)

begin

Page | 114
case(1):

function system("cls")

function showDatabases

function selectDatabase

print"The database %s has been selected ", dBI.databaseInputName

function system("cls")

function createTablesInputWorksheet

function system("cls")

function insertTableColumnsWorksheet

print"The table has been created with the columns "

function decisionPrompt

case(2):

function system("cls")

function adminEditWorksheetScreenOptions

print" "

print "Enter your input here: "

Read admin.adminInputDB

switch (admin.adminInputDB)

begin

case(1):

function system("cls")

function showDatabases

Page | 115
function selectDatabase

function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function insertTableValues2

print "The records have been added to the worksheet"

function decisionPrompt

case(2):

function system("cls")

function showDatabases

function selectDatabase

function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function showColumns

function deleteTableValuesQuery

function deleteTableValues

print "The records have been successfully deleted"

function decisionPrompt

case(3):

function system("cls")

Page | 116
function showDatabases

function selectDatabase

function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function showColumns

function updateTableValuesQuery

function updateTableValues

print "The records have been successfully updated"

function decisionPrompt

case(4):

function system("cls")

function showDatabases

function selectDatabase

function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function showColumns

function decisionPrompt

case(5):

function system("cls")

Page | 117
function showDatabases

function selectDatabase

function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function alterTables

function decisionPrompt

case(6):

function system("cls")

function showDatabases

function selectDatabase

function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function showDatabaseTableData

function decisionPrompt

case(7):

function system("cls")

function adminWelcomeScreen

Page | 118
default:

printf("Wrong Input, try again")

function decisionPrompt

end

case(3):

function system("cls")

function showDatabases

function selectDatabase

function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function deleteDatabaseTables

print"The database table has been deleted"

function decisionPrompt

case(4):

function system("cls")

function adminWelcomeScreen

default:

print"Wrong Input, try again"

function decisionPrompt

end

Page | 119
case (3):

function system("cls")

function adminWelcomeScreenOption3

print " "

print "Enter your input here: "

Read admin.adminInputDB

switch (admin.adminInputDB)

begin

case(1):

function system("cls")

function showDatabases

function selectDatabase

print "The database %s has been selected ", dBI.databaseInputName

function system("cls")

function createTablesInputJobsheet

function insertTableColumnsJobsheet

print "The table has been created with the columns "

function decisionPrompt

case(2):

function system("cls")

function adminEditWorksheetScreenOptions

print " "

Page | 120
print "Enter your input here: "

Read admin.adminInputDB

switch (admin.adminInputDB)

Begin

case(1):

function system("cls")

function showDatabases

function selectDatabase

function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function insertTableValuesJobsheet

print "The records have been added to the jobsheet"

function decisionPrompt

case(2):

function system("cls")

function showDatabases

function selectDatabase

function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

Page | 121
function showColumns

function deleteTableValuesQuery

function deleteTableValues

print "The records have been successfully deleted"

function decisionPrompt

case(3):

function system("cls")

function showDatabases

function selectDatabase

function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function showColumns

function updateTableValuesQuery

function updateTableValues

print "The records have been successfully updated"

function decisionPrompt

case(4):

function system("cls")

function showDatabases

function selectDatabase

Page | 122
function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function showColumns

function decisionData

function adminWelcomeScreen

case(5):

function system("cls")

function showDatabases

function selectDatabase

function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function alterTables

function decisionPrompt

case(6):

function system("cls")

function showDatabases

function selectDatabase

Page | 123
function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function showDatabaseTableData

function decisionData

function adminWelcomeScreen

case(7):

function system("cls")

function adminWelcomeScreen

default:

print "Wrong Input, try again"

function decisionPrompt

case(3):

function system("cls")

function showDatabases

function selectDatabase

function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function deleteDatabaseTables

Page | 124
print "The database table has been deleted"

function decisionPrompt

case(4):

function system("cls")

function adminWelcomeScreen

default:

print "Wrong Input, try again"

function decisionPrompt

case (4):

function stem("cls")

print"+-----------------+"

print"| 1)User Database |"

print"+-----------------+"

print"| 2)User Tables |"

print"+-----------------+"

print"| 3)Users |"

print"+-----------------+"

print"| 4)Previous Page |"

print"+-----------------+"

print""

print"Enter your input here: "

Read admin.adminInputUsers

Page | 125
switch (admin.adminInputUsers)

Begin

case(1):

function system("cls")

print"+------------------------+"

print"| 1)Create User Database |"

print"+------------------------+"

print"| 2)Delete User Database |"

print"+------------------------+"

print"| 3)View User Database |"

print"+------------------------+"

print"| 4)Previous Page |"

print"+------------------------+"

print" "

print "Enter your input here: "

Read admin.adminInputUsersDatabase)

switch (admin.adminInputUsersDatabase)

begin

case(1):

function system("cls")

function createDatabaseName

function createDatabase

function userDatabaseNameFileCreation

Page | 126
function userDatabaseNameFileStorage

print "The database %s has been created ", db.name

function decisionPrompt

case(2):

function system("cls")

function showDatabases

function selectDatabase

function deleteDatabase

print "The database %s has been deleted ", dBI.databaseInputName

function decisionPrompt

case(3):

function system("cls")

function showDatabases

function selectDatabase

print "The database %s has been selected ", dBI.databaseInputName

function decisionPrompt

case(4):

function system("cls")

function adminWelcomeScreen

default:

print "Wrong Input, try again"

function decisionPrompt

end

Page | 127
case(2):

function system("cls")

print"+-----------------------+"

print"| 1)Create a User Table |"

print"+-----------------------+"

print"| 2)Edit a User Table |"

print"+-----------------------+"

print"| 3)Delete a User Table |"

print"+-----------------------+"

print"| 4)Previous Page |"

print"+-----------------------+"

print " "

print "Enter your input here: "

Read admin.adminInputUsersTable

switch (admin.adminInputUsersTable)

begin

case(1):

function system("cls")

function showDatabases

function selectDatabase

print "The database %s has been selected ", dBI.databaseInputName

function system("cls")

function createTablesInputUsers

Page | 128
function insertTableColumnsUsers

function userTableNameFileCreation

function userTableNameFileStorage

print "The table has been created with the columns "

function decisionPrompt

case(2):

function system("cls")

print"+-------------------+"

print"| 1)Add records |"

print"+-------------------+"

print"| 2)Delete records |"

print"+-------------------+"

print"| 3)Update records |"

print"+-------------------+"

print"| 4)Show colums |"

print"+-------------------+"

print"| 5)Alter Columns |"

print"+-------------------+"

print"| 6)Show Table Data |"

print"+-------------------+"

print"| 7)Previous Page |"

print"+-------------------+"

Page | 129
print" "

print "Enter your input here: "

Read admin.adminInputDB

switch (admin.adminInputDB)

begin

case(1):

function system("cls")

function showDatabases

function selectDatabase

function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function insertTableValuesUsers

function userDatabaseNameFileStorage

function userTableNameFileStorage

function userEmail

print"The records have been added to the table"

function decisionPrompt

case(2):

function system("cls")

function showDatabases

function selectDatabase

Page | 130
function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function showColumns

function deleteTableValuesQuery

function deleteTableValues

print "The records have been successfully deleted"

function decisionPrompt

case(3):

function system("cls")

function showDatabases

function selectDatabase

function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function showColumns

function updateTableValuesQuery

function updateTableValues

print "The records have been successfully updated"

function decisionPrompt

Page | 131
case(4):

function system("cls")

function showDatabases

function selectDatabase

function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function showColumns

function decisionData

function adminWelcomeScreen

case(5):

function system("cls")

function showDatabases

function selectDatabase

function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function alterTables

function decisionPrompt

Page | 132
case(6):

function system("cls")

function showDatabases

function selectDatabase

function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function showDatabaseTableData

function decisionData

function adminWelcomeScreen

case(7):

function system("cls")

function adminWelcomeScreen

default:

print "Wrong Input, try again"

function decisionPrompt

end

case(3):

function system("cls")

function showDatabases

function selectDatabase

Page | 133
function system("cls")

function showDatabaseTables

function selectDatabaseTables

function function system("cls")

deleteDatabaseTables

print "The database table has been deleted"

function decisionPrompt

case(4):

function system("cls")

function adminWelcomeScreen

default:

print "Wrong Input, try again"

function decisionPrompt

end

case(3):

function system("cls")

function showDatabases

function selectDatabase

function system("cls")

function showDatabaseTables

function selectDatabaseTables

function system("cls")

function showDatabaseTableData

Page | 134
function decisionPrompt

case(4):

function system("cls")

function adminWelcomeScreen

default:

print "Wrong Input, try again"

function decisionPrompt

end

case (5):

function mainMenu

default:

print "Wrong Input, try again"

function decisionPrompt

end

end

FUNCTION startupMenu ()

Begin

Declare comp_name as string

length as integer

length = sizeof(comp_name)/ sizeof(comp_name[0])

Page | 135
Print

"*****************************************************************************

*************************************************"

Print " ___ ___ ___ ___ ___ ________ ________ _______ ________

________ ________ _______"

sleep(200)

Print " | | | | | | | | | | |___ ___| |___ ___| | ____| | | | | ______ | | ______|

| ____|"

Sleep(200)

Print " | | | | | | | |____| | | | | | | |____ | _____| | | | | | |_____ |

|____ "

Sleep(200)

Print " | | | | | | | |____| | | | | | | ____| | | \\ \\ | | | | |_____ | |

____|"

Sleep(200)

Print " | |____| |____| | | | | | ___| |___ | | | |____ | | \\ \\ | |____| | _____|

| | |____"

Sleep(200)

Print " |_______________| |_| |_| |________| |__| |______| |_| \\_\\

|_______ | |_______ | |______|"

Page | 136
Print

"*****************************************************************************

*************************************************"

For i 1 to length do

Print comp_name[i]

Sleep(50)

Print " "

End

End

FUNCTION menu()

Begin

declare comp_name as string

length,i as integer

length = sizeof(comp_name)/sizeof(comp_name[0])

Print

"*****************************************************************************

*************************************************"

Print " ___ ___ ___ ___ ___ ________ ________ _______ ________

________ ________ _______ "

Print " | | | | | | | | | | |___ ___| |___ ___| | ____| | | | | ______ | | ______|

| ____| "

Print " | | | | | | | |____| | | | | | | |____ | _____| | | | | | |_____ |

|____ "

Page | 137
Print " | | | | | | | |____| | | | | | | ____| | | \\ \\ | | | | |_____ | |

____|"

Print " | |____| |____| | | | | | ___| |___ | | | |____ | | \\ \\ | |____| | _____|

| | |____"

Print " |_______________| |_| |_| |________| |__| |______| |_| \\_\\

|_______ | |_______ | |______|"

Print

"*****************************************************************************

*************************************************"

for i to length do

Print comp_name[i]

Print " "

End

//The main function that calls main menu

FUNCTION main

Begin

function mainMenu

End

Page | 138
C-Program
#define _CRT_SECURE_NO_WARNINGS

#define MAX 999

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <mysql.h>

#include <windows.h>

#include <time.h>

#include <conio.h>

#include <ctype.h>

//Structure that has members to use in worksheet reference

struct worksheets {

char name[MAX];

char namePerson[MAX];

char address[MAX];

char telephone[MAX];

char date[MAX];

char email[MAX];

char jobNumber[MAX];

char contactPerson[MAX];

int records;

Page | 139
int id;

int randomNumber;

};

struct worksheets wk;

//Structure that has members to use in jobsheet reference

struct jobsheets {

char name[MAX];

char telephone[MAX];

char address[MAX];

char date[MAX];

char contactPerson[MAX];

char services[MAX];

char subService[MAX];

char servicesQuery[MAX];

char servicesArray[MAX];

int subServiceAmount;

int serviceType;

int records;

int id;

};

struct jobsheets jb;

Page | 140
//Structure that has members to use in gathering the inputs from users in regards to different

databases

struct databaseInputs {

int databaseInput;

char databaseInputName[MAX];

int databaseInputTable;

};

struct databaseInputs dBI;

//Structure that has a member to use in creating a name for the databases

struct databaseName {

char name[100];

char nameInput[100];

};

struct databaseName db;

//Structure that has members to use in creating a database table

struct databaseTables {

char name[MAX];

Page | 141
char dataType[MAX];

char columnName[MAX];

char columnDataType[MAX];

char columnDataString[MAX];

char alterTableQuery[MAX];

char query[MAX];

char columnNameForQuery[MAX];

char columnNameNew[MAX];

int columns;

int columnDataSize;

int columnDataInt;

int columnDataStringChar;

int columnNumber;

};

struct databaseTables dbt;

//Structure that has members to use in creating user fields in a database table

struct userInformation {

int numberOfUsers;

char userFirstName[MAX];

char userSurname[MAX];

Page | 142
char userDOB[MAX];

int userID;

char userEmail[MAX];

};

struct userInformation userInfo;

//Structure that has members that holds login information for users

struct userCredentials {

char userName[MAX];

char password[MAX];

int menuInput;

};

struct userCredentials user;

//Structure that has members to use in the admin option selection menu

struct adminControls {

int adminInput;

int adminInputDB;

int adminInputUsers;

int adminInputUsersDatabase;

int adminInputUsersTable;

Page | 143
};

struct adminControls admin;

// Structure that has controls to use in switch statements for users

struct userControls {

int userInput;

int userInputDB;

char userDBName[MAX];

char userdbtName[MAX];

};

struct userControls u;

// Hierarchy of functions

void startupMenu();

void mainMenu();

void menu();

void insertTableValuesJobsheet2();

void welcomeScreen();

void loginScreen();

void adminWelcomeScreen();

void createDatabaseName();

Page | 144
// Function that checks to see which type of user is logged in to then decide which

// user function to call because of an error

void decisionError() {

if (strcmp(user.userName, "admin") == 0) {

Sleep(3000);

adminWelcomeScreen();

else if (strcmp(user.userName, user.userName) == 0) {

Sleep(3000);

welcomeScreen();

// Function that checks to see which type of user is logged in

void decision() {

printf("%s", user.userName);

if (strcmp(user.userName, "admin") == 0) {

adminWelcomeScreen();

Page | 145
else if (strcmp(user.userName, user.userName) == 0) {

welcomeScreen();

// Function that checks the data entered by a user for a decision

void decisionData() {

printf("\n");

printf("\n");

printf("Enter 'Return' to go to back : ");

scanf("%s", dbt.name);

if (strcmp(dbt.name, "Return") == 0) {

decision();

// Function that checks to see if a user entered a key to return to a

// previous page

void decisionPrompt() {

printf("\n");

printf("Press any key to go back ");

Page | 146
_getch();

decision();

//A function that checks to see if a mySQL query was executed with errors

void finish_with_error(MYSQL* con)

fprintf(stderr, "%s\n", mysql_error(con));

decisionError();

//A function that prompts the user to enter a name to create a database

void createDatabaseName() {

printf("Enter a name for the Database, Enter 'Return' to go to back: ");

scanf("%s", db.name);

if (strcmp(db.name, "Return") == 0) {

decision();

//A function that creates a database using a name provided by the user

Page | 147
int createDatabase() {

MYSQL* con = mysql_init(NULL);

if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

NULL, 0, NULL, 0) == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

mysql_close(con);

exit(1);

char query[255];

sprintf(query, "CREATE DATABASE `%s` ", db.name);

if (mysql_query(con, query))

fprintf(stderr, "%s\n", mysql_error(con));

decisionError();

Page | 148
}

mysql_close(con);

//A function that deletes a database that was provided by the user

int deleteDatabase() {

MYSQL* con = mysql_init(NULL);

if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

NULL, 0, NULL, 0) == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

mysql_close(con);

exit(1);

Page | 149
}

char query[255];

sprintf(query, "DROP DATABASE %s", dBI.databaseInputName);

if (mysql_query(con, query))

fprintf(stderr, "%s\n", mysql_error(con));

decisionError();

mysql_close(con);

//A function that prompts the user to enter the name of a database that will be used in mySQL

queries

void selectDatabase() {

printf("Select the name of the database to use, Enter 'Return' to go to the previous page: ");

scanf("%s", dBI.databaseInputName);

if (strcmp(dBI.databaseInputName, "Return") == 0) {

decision();

Page | 150
}

//A function that shows the list of available databases for the admin

int showDatabases() {

MYSQL* con = mysql_init(NULL);

if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

NULL, 0, NULL, 0) == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

mysql_close(con);

exit(1);

char query[255];

sprintf(query, "SHOW SCHEMAS");

Page | 151
if (mysql_query(con, query))

fprintf(stderr, "%s\n", mysql_error(con));

decisionError();

MYSQL_RES* result = mysql_store_result(con);

int num_fields = mysql_num_fields(result);

MYSQL_ROW row;

printf("List of Databases");

printf("\n");

while ((row = mysql_fetch_row(result)))

printf("\n");

for (int i = 0; i < num_fields; i++)

printf("%s", row[i] ? row[i] : "NULL");

printf("\n");

Page | 152
}

printf("\n");

mysql_free_result(result);

mysql_close(con);

//A function that prompts the user to enter a name to create a database table

void createDatabaseTableName() {

printf("Enter a name for the table, Enter 'Return' to go to back : ");

scanf("%s", dbt.name);

if (strcmp(dbt.name, "Return") == 0) {

decision();

//A function that returns the list of available databases specifically for users, after hiding the

default mySQL databases

int showDatabasesForUsers() {

MYSQL* con = mysql_init(NULL);

Page | 153
if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

NULL, 0, NULL, 0) == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

mysql_close(con);

exit(1);

char query[255];

sprintf(query, "SELECT `schema_name` from INFORMATION_SCHEMA.SCHEMATA

WHERE `schema_name` NOT IN('information_schema', 'mysql', 'performance_schema', 'sys',

'%s')", u.userDBName);

if (mysql_query(con, query))

fprintf(stderr, "%s\n", mysql_error(con));

decisionError();

Page | 154
}

MYSQL_RES* result = mysql_store_result(con);

int num_fields = mysql_num_fields(result);

MYSQL_ROW row;

if (result == NULL)

finish_with_error(con);

printf("List of Databases");

printf("\n");

while ((row = mysql_fetch_row(result)))

printf("\n");

for (int i = 0; i < num_fields; i++)

printf("%s ", row[i] ? row[i] : "NULL");

Page | 155
printf("\n");

printf("\n");

mysql_free_result(result);

mysql_close(con);

//A function that returns the list of available tables in a database

int showDatabaseTables() {

MYSQL* con = mysql_init(NULL);

if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL)

Page | 156
finish_with_error(con);

char query[255];

sprintf(query, "SHOW TABLES");

if (mysql_query(con, query))

fprintf(stderr, "%s\n", mysql_error(con));

decisionError();

MYSQL_RES* result = mysql_store_result(con);

int num_fields = mysql_num_fields(result);

MYSQL_ROW row;

printf("List of Tables");

printf("\n");

while ((row = mysql_fetch_row(result)))

printf("\n");

for (int i = 0; i < num_fields; i++)

Page | 157
{

printf("%s ", row[i] ? row[i] : "NULL");

printf("\n");

printf("\n");

mysql_free_result(result);

mysql_close(con);

//A function that prompts the user to enter the name of a database table that will be used in

mySQL queries

void selectDatabaseTables() {

printf("Select the name of the Worksheet to use, Enter 'Return' to go to the previous page: ");

scanf("%s", dbt.name);

if (strcmp(dbt.name, "Return") == 0) {

decision();

Page | 158
}

//A function that deletes a database table gthat was provided by the user

int deleteDatabaseTables() {

MYSQL* con = mysql_init(NULL);

if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL)

finish_with_error(con);

char query[255];

sprintf(query, "DROP TABLE %s", dbt.name);

if (mysql_query(con, query))

fprintf(stderr, "%s\n", mysql_error(con));

Page | 159
decisionError();

mysql_close(con);

//A function that shows the data of a database table that was provided by the user

int showDatabaseTableData() {

MYSQL* con = mysql_init(NULL);

if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL)

finish_with_error(con);

Page | 160
char query[255];

sprintf(query, "SELECT * FROM %s", dbt.name);

if (mysql_query(con, query))

fprintf(stderr, "%s\n", mysql_error(con));

decisionError();

MYSQL_RES* result = mysql_store_result(con);

if (result == NULL)

finish_with_error(con);

int num_fields = mysql_num_fields(result);

MYSQL_ROW row;

int count = 1;

while ((row = mysql_fetch_row(result)))

Page | 161
/*printf("%i ", count);

count ++;*/

for (int i = 0; i < num_fields; i++)

printf("%s ", row[i] ? row[i] : "NULL");

printf("\n");

mysql_free_result(result);

mysql_close(con);

//A function that creates a database table using a name provided by the user

int createTables() {

Page | 162
MYSQL* con = mysql_init(NULL);

if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL)

finish_with_error(con);

char query[255];

sprintf(query, "CREATE TABLE %s (%s %s PRIMARY KEY)", dbt.name, dbt.columnName,

dbt.dataType);

if (mysql_query(con, query))

fprintf(stderr, "%s\n", mysql_error(con));

decisionError();

mysql_close(con);

Page | 163
}

//A function that returns the names of the columns from a database table

int showColumns() {

MYSQL* con = mysql_init(NULL);

if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL)

finish_with_error(con);

char query[255];

sprintf(query, "SELECT column_name from information_schema.columns where

table_schema = database() and table_name = '%s'", dbt.name);

Page | 164
if (mysql_query(con, query))

fprintf(stderr, "%s\n", mysql_error(con));

decisionError();

MYSQL_RES* result = mysql_store_result(con);

if (result == NULL)

finish_with_error(con);

int num_fields = mysql_num_fields(result);

MYSQL_ROW row;

MYSQL_FIELD* field;

while ((row = mysql_fetch_row(result)))

for (int i = 0; i < num_fields; i++)

Page | 165
{

if (i == 0)

while (field = mysql_fetch_field(result))

printf("%s", field->name);

printf("\n");

printf("%s ", row[i] ? row[i] : "NULL");

printf("\n");

mysql_free_result(result);

mysql_close(con);

Page | 166
}

//A function that creates a database table with column names and data types

int createTablesInputWorksheet() {

MYSQL* con = mysql_init(NULL);

if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL)

finish_with_error(con);

printf("Create the table by entering a name, Enter 'Return' to go to back: ");

scanf("%s", dbt.name);

if (strcmp(dbt.name, "Return") == 0) {

decision();

Page | 167
}

system("cls");

printf("+-----------------------------------------+\n");

printf("| Alert |\n");

printf("+-----------------------------------------+\n");

printf("| To create a worksheet enter 8 columns |\n");

printf("+-----------------------------------------+\n");

printf("\n");

printf("\n");

printf("Continue creating the table by entering the number of columns: ");

scanf("%i", &dbt.columns);

printf("Create a primary key column by entering 'ID': ");

scanf("%s", dbt.columnName);

printf("Set the datatype of the column by entering 'INT': ");

scanf("%s", dbt.columnDataType);

if (strcmp(dbt.columnDataType, "int") == 0 || strcmp(dbt.columnDataType, "INT") == 0) {

sprintf(dbt.dataType, "INT");

createTables();

else if (strcmp(dbt.columnDataType, "varchar") == 0 || strcmp(dbt.columnDataType,

"VARCHAR") == 0) {

sprintf(dbt.dataType, "VARCHAR(%i)", MAX);

Page | 168
createTables();

else if (strcmp(dbt.columnDataType, "date") == 0 || strcmp(dbt.columnDataType, "DATE")

== 0) {

sprintf(dbt.dataType, "DATE");

createTables();

mysql_close(con);

//A function that allows the user to add database tables

int addTables() {

MYSQL* con = mysql_init(NULL);

if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL)

Page | 169
{

finish_with_error(con);

char query[255];

sprintf(query, "ADD %s %s", dbt.columnName, dbt.columnDataType);

if (mysql_query(con, query))

fprintf(stderr, "%s\n", mysql_error(con));

decisionError();

mysql_close(con);

//A function that is called to

int insertTableColumns2() {

MYSQL* con = mysql_init(NULL);

if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

Page | 170
exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL)

finish_with_error(con);

char query[255];

sprintf(query, "ALTER TABLE %s ADD COLUMN %s %s", dbt.name, dbt.columnName,

dbt.dataType);

if (mysql_query(con, query))

fprintf(stderr, "%s\n", mysql_error(con));

decisionError();

mysql_close(con);

//A function that allows the user to make modifications to a database table

int alterTables() {

Page | 171
MYSQL* con = mysql_init(NULL);

if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL)

finish_with_error(con);

char query[255];

printf("Enter the change to make to the table's column ADD, MODIFY, DROP, RENAME,

Enter 'Return' to go to the previous page: ");

scanf("%s", dbt.alterTableQuery);

if (strcmp(dbt.alterTableQuery, "Return") == 0) {

decision();

Page | 172
else if (strcmp(dbt.alterTableQuery, "add") == 0 || strcmp(dbt.alterTableQuery, "ADD") == 0)

system("cls");

showColumns();

printf("\n");

printf("Enter the name of the column: ");

scanf("%s", dbt.columnName);

printf("Enter the Data type of the column INT() , VARCHAR() , DATE , DECIMAL: ");

scanf("%s", dbt.columnDataType);

if (strcmp(dbt.columnDataType, "INT") == 0) {

sprintf(dbt.dataType, "INT");

else if (strcmp(dbt.columnDataType, "varchar") == 0 || strcmp(dbt.columnDataType,

"VARCHAR") == 0) {

sprintf(dbt.dataType, "VARCHAR(%i)", MAX);

else if (strcmp(dbt.columnDataType, "DATE") == 0 || strcmp(dbt.columnDataType, "date")

== 0) {

sprintf(dbt.dataType, "DATE");

Page | 173
}

else {

printf("Incorrect data type entered");

decisionError();

sprintf(query, "ALTER TABLE %s ADD %s %s", dbt.name, dbt.columnName,

dbt.dataType);

if (mysql_query(con, query))

fprintf(stderr, "%s\n", mysql_error(con));

decisionError();

else if (strcmp(dbt.alterTableQuery, "drop") == 0 || strcmp(dbt.alterTableQuery, "DROP") ==

0) {

system("cls");

showColumns();

printf("\n");

printf("Enter the name of the column: ");

scanf("%s", dbt.columnName);

sprintf(query, "ALTER TABLE %s DROP COLUMN %s", dbt.name, dbt.columnName);

Page | 174
if (mysql_query(con, query))

fprintf(stderr, "%s\n", mysql_error(con));

decisionError();

else if (strcmp(dbt.alterTableQuery, "modify") == 0 || strcmp(dbt.alterTableQuery,

"MODIFY") == 0) {

system("cls");

showColumns();

printf("\n");

printf("Enter the name of the column: ");

scanf("%s", dbt.columnName);

printf("Enter the Data type of the column INT() , VARCHAR() , DATE , DECIMAL: ");

scanf("%s", dbt.columnDataType);

if (strcmp(dbt.columnDataType, "int") == 0 || strcmp(dbt.columnDataType, "INT") == 0) {

sprintf(dbt.dataType, "INT");

else if (strcmp(dbt.columnDataType, "varchar") == 0 || strcmp(dbt.columnDataType,

"VARCHAR") == 0) {

sprintf(dbt.dataType, "VARCHAR(%i)", MAX);

Page | 175
}

else if (strcmp(dbt.columnDataType, "date") == 0 || strcmp(dbt.columnDataType, "DATE")

== 0) {

sprintf(dbt.dataType, "DATE");

sprintf(query, "ALTER TABLE %s MODIFY %s %s", dbt.name, dbt.columnName,

dbt.dataType);

if (mysql_query(con, query))

fprintf(stderr, "%s\n", mysql_error(con));

decisionError();

else if (strcmp(dbt.alterTableQuery, "rename") == 0 || strcmp(dbt.alterTableQuery,

"RENAME") == 0) {

system("cls");

showColumns();

printf("\n");

printf("Enter the name of the old column: ");

scanf("%s", dbt.columnName);

Page | 176
printf("Enter the name to change the column to: ");

scanf("%s", dbt.columnNameNew);

sprintf(query, "ALTER TABLE %s RENAME COLUMN %s to %s", dbt.name,

dbt.columnName, dbt.columnNameNew);

if (mysql_query(con, query))

fprintf(stderr, "%s\n", mysql_error(con));

decisionError();

mysql_close(con);

// Funcction that generates an email script to send a confirmation

// message to an email entered by a user

void userEmail() {

Page | 177
FILE* email;

char script[MAX];

sprintf(script,

"$from = 'whiteroseprogramcredentials@gmail.com'\n"

"$to = '%s'\n"

"$subject = 'Welcome to White Rose Interiors Database Program'\n"

"$body = 'Your credentials are as follows: \n Username: %i\n Password: %s'\n"

"$smtpServer = 'smtp.gmail.com'\n"

"$port = 587\n"

"$username = 'whiteroseprogramcredentials@gmail.com'\n"

"$password = 'oduqxmklfciozdpm'\n"

"$mailMessage = New-Object System.Net.Mail.MailMessage $from, $to, $subject,

$body\n"

"$mailMessage.From = New-Object System.Net.Mail.MailAddress($from, 'White Rose

Interiors Admin')\n"

"$smtpClient = New-Object System.Net.Mail.SmtpClient $smtpServer\n"

"$smtpClient.Port = $port\n"

"$smtpClient.EnableSsl = $true\n"

"$smtpClient.Credentials = New-Object System.Net.NetworkCredential($username,

$password)\n"

"$smtpClient.Send($mailMessage)\n", userInfo.userEmail, userInfo.userID, user.password);

char command[MAX];

Page | 178
sprintf(command, "%s", script); //Store the completed script into a variable

email = fopen("emailscript.ps1", "w");

if (email == NULL) {

printf("Couldn't create script file");

exit(1);

fprintf(email, "%s", command);

fclose(email);

system("powershell.exe

C:\\Users\\Dell\\Desktop\\CSUnit1SBA\\CSUnit1SBA\\emailscript.ps1");

/*system("cd C:\\Users\\Dell\\Desktop\\CSUnit1SBA\\CSUnit1SBA\\emailscript.ps1 && del

emailscript.ps1");*/

// Function that gives a guide to the administrator when creating

// columsn for the database table worksheet

int insertTableColumnsWorksheet() {

Page | 179
MYSQL* con = mysql_init(NULL);

if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL)

finish_with_error(con);

printf("+-------------------------------------------+\n");

printf("| Alert |\n");

printf("+-------------------------------------------+\n");

printf("| Create the remaining columns of the table |\n");

printf("| in the following order: |\n");

printf("+-------------------------------------------+\n");

printf("| Name: Varchar |\n");

printf("+-------------------------------------------+\n");

printf("| Address: Varchar |\n");

printf("+-------------------------------------------+\n");

Page | 180
printf("| Telephone: Varchar |\n");

printf("+-------------------------------------------+\n");

printf("| Date: Date |\n");

printf("+-------------------------------------------+\n");

printf("| Email: Varchar |\n");

printf("+-------------------------------------------+\n");

printf("| JobNumber: Int |\n");

printf("+-------------------------------------------+\n");

printf("| ContactPerson: Varchar |\n");

printf("+-------------------------------------------+\n");

printf("\n");

printf("\n");

for (int i = 0; i < dbt.columns - 1; ++i) {

printf("Create the column by entering a name, Enter 'Return' to go to the previous page: ");

scanf("%s", dbt.columnName);

if (strcmp(dbt.columnName, "Return") == 0) {

adminWelcomeScreen();

printf("Enter the Data type of the column INT , VARCHAR , DATE , DECIMAL: ");

scanf("%s", dbt.columnDataType);

if (strcmp(dbt.columnDataType, "int") == 0 || strcmp(dbt.columnDataType, "INT") == 0) {

Page | 181
sprintf(dbt.dataType, "INT");

insertTableColumns2();

else if (strcmp(dbt.columnDataType, "varchar") == 0 || strcmp(dbt.columnDataType,

"VARCHAR") == 0) {

sprintf(dbt.dataType, "VARCHAR(%i)", MAX);

insertTableColumns2();

else if (strcmp(dbt.columnDataType, "date") == 0 || strcmp(dbt.columnDataType, "DATE")

== 0) {

sprintf(dbt.dataType, "DATE");

insertTableColumns2();

else {

printf("Incorrect data type entered");

decisionError();

mysql_close(con);

Page | 182
//A function that gathers input from the user regarding the database table values to be passed into

a worksheet

void insertTableValues() {

printf("Enter the amount of records you want to insert: ");

scanf("%i", &wk.records);

for (int i = 0; i < wk.records; ++i) {

printf("Enter the name of the person: ");

scanf("%s", wk.namePerson);

printf("Enter the address of the person: ");

scanf("%s", wk.address);

printf("Enter the telephone number of the person: ");

scanf("%s", wk.telephone);

printf("Enter the date YYYY-MM-DD: ");

scanf("%s", wk.date);

printf("Enter the email of the person: ");

scanf("%s", wk.email);

printf("Enter the Job Number of the person: ");

scanf("%s", wk.jobNumber);

printf("Enter the Contact Person: ");

scanf("%s", wk.contactPerson);

Page | 183
}

//A function that gathers input from the user regarding the database table values to be passed into

a worksheet

int insertTableValues2() {

MYSQL* con = mysql_init(NULL);

if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL)

finish_with_error(con);

char query[255];

Page | 184
printf("Enter the amount of records you want to insert: ");

scanf("%i", &wk.records);

time_t t1;

srand((unsigned)time(&t1));

for (int i = 0; i < wk.records; ++i) {

printf("Enter the name of the person: ");

scanf("%s", wk.namePerson);

printf("Enter the address of the person: ");

scanf("%s", wk.address);

printf("Enter the telephone number of the person: ");

scanf("%s", wk.telephone);

printf("Enter the date YYYY-MM-DD: ");

scanf("%s", wk.date);

printf("Enter the email of the person: ");

scanf("%s", wk.email);

printf("Enter the Job Number of the person: ");

scanf("%s", wk.jobNumber);

printf("Enter the Contact Person: ");

scanf("%s", wk.contactPerson);

wk.id = rand() % MAX;

Page | 185
sprintf(query, "INSERT INTO %s VALUES(%i,'%s', '%s', '%s', '%s', '%s', '%s', '%s')",

dbt.name, wk.id, wk.namePerson, wk.address, wk.telephone, wk.date, wk.email, wk.jobNumber,

wk.contactPerson);

if (mysql_query(con, query))

fprintf(stderr, "%s\n", mysql_error(con));

decisionError();

mysql_close(con);

//A function that gathers input from the user regarding the database table values to be passed into

the user table that will hold the login credentials

int insertTableValuesUsers() {

MYSQL* con = mysql_init(NULL);

if (con == NULL)

Page | 186
fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL)

finish_with_error(con);

char query[255];

printf("Enter the amount of records you want to insert: ");

scanf("%i", &userInfo.numberOfUsers);

time_t t1;

srand((unsigned)time(&t1));

for (int i = 0; i < userInfo.numberOfUsers; ++i) {

printf("Enter your first name: ");

scanf("%s", userInfo.userFirstName);

printf("Enter your last name: ");

scanf("%s", userInfo.userSurname);

printf("Enter your Date of birth YYYY-MM-DD: ");

scanf("%s", userInfo.userDOB);

Page | 187
printf("Enter your email: ");

scanf("%s", userInfo.userEmail);

printf("Enter a password: ");

scanf("%s", user.password);

userInfo.userID = rand() % MAX;

sprintf(query, "INSERT INTO %s VALUES(%i, '%s', '%s', '%s', '%s', '%s')", dbt.name,

userInfo.userID, userInfo.userFirstName, userInfo.userSurname, userInfo.userEmail,

userInfo.userDOB, user.password);

if (mysql_query(con, query))

fprintf(stderr, "%s\n", mysql_error(con));

decisionError();

mysql_close(con);

// Function that inserts the records in a database table created

// for users when signing into the program

int insertTableValuesUsersSignIn() {

MYSQL* con = mysql_init(NULL);

Page | 188
if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

u.userDBName, 0, NULL, 0) == NULL)

finish_with_error(con);

char query[255];

time_t t1;

srand((unsigned)time(&t1));

printf("Enter your first name: ");

scanf("%s", userInfo.userFirstName);

printf("Enter your last name: ");

scanf("%s", userInfo.userSurname);

printf("Enter your Date of birth YYYY-MM-DD: ");

scanf("%s", userInfo.userDOB);

printf("Enter your email: ");

Page | 189
scanf("%s", userInfo.userEmail);

printf("Enter a password: ");

scanf("%s", user.password);

userInfo.userID = rand() % MAX;

sprintf(query, "INSERT INTO %s VALUES(%i, '%s', '%s', '%s', '%s', '%s')", u.userdbtName,

userInfo.userID, userInfo.userFirstName, userInfo.userSurname, userInfo.userEmail,

userInfo.userDOB, user.password);

if (mysql_query(con, query))

fprintf(stderr, "%s\n", mysql_error(con));

decisionError();

mysql_close(con);

// Function that gives guide to administrators when creating a database

// table

int createTablesInputUsers() {

MYSQL* con = mysql_init(NULL);

Page | 190
if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL)

finish_with_error(con);

printf("Create the table by entering a name, Enter 'Return' to go to back: ");

scanf("%s", dbt.name);

if (strcmp(dbt.name, "Return") == 0) {

decision();

system("cls");

printf("+-----------------------------------------+\n");

printf("| Alert |\n");

printf("+-----------------------------------------+\n");

printf("| To create a table enter 6 columns |\n");

printf("+-----------------------------------------+\n");

Page | 191
printf("\n");

printf("\n");

printf("Continue creating the table by entering the number of columns: ");

scanf("%i", &dbt.columns);

printf("Create a primary key column by entering 'ID': ");

scanf("%s", dbt.columnName);

printf("Set the datatype of the column by entering 'INT': ");

scanf("%s", dbt.columnDataType);

if (strcmp(dbt.columnDataType, "int") == 0 || strcmp(dbt.columnDataType, "INT") == 0) {

sprintf(dbt.dataType, "INT");

createTables();

else if (strcmp(dbt.columnDataType, "varchar") == 0 || strcmp(dbt.columnDataType,

"VARCHAR") == 0) {

sprintf(dbt.dataType, "VARCHAR(%i)", MAX);

createTables();

else if (strcmp(dbt.columnDataType, "date") == 0 || strcmp(dbt.columnDataType, "DATE")

== 0) {

sprintf(dbt.dataType, "DATE");

createTables();

Page | 192
}

mysql_close(con);

// Function that gives guide to administrators when creating a database

// table columns for users

int insertTableColumnsUsers() {

MYSQL* con = mysql_init(NULL);

if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL)

finish_with_error(con);

system("cls");

printf("+-------------------------------------------+\n");

printf("| Alert |\n");

Page | 193
printf("+-------------------------------------------+\n");

printf("| Create the remaining columns of the table |\n");

printf("| in the following order: |\n");

printf("+-------------------------------------------+\n");

printf("| First Name: Varchar |\n");

printf("+-------------------------------------------+\n");

printf("| Surname: Varchar |\n");

printf("+-------------------------------------------+\n");

printf("| Email: Varchar |\n");

printf("+-------------------------------------------+\n");

printf("| Date of Birth: Date |\n");

printf("+-------------------------------------------+\n");

printf("| Password: Varchar |\n");

printf("+-------------------------------------------+\n");

printf("\n");

printf("\n");

for (int i = 0; i < dbt.columns - 1; ++i) {

printf("Create the column by entering a name, Enter 'Return' to go to the previous page: ");

scanf("%s", dbt.columnName);

if (strcmp(dbt.columnName, "Return") == 0) {

adminWelcomeScreen();

Page | 194
}

printf("Enter the Data type of the column INT , VARCHAR , DATE , DECIMAL: ");

scanf("%s", dbt.columnDataType);

if (strcmp(dbt.columnDataType, "int") == 0 || strcmp(dbt.columnDataType, "INT") == 0) {

sprintf(dbt.dataType, "INT");

insertTableColumns2();

else if (strcmp(dbt.columnDataType, "varchar") == 0 || strcmp(dbt.columnDataType,

"VARCHAR") == 0) {

sprintf(dbt.dataType, "VARCHAR(%i)", MAX);

insertTableColumns2();

else if (strcmp(dbt.columnDataType, "date") == 0 || strcmp(dbt.columnDataType, "DATE")

== 0) {

sprintf(dbt.dataType, "DATE");

insertTableColumns2();

else {

printf("Incorrect data type entered");

decisionError();

Page | 195
}

mysql_close(con);

//A function that searches the user login table and selects the password based on the ID number

provided

//it then stores the password inside of a variable that is authenticated with the password provided

//by the user

int userAuthentication() {

MYSQL* con = mysql_init(NULL);

const char* res = "\0";

if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

u.userDBName, 0, NULL, 0) == NULL)

Page | 196
finish_with_error(con);

char query[255];

sprintf(query, "SELECT PASSWORD FROM %s WHERE ID = %s", u.userdbtName,

user.userName);

if (mysql_query(con, query))

fprintf(stderr, "%s\n", mysql_error(con));

decisionError();

MYSQL_RES* result = mysql_store_result(con);

int num_fields = mysql_num_fields(result);

MYSQL_ROW row;

while ((row = mysql_fetch_row(result)))

for (int i = 0; i < num_fields; i++)

Page | 197
res = row[i] ? row[i] : "NULL";

printf("\n");

printf("\n");

if (strcmp(user.userName, "admin") == 0) {

adminWelcomeScreen();

else if (strcmp(user.password, res) == 0) {

welcomeScreen();

else {

printf("Incorrect Username or password");

Sleep(3000);

loginScreen();

mysql_free_result(result);

mysql_close(con);

Page | 198
}

//A function that gather the information that will be used to update the records in a database table

void updateTableValuesQuery() {

printf("\n");

printf("Enter the name of the Column in updating the records: ");

scanf("%s", dbt.columnName);

system("cls");

showDatabaseTableData();

printf("\n");

printf("Enter the ID of the record: ");

scanf("%i", &wk.id);

printf("Enter the new record value: ");

scanf("%s", dbt.query);

Page | 199
//A function that updates records in a database table

int updateTableValues() {

MYSQL* con = mysql_init(NULL);

if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL)

finish_with_error(con);

char query[255];

if (strcmp(dbt.columnName, "JobNumber") == 0) {

sprintf(query, "UPDATE %s SET %s = %i WHERE ID = %i", dbt.name, dbt.columnName,

dbt.query, wk.id);

else {

Page | 200
sprintf(query, "UPDATE %s SET %s = '%s' WHERE ID = %i", dbt.name,

dbt.columnName, dbt.query, wk.id);

if (mysql_query(con, query))

fprintf(stderr, "%s\n", mysql_error(con));

decisionError();

mysql_close(con);

//A function that gathers the input from the user to use in deleting values from a database table

void deleteTableValuesQuery() {

printf("Enter the name of the Column to use for deletion: ");

scanf("%s", dbt.columnName);

system("cls");

Page | 201
showDatabaseTableData();

printf("\n");

printf("Enter the record value to delete: ");

scanf("%s", dbt.query);

//A function that deletes records in a database table

int deleteTableValues() {

MYSQL* con = mysql_init(NULL);

if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL)

finish_with_error(con);

Page | 202
char query[255];

if (strcmp(dbt.columnName, "JobNumber") == 0) {

sprintf(query, "DELETE FROM %s WHERE %s = %s", dbt.name, dbt.columnName,

dbt.query);

else {

sprintf(query, "DELETE FROM %s WHERE %s = '%s'", dbt.name, dbt.columnName,

dbt.query);

if (mysql_query(con, query))

fprintf(stderr, "%s\n", mysql_error(con));

decisionError();

mysql_close(con);

// Function that gives a guide to the administrator when creating

// records for the database table jobsheet

Page | 203
int createTablesInputJobsheet() {

MYSQL* con = mysql_init(NULL);

if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL)

finish_with_error(con);

printf("Create the table by entering a name, Enter 'Return' to go to back: ");

scanf("%s", dbt.name);

if (strcmp(dbt.name, "Return") == 0) {

decision();

system("cls");

printf("+-----------------------------------------+\n");

printf("| Alert |\n");

Page | 204
printf("+-----------------------------------------+\n");

printf("| To create a jobsheet enter 7 columns |\n");

printf("+-----------------------------------------+\n");

printf("\n");

printf("\n");

printf("Continue creating the table by entering the number of columns: ");

scanf("%i", &dbt.columns);

printf("Create a primary key column by entering 'ID': ");

scanf("%s", dbt.columnName);

printf("Set the datatype of the column by entering 'INT': ");

scanf("%s", dbt.columnDataType);

if (strcmp(dbt.columnDataType, "int") == 0 || strcmp(dbt.columnDataType, "INT") == 0) {

sprintf(dbt.dataType, "INT");

createTables();

else if (strcmp(dbt.columnDataType, "varchar") == 0 || strcmp(dbt.columnDataType,

"VARCHAR") == 0) {

sprintf(dbt.dataType, "VARCHAR(%i)", MAX);

createTables();

Page | 205
else if (strcmp(dbt.columnDataType, "date") == 0 || strcmp(dbt.columnDataType, "DATE")

== 0) {

sprintf(dbt.dataType, "DATE");

createTables();

mysql_close(con);

// Function that gives a guide to the administrator when creating

// columns for the database table jobsheet

int insertTableColumnsJobsheet() {

MYSQL* con = mysql_init(NULL);

if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL)

finish_with_error(con);

Page | 206
}

system("cls");

printf("+-------------------------------------------+\n");

printf("| Alert |\n");

printf("+-------------------------------------------+\n");

printf("| Create the remaining columns of the table |\n");

printf("| in the following order: |\n");

printf("+-------------------------------------------+\n");

printf("| Name: Varchar |\n");

printf("+-------------------------------------------+\n");

printf("| Telephone: Varchar |\n");

printf("+-------------------------------------------+\n");

printf("| Address: Varchar |\n");

printf("+-------------------------------------------+\n");

printf("| Date: Date |\n");

printf("+-------------------------------------------+\n");

printf("| Contact Person: Varchar |\n");

printf("+-------------------------------------------+\n");

printf("| Services: Varchar |\n");

printf("+-------------------------------------------+\n");

printf("\n");

printf("\n");

Page | 207
for (int i = 0; i < dbt.columns - 1; ++i) {

printf("Create the column by entering a name, Enter 'Return' to go to the previous page: ");

scanf("%s", dbt.columnName);

if (strcmp(dbt.columnName, "Return") == 0) {

adminWelcomeScreen();

printf("Enter the Data type of the column INT , VARCHAR , DATE , DECIMAL: ");

scanf("%s", dbt.columnDataType);

if (strcmp(dbt.columnDataType, "int") == 0 || strcmp(dbt.columnDataType, "INT") == 0) {

sprintf(dbt.dataType, "INT");

insertTableColumns2();

else if (strcmp(dbt.columnDataType, "varchar") == 0 || strcmp(dbt.columnDataType,

"VARCHAR") == 0) {

sprintf(dbt.dataType, "VARCHAR(%i)", MAX);

insertTableColumns2();

else if (strcmp(dbt.columnDataType, "date") == 0 || strcmp(dbt.columnDataType, "DATE")

== 0) {

Page | 208
sprintf(dbt.dataType, "DATE");

insertTableColumns2();

else {

printf("Incorrect data type entered");

decisionError();

printf("\n");

mysql_close(con);

//A function that creates a files that will store the services provided in a jobsheet

void servicesFileCreation() {

FILE* filePointer;

filePointer = fopen("services.txt", "w");

if (filePointer == NULL) {

printf("Error!");

exit(1);

Page | 209
}

if (jb.subServiceAmount < 2) {

fprintf(filePointer, "%s", jb.subService);

else {

fprintf(filePointer, "%s,", jb.subService);

fclose(filePointer);

//A function that appends to a file that will store the services provided in a jobsheet

void servicesFileAppend() {

FILE* filePointer;

filePointer = fopen("services.txt", "a");

if (filePointer == NULL) {

printf("Error!");

exit(1);

Page | 210
if (jb.subServiceAmount < 2) {

fprintf(filePointer, "%s", jb.subService);

else {

fprintf(filePointer, "%s,", jb.subService);

fclose(filePointer);

//A function that stores the services provided

void servicesFileStorage() {

FILE* filePointer;

filePointer = fopen("services.txt", "r");

if (filePointer == NULL) {

printf("Error!");

exit(1);

Page | 211
fscanf(filePointer, "%s", jb.services);

fclose(filePointer);

// A function that stores the subservices for a installation

// job in a jobsheet

void installationCase() {

for (int i = 0; i < 1; ++i) {

printf("+----------------------+\n");

printf("| Carpet |\n");

printf("+----------------------+\n");

printf("| Drapery |\n");

printf("+----------------------+\n");

printf("| Blinds/Roller Shades |\n");

printf("+----------------------+\n");

printf("Enter Sub-Service : ");

scanf("%s", jb.subService);

system("cls");

servicesFileCreation();

for (int j = 0; j < jb.subServiceAmount - 1; ++j) {

Page | 212
printf("+----------------------+\n");

printf("| Carpet |\n");

printf("+----------------------+\n");

printf("| Drapery |\n");

printf("+----------------------+\n");

printf("| Blinds/Roller Shades |\n");

printf("+----------------------+\n");

printf("Enter Sub-Service : ");

scanf("%s", jb.subService);

system("cls");

servicesFileAppend();

servicesFileStorage();

sprintf(jb.servicesQuery, "Installation of %s ", jb.services);

//A function that presents the different types of jobsheet sub-services for the repair service

void repairCase() {

for (int i = 0; i < 1; ++i) {

printf("+----------------------+\n");

printf("| Carpet |\n");

Page | 213
printf("+----------------------+\n");

printf("| Drapery |\n");

printf("+----------------------+\n");

printf("| Blinds/Roller Shades |\n");

printf("+----------------------+\n");

printf("Enter Sub-Service : ");

scanf("%s", jb.subService);

system("cls");

servicesFileCreation();

for (int j = 0; j < jb.subServiceAmount - 1; ++j) {

printf("+----------------------+\n");

printf("| Carpet |\n");

printf("+----------------------+\n");

printf("| Drapery |\n");

printf("+----------------------+\n");

printf("| Blinds/Roller Shades |\n");

printf("+----------------------+\n");

printf("Enter Sub-Service : ");

scanf("%s", jb.subService);

system("cls");

servicesFileAppend();

servicesFileStorage();

Page | 214
sprintf(jb.servicesQuery, "Repair of %s ", jb.services);

//A function that presents the different types of jobsheet sub-services for the pest control service

void pestControlCase() {

for (int i = 0; i < 1; ++i) {

printf("+----------------------+\n");

printf("| Spraying |\n");

printf("+----------------------+\n");

printf("| Bait/Paste |\n");

printf("+----------------------+\n");

printf("| Termite Treatment |\n");

printf("+----------------------+\n");

printf("Enter Sub-Service : ");

scanf("%s", jb.subService);

system("cls");

servicesFileCreation();

for (int j = 0; j < (jb.subServiceAmount - 1); ++j) {

printf("+-------------------+\n");

Page | 215
printf("| Spraying |\n");

printf("+-------------------+\n");

printf("| Bait/Paste |\n");

printf("+-------------------+\n");

printf("| Termite Treatment |\n");

printf("+-------------------+\n");

printf("Enter Sub-Service : ");

scanf("%s", jb.subService);

system("cls");

servicesFileAppend();

servicesFileStorage();

sprintf(jb.servicesQuery, "Pest Control of %s", jb.services);

//A function that presents the different types of jobsheet sub-services for the sanitation service

void sanitationCase() {

for (int j = 0; j < 1; ++j) {

printf("+----------------------+\n");

printf("| Rug |\n");

printf("+----------------------+\n");

Page | 216
printf("| Carpet |\n");

printf("+----------------------+\n");

printf("| Drapery |\n");

printf("+----------------------+\n");

printf("| Blinds/Roller Shades |\n");

printf("+----------------------+\n");

printf("| Deep Clean |\n");

printf("+----------------------+\n");

printf("| Windows |\n");

printf("+----------------------+\n");

printf("| Vehicle Interior |\n");

printf("+----------------------+\n");

printf("| Tile Stipping |\n");

printf("+----------------------+\n");

printf("| Sofa/Settee |\n");

printf("+----------------------+\n");

printf("| Sanitization |\n");

printf("+----------------------+\n");

printf("| Partitions |\n");

printf("+----------------------+\n");

printf("| Office Chairs |\n");

printf("+----------------------+\n");

printf("| Dining Chairs |\n");

Page | 217
printf("+----------------------+\n");

printf("| Mattress |\n");

printf("+----------------------+\n");

printf("Enter Sub-Service : ");

scanf("%s", jb.subService);

system("cls");

servicesFileCreation();

for (int j = 0; j < jb.subServiceAmount - 1; ++j) {

printf("+----------------------+\n");

printf("| Rug |\n");

printf("+----------------------+\n");

printf("| Carpet |\n");

printf("+----------------------+\n");

printf("| Drapery |\n");

printf("+----------------------+\n");

printf("| Blinds/Roller Shades |\n");

printf("+----------------------+\n");

printf("| Deep Clean |\n");

printf("+----------------------+\n");

printf("| Windows |\n");

printf("+----------------------+\n");

Page | 218
printf("| Vehicle Interior |\n");

printf("+----------------------+\n");

printf("| Tile Stipping |\n");

printf("+----------------------+\n");

printf("| Sofa/Settee |\n");

printf("+----------------------+\n");

printf("| Sanitization |\n");

printf("+----------------------+\n");

printf("| Partitions |\n");

printf("+----------------------+\n");

printf("| Office Chairs |\n");

printf("+----------------------+\n");

printf("| Dining Chairs |\n");

printf("+----------------------+\n");

printf("| Mattress |\n");

printf("+----------------------+\n");

printf("Enter Sub-Service : ");

scanf("%s", jb.subService);

system("cls");

servicesFileAppend();

servicesFileStorage();

sprintf(jb.servicesQuery, "Cleaning/Sanitization of %s", jb.services);

Page | 219
}

//A function that gathers information that will be stored in a jobsheet

int insertTableValuesJobsheet() {

MYSQL* con = mysql_init(NULL);

if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

dBI.databaseInputName, 0, NULL, 0) == NULL)

finish_with_error(con);

char query[255];

Page | 220
printf("Enter the amount of records you want to insert: ");

scanf("%i", &jb.records);

time_t t1;

srand((unsigned)time(&t1));

for (int i = 0; i < jb.records; ++i) {

printf("Enter the name of the person: ");

scanf("%s", jb.name);

printf("Enter the telephone number of the person: ");

scanf("%s", jb.telephone);

printf("Enter the address of the person: ");

scanf("%s", jb.address);

printf("Enter the date YYYY-MM-DD: ");

scanf("%s", jb.date);

printf("Enter the Contact Person: ");

scanf("%s", jb.contactPerson);

jb.id = rand() % MAX;

system("cls");

printf("+-------------------------+\n");

printf("| 1)Installation |\n");

printf("+-------------------------+\n");

printf("| 2)Repair |\n");

printf("+-------------------------+\n");

Page | 221
printf("| 3)Pest Control |\n");

printf("+-------------------------+\n");

printf("| 4)Cleaning/Sanitization |\n");

printf("+-------------------------+\n");

printf("Enter the type of Service: ");

scanf("%i", &jb.serviceType);

insertTableValuesJobsheet2();

sprintf(query, "INSERT INTO %s VALUES(%i, '%s', '%s', '%s', '%s', '%s', '%s')",

dbt.name, jb.id, jb.name, jb.telephone, jb.address, jb.date, jb.contactPerson, jb.servicesQuery);

if (mysql_query(con, query))

fprintf(stderr, "%s\n", mysql_error(con));

decisionError();

mysql_close(con);

//A function that prompts the user for the number of subservices, then calles the respective

function based on the service type

Page | 222
void insertTableValuesJobsheet2() {

printf("Enter the amount of Sub-Services: ");

scanf("%i", &jb.subServiceAmount);

if (jb.serviceType == 1) {

installationCase();

else if (jb.serviceType == 2) {

repairCase();

else if (jb.serviceType == 3) {

pestControlCase();

else if (jb.serviceType == 4) {

sanitationCase();

else {

printf("Incorrect input entered");

decisionError();

Page | 223
}

//A function that creates a files that will store the user database name provided by the admin

void userDatabaseNameFileCreation() {

FILE* filePointer;

filePointer = fopen("userdatabasename.txt", "w");

if (filePointer == NULL) {

printf("Error!");

exit(1);

fprintf(filePointer, "%s", db.name);

fclose(filePointer);

//A function that stores the userdatabase name

void userDatabaseNameFileStorage() {

Page | 224
FILE* filePointer;

filePointer = fopen("userdatabasename.txt", "r");

if (filePointer == NULL) {

printf("Error!");

exit(1);

fscanf(filePointer, "%s", u.userDBName);

fclose(filePointer);

//A function that creates a files that will store the user database table name provided by the

admin

void userTableNameFileCreation() {

FILE* filePointer;

filePointer = fopen("usertablename.txt", "w");

if (filePointer == NULL) {

Page | 225
printf("Error!");

exit(1);

fprintf(filePointer, "%s", dbt.name);

fclose(filePointer);

//A function that stores the userdatabase table name

void userTableNameFileStorage() {

FILE* filePointer;

filePointer = fopen("usertablename.txt", "r");

if (filePointer == NULL) {

printf("Error!");

exit(1);

fscanf(filePointer, "%s", u.userdbtName);

fclose(filePointer);

Page | 226
}

//A function that authenticates the password provided by the user and calls the specific function

void loginScreen() {

MYSQL* con = mysql_init(NULL);

if (con == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

exit(1);

if (mysql_real_connect(con, "localhost", "root", "root",

NULL, 0, NULL, 0) == NULL)

fprintf(stderr, "%s\n", mysql_error(con));

mysql_close(con);

exit(1);

system("cls");

Page | 227
menu();

printf("Username: ");

scanf("%s", user.userName);

printf("\n");

printf("Password: ");

scanf("%s", user.password);

if (strcmp(user.userName, "admin") == 0) {

adminWelcomeScreen();

else {

userDatabaseNameFileStorage();

userTableNameFileStorage();

userAuthentication();

// Function that allows users to signup to use the program

// and store their information in the user database table

void signupScreen() {

system("cls");

userDatabaseNameFileStorage();

userTableNameFileStorage();

Page | 228
insertTableValuesUsersSignIn();

userEmail();

printf("\n");

printf("Your credentials have been sent to %s", userInfo.userEmail);

printf("\n");

printf("Press any key to go back ");

_getch();

mainMenu();

// A function that presents the different options for the admin

void adminWelcomeScreenOption2() {

printf("+----------------------+\n");

printf("| 1)Create a Worksheet |\n");

printf("+----------------------+\n");

printf("| 2)Edit a Worksheet |\n");

printf("+----------------------+\n");

printf("| 3)Delete a Worksheet |\n");

printf("+----------------------+\n");

printf("| 4)Previous Page |\n");

printf("+----------------------+\n");

Page | 229
//A function that presents the different options for the admin

void adminWelcomeScreenOption3() {

printf("+---------------------+\n");

printf("| 1)Create a Jobsheet |\n");

printf("+---------------------+\n");

printf("| 2)Edit a Jobsheet |\n");

printf("+---------------------+\n");

printf("| 3)Delete a Jobsheet |\n");

printf("+---------------------+\n");

printf("| 4)Previous Page |\n");

printf("+---------------------+\n");

//A function that presents the different options for the user

void userEditWorksheetScreenOptions() {

printf("+-------------------+\n");

printf("| 1)Add records |\n");

printf("+-------------------+\n");

printf("| 2)Delete records |\n");

printf("+-------------------+\n");

Page | 230
printf("| 3)Update records |\n");

printf("+-------------------+\n");

printf("| 4)Show Table Data |\n");

printf("+-------------------+\n");

printf("| 5)Previous Page |\n");

printf("+-------------------+\n");

//A function that presents the different options for the user

void userWelcomeScreenOptions() {

time_t t;

time(&t);

printf("Welcome %s\n", user.userName);

printf("Login time: %s\n", ctime(&t));

printf("+--------------+\n");

printf("| 1)Worksheets |\n");

printf("+--------------+\n");

printf("| 2)Jobsheets |\n");

printf("+--------------+\n");

printf("| 3)Log Out |\n");

printf("+--------------+\n");

Page | 231
}

//A function that presents the different options for the admin

void adminWelcomeScreenOption1() {

system("cls");

printf("+---------------------+\n");

printf("| 1)Create a Database |\n");

printf("+---------------------+\n");

printf("| 2)Delete Database |\n");

printf("+---------------------+\n");

printf("| 3)View Databases |\n");

printf("+---------------------+\n");

printf("| 4)Previous Page |\n");

printf("+---------------------+\n");

//A function that presents the different options for the admin

void adminWelcomeScreenOptions() {

Page | 232
time_t t;

time(&t);

printf("Welcome %s\n", user.userName);

printf("Login time: %s\n", ctime(&t));

printf("+--------------+\n");

printf("| 1)Databases |\n");

printf("+--------------+\n");

printf("| 2)Worksheets |\n");

printf("+--------------+\n");

printf("| 3)Jobsheets |\n");

printf("+--------------+\n");

printf("| 4)Users |\n");

printf("+--------------+\n");

printf("| 5)Log Out |\n");

printf("+--------------+\n");

//A function that presents the different options for the admin

void adminEditWorksheetScreenOptions() {

printf("+-------------------+\n");

printf("| 1)Add records |\n");

Page | 233
printf("+-------------------+\n");

printf("| 2)Delete records |\n");

printf("+-------------------+\n");

printf("| 3)Update records |\n");

printf("+-------------------+\n");

printf("| 4)Show colums |\n");

printf("+-------------------+\n");

printf("| 5)Alter Columns |\n");

printf("+-------------------+\n");

printf("| 6)Show Table Data |\n");

printf("+-------------------+\n");

printf("| 7)Previous Page |\n");

printf("+-------------------+\n");

//A function that presents the welcome screen for the user and allows them to navigate to the

specific functions

void welcomeScreen() {

system("cls");

menu();

userWelcomeScreenOptions();

printf("\n");

Page | 234
printf("Enter your input here: ");

scanf("%i", &u.userInput);

switch (u.userInput) {

case(1):

system("cls");

userEditWorksheetScreenOptions();

printf("\n");

printf("Enter your input here: ");

scanf("%i", &u.userInputDB);

switch (u.userInputDB) {

case(1):

system("cls");

showDatabasesForUsers();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

insertTableValues2();

printf("The records have been added to the worksheet");

decisionPrompt();

case(2):

system("cls");

Page | 235
showDatabasesForUsers();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

showColumns();

deleteTableValuesQuery();

deleteTableValues();

printf("The records have been successfully deleted");

decisionPrompt();

case(3):

system("cls");

showDatabasesForUsers();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

showColumns();

updateTableValuesQuery();

updateTableValues();

printf("The records have been successfully updated");

Page | 236
decisionPrompt();

case(4):

system("cls");

showDatabasesForUsers();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

showDatabaseTableData();

decisionPrompt();

case(5):

system("cls");

welcomeScreen();

default:

printf("Wrong Input, try again");

system("cls");

welcomeScreen();

case(2):

system("cls");

Page | 237
userEditWorksheetScreenOptions();

printf("\n");

printf("Enter your input here: ");

scanf("%i", &u.userInputDB);

switch (u.userInputDB) {

case(1):

system("cls");

showDatabasesForUsers();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

insertTableValuesJobsheet();

printf("The records have been added to the jobsheet");

decisionPrompt();

case(2):

system("cls");

showDatabasesForUsers();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

Page | 238
system("cls");

showColumns();

deleteTableValuesQuery();

deleteTableValues();

printf("The records have been successfully deleted");

decisionPrompt();

case(3):

system("cls");

showDatabasesForUsers();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

showColumns();

updateTableValuesQuery();

updateTableValues();

printf("The records have been successfully updated");

decisionPrompt();

case(4):

system("cls");

showDatabasesForUsers();

selectDatabase();

Page | 239
system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

showDatabaseTableData();

decisionPrompt();

case(5):

system("cls");

welcomeScreen();

default:

printf("Wrong Input, try again");

decisionPrompt();

case(3):

system("cls");

mainMenu();

default:

printf("Wrong Input, try again");

decisionPrompt();

Page | 240
}

//A function that presents the welcome screen for the admin and allows them to navigate to the

specific functions

void adminWelcomeScreen() {

system("cls");

menu();

adminWelcomeScreenOptions();

printf("\n");

printf("Enter your input here: ");

scanf("%i", &admin.adminInput);

switch (admin.adminInput) {

case(1):

system("cls");

adminWelcomeScreenOption1();

printf("\n");

printf("Enter your input here: ");

scanf("%i", &dBI.databaseInput);

switch (dBI.databaseInput) {

case(1):

Page | 241
system("cls");

createDatabaseName();

createDatabase();

printf("The database %s has been created \n", db.name);

system("cls");

decisionPrompt();

case(2):

system("cls");

showDatabases();

selectDatabase();

deleteDatabase();

printf("The database %s has been deleted ", dBI.databaseInputName);

decisionPrompt();;

case(3):

system("cls");

showDatabases();

decisionPrompt();

case(4):

system("cls");

adminWelcomeScreen();

default:

printf("Wrong Input, try again");

decisionPrompt();

Page | 242
}

case(2):

system("cls");

adminWelcomeScreenOption2();

printf("\n");

printf("Enter your input here: ");

scanf("%i", &admin.adminInputDB);

switch (admin.adminInputDB) {

case(1):

system("cls");

showDatabases();

selectDatabase();

printf("The database %s has been selected ", dBI.databaseInputName);

system("cls");

createTablesInputWorksheet();

system("cls");

insertTableColumnsWorksheet();

printf("The table has been created with the columns ");

decisionPrompt();

case(2):

Page | 243
system("cls");

adminEditWorksheetScreenOptions();

printf("\n");

printf("Enter your input here: ");

scanf("%i", &admin.adminInputDB);

switch (admin.adminInputDB) {

case(1):

system("cls");

showDatabases();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

insertTableValues2();

printf("The records have been added to the worksheet");

decisionPrompt();

case(2):

system("cls");

showDatabases();

selectDatabase();

system("cls");

showDatabaseTables();

Page | 244
selectDatabaseTables();

system("cls");

showColumns();

deleteTableValuesQuery();

deleteTableValues();

printf("The records have been successfully deleted");

decisionPrompt();

case(3):

system("cls");

showDatabases();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

showColumns();

updateTableValuesQuery();

updateTableValues();

printf("The records have been successfully updated");

decisionPrompt();

case(4):

system("cls");

showDatabases();

Page | 245
selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

showColumns();

decisionPrompt();

case(5):

system("cls");

showDatabases();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

alterTables();

decisionPrompt();

case(6):

system("cls");

showDatabases();

selectDatabase();

system("cls");

Page | 246
showDatabaseTables();

selectDatabaseTables();

system("cls");

showDatabaseTableData();

decisionPrompt();

case(7):

system("cls");

adminWelcomeScreen();

default:

printf("Wrong Input, try again");

decisionPrompt();

case(3):

system("cls");

showDatabases();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

deleteDatabaseTables();

Page | 247
printf("The database table has been deleted");

decisionPrompt();

case(4):

system("cls");

adminWelcomeScreen();

default:

printf("Wrong Input, try again");

decisionPrompt();

case (3):

system("cls");

adminWelcomeScreenOption3();

printf("\n");

printf("Enter your input here: ");

scanf("%i", &admin.adminInputDB);

switch (admin.adminInputDB) {

case(1):

system("cls");

showDatabases();

selectDatabase();

printf("The database %s has been selected ", dBI.databaseInputName);

system("cls");

Page | 248
createTablesInputJobsheet();

insertTableColumnsJobsheet();

printf("The table has been created with the columns ");

decisionPrompt();

case(2):

system("cls");

adminEditWorksheetScreenOptions();

printf("\n");

printf("Enter your input here: ");

scanf("%i", &admin.adminInputDB);

switch (admin.adminInputDB) {

case(1):

system("cls");

showDatabases();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

insertTableValuesJobsheet();

printf("The records have been added to the jobsheet");

decisionPrompt();

case(2):

Page | 249
system("cls");

showDatabases();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

showColumns();

deleteTableValuesQuery();

deleteTableValues();

printf("The records have been successfully deleted");

decisionPrompt();

case(3):

system("cls");

showDatabases();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

showColumns();

updateTableValuesQuery();

updateTableValues();

Page | 250
printf("The records have been successfully updated");

decisionPrompt();

case(4):

system("cls");

showDatabases();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

showColumns();

decisionData();

adminWelcomeScreen();

case(5):

system("cls");

showDatabases();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

Page | 251
alterTables();

decisionPrompt();

case(6):

system("cls");

showDatabases();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

showDatabaseTableData();

decisionData();

adminWelcomeScreen();

case(7):

system("cls");

adminWelcomeScreen();

default:

printf("Wrong Input, try again");

decisionPrompt();

case(3):

system("cls");

Page | 252
showDatabases();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

deleteDatabaseTables();

printf("The database table has been deleted");

decisionPrompt();

case(4):

system("cls");

adminWelcomeScreen();

default:

printf("Wrong Input, try again");

decisionPrompt();

case (4):

system("cls");

printf("+-----------------+\n");

printf("| 1)User Database |\n");

printf("+-----------------+\n");

printf("| 2)User Tables |\n");

printf("+-----------------+\n");

Page | 253
printf("| 3)Users |\n");

printf("+-----------------+\n");

printf("| 4)Previous Page | \n");

printf("+-----------------+\n");

printf("\n");

printf("Enter your input here: ");

scanf("%i", &admin.adminInputUsers);

switch (admin.adminInputUsers) {

case(1):

system("cls");

printf("+------------------------+\n");

printf("| 1)Create User Database |\n");

printf("+------------------------+\n");

printf("| 2)Delete User Database |\n");

printf("+------------------------+\n");

printf("| 3)View User Database |\n");

printf("+------------------------+\n");

printf("| 4)Previous Page |\n");

printf("+------------------------+\n");

printf("\n");

printf("Enter your input here: ");

scanf("%i", &admin.adminInputUsersDatabase);

switch (admin.adminInputUsersDatabase) {

Page | 254
case(1):

system("cls");

createDatabaseName();

createDatabase();

userDatabaseNameFileCreation();

userDatabaseNameFileStorage();

printf("The database %s has been created ", db.name);

decisionPrompt();

case(2):

system("cls");

showDatabases();

selectDatabase();

deleteDatabase();

printf("The database %s has been deleted ", dBI.databaseInputName);

decisionPrompt();

case(3):

system("cls");

showDatabases();

selectDatabase();

printf("The database %s has been selected ", dBI.databaseInputName);

decisionPrompt();

case(4):

system("cls");

Page | 255
adminWelcomeScreen();

default:

printf("Wrong Input, try again");

decisionPrompt();

case(2):

system("cls");

printf("+-----------------------+\n");

printf("| 1)Create a User Table |\n");

printf("+-----------------------+\n");

printf("| 2)Edit a User Table |\n");

printf("+-----------------------+\n");

printf("| 3)Delete a User Table |\n");

printf("+-----------------------+\n");

printf("| 4)Previous Page |\n");

printf("+-----------------------+\n");

printf("\n");

printf("Enter your input here: ");

scanf("%i", &admin.adminInputUsersTable);

switch (admin.adminInputUsersTable) {

case(1):

system("cls");

showDatabases();

Page | 256
selectDatabase();

printf("The database %s has been selected ", dBI.databaseInputName);

system("cls");

createTablesInputUsers();

insertTableColumnsUsers();

userTableNameFileCreation();

userTableNameFileStorage();

printf("The table has been created with the columns ");

decisionPrompt();

case(2):

system("cls");

printf("+-------------------+\n");

printf("| 1)Add records |\n");

printf("+-------------------+\n");

printf("| 2)Delete records |\n");

printf("+-------------------+\n");

printf("| 3)Update records |\n");

printf("+-------------------+\n");

printf("| 4)Show colums |\n");

printf("+-------------------+\n");

printf("| 5)Alter Columns |\n");

printf("+-------------------+\n");

Page | 257
printf("| 6)Show Table Data |\n");

printf("+-------------------+\n");

printf("| 7)Previous Page |\n");

printf("+-------------------+\n");

printf("\n");

printf("Enter your input here: ");

scanf("%i", &admin.adminInputDB);

switch (admin.adminInputDB) {

case(1):

system("cls");

showDatabases();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

insertTableValuesUsers();

userDatabaseNameFileStorage();

userTableNameFileStorage();

userEmail();

printf("The records have been added to the table");

decisionPrompt();

case(2):

Page | 258
system("cls");

showDatabases();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

showColumns();

deleteTableValuesQuery();

deleteTableValues();

printf("The records have been successfully deleted");

decisionPrompt();

case(3):

system("cls");

showDatabases();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

showColumns();

updateTableValuesQuery();

updateTableValues();

Page | 259
printf("The records have been successfully updated");

decisionPrompt();

case(4):

system("cls");

showDatabases();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

showColumns();

decisionData();

adminWelcomeScreen();

case(5):

system("cls");

showDatabases();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

Page | 260
alterTables();

decisionPrompt();

case(6):

system("cls");

showDatabases();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

showDatabaseTableData();

decisionData();

adminWelcomeScreen();

case(7):

system("cls");

adminWelcomeScreen();

default:

printf("Wrong Input, try again");

decisionPrompt();

case(3):

Page | 261
system("cls");

showDatabases();

selectDatabase();

system("cls");

showDatabaseTables();

selectDatabaseTables();

system("cls");

deleteDatabaseTables();

printf("The database table has been deleted");

decisionPrompt();

case(4):

system("cls");

adminWelcomeScreen();

default:

printf("Wrong Input, try again");

decisionPrompt();

case(3):

system("cls");

showDatabases();

selectDatabase();

system("cls");

Page | 262
showDatabaseTables();

selectDatabaseTables();

system("cls");

showDatabaseTableData();

decisionPrompt();

case(4):

system("cls");

adminWelcomeScreen();

default:

printf("Wrong Input, try again");

decisionPrompt();

case (5):

mainMenu();

default:

printf("Wrong Input, try again");

decisionPrompt();

//A function that presents the main menu on startup

Page | 263
void mainMenu() {

system("cls");

startupMenu();

printf("+-------------+\n");

printf("| MAIN MENU |\n");

printf("+-------------+\n");

printf("| 1) Sign in |\n");

printf("+-------------+\n");

printf("| 2) Sign up |\n");

printf("+-------------+\n");

printf("| 3) EXIT |\n");

printf("+-------------+\n");

printf("\n");

printf("Enter your input here: ");

scanf("%i", &user.menuInput);

switch (user.menuInput) {

case(1):

loginScreen();

case(2):

signupScreen();

case(3):

exit(0);

default:

Page | 264
printf("Wrong Input, try again");

Sleep(3000);

system("cls");

mainMenu();

//A function that presents the startup menu graphics

void startupMenu() {

/*char comp_name[40] = "\t\t\t\t\t\tWelcome To White Rose Interiors";

int length = sizeof(comp_name) / sizeof(comp_name[0]);

printf("************************************************************************

******************************************************\n");

printf(" ___ ___ ___ ___ ___ ________ ________ _______ ________

________ ________ _______ \n");

Sleep(200);

printf(" || || || || | | |___ ___| |___ ___| | ____| | | | | ______ | | ______| |

____| \n");

Sleep(200);

Page | 265
printf(" | | | | | | | |____| | | | | | | |____ | _____| | | | | | |_____ | |____

\n");

Sleep(200);

printf(" | | | | | | | |____| | | | | | | ____| | | \\ \\ | | | | |_____ | |

____|\n");

Sleep(200);

printf(" | |____| |____| | | | | | ___| |___ | | | |____ | | \\ \\ | |____| | _____| | |

|____\n");

Sleep(200);

printf(" |_______________| |_| |_| |________| |__| |______| |_| \\_\\ |_______ |

|_______ | |______|\n");

printf("\n**********************************************************************

********************************************************\n");

for (int i = 0; i < length; i++) {

printf("%c", comp_name[i]);

sleep(50);

printf("\n");*/

Page | 266
//A function that presents the menu graphics

void menu() {

/*char comp_name[40] = "\t\t\t\t\t\tWelcome To White Rose Interiors";

int length = sizeof(comp_name) / sizeof(comp_name[0]);

printf("************************************************************************

******************************************************\n");

printf(" ___ ___ ___ ___ ___ ________ ________ _______ ________

________ ________ _______ \n");

printf(" || || || || | | |___ ___| |___ ___| | ____| | | | | ______ | | ______| |

____| \n");

printf(" | | | | | | | |____| | | | | | | |____ | _____| | | | | | |_____ | |____

\n");

printf(" | | | | | | | |____| | | | | | | ____| | | \\ \\ | | | | |_____ | |

____|\n");

printf(" | |____| |____| | | | | | ___| |___ | | | |____ | | \\ \\ | |____| | _____| | |

|____\n");

printf(" |_______________| |_| |_| |________| |__| |______| |_| \\_\\ |_______ |

|_______ | |______|\n");

Page | 267
printf("\n**********************************************************************

********************************************************\n");

for (int i = 0; i < length; i++) {

printf("%c", comp_name[i]);

printf("\n");*/

//The main function that calls main menu

int main()

mainMenu();

Page | 268
Test Plan

RUN PROGRAM (CREATION OF A DATABASE)

Variable Name Data Type Test Data Purpose of Expected Result Actual Result
Data

user.menuInput Integer 1 To go to the Brings the program Program


login screen of forward to the login proceeded to the
the program screen login screen

user.username String admin Unique Prompts the admin to Prompted the


username used enter a unique admin to enter the
to access the password admin specific
functions of the password
program

User.password String password123 Unique Brings the program to Program was


password used options special to forwarded to
to access all the admins admin only
functions options
available to the
admin

admin.adminInp Integer 1 To present the Goes to admin specific Goes to admin


ut different database related options database related
options for the options
admin relating
to databases

dBI.databaseInp Integer 1 Represents the Goes to an option to Allows the admin


ut creation of a create a name for a to create a name
database in the database for a new
program database

db.name String testplan Prompts the A new database should The database
user to enter a be assigned the name “testplan” was
name to create a “testplan” created
new database

dBI.databaseInp Integer 3 Shows a list of The database “testplan” Database


ut the available should be listed “testingplan” is
databases that shown, therefore
are present to the database was
the admin successfully
created

Page | 269
RUN PROGRAM AGAIN (CREATION OF A USER ACCOUNT)

user.menuInput Integer 2 To create a user Goes to the sign-up Goes to the sign-
account for the options up options
use of the
program

u.userDBName Integer n/a Used to store A file called A file called


the name of the “userdatabasename.txt” “userdatabasenam
user creating an should be created to e.txt” was created
account in to a store the user name of
file the user

u.userdbtName Integer n/a Used to store A file called A file called


the user “usertablename.txt” “usertablename.tx
database table should be created to t” was created
name into a file store the necessary
information

userInfo.userFir String Dejorn Used to store Should store “Dejorn” Stores “Dejorn ”
stName the first name of
the user that is
being created

userInfo.userSur Sting Byfield Used to store Should stores “Byfield” Stores “Byfield”
name the surname of
the user that is
being created

userInfo.DOB String 2005-20-01 Used to store Should store Stores 2005-20-01


the date of birth 2005-20-01
of the user that
is being created

userInfo.userEm String dejornbyfield Used to stroes Should store Stores


ail 78@gmail.co the email dejornbyfield78@gmail dejornbyfield78@
m address of the .com gmail.com
user creating the
account

Command Void n/a Used to send Should send the login Login credential
the login credentials to the new were sent to the
credentials to user via email user.
the new user via
email

Page | 270
user.menuInput Integer 1 To go to the Brings the program Program
login screen of forward to the login proceeded to the
the program screen login screen

user.username String 8 Unique Prompts the user to Prompted the user


username used enter a unique to enter the admin
to access the password for the specific password
functions of the account
program for
users

User.password String 777 Unique Brings the program to Program was


password used options special to users forwarded to user
to access all the only options
functions
available to the
user

RUN PROGRAM AGAIN (CREATION OF A WORKSHEET)

user.menuInput Integer 1 To go to the Brings the program Program


login screen of forward to the login proceeded to the
the program screen login screen

user.username String admin Unique Prompts the admin to Prompted the


username used enter a unique admin to enter the
to access the password admin specific
functions of the password
program

User.password String password123 Unique Brings the program to Program was


password used options special to forwarded to
to access all the admins admin only
functions options
available to the
admin

admin.adminInp Integer 2 To present the Goes to admin specific Goes to admin


ut different worksheet related worksheet related
options for the options options
admin relating
to worksheets

admin.adminInp integer 1 To present the Should show “testplan” Shows “testplan ”


utDB different database database
databases that
are available to

Page | 271
create the
worksheet for

dBI.databaseInp String testplan Promps the user Should select the Selects the
utName to enter the database “testplan” database
name of a “testplan”
databse that will
be used to
created the
worksheet

dbt.name String testplanworks Creates a Should create a A database table


heet database table database table for the for the worksheet
with column worksheet called called
names and data “testplanworksheet” “testplanworkshee
types for the t” was created
worksheet

dbt.columns integer 8 Creates the Creates 8 columns for 8 columns were


number of the worksheet created
columns for the
worksheet that
is specified

dbt.columnNam String ID Creates a Creats a primary key Primary key


e primary key for the worksheet created
column for the
worksheet

dbt.columnData String INT Sets the data The datatype of the The primary key
Type type of the primary key column column was set to
primary key should be set to the INT the INT data type
column to only data type
collect a
specific data
type of
informtion

dbt.columnNam String Name Creates a Column named Column named


e column for the “Name” “Name” was
worksheet by Should be created created
entering a name

dbt.columnData String VARCHAR Specifies the Should create a column Column created
Type data type of the to house information of that only house
information that the VARCHAR data information of the
should be type

Page | 272
present in the VARCHAR
created column datatype

dbt.columnNam String Address Creates a Column named Column named


e column for the “Address” “Address” was
worksheet by Should be created created
entering a name

dbt.columnData String VARCHAR Specifies the Should create a column Column created
Type data type of the to house information of that only house
information that the VARCHAR data information of the
should be type VARCHAR
present in the datatype
created column

dbt.columnNam String Telephone Creates a Column named Column named


e column for the “Telephone” “Telephone” was
worksheet by Should be created created
entering a name

dbt.columnData String VARCHAR Specifies the Should create a column Column created
Type data type of the to house information of that only house
information that the VARCHAR data information of the
should be type VARCHAR
present in the datatype
created column

dbt.columnNam String Date Creates a Column named “Date” Column named


e column for the Should be created “Date” was
worksheet by created
entering a name

dbt.columnData String DATE Specifies the Should create a column Column created
Type data type of the to house information of that only house
information that the DATE data type information of the
should be DATE datatype
present in the
created column

dbt.columnNam String Email Creates a Column named Column named


e column for the “Email” “Email” was
worksheet by Should be created created
entering a name

dbt.columnData String VARCHAR Specifies the Should create a column Column created
Type data type of the to house information of that only house
information that information of the

Page | 273
should be the VARCHAR data VARCHAR
present in the type datatype
created column

dbt.columnNam String JobNumber Creates a Column named Column named


e column for the “JobNumber” “JobNumber” was
worksheet by Should be created created
entering a name

dbt.columnData String INT Specifies the Should create a column Column created
Type data type of the to house information of that only house
information that the INT data type information of the
should be INT data type
present in the
created column

dbt.columnNam String ContactPerso Creates a Column named Column named


e n column for the “ContactPerson” “ContactPerson”
worksheet by Should be created was created
entering a name

dbt.columnData String VARCHAR Specifies the Should create a column Column created
Type data type of the to house information of that only house
information that the VARCHAR data information of the
should be type VARCHAR
present in the datatype
created column

RUN PROGRAM AGAIN (ADDING A RECORD TO THE WORKSHEET)

user.menuInput Integer 1 To go to the Brings the program Program


login screen of forward to the login proceeded to the
the program screen login screen

user.username String admin Unique Prompts the admin to Prompted the


username used enter a unique admin to enter the
to access the password admin specific
functions of the password
program

User.password String password123 Unique Brings the program to Program was


password used options special to forwarded to
to access all the admins admin only
functions options
available to the
admin

Page | 274
admin.adminInp Integer 2 To present the Goes to admin specific Goes to admin
ut different worksheet related worksheet related
options for the options options
admin relating
to worksheets

admin.adminInp integer 2 To present the Should show options Shows options


utDB different relating to worksheets relating to
options for the worksheets
editing of a
created
worksheet

admin.adminIN Integer 1 Used to add Should forward the Program


putDB records to program to the database forwarded to the
existing created selection list database selection
worksheets list

dBI.databaseInp String testplan Promps the user Should select the Selects the
utName to enter the database “testplan” database
name of a “testplan”
databse that will
be used to add
records to the
worksheet

dbt.name Sting Testplanwork Prompts the Should select the Selected the
sheet user to enter the “testplanworksheet” “testplanworkshee
name of a and forward the t” and forwarded
database table program to entering the program
that will be used specifics
for the addition
of the records

wk.records Integer 1 Specifies the Should create the The area for the
number of needed area for the addition of one
records that the addition of 1 record reocrd was
admin would created
like to add to
the worksheet

wk.namePerson String John_Doe Represent the The name “John Doe” The name “John
name of the was added to the Doe” was added
person that will worksheet to the worksheet
be added to the
worksheet

Page | 275
wk.address String 10-Ardenne- Represents the The address “10 The address “10
Road address of the Ardenne Road” was Ardenne Road”
person that will added tot hte was added tot hte
be added to the worksheet worksheet
worksheet

wk.telephone String 1(876)777- Represents the The number The number


7777 number of the “1(876)777-7777” was “1(876)777-7777”
person that will added to the was added to the
be added to the worksheet worksheet
worksheet

wk.date String 2023-01-01 Represents the The date of The date of


present date that 2032-01-01 was added 2032-01-01 was
the worksheet to the worksheet added to the
was filled out worksheet
by the person

wk.email String testplan@gm Represents the The email The email


ail.com email of the testplan@gmail.com testplan@gmail.c
person that will was added to the om was added to
be added to the worksheet the worksheet
worksheet

wk.jobNumber String 1(876)888- Represents the The number The number


8888 job number of “1(876)888-8888” was “1(876)888-8888”
the person that added to the was added to the
will be added to worksheet worksheet
the worksheet

wk.contactPerso String Represents an


n alternate person
for the person
that filled out
the worksheet
that will be
added to the
worksheet

RUN PROGRAM AGAIN (CREATION OF A JOBSHEET)

user.menuInput Integer 1 To go to the Brings the program Program


login screen of forward to the login proceeded to the
the program screen login screen

Page | 276
user.username String admin Unique Prompts the admin to Prompted the
username used enter a unique admin to enter the
to access the password admin specific
functions of the password
program

User.password String password123 Unique Brings the program to Program was


password used options special to forwarded to
to access all the admins admin only
functions options
available to the
admin

admin.adminInp Integer 3 To present the Goes to admin specific Goes to admin


ut different jobsheet related options jobsheet related
options for the options
admin relating
to jobsheets

admin.adminInp Integer 1 Used to create Should forward the Program


utDB jobsheets program to the database forwarded to the
selection list database selection
list

dBI.databaseInp String testplan Promps the user Should select the Selects the
utName to enter the database “testplan” database
name of a “testplan”
databse that will
be selected to
make the
jobsheet

dbt.name Sting Testplanjobs Prompts the Should create a A database table


heet user to enter a database table for the for the jobsheet
name for the jobsheet called called
creation of a “testplanjobsheet” “testplanjobsheet”
table for the was created
jobsheet

dbt.columns Int 7 Creates the Should create a table A table with 7


number of with 7 columns columns was
columns for the created for the
jobsheet that is jobsheet
specified

Page | 277
dbt.columnNam String ID Creates a Creats a primary key Primary key
e primary key for the jobsheet created for the
column for the jobsheet
jobsheet

dbt.columnData String INT Sets the data The datatype of the the The primary key
Type type of the primary key column column was set to
primary key should be set to INT INT data type
column to only data type
collect a
specific data
type of
informtion

dbt.columnNam String Name Creates a Column named Column named


e column for the “Name” “Name” was
jobsheet by Should be created created
entering a name

dbt.columnData String VARCHAR Specifies the Should create a column Column created
Type data type of the to house information of that only house
information that the VARCHAR data information of the
should be type VARCHAR
present in the datatype
created column

dbt.columnNam String Telephone Creates a Column named Column named


e column for the “Telephone” “Telephone” was
jobsheet by Should be created created
entering a name

dbt.columnData String VARCHAR Specifies the Should create a column Column created
Type data type of the to house information of that only house
information that the VARCHAR data information of the
should be type VARCHAR
present in the datatype
created column

dbt.columnNam String Address Creates a Column named Column named


e column for the “Address” “Address” was
jobsheet by Should be created created
entering a name

dbt.columnData String VARCHAR Specifies the Should create a column Column created
Type data type of the to house information of that only house
information that the VARCHAR data information of the
should be type

Page | 278
present in the VARCHAR
created column datatype

dbt.columnNam String Date Creates a Column named “Date” Column named


e column for the Should be created “Date” was
jobsheet by created
entering a name

dbt.columnData String DATE Specifies the Should create a column Column created
Type data type of the to house information of that only house
information that the DATE data type information of the
should be DATE datatype
present in the
created column

dbt.columnNam String Contact_Pers Creates a Column named Column named


e on column for the “Contact_Person” “Contact_Person”
jobsheet by Should be created was created
entering a name

dbt.columnData String VARCHAR Specifies the Should create a column Column created
Type data type of the to house information of that only house
information that the VARCHAR data information of the
should be type VARCHAR
present in the datatype
created column

dbt.columnNam String Services Creates a Column named Column named


e column for the “Services” “Services” was
jobsheet by Should be created created
entering a name

dbt.columnData String VARCHAR Specifies the Should create a column Column created
Type data type of the to house information of that only house
information that the VARCHAR data information of the
should be type VARCHAR
present in the datatype
created column

RUN PROGRAM AGAIN(ADDING RECORDS TO THE JOBSHEET)

user.menuInput Integer 1 To go to the Brings the program Program


login screen of forward to the login proceeded to the
the program screen login screen

Page | 279
user.username String admin Unique Prompts the admin to Prompted the
username used enter a unique admin to enter the
to access the password admin specific
functions of the password
program

User.password String password123 Unique Brings the program to Program was


password used options special to forwarded to
to access all the admins admin only
functions options
available to the
admin

admin.adminInp Integer 3 To present the Goes to admin specific Goes to admin


ut different jobsheet related options jobsheet related
options for the options
admin relating
to jobsheets

admin.adminInp Integer 2 Used to edit Should forward the Program


utDB jobsheets program other options forwarded to the
regarding to jobsheets other jobsheet
options

admin.adminIN Integer 1 Used to add Should forward the Program


putDB records to program to the database forwarded to the
existing created selection list database selection
jobsheets list

dBI.databaseInp String testplan Promps the user Should select the Selects the
utName to enter the database “testplan” database
name of a “testplan”
databse that will
be selected to
make the
jobsheet

dbt.name Sting Testplanjobs Prompts the Should select the Selected the
heet user to enter the “testplanworksheet” “testplanworkshee
name of a and forward the t” and forwarded
database table program to entering the program
that will be used specifics
for the addition
of the records to
a jobsheet

Page | 280
jb.records Integer 1 Specifies the Should create the The area for the
number of needed area for the addition of one
records that the addition of 1 record reocrd was
admin would created
like to add to
the jobsheet

jb.name String John Doe Represent the The name “John Doe” The name “John
name of the was added to the Doe” was added
person that will jobsheet to the jobsheet
be added to the
jobsheet

jb.telephone String 1(876)777- Represents the The number The number


7777 number of the “1(876)777-7777” was “1(876)777-7777”
person that will added to the jobsheet was added to the
be added to the jobsheet
jobsheet

jb.address String 10-Ardenne- Represents the The address “10 The address “10
Road address of the Ardenne Road” was Ardenne Road”
person that will added tot hte jobsheet was added tot hte
be added to the jobsheet
jobsheet

jb.date String 2023-01-01 Represents the The date of The date of


present date that 2032-01-01 was added 2032-01-01 was
the jobsheet was to the jobsheet added to the
filled out by the jobsheet
person

jb.contactPerson String Represents an


alternate person
for the person
that filled out
the worksheet
that will be
added to the
jobsheet

jb.serviceType Integer 1 Used to Should specify that the The installation


respresnt the type of service that is service was
type of service needed is Installation specified to be
that is required needed
from the
company

Page | 281
jb.subServiceA Integer 1 Used to specifiy Should specify that Only 1 subservice
mount the amount of only 1 subservice is was specified to
subservice(s) needed be needed
that are needed

jb.subService String Carpet Used to The “Carpet” Sub- The “Carpet”


represent the Service was selected Sub-Service was
type of selected
subservice that
is needed

Page | 282

You might also like