Cape Computer Science School-Based Assessment: Group Members
Cape Computer Science School-Based Assessment: Group Members
SCHOOL-BASED ASSESSMENT
Group members:
1) Cajaun Campbell
2) Dejorn Byfield
3) Patrick Marsden
4) David Wong
5) Dominic Wiggan
Territory: Jamaica
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
households through the effective combination of teamwork, innovation and motivated staff for
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
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
5) It takes up a vast quantity of space in the office to store all the files.
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
2) Store all the data on a database that can be accessed with a username and password by
4) The data would be stored in a database where it easily be store, retrieved, organize and
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
Page | 4
Pseudocode
Pseudocode
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
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
//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
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
//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
//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
//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 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
FUNCTION decisionError
Begin
Sleep(3000)
FUNCTION adminWelcomeScreen
Sleep(3000)
FUNCTION welcomeScreen
Endif
End
FUNCTION decision
Begin
Print user.userName
FUNCTION adminWelcomeScreen
Page | 11
else if user.userName == user.userName then
FUNCTION welcomeScreen
Endif
End
FUNCTION decisionData
Begin
Read dbt.name
FUNCTION decision
Endif
End
// previous page
FUNCTION decisionPrompt
Begin
Page | 12
Function getcharacter
FUNCTION decision
End
//A function that checks to see if a mySQL query was executed with errors
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
FUNCTION decision
Endif
End
//A function that creates a database using a name provided by the user
FUNCTION createDatabase
Page | 13
Begin
Begin
exit(1)
Endif
Begin
mysql_close(con)
exit(1)
Endif
Declare
Begin
query[255]
End
Page | 14
if (mysql_query(con, query)) then
Begin
Function decisionError
Endif
mysql_close(con)
End
//A function that deletes a database that was provided by the user
Function deleteDatabase
Begin
Begin
exit(1)
Endif
Page | 15
Begin
mysql_close(con)
exit(1)
Endif
Declare
Begin
query[255]
End
Begin
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
Begin
Function decision
Endif
End
//A function that shows the list of available databases for the admin
Function showDatabases
Begin
Begin
exit(1)
Endif
Page | 17
if (mysql_real_connect(con, "localhost", "root", "root",
Begin
fprintf(stderr, mysql_error(con))
mysql_close(con)
exit(1)
Endif
Declare
Begin
query[255]
End
Begin
fprintf(stderr, mysql_error(con))
Function decisionError
Endif
Page | 18
int num_fields = mysql_num_fields(result)
MYSQL_ROW row
print" "
Begin
print" "
for i to num_fields do
Begin
Endfor
Endwhile
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
Read dbt.name
FUNCTION decision
Endif
End
//A function that returns the list of available databases specifically for users, after hiding the
Function showDatabasesForUsers() {
Begin
Begin
exit(1)
Endif
Page | 20
if (mysql_real_connect(con, "localhost", "root", "root",
Begin
mysql_close(con)
exit(1)
Endif
Declare
Begin
query[255]
End
'%s')", u.userDBName)
Begin
Function decisionError
Endif
Page | 21
MYSQL_RES* result = mysql_store_result(con)
MYSQL_ROW row
Begin
finish_with_error(con)
Endif
print"List of Databases"
print" "
Begin
print" "
for i to num_fields do
Begin
End
print" "
Page | 22
Endwhile
print" "
mysql_free_result(result)
mysql_close(con)
End
FUNCTION showDatabaseTables
Begin
Begin
exit(1)
Endif
Begin
Page | 23
fprintf(stderr, "%s\n", mysql_error(con))
mysql_close(con)
exit(1)
Endif
Declare
Begin
query as string
End
Begin
Function decisionError
Endif
MYSQL_ROW row
Page | 24
print "List of Tables"
Begin
for i to num_fields do
printf" "
Endwhile
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
Begin
Function decision
Endif
End
//A function that deletes a database table that was provided by the user
FUNCTION deleteDatabaseTables
Begin
Print mysql_error(con)
exit(1)
Endif
finish_with_error(con)
Endif
Page | 26
Declare
Begin
query as string
End
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
Print mysql_error(con)
exit(1)
Page | 27
Endif
finish_with_error(con)
Endif
Declare
Begin
query as string
End
Print mysql_error(con)
FUNCTION decisionError
Endif
Page | 28
finish_with_error(con)
Endif
MYSQL_ROW row
MYSQL_FIELD* field
for 1 to num_field do
if (i == 0) then
Print field->name
Endwhile
Endif
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
Begin
Print mysql_error(con)
exit(1)
Endif
begin
finish_with_error(con)
Page | 30
Endif
Declare
Begin
query as string
End
dbt.dataType)
begin
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)
begin
Print mysql_error(con)
exit(1)
Endif
begin
finish_with_error(con)
Endif
Declare
Begin
query as string
End
if (mysql_query(con, query))
Page | 32
begin
decisionError()
endif
if (result == NULL)
begin
finish_with_error(con)
endif
MYSQL_ROW row
MYSQL_FIELD* field
begin
for i to num_fields do
begin
if (i == 0)
Page | 33
begin
begin
print "field->name"
endwhile
endif
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
begin
Print mysql_error(con)
exit(1)
Endif
begin
finish_with_error(con)
Endif
Read dbt.name
Page | 35
begin
function decision
endif
function system("cls")
print"+-----------------------------------------+"
print"+-----------------------------------------+"
print"+-----------------------------------------+"
print" "
print ""
Read dbt.columns
Read dbt.columnName
Read dbt.columnDataType
begin
sprintf(dbt.dataType, "INT")
function createTables()
Page | 36
function createTables
sprintf(dbt.dataType, "DATE")
function createTables()
endif
mysql_close(con)
End
FUNCTION addTables
Begin
Print mysql_error(con)
exit(1)
Endif
Page | 37
finish_with_error(con)
Endif
Declare
Begin
query as string
End
begin
function decisionError
endif
mysql_close(con)
end
FUNCTION insertTableColumns2
Begin
Page | 38
if (con == NULL) then
Print mysql_error(con)
exit(1)
Endif
finish_with_error(con)
Endif
Declare
Begin
query as string
End
dbt.dataType)
begin
decisionError()
endif
Page | 39
mysql_close(con)
End
//A function that allows the user to make modifications to a database table
FUNCTION alterTables
Begin
Print mysql_error(con)
exit(1)
Endif
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,
Read dbt.alterTableQuery
begin
function decision
endif
begin
function system("cls")
function showColumns
Read dbt.columnName
print"Enter the Data type of the column INT() , VARCHAR() , DATE , DECIMAL: "
Read dbt.columnDataType
begin
Page | 41
sprintf(dbt.dataType, "INT")
then
sprintf(dbt.dataType, "DATE")
else then
Function decisionError()
endif
dbt.dataType)
begin
function decisionError
endif
begin
function system("cls")
function showColumns
Page | 42
print " "
Read dbt.columnName
Begin
decisionError();
Endif
function system("cls")
function showColumns
print" "
Read dbt.columnName
print "Enter the Data type of the column INT() , VARCHAR() , DATE , DECIMAL: "
Read dbt.columnDataType
begin
sprintf(dbt.dataType, "INT")
then
Page | 43
begin
begin
sprintf(dbt.dataType, "DATE")
dbt.dataType)
begin
function decisionError
endif
begin
function system("cls")
function showColumns
print" "
Read dbt.columnName
Page | 44
print "Enter the name to change the column to: "
Readdbt.columnNameNew
dbt.columnName, dbt.columnNameNew)
begin
function decisionError
endif
endif
mysql_close(con)
End
FUNCTION userEmail
Begin
FILE* email
Page | 45
Declare
script as string
command as string
end
sprintf(script,
"$from = '[email protected]'\n"
"$to = '%s'\n"
"$smtpServer = 'smtp.gmail.com'\n"
"$port = 587\n"
"$username = '[email protected]'\n"
"$password = 'oduqxmklfciozdpm'\n"
$body\n"
Interiors Admin')\n"
"$smtpClient.Port = $port\n"
"$smtpClient.EnableSsl = $true\n"
$password)\n"
Page | 46
"$smtpClient.Send($mailMessage)\n", userInfo.userEmail, userInfo.userID, user.password)
begin
exit(1)
endif
fclose(email)
function system("powershell.exe
C:\\Users\\Dell\\Desktop\\CSUnit1SBA\\CSUnit1SBA\\emailscript.ps1")
End
FUNCTION insertTableColumnsWorksheet
Page | 47
Begin
Print mysql_error(con)
exit(1)
Endif
finish_with_error(con)
Endif
print"+-------------------------------------------+"
print"+-------------------------------------------+"
print"+-------------------------------------------+"
print"+-------------------------------------------+"
Page | 48
print"+-------------------------------------------+"
print"+-------------------------------------------+"
print"+-------------------------------------------+"
print"+-------------------------------------------+"
print"+-------------------------------------------+"
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
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
begin
function insertTableColumns2
begin
sprintf(dbt.dataType, "DATE")
function insertTableColumns2
end
else then
begin
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
Read wk.records
for i to wk.records do
begin
Read wk.namePerson
Read wk.address
Read wk.telephone
Read wk.date
Page | 51
Read wk.email
Read wk.jobNumber
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
Print mysql_error(con)
exit(1)
Endif
Page | 52
finish_with_error(con)
Endif
Declare
Begin
query as string
End
Read wk.records
function time_t t1
function srand((unsigned)time(&t1))
for i to wk.records do
begin
Read wk.namePerson
Read wk.address
Read wk.telephone
Page | 53
Read wk.date
Read wk.email
Read wk.jobNumber
Read wk.contactPerson
sprintf(query, "INSERT INTO %s VALUES(%i,'%s', '%s', '%s', '%s', '%s', '%s', '%s')",
wk.contactPerson)
if (mysql_query(con, query))
begin
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
Function insertTableValuesUsers
Begin
Print mysql_error(con)
exit(1)
Endif
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
Read userInfo.userFirstName
Read userInfo.userSurname);
Read userInfo.userDOB
Read userInfo.userEmail
Read user.password
sprintf(query, "INSERT INTO %s VALUES(%i, '%s', '%s', '%s', '%s', '%s')" dbt.name,
userInfo.userDOB, user.password
begin
Page | 56
function decisionError
endif
endfor
mysql_close(con)
end
function insertTableValuesUsersSignIn
Begin
Print mysql_error(con)
exit(1)
Endif
finish_with_error(con)
Endif
Page | 57
Declare
Begin
query as string
End
function time_t t1
function srand((unsigned)time(&t1))
Read userInfo.userFirstName
Read userInfo.userSurname
Read userInfo.userDOB
Read userInfo.userEmail
Read user.password
sprintf(query, "INSERT INTO %s VALUES(%i, '%s', '%s', '%s', '%s', '%s')", u.userdbtName,
userInfo.userDOB, user.password
Page | 58
if (mysql_query(con, query))
begin
function decisionError
endif
mysql_close(con)
end
// table
Function createTablesInputUsers
begin
Print mysql_error(con)
exit(1)
Endif
Page | 59
dBI.databaseInputName, 0, NULL, 0) == NULL) then
finish_with_error(con)
Endif
Read dbt.name
begin
function decision
endif
function system("cls")
print"+-----------------------------------------+"
print"+-----------------------------------------+"
print"+-----------------------------------------+"
print" "
print" "
print "Continue creating the table by entering the number of columns: "
Read dbt.columns
Read dbt.columnName
Page | 60
print "Set the datatype of the column by entering 'INT': "
Read dbt.columnDataType
begin
sprintf(dbt.dataType, "INT")
function createTables
begin
function createTables
begin
sprintf(dbt.dataType, "DATE")
function createTables
endif
mysql_close(con)
end
Function insertTableColumnsUsers
begin
Page | 61
MYSQL* con = mysql_init(NULL)
Print mysql_error(con)
exit(1)
Endif
finish_with_error(con)
Endif
function system("cls")
print"+-------------------------------------------+"
print"+-------------------------------------------+"
print"+-------------------------------------------+"
print"+-------------------------------------------+"
Page | 62
print"+-------------------------------------------+"
print"+-------------------------------------------+"
print"+-------------------------------------------+"
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
begin
function adminWelcomeScreen
endif
print "Enter the Data type of the column INT , VARCHAR , DATE , DECIMAL: "
Read dbt.columnDataType
sprintf(dbt.dataType, "INT")
function insertTableColumns2
Page | 63
else if (dbt.columnDataType == "varchar") OR dbt.columnDataType == "VARCHAR"
then
function insertTableColumns2
sprintf(dbt.dataType, "DATE")
function insertTableColumns2
else then
begin
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
Function userAuthentication
begin
Page | 64
MYSQL* con = mysql_init(NULL)
Print mysql_error(con)
exit(1)
Endif
finish_with_error(con)
Endif
Declare
Begin
query as string
End
user.userName)
begin
Page | 65
fprintf(stderr, "%s\n", mysql_error(con))
function decisionError
endif
MYSQL_ROW row
begin
for i to num_fields do
begin
endfor
endwhile
print" "
Page | 66
begin
function adminWelcomeScreen
begin
function welcomeScreen
else
begin
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
Read wk.id
Read dbt.query
end
Function updateTableValues
begin
Print mysql_error(con)
exit(1)
Endif
Page | 68
if (mysql_real_connect(con, "localhost", "root", "root",
finish_with_error(con)
Endif
Declare
Begin
query as string
End
begin
dbt.query, wk.id)
else then
endif
if (mysql_query(con, query))
Page | 69
begin
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
Read dbt.columnName
function system("cls")
function showDatabaseTableData
Read dbt.query)
end
Page | 70
//A function that deletes records in a database table
Function deleteTableValues
Begin
Print mysql_error(con)
exit(1)
Endif
finish_with_error(con)
Endif
Declare
Begin
query as string
End
Page | 71
begin
dbt.query)
endif
else then
begin
dbt.query)
endif
if (mysql_query(con, query))
begin
function decisionError
endif
mysql_close(con)
end
Function createTablesInputJobsheet
begin
Page | 72
MYSQL* con = mysql_init(NULL)
Print mysql_error(con)
exit(1)
Endif
finish_with_error(con)
Endif
Read dbt.name
begin
function decision
endif
function system("cls")
print"+-----------------------------------------+"
Page | 73
print"| Alert |"
print"+-----------------------------------------+"
print"+-----------------------------------------+"
print" "
print" "
Read dbt.columns
Read dbt.columnName
Read dbt.columnDataType
begin
sprintf(dbt.dataType, "INT")
function createTables
"VARCHAR") then
function createTables
sprintf(dbt.dataType, "DATE")
function createTables
Page | 74
endif
mysql_close(con)
end
Function insertTableColumnsJobsheet
begin
Print mysql_error(con)
exit(1)
Endif
finish_with_error(con)
Endif
Page | 75
Declare
Begin
query as string
End
function system("cls")
print"+-------------------------------------------+"
print"+-------------------------------------------+"
print"+-------------------------------------------+"
print"+-------------------------------------------+"
print"+-------------------------------------------+"
print"+-------------------------------------------+"
print"+-------------------------------------------+"
Page | 76
print"+-------------------------------------------+"
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
begin
function adminWelcomeScreen
endif
print "Enter the Data type of the column INT , VARCHAR , DATE , DECIMAL: "
Read dbt.columnDataType
begin
sprintf(dbt.dataType, "INT")
function insertTableColumns2
begin
Page | 77
sprintf(dbt.dataType, "VARCHAR(%i)", MAX)
function insertTableColumns2
begin
sprintf(dbt.dataType, "DATE")
function insertTableColumns2
else then
begin
function decisionError
endif
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")
begin
Print "Error!"
exit(1)
Endif
begin
else
begin
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
begin
Print("Error!")
exit(1)
Endif
begin
else then
begin
Endif
fclose(filePointer)
End
Page | 80
//A function that stores the services provided
FUNCTION servicesFileStorage()
Begin
FILE* filePointer
begin
Print ("Error!")
exit(1)
Endif
fclose(filePointer)
End
// job in a jobsheet
Page | 81
Function installationCase
begin
for i to i do
begin
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
Read jb.subService
function system("cls")
function servicesFileCreation
endfor
for j to jb.subServiceAmount - 1 do
begin
print"+----------------------+"
print"+----------------------+"
Page | 82
print"+----------------------+"
print"+----------------------+"
Read jb.subService
function system("cls")
function servicesFileAppend
function servicesFileStorage
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"+----------------------+"
Page | 83
print"+----------------------+"
print"+----------------------+"
Read jb.subService
function system("cls")
function servicesFileCreation
endfor
for j to jb.subServiceAmount - 1 do
begin
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
Read jb.subService
function system("cls")
function servicesFileAppend
function servicesFileStorage
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"+----------------------+"
print"+----------------------+"
print"+----------------------+"
Read jb.subService
function system("cls")
function servicesFileCreation
endfor
for i to jb.subServiceAmount - 1 do
Page | 85
begin
print"+-------------------+"
print"+-------------------+"
print"+-------------------+"
print"+-------------------+"
Read jb.subService
function system("cls")
function servicesFileAppend
function servicesFileStorage
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"+----------------------+"
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
Page | 87
print"| Partitions |"
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
Read jb.subService
function system("cls"
functionservicesFileCreation
endfor
for j to jb.subServiceAmount - 1 do
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
Page | 88
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
Read jb.subService
Page | 89
function system("cls")
function servicesFileAppend
function servicesFileStorage
endfor
end
Function insertTableValuesJobsheet
begin
Print mysql_error(con)
exit(1)
Endif
Page | 90
dBI.databaseInputName, 0, NULL, 0) == NULL) then
finish_with_error(con)
Endif
Declare
Begin
query as string
End
Read jb.records
function time_t t1
function srand((unsigned)time(&t1))
for i to jb.records do
Read jb.name
Read jb.telephone
Read jb.address
Page | 91
Read jb.date
Read jb.contactPerson
function system("cls")
print"+-------------------------+"
print"+-------------------------+"
print"+-------------------------+"
print"+-------------------------+"
print"+-------------------------+"
Read jb.serviceType
function insertTableValuesJobsheet2
sprintf(query, "INSERT INTO %s VALUES(%i, '%s', '%s', '%s', '%s', '%s', '%s')",
begin
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 insertTableValuesJobsheet2
begin
Read jb.subServiceAmount
if (jb.serviceType == 1) then
begin
function installationCase
begin
function repairCase
Page | 93
begin
function pestControlCase
begin
function sanitationCase
else then
begin
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
Page | 94
if (filePointer == NULL) then
begin
printf("Error!")
exit(1)
endif
fclose(filePointer)
end
Function userDatabaseNameFileStorage
begin
FILE* filePointer
begin
Page | 95
printf("Error!")
exit(1)
endif
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
begin
printf("Error!")
exit(1)
endif
Page | 96
fprintf(filePointer, "%s", dbt.name)
fclose(filePointer)
end
Function userTableNameFileStorage
begin
FILE* filePointer
begin
printf("Error!")
exit(1)
endif
fclose(filePointer)
end
Page | 97
//A function that authenticates the password provided by the user and calls the specific function
Function loginScreen
begin
exit(1)
endif
begin
mysql_close(con)
exit(1)
endif
function system("cls")
function menu
print"Username: "
Page | 98
Read user.userName
Read user.password
function adminWelcomeScreen
else then
begin
function userDatabaseNameFileStorage
function userTableNameFileStorage
function userAuthentication
endif
end
Function signupScreen
begin
function system("cls")
function userDatabaseNameFileStorage
function userTableNameFileStorage
Page | 99
function insertTableValuesUsersSignIn
function userEmail
print" "
print" "
function getcharacter
function mainMenu
end
Function adminWelcomeScreenOption2
begin
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
print"+----------------------+"
Page | 100
end
//A function that presents the different options for the admin
Function adminWelcomeScreenOption3
begin
print"+---------------------+"
print"+---------------------+"
print"+---------------------+"
print"+---------------------+"
print"+---------------------+"
end
//A function that presents the different options for the user
Function userEditWorksheetScreenOptions
begin
print"+-------------------+"
Page | 101
print"+-------------------+"
print"+-------------------+"
print"+-------------------+"
print"+-------------------+"
print"+-------------------+"
end
//A function that presents the different options for the user
Function userWelcomeScreenOptions
begin
function time_t t
function time(&t)
print"+--------------+"
print"+--------------+"
Page | 102
print"| 2)Jobsheets |"
print"+--------------+"
print"+--------------+"
end
//A function that presents the different options for the admin
Function adminWelcomeScreenOption1
begin
function system("cls"
print"+---------------------+"
print"+---------------------+"
print"+---------------------+"
print"+---------------------+"
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"+--------------+"
print"+--------------+"
print"+--------------+"
print"+--------------+"
print"+--------------+"
print"+--------------+"
Page | 104
end
//A function that presents the different options for the admin
Function adminEditWorksheetScreenOptions
begin
print"+-------------------+"
print"+-------------------+"
print"+-------------------+"
print"+-------------------+"
print"+-------------------+"
print"+-------------------+"
print"+-------------------+"
print"+-------------------+"
Page | 105
end
FUNCTION welcomeScreen
begin
function system("cls")
function menu
function userWelcomeScreenOptions
print" "
Read u.userInput
switch (u.userInput)
begin
case(1):
function system("cls")
function userEditWorksheetScreenOptions
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
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
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
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:
function system("cls")
function welcomeScreen
end
case(2):
function system("cls")
function userEditWorksheetScreenOptions
print" "
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
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
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
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:
function decisionPrompt
end
end
function adminWelcomeScreen
begin
function system("cls")
function menu
function adminWelcomeScreenOptions
Page | 112
Read admin.adminInput
switch (admin.adminInput)
begin
case(1):
function system("cls")
function adminWelcomeScreenOption1
Read dBI.databaseInput
switch (dBI.databaseInput)
begin
case(1):
function system("cls")
function createDatabaseName
function createDatabase
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:
function decisionPrompt
end
case(2):
function system("cls")
function adminWelcomeScreenOption2
print" "
Read admin.adminInputDB
switch (admin.adminInputDB)
begin
Page | 114
case(1):
function system("cls")
function showDatabases
function selectDatabase
function system("cls")
function createTablesInputWorksheet
function system("cls")
function insertTableColumnsWorksheet
function decisionPrompt
case(2):
function system("cls")
function adminEditWorksheetScreenOptions
print" "
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
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
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
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:
function decisionPrompt
end
case(3):
function system("cls")
function showDatabases
function selectDatabase
function system("cls")
function showDatabaseTables
function selectDatabaseTables
function system("cls")
function deleteDatabaseTables
function decisionPrompt
case(4):
function system("cls")
function adminWelcomeScreen
default:
function decisionPrompt
end
Page | 119
case (3):
function system("cls")
function adminWelcomeScreenOption3
Read admin.adminInputDB
switch (admin.adminInputDB)
begin
case(1):
function system("cls")
function showDatabases
function selectDatabase
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
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
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
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
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:
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:
function decisionPrompt
case (4):
function stem("cls")
print"+-----------------+"
print"+-----------------+"
print"+-----------------+"
print"+-----------------+"
print"+-----------------+"
print""
Read admin.adminInputUsers
Page | 125
switch (admin.adminInputUsers)
Begin
case(1):
function system("cls")
print"+------------------------+"
print"+------------------------+"
print"+------------------------+"
print"+------------------------+"
print"+------------------------+"
print" "
Read admin.adminInputUsersDatabase)
switch (admin.adminInputUsersDatabase)
begin
case(1):
function system("cls")
function createDatabaseName
function createDatabase
function userDatabaseNameFileCreation
Page | 126
function userDatabaseNameFileStorage
function decisionPrompt
case(2):
function system("cls")
function showDatabases
function selectDatabase
function deleteDatabase
function decisionPrompt
case(3):
function system("cls")
function showDatabases
function selectDatabase
function decisionPrompt
case(4):
function system("cls")
function adminWelcomeScreen
default:
function decisionPrompt
end
Page | 127
case(2):
function system("cls")
print"+-----------------------+"
print"+-----------------------+"
print"+-----------------------+"
print"+-----------------------+"
print"+-----------------------+"
Read admin.adminInputUsersTable
switch (admin.adminInputUsersTable)
begin
case(1):
function system("cls")
function showDatabases
function selectDatabase
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"+-------------------+"
print"+-------------------+"
print"+-------------------+"
print"+-------------------+"
print"+-------------------+"
print"+-------------------+"
print"+-------------------+"
Page | 129
print" "
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
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
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
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:
function decisionPrompt
end
case(3):
function system("cls")
function showDatabases
function selectDatabase
Page | 133
function system("cls")
function showDatabaseTables
function selectDatabaseTables
deleteDatabaseTables
function decisionPrompt
case(4):
function system("cls")
function adminWelcomeScreen
default:
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:
function decisionPrompt
end
case (5):
function mainMenu
default:
function decisionPrompt
end
end
FUNCTION startupMenu ()
Begin
length as integer
Page | 135
Print
"*****************************************************************************
*************************************************"
Print " ___ ___ ___ ___ ___ ________ ________ _______ ________
sleep(200)
| ____|"
Sleep(200)
|____ "
Sleep(200)
____|"
Sleep(200)
| | |____"
Sleep(200)
Print " |_______________| |_| |_| |________| |__| |______| |_| \\_\\
Page | 136
Print
"*****************************************************************************
*************************************************"
For i 1 to length do
Print comp_name[i]
Sleep(50)
End
End
FUNCTION menu()
Begin
length,i as integer
length = sizeof(comp_name)/sizeof(comp_name[0])
"*****************************************************************************
*************************************************"
Print " ___ ___ ___ ___ ___ ________ ________ _______ ________
| ____| "
|____ "
Page | 137
Print " | | | | | | | |____| | | | | | | ____| | | \\ \\ | | | | |_____ | |
____|"
| | |____"
Print " |_______________| |_| |_| |________| |__| |______| |_| \\_\\
"*****************************************************************************
*************************************************"
for i to length do
Print comp_name[i]
End
FUNCTION main
Begin
function mainMenu
End
Page | 138
C-Program
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mysql.h>
#include <windows.h>
#include <time.h>
#include <conio.h>
#include <ctype.h>
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 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;
};
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;
};
//Structure that has a member to use in creating a name for the databases
struct databaseName {
char name[100];
char nameInput[100];
};
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;
};
//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];
};
//Structure that has members that holds login information for users
struct userCredentials {
char userName[MAX];
char password[MAX];
int menuInput;
};
//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 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
void decisionError() {
if (strcmp(user.userName, "admin") == 0) {
Sleep(3000);
adminWelcomeScreen();
Sleep(3000);
welcomeScreen();
void decision() {
printf("%s", user.userName);
if (strcmp(user.userName, "admin") == 0) {
adminWelcomeScreen();
Page | 145
else if (strcmp(user.userName, user.userName) == 0) {
welcomeScreen();
void decisionData() {
printf("\n");
printf("\n");
scanf("%s", dbt.name);
if (strcmp(dbt.name, "Return") == 0) {
decision();
// previous page
void decisionPrompt() {
printf("\n");
Page | 146
_getch();
decision();
//A function that checks to see if a mySQL query was executed with errors
decisionError();
//A function that prompts the user to enter a name to create a database
void createDatabaseName() {
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() {
if (con == NULL)
exit(1);
mysql_close(con);
exit(1);
char query[255];
if (mysql_query(con, query))
decisionError();
Page | 148
}
mysql_close(con);
//A function that deletes a database that was provided by the user
int deleteDatabase() {
if (con == NULL)
exit(1);
mysql_close(con);
exit(1);
Page | 149
}
char query[255];
if (mysql_query(con, query))
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() {
if (con == NULL)
exit(1);
mysql_close(con);
exit(1);
char query[255];
Page | 151
if (mysql_query(con, query))
decisionError();
MYSQL_ROW row;
printf("List of Databases");
printf("\n");
printf("\n");
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() {
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
int showDatabasesForUsers() {
Page | 153
if (con == NULL)
exit(1);
mysql_close(con);
exit(1);
char query[255];
'%s')", u.userDBName);
if (mysql_query(con, query))
decisionError();
Page | 154
}
MYSQL_ROW row;
if (result == NULL)
finish_with_error(con);
printf("List of Databases");
printf("\n");
printf("\n");
Page | 155
printf("\n");
printf("\n");
mysql_free_result(result);
mysql_close(con);
int showDatabaseTables() {
if (con == NULL)
exit(1);
Page | 156
finish_with_error(con);
char query[255];
if (mysql_query(con, query))
decisionError();
MYSQL_ROW row;
printf("List of Tables");
printf("\n");
printf("\n");
Page | 157
{
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() {
if (con == NULL)
exit(1);
finish_with_error(con);
char query[255];
if (mysql_query(con, query))
Page | 159
decisionError();
mysql_close(con);
//A function that shows the data of a database table that was provided by the user
int showDatabaseTableData() {
if (con == NULL)
exit(1);
finish_with_error(con);
Page | 160
char query[255];
if (mysql_query(con, query))
decisionError();
if (result == NULL)
finish_with_error(con);
MYSQL_ROW row;
int count = 1;
Page | 161
/*printf("%i ", count);
count ++;*/
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)
exit(1);
finish_with_error(con);
char query[255];
dbt.dataType);
if (mysql_query(con, query))
decisionError();
mysql_close(con);
Page | 163
}
//A function that returns the names of the columns from a database table
int showColumns() {
if (con == NULL)
exit(1);
finish_with_error(con);
char query[255];
Page | 164
if (mysql_query(con, query))
decisionError();
if (result == NULL)
finish_with_error(con);
MYSQL_ROW row;
MYSQL_FIELD* field;
Page | 165
{
if (i == 0)
printf("%s", field->name);
printf("\n");
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() {
if (con == NULL)
exit(1);
finish_with_error(con);
scanf("%s", dbt.name);
if (strcmp(dbt.name, "Return") == 0) {
decision();
Page | 167
}
system("cls");
printf("+-----------------------------------------+\n");
printf("+-----------------------------------------+\n");
printf("+-----------------------------------------+\n");
printf("\n");
printf("\n");
scanf("%i", &dbt.columns);
scanf("%s", dbt.columnName);
scanf("%s", dbt.columnDataType);
sprintf(dbt.dataType, "INT");
createTables();
"VARCHAR") == 0) {
Page | 168
createTables();
== 0) {
sprintf(dbt.dataType, "DATE");
createTables();
mysql_close(con);
int addTables() {
if (con == NULL)
exit(1);
Page | 169
{
finish_with_error(con);
char query[255];
if (mysql_query(con, query))
decisionError();
mysql_close(con);
int insertTableColumns2() {
if (con == NULL)
Page | 170
exit(1);
finish_with_error(con);
char query[255];
dbt.dataType);
if (mysql_query(con, query))
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)
exit(1);
finish_with_error(con);
char query[255];
printf("Enter the change to make to the table's column ADD, MODIFY, DROP, RENAME,
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");
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");
"VARCHAR") == 0) {
== 0) {
sprintf(dbt.dataType, "DATE");
Page | 173
}
else {
decisionError();
dbt.dataType);
if (mysql_query(con, query))
decisionError();
0) {
system("cls");
showColumns();
printf("\n");
scanf("%s", dbt.columnName);
Page | 174
if (mysql_query(con, query))
decisionError();
"MODIFY") == 0) {
system("cls");
showColumns();
printf("\n");
scanf("%s", dbt.columnName);
printf("Enter the Data type of the column INT() , VARCHAR() , DATE , DECIMAL: ");
scanf("%s", dbt.columnDataType);
sprintf(dbt.dataType, "INT");
"VARCHAR") == 0) {
Page | 175
}
== 0) {
sprintf(dbt.dataType, "DATE");
dbt.dataType);
if (mysql_query(con, query))
decisionError();
"RENAME") == 0) {
system("cls");
showColumns();
printf("\n");
scanf("%s", dbt.columnName);
Page | 176
printf("Enter the name to change the column to: ");
scanf("%s", dbt.columnNameNew);
dbt.columnName, dbt.columnNameNew);
if (mysql_query(con, query))
decisionError();
mysql_close(con);
void userEmail() {
Page | 177
FILE* email;
char script[MAX];
sprintf(script,
"$from = '[email protected]'\n"
"$to = '%s'\n"
"$smtpServer = 'smtp.gmail.com'\n"
"$port = 587\n"
"$username = '[email protected]'\n"
"$password = 'oduqxmklfciozdpm'\n"
$body\n"
Interiors Admin')\n"
"$smtpClient.Port = $port\n"
"$smtpClient.EnableSsl = $true\n"
$password)\n"
char command[MAX];
Page | 178
sprintf(command, "%s", script); //Store the completed script into a variable
if (email == NULL) {
exit(1);
fclose(email);
system("powershell.exe
C:\\Users\\Dell\\Desktop\\CSUnit1SBA\\CSUnit1SBA\\emailscript.ps1");
emailscript.ps1");*/
int insertTableColumnsWorksheet() {
Page | 179
MYSQL* con = mysql_init(NULL);
if (con == NULL)
exit(1);
finish_with_error(con);
printf("+-------------------------------------------+\n");
printf("+-------------------------------------------+\n");
printf("+-------------------------------------------+\n");
printf("+-------------------------------------------+\n");
printf("+-------------------------------------------+\n");
Page | 180
printf("| Telephone: Varchar |\n");
printf("+-------------------------------------------+\n");
printf("+-------------------------------------------+\n");
printf("+-------------------------------------------+\n");
printf("+-------------------------------------------+\n");
printf("+-------------------------------------------+\n");
printf("\n");
printf("\n");
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);
Page | 181
sprintf(dbt.dataType, "INT");
insertTableColumns2();
"VARCHAR") == 0) {
insertTableColumns2();
== 0) {
sprintf(dbt.dataType, "DATE");
insertTableColumns2();
else {
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() {
scanf("%i", &wk.records);
scanf("%s", wk.namePerson);
scanf("%s", wk.address);
scanf("%s", wk.telephone);
scanf("%s", wk.date);
scanf("%s", wk.email);
scanf("%s", wk.jobNumber);
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() {
if (con == NULL)
exit(1);
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));
scanf("%s", wk.namePerson);
scanf("%s", wk.address);
scanf("%s", wk.telephone);
scanf("%s", wk.date);
scanf("%s", wk.email);
scanf("%s", wk.jobNumber);
scanf("%s", wk.contactPerson);
Page | 185
sprintf(query, "INSERT INTO %s VALUES(%i,'%s', '%s', '%s', '%s', '%s', '%s', '%s')",
wk.contactPerson);
if (mysql_query(con, query))
decisionError();
mysql_close(con);
//A function that gathers input from the user regarding the database table values to be passed into
int insertTableValuesUsers() {
if (con == NULL)
Page | 186
fprintf(stderr, "%s\n", mysql_error(con));
exit(1);
finish_with_error(con);
char query[255];
scanf("%i", &userInfo.numberOfUsers);
time_t t1;
srand((unsigned)time(&t1));
scanf("%s", userInfo.userFirstName);
scanf("%s", userInfo.userSurname);
scanf("%s", userInfo.userDOB);
Page | 187
printf("Enter your email: ");
scanf("%s", userInfo.userEmail);
scanf("%s", user.password);
sprintf(query, "INSERT INTO %s VALUES(%i, '%s', '%s', '%s', '%s', '%s')", dbt.name,
userInfo.userDOB, user.password);
if (mysql_query(con, query))
decisionError();
mysql_close(con);
int insertTableValuesUsersSignIn() {
Page | 188
if (con == NULL)
exit(1);
finish_with_error(con);
char query[255];
time_t t1;
srand((unsigned)time(&t1));
scanf("%s", userInfo.userFirstName);
scanf("%s", userInfo.userSurname);
scanf("%s", userInfo.userDOB);
Page | 189
scanf("%s", userInfo.userEmail);
scanf("%s", user.password);
sprintf(query, "INSERT INTO %s VALUES(%i, '%s', '%s', '%s', '%s', '%s')", u.userdbtName,
userInfo.userDOB, user.password);
if (mysql_query(con, query))
decisionError();
mysql_close(con);
// table
int createTablesInputUsers() {
Page | 190
if (con == NULL)
exit(1);
finish_with_error(con);
scanf("%s", dbt.name);
if (strcmp(dbt.name, "Return") == 0) {
decision();
system("cls");
printf("+-----------------------------------------+\n");
printf("+-----------------------------------------+\n");
printf("+-----------------------------------------+\n");
Page | 191
printf("\n");
printf("\n");
scanf("%i", &dbt.columns);
scanf("%s", dbt.columnName);
scanf("%s", dbt.columnDataType);
sprintf(dbt.dataType, "INT");
createTables();
"VARCHAR") == 0) {
createTables();
== 0) {
sprintf(dbt.dataType, "DATE");
createTables();
Page | 192
}
mysql_close(con);
int insertTableColumnsUsers() {
if (con == NULL)
exit(1);
finish_with_error(con);
system("cls");
printf("+-------------------------------------------+\n");
Page | 193
printf("+-------------------------------------------+\n");
printf("+-------------------------------------------+\n");
printf("+-------------------------------------------+\n");
printf("+-------------------------------------------+\n");
printf("+-------------------------------------------+\n");
printf("+-------------------------------------------+\n");
printf("+-------------------------------------------+\n");
printf("\n");
printf("\n");
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);
sprintf(dbt.dataType, "INT");
insertTableColumns2();
"VARCHAR") == 0) {
insertTableColumns2();
== 0) {
sprintf(dbt.dataType, "DATE");
insertTableColumns2();
else {
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
int userAuthentication() {
if (con == NULL)
exit(1);
Page | 196
finish_with_error(con);
char query[255];
user.userName);
if (mysql_query(con, query))
decisionError();
MYSQL_ROW row;
Page | 197
res = row[i] ? row[i] : "NULL";
printf("\n");
printf("\n");
if (strcmp(user.userName, "admin") == 0) {
adminWelcomeScreen();
welcomeScreen();
else {
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");
scanf("%s", dbt.columnName);
system("cls");
showDatabaseTableData();
printf("\n");
scanf("%i", &wk.id);
scanf("%s", dbt.query);
Page | 199
//A function that updates records in a database table
int updateTableValues() {
if (con == NULL)
exit(1);
finish_with_error(con);
char query[255];
if (strcmp(dbt.columnName, "JobNumber") == 0) {
dbt.query, wk.id);
else {
Page | 200
sprintf(query, "UPDATE %s SET %s = '%s' WHERE ID = %i", dbt.name,
if (mysql_query(con, query))
decisionError();
mysql_close(con);
//A function that gathers the input from the user to use in deleting values from a database table
void deleteTableValuesQuery() {
scanf("%s", dbt.columnName);
system("cls");
Page | 201
showDatabaseTableData();
printf("\n");
scanf("%s", dbt.query);
int deleteTableValues() {
if (con == NULL)
exit(1);
finish_with_error(con);
Page | 202
char query[255];
if (strcmp(dbt.columnName, "JobNumber") == 0) {
dbt.query);
else {
dbt.query);
if (mysql_query(con, query))
decisionError();
mysql_close(con);
Page | 203
int createTablesInputJobsheet() {
if (con == NULL)
exit(1);
finish_with_error(con);
scanf("%s", dbt.name);
if (strcmp(dbt.name, "Return") == 0) {
decision();
system("cls");
printf("+-----------------------------------------+\n");
Page | 204
printf("+-----------------------------------------+\n");
printf("+-----------------------------------------+\n");
printf("\n");
printf("\n");
scanf("%i", &dbt.columns);
scanf("%s", dbt.columnName);
scanf("%s", dbt.columnDataType);
sprintf(dbt.dataType, "INT");
createTables();
"VARCHAR") == 0) {
createTables();
Page | 205
else if (strcmp(dbt.columnDataType, "date") == 0 || strcmp(dbt.columnDataType, "DATE")
== 0) {
sprintf(dbt.dataType, "DATE");
createTables();
mysql_close(con);
int insertTableColumnsJobsheet() {
if (con == NULL)
exit(1);
finish_with_error(con);
Page | 206
}
system("cls");
printf("+-------------------------------------------+\n");
printf("+-------------------------------------------+\n");
printf("+-------------------------------------------+\n");
printf("+-------------------------------------------+\n");
printf("+-------------------------------------------+\n");
printf("+-------------------------------------------+\n");
printf("+-------------------------------------------+\n");
printf("+-------------------------------------------+\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);
sprintf(dbt.dataType, "INT");
insertTableColumns2();
"VARCHAR") == 0) {
insertTableColumns2();
== 0) {
Page | 208
sprintf(dbt.dataType, "DATE");
insertTableColumns2();
else {
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;
if (filePointer == NULL) {
printf("Error!");
exit(1);
Page | 209
}
if (jb.subServiceAmount < 2) {
else {
fclose(filePointer);
//A function that appends to a file that will store the services provided in a jobsheet
void servicesFileAppend() {
FILE* filePointer;
if (filePointer == NULL) {
printf("Error!");
exit(1);
Page | 210
if (jb.subServiceAmount < 2) {
else {
fclose(filePointer);
void servicesFileStorage() {
FILE* filePointer;
if (filePointer == NULL) {
printf("Error!");
exit(1);
Page | 211
fscanf(filePointer, "%s", jb.services);
fclose(filePointer);
// job in a jobsheet
void installationCase() {
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
scanf("%s", jb.subService);
system("cls");
servicesFileCreation();
Page | 212
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
scanf("%s", jb.subService);
system("cls");
servicesFileAppend();
servicesFileStorage();
//A function that presents the different types of jobsheet sub-services for the repair service
void repairCase() {
printf("+----------------------+\n");
Page | 213
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
scanf("%s", jb.subService);
system("cls");
servicesFileCreation();
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
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() {
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
scanf("%s", jb.subService);
system("cls");
servicesFileCreation();
printf("+-------------------+\n");
Page | 215
printf("| Spraying |\n");
printf("+-------------------+\n");
printf("+-------------------+\n");
printf("+-------------------+\n");
scanf("%s", jb.subService);
system("cls");
servicesFileAppend();
servicesFileStorage();
//A function that presents the different types of jobsheet sub-services for the sanitation service
void sanitationCase() {
printf("+----------------------+\n");
printf("+----------------------+\n");
Page | 216
printf("| Carpet |\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
Page | 217
printf("+----------------------+\n");
printf("+----------------------+\n");
scanf("%s", jb.subService);
system("cls");
servicesFileCreation();
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
Page | 218
printf("| Vehicle Interior |\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
scanf("%s", jb.subService);
system("cls");
servicesFileAppend();
servicesFileStorage();
Page | 219
}
int insertTableValuesJobsheet() {
if (con == NULL)
exit(1);
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));
scanf("%s", jb.name);
scanf("%s", jb.telephone);
scanf("%s", jb.address);
scanf("%s", jb.date);
scanf("%s", jb.contactPerson);
system("cls");
printf("+-------------------------+\n");
printf("+-------------------------+\n");
printf("+-------------------------+\n");
Page | 221
printf("| 3)Pest Control |\n");
printf("+-------------------------+\n");
printf("+-------------------------+\n");
scanf("%i", &jb.serviceType);
insertTableValuesJobsheet2();
sprintf(query, "INSERT INTO %s VALUES(%i, '%s', '%s', '%s', '%s', '%s', '%s')",
if (mysql_query(con, query))
decisionError();
mysql_close(con);
//A function that prompts the user for the number of subservices, then calles the respective
Page | 222
void insertTableValuesJobsheet2() {
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 {
decisionError();
Page | 223
}
//A function that creates a files that will store the user database name provided by the admin
void userDatabaseNameFileCreation() {
FILE* filePointer;
if (filePointer == NULL) {
printf("Error!");
exit(1);
fclose(filePointer);
void userDatabaseNameFileStorage() {
Page | 224
FILE* filePointer;
if (filePointer == NULL) {
printf("Error!");
exit(1);
fclose(filePointer);
//A function that creates a files that will store the user database table name provided by the
admin
void userTableNameFileCreation() {
FILE* filePointer;
if (filePointer == NULL) {
Page | 225
printf("Error!");
exit(1);
fclose(filePointer);
void userTableNameFileStorage() {
FILE* filePointer;
if (filePointer == NULL) {
printf("Error!");
exit(1);
fclose(filePointer);
Page | 226
}
//A function that authenticates the password provided by the user and calls the specific function
void loginScreen() {
if (con == NULL)
exit(1);
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();
void signupScreen() {
system("cls");
userDatabaseNameFileStorage();
userTableNameFileStorage();
Page | 228
insertTableValuesUsersSignIn();
userEmail();
printf("\n");
printf("\n");
_getch();
mainMenu();
void adminWelcomeScreenOption2() {
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
printf("+----------------------+\n");
Page | 229
//A function that presents the different options for the admin
void adminWelcomeScreenOption3() {
printf("+---------------------+\n");
printf("+---------------------+\n");
printf("+---------------------+\n");
printf("+---------------------+\n");
printf("+---------------------+\n");
//A function that presents the different options for the user
void userEditWorksheetScreenOptions() {
printf("+-------------------+\n");
printf("+-------------------+\n");
printf("+-------------------+\n");
Page | 230
printf("| 3)Update records |\n");
printf("+-------------------+\n");
printf("+-------------------+\n");
printf("+-------------------+\n");
//A function that presents the different options for the user
void userWelcomeScreenOptions() {
time_t t;
time(&t);
printf("+--------------+\n");
printf("+--------------+\n");
printf("+--------------+\n");
printf("+--------------+\n");
Page | 231
}
//A function that presents the different options for the admin
void adminWelcomeScreenOption1() {
system("cls");
printf("+---------------------+\n");
printf("+---------------------+\n");
printf("+---------------------+\n");
printf("+---------------------+\n");
printf("+---------------------+\n");
//A function that presents the different options for the admin
void adminWelcomeScreenOptions() {
Page | 232
time_t t;
time(&t);
printf("+--------------+\n");
printf("+--------------+\n");
printf("+--------------+\n");
printf("+--------------+\n");
printf("+--------------+\n");
printf("+--------------+\n");
//A function that presents the different options for the admin
void adminEditWorksheetScreenOptions() {
printf("+-------------------+\n");
Page | 233
printf("+-------------------+\n");
printf("+-------------------+\n");
printf("+-------------------+\n");
printf("+-------------------+\n");
printf("+-------------------+\n");
printf("+-------------------+\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");
scanf("%i", &u.userInputDB);
switch (u.userInputDB) {
case(1):
system("cls");
showDatabasesForUsers();
selectDatabase();
system("cls");
showDatabaseTables();
selectDatabaseTables();
system("cls");
insertTableValues2();
decisionPrompt();
case(2):
system("cls");
Page | 235
showDatabasesForUsers();
selectDatabase();
system("cls");
showDatabaseTables();
selectDatabaseTables();
system("cls");
showColumns();
deleteTableValuesQuery();
deleteTableValues();
decisionPrompt();
case(3):
system("cls");
showDatabasesForUsers();
selectDatabase();
system("cls");
showDatabaseTables();
selectDatabaseTables();
system("cls");
showColumns();
updateTableValuesQuery();
updateTableValues();
Page | 236
decisionPrompt();
case(4):
system("cls");
showDatabasesForUsers();
selectDatabase();
system("cls");
showDatabaseTables();
selectDatabaseTables();
system("cls");
showDatabaseTableData();
decisionPrompt();
case(5):
system("cls");
welcomeScreen();
default:
system("cls");
welcomeScreen();
case(2):
system("cls");
Page | 237
userEditWorksheetScreenOptions();
printf("\n");
scanf("%i", &u.userInputDB);
switch (u.userInputDB) {
case(1):
system("cls");
showDatabasesForUsers();
selectDatabase();
system("cls");
showDatabaseTables();
selectDatabaseTables();
system("cls");
insertTableValuesJobsheet();
decisionPrompt();
case(2):
system("cls");
showDatabasesForUsers();
selectDatabase();
system("cls");
showDatabaseTables();
selectDatabaseTables();
Page | 238
system("cls");
showColumns();
deleteTableValuesQuery();
deleteTableValues();
decisionPrompt();
case(3):
system("cls");
showDatabasesForUsers();
selectDatabase();
system("cls");
showDatabaseTables();
selectDatabaseTables();
system("cls");
showColumns();
updateTableValuesQuery();
updateTableValues();
decisionPrompt();
case(4):
system("cls");
showDatabasesForUsers();
selectDatabase();
Page | 239
system("cls");
showDatabaseTables();
selectDatabaseTables();
system("cls");
showDatabaseTableData();
decisionPrompt();
case(5):
system("cls");
welcomeScreen();
default:
decisionPrompt();
case(3):
system("cls");
mainMenu();
default:
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");
scanf("%i", &admin.adminInput);
switch (admin.adminInput) {
case(1):
system("cls");
adminWelcomeScreenOption1();
printf("\n");
scanf("%i", &dBI.databaseInput);
switch (dBI.databaseInput) {
case(1):
Page | 241
system("cls");
createDatabaseName();
createDatabase();
system("cls");
decisionPrompt();
case(2):
system("cls");
showDatabases();
selectDatabase();
deleteDatabase();
decisionPrompt();;
case(3):
system("cls");
showDatabases();
decisionPrompt();
case(4):
system("cls");
adminWelcomeScreen();
default:
decisionPrompt();
Page | 242
}
case(2):
system("cls");
adminWelcomeScreenOption2();
printf("\n");
scanf("%i", &admin.adminInputDB);
switch (admin.adminInputDB) {
case(1):
system("cls");
showDatabases();
selectDatabase();
system("cls");
createTablesInputWorksheet();
system("cls");
insertTableColumnsWorksheet();
decisionPrompt();
case(2):
Page | 243
system("cls");
adminEditWorksheetScreenOptions();
printf("\n");
scanf("%i", &admin.adminInputDB);
switch (admin.adminInputDB) {
case(1):
system("cls");
showDatabases();
selectDatabase();
system("cls");
showDatabaseTables();
selectDatabaseTables();
system("cls");
insertTableValues2();
decisionPrompt();
case(2):
system("cls");
showDatabases();
selectDatabase();
system("cls");
showDatabaseTables();
Page | 244
selectDatabaseTables();
system("cls");
showColumns();
deleteTableValuesQuery();
deleteTableValues();
decisionPrompt();
case(3):
system("cls");
showDatabases();
selectDatabase();
system("cls");
showDatabaseTables();
selectDatabaseTables();
system("cls");
showColumns();
updateTableValuesQuery();
updateTableValues();
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:
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:
decisionPrompt();
case (3):
system("cls");
adminWelcomeScreenOption3();
printf("\n");
scanf("%i", &admin.adminInputDB);
switch (admin.adminInputDB) {
case(1):
system("cls");
showDatabases();
selectDatabase();
system("cls");
Page | 248
createTablesInputJobsheet();
insertTableColumnsJobsheet();
decisionPrompt();
case(2):
system("cls");
adminEditWorksheetScreenOptions();
printf("\n");
scanf("%i", &admin.adminInputDB);
switch (admin.adminInputDB) {
case(1):
system("cls");
showDatabases();
selectDatabase();
system("cls");
showDatabaseTables();
selectDatabaseTables();
system("cls");
insertTableValuesJobsheet();
decisionPrompt();
case(2):
Page | 249
system("cls");
showDatabases();
selectDatabase();
system("cls");
showDatabaseTables();
selectDatabaseTables();
system("cls");
showColumns();
deleteTableValuesQuery();
deleteTableValues();
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:
decisionPrompt();
case(3):
system("cls");
Page | 252
showDatabases();
selectDatabase();
system("cls");
showDatabaseTables();
selectDatabaseTables();
system("cls");
deleteDatabaseTables();
decisionPrompt();
case(4):
system("cls");
adminWelcomeScreen();
default:
decisionPrompt();
case (4):
system("cls");
printf("+-----------------+\n");
printf("+-----------------+\n");
printf("+-----------------+\n");
Page | 253
printf("| 3)Users |\n");
printf("+-----------------+\n");
printf("+-----------------+\n");
printf("\n");
scanf("%i", &admin.adminInputUsers);
switch (admin.adminInputUsers) {
case(1):
system("cls");
printf("+------------------------+\n");
printf("+------------------------+\n");
printf("+------------------------+\n");
printf("+------------------------+\n");
printf("+------------------------+\n");
printf("\n");
scanf("%i", &admin.adminInputUsersDatabase);
switch (admin.adminInputUsersDatabase) {
Page | 254
case(1):
system("cls");
createDatabaseName();
createDatabase();
userDatabaseNameFileCreation();
userDatabaseNameFileStorage();
decisionPrompt();
case(2):
system("cls");
showDatabases();
selectDatabase();
deleteDatabase();
decisionPrompt();
case(3):
system("cls");
showDatabases();
selectDatabase();
decisionPrompt();
case(4):
system("cls");
Page | 255
adminWelcomeScreen();
default:
decisionPrompt();
case(2):
system("cls");
printf("+-----------------------+\n");
printf("+-----------------------+\n");
printf("+-----------------------+\n");
printf("+-----------------------+\n");
printf("+-----------------------+\n");
printf("\n");
scanf("%i", &admin.adminInputUsersTable);
switch (admin.adminInputUsersTable) {
case(1):
system("cls");
showDatabases();
Page | 256
selectDatabase();
system("cls");
createTablesInputUsers();
insertTableColumnsUsers();
userTableNameFileCreation();
userTableNameFileStorage();
decisionPrompt();
case(2):
system("cls");
printf("+-------------------+\n");
printf("+-------------------+\n");
printf("+-------------------+\n");
printf("+-------------------+\n");
printf("+-------------------+\n");
printf("+-------------------+\n");
Page | 257
printf("| 6)Show Table Data |\n");
printf("+-------------------+\n");
printf("+-------------------+\n");
printf("\n");
scanf("%i", &admin.adminInputDB);
switch (admin.adminInputDB) {
case(1):
system("cls");
showDatabases();
selectDatabase();
system("cls");
showDatabaseTables();
selectDatabaseTables();
system("cls");
insertTableValuesUsers();
userDatabaseNameFileStorage();
userTableNameFileStorage();
userEmail();
decisionPrompt();
case(2):
Page | 258
system("cls");
showDatabases();
selectDatabase();
system("cls");
showDatabaseTables();
selectDatabaseTables();
system("cls");
showColumns();
deleteTableValuesQuery();
deleteTableValues();
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:
decisionPrompt();
case(3):
Page | 261
system("cls");
showDatabases();
selectDatabase();
system("cls");
showDatabaseTables();
selectDatabaseTables();
system("cls");
deleteDatabaseTables();
decisionPrompt();
case(4):
system("cls");
adminWelcomeScreen();
default:
decisionPrompt();
case(3):
system("cls");
showDatabases();
selectDatabase();
system("cls");
Page | 262
showDatabaseTables();
selectDatabaseTables();
system("cls");
showDatabaseTableData();
decisionPrompt();
case(4):
system("cls");
adminWelcomeScreen();
default:
decisionPrompt();
case (5):
mainMenu();
default:
decisionPrompt();
Page | 263
void mainMenu() {
system("cls");
startupMenu();
printf("+-------------+\n");
printf("+-------------+\n");
printf("+-------------+\n");
printf("+-------------+\n");
printf("+-------------+\n");
printf("\n");
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();
void startupMenu() {
printf("************************************************************************
******************************************************\n");
printf(" ___ ___ ___ ___ ___ ________ ________ _______ ________
Sleep(200);
____| \n");
Sleep(200);
Page | 265
printf(" | | | | | | | |____| | | | | | | |____ | _____| | | | | | |_____ | |____
\n");
Sleep(200);
____|\n");
Sleep(200);
|____\n");
Sleep(200);
printf(" |_______________| |_| |_| |________| |__| |______| |_| \\_\\ |_______ |
|_______ | |______|\n");
printf("\n**********************************************************************
********************************************************\n");
printf("%c", comp_name[i]);
sleep(50);
printf("\n");*/
Page | 266
//A function that presents the menu graphics
void menu() {
printf("************************************************************************
******************************************************\n");
printf(" ___ ___ ___ ___ ___ ________ ________ _______ ________
____| \n");
\n");
____|\n");
|____\n");
printf(" |_______________| |_| |_| |________| |__| |______| |_| \\_\\ |_______ |
|_______ | |______|\n");
Page | 267
printf("\n**********************************************************************
********************************************************\n");
printf("%c", comp_name[i]);
printf("\n");*/
int main()
mainMenu();
Page | 268
Test Plan
Variable Name Data Type Test Data Purpose of Expected Result Actual Result
Data
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
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
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
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
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.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.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.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.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.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.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.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.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
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
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
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
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
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.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.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.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.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.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.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
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
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.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
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
Page | 282