You are on page 1of 12

Class list

number

Practical
FACULTY: INFORMATION AND COMMUNICATION TECHNOLOGY
DEPARTMENT: Computer Science
Technical Programming 201T (C++)
CT2
TPG201T

CLASS TEST 1 Examiner:


Duration: 55 min
Date: March 2023 Mr H Jeske
Total: 22
By signing this paper and/ or
Full Marks 22
taking this test I hereby declare Pages: 12
that I am familiar with, and will
abide to the examination rules of Student number
Tshwane University of Tech-
nology.

%
___________________
Signature Campus Lecturer Group Venue/PC#

How to receive your files / question paper


✓ Make sure your PC is on. Logon to EC. What clever students
✓ Go to Student -> Tests -> Web Test 4
are doing!
✓ Select - Subject Code: TPG201T
✓ Intake: 20231
✓ Test Number: S
✓ Click Enter and START
✓ Follow instructions and download provided files to your D drive (D:\My Documents)

How to upload your Results to EC (as code fragments)


✓ At the end of the session, you upload your code segments to EC.
✓ Upon completion and/ or before the duration of the test ends, you must submit on EC:
Web Test: Subject TPG201T – 20231 – Web Test S).
✓ The test duration includes the submission time, give yourself enough time to submit.
✓ Copy indicated source code segments (events/ methods) and paste it into the provided questions on
the web test.

NOTE: YOUR TEST WILL BE MARKED FROM EC!

Page 1 of 12
TPG201T – 2023A CT 2
SCENARIO

You are going to develop an application that focusses on some operations regarding the Kruger National
Park.(This applies to tab sheet TWO & THREE)

All applicable data files are stored within the subfolder:


Take note: Open this folder and study the given files.

DB Description

The applicable database for the question has been provided in the folder AppData which is a subfolder
within your project folder.

The applicable DB (in Access) is named: (KrugerPark.accdb)

Study the following database schemas and excerpts of the data from the various applicable tables. Not all records are
shown

The Camps table

Some sample data from the table

Notes on some fields:


-The CampType field is a FK field to the CampTypes table, relating to the CTypeCode field.

The CampTypes Table

Page 2 of 12
TPG201T – 2023A CT 2
Some sample data from the table

Notes on the table


- The CTypeCode is the PK field

The AccomodationTypes table

Some sample data from the table

- This table comprise of an accommodation type code and a description of the applicable accommodation
type.

Page 3 of 12
TPG201T – 2023A CT 2
The Clients table

This table contain data from the clients (i.e., visitors) that has visited the park in the past.

Some sample data from the table

Notes on the table


- The ClientNr is the PK field
- The WildCardNr is a FK field to the ClientWildCards table (Note: Not all clients do have wildcards)

The ClientWildCards table

This table relate to the clients that have wildcards which is a type of Loyalty-card that promotes conservation of
animals

Page 4 of 12
TPG201T – 2023A CT 2
Some sample data from the table

Notes on the table


- The WildCardNr is the PK field
- A WildCard is valid only for a year and must then be renewed
- The WildCardType is a FK field to the WildCard table

The WildCard table

Some sample data from the table

Notes on the table


- The Code field is the PK field of the table and the Fullname is the name of the type of wildcard
- (A WildCard is valid only for a year and must then be renewed)

Table relationships: WildCard - ClientWildCards - Clients

Page 5 of 12
TPG201T – 2023A CT 2
The Rangers table1

This table contain data relating to the different rangers in the park. Each ranger is assigned to a base camp.

Some sample data from the table

Notes on the table


- The RangerID is the PK field
- The ReportCamp field is a FK field to the Camps Table

The Sightings table

1
The Sightings and the adapted Rangers table is taken from the DBE NSC IT Paper 1 exam of 2009. – Recognition Department of
Basic Education
Page 6 of 12
TPG201T – 2023A CT 2
Some sample data from the table

Notes on the table


- The SightingsID is the PK field (it is incremental)
- The RangerID field is a FK field to the Rangers table

The TarrifRates table

This table contain the data of the different rates per night for the different accommodation types at the various camps.

