Professional Documents
Culture Documents
TPG201T CT2 2023a
TPG201T CT2 2023a
number
Practical
FACULTY: INFORMATION AND COMMUNICATION TECHNOLOGY
DEPARTMENT: Computer Science
Technical Programming 201T (C++)
CT2
TPG201T
%
___________________
Signature Campus Lecturer Group Venue/PC#
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)
DB Description
The applicable database for the question has been provided in the folder AppData which is a subfolder
within your project folder.
Study the following database schemas and excerpts of the data from the various applicable tables. Not all records are
shown
Page 2 of 12
TPG201T – 2023A CT 2
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.
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
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.
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
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.
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.
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
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.
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