Page 7 of 12
TPG201T – 2023A CT 2
Notes on the table
- The table has a composite primary key comprising of the AccommodationType and CampCode fields
- The BaseRate field is the rate per night for one of the types of accommodation, the BaseRatePAX is
the number of people that may be included in the BaseRate(-price).
- The MaxPax field indicates the maximum number of persons that may be accommodated in the
accommodation

Example - If we evaluate the first record of the table, we could state the following:

At the Berg-en-Dal Rest Camp (KPBED) there are 15 x BA3 (which are Bungalows) units available. Each such unit
costs R1150 per night for 2 visitors (BaseRatePAX) and additional one person could be added (MaxPAX = 3), which
is either a child or adult for a R130 or R260 respectively.

The relationship diagram is presented below:

Page 8 of 12
TPG201T – 2023A CT 2
For the application that you are going to develop the following DataModule has been made and is included as part of
the Project.

You will have to set the Connection Settings using the object inspector to point to the applicable file
KrugerPark.accdb if you want to simulate some real data-display during design time.

For run-time purposes code is provided and included, that will connect the DB automatically!

 The ADOdsTemp dataset is used for temporary processing of queries and records.

 The ADOUseQuery1 and ADOUseQuery2 query components are used to execute queries for
data retrieval.

 The ADOCommand component is used to execute queries for data modification purposes.

Please familiarize yourself with the CommandText properties for each of the DataSet components.

Page 9 of 12
TPG201T – 2023A CT 2
A demo application can be found at Win32\Debug\KrugerParkProjDEMO.exe. Run the demo for a
better understanding. DO NOT run the demo AND your application the SAME time.

The demo will open the first tab-sheet prompting you to activate the DB-connection. By clicking on
the button [Not Connected] the KNP DB will automatically be connected to your TADOConnection
component named: ADOConn. The button changes colour and wording, see figure 2.

Click here to CONNECT to your database.

Figure 1 The DB DEMO application


running, but not yet connected with DB

Figure 2 Application running after DB being connected

After CONNECTION turn to tab sheet ONE.

Question 1 [6]

Write the code for the onclick-event of the [Setup and display] button that will connect necessary
components to produce the result of an SQL query that will show all the records with indicated fields from
the table Rangers. Attend to the following:
- Use the dataset ADOdsTemp!
- Ensure that the DBGrid shows the result as seen in figure 3.
- Take note of the limited fields being displayed.
- Take note of the header names – see especially red ellipses in figure 3.

Page 10 of 12
TPG201T – 2023A CT 2
Figure 3 Rangers data displayed on a DB-grid with the ADOdsTemp component

Turn to tab sheet TWO.

Question 2 [7]

While turning to tab sheet TWO some preparation must be completed before tab TWO becomes visible.

Provide code for the tbsTWOShow()-event that will populate the radio group
box rdgCamps on tab sheet TWO to list all unique “Reporting” camp codes for
the rangers. Run through your dataset ADOdsTemp and extract unique values
from the field “Reporting at Camp” to be listed inside the radio group. See
figure 4.

Note: The action taken here is not SQL query based but is using ADO
constructs.

Add or insert the option at first position: “All Rangers”. If this option is
selected in question 3, then all rangers must be listed, because it would imply
that all camp codes where-ever rangers are reporting were selected.

Figure 4 Unique camp codes listed where rangers are reporting to

Question 3 [9]

When the user changes to tab sheet TWO the radio group box is populated as figure 4 demonstrates. Now
the user is provided the opportunity to take a selection.

If the user would select the camp code “KPLET”, then all rangers that are reporting at this camp must be
listed on the left hand side’s db-grid as seen in figure 5.

The number of rangers that are reporting must also be displayed as “Selected records = __”. See figure 5.

Page 11 of 12
TPG201T – 2023A CT 2
Figure 5 A camp code selected by the user and relevant reporting rangers displayed in db-grid

If the user would select the first option “All Rangers”, then all rangers that are reporting at any camp must
be listed on the left-hand side’s db-grid as seen in figure 6. That means all rangers will be listed.

Figure 6 “All Rangers” selected, i.e. any ranger that reports at any camp.

Take note of the limited fields that are listed from the ranger’s dataset.

Total: [22]

Happy Coding

Page 12 of 12
TPG201T – 2023A CT 2

You might also like