RTL.BDShoppingList Sample

From RAD Studio Code Examples
Jump to: navigation, search

BDShoppingList is a sample application with a client-server architecture where the server application keeps a table of products with the current and required units in stock, and a client application lets you increase the current units in stock remotely in batches of 100 units until you reach the required stock of a product.


You can find the BDShoppingList project at:

  • Start | Programs | Embarcadero RAD Studio Alexandria | Samples and then navigate to either of the following folders:
    • CPP/RTL/Tethering/BDShoppingList
    • Object Pascal/RTL/Tethering/BDShoppingList
  • Subversion Repository:
    • You can find Delphi and C++ code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.


This sample applications folder provides a client project and a server project. The projects are designed so that you can run any number of instances of the client project, but only one server.

In the server application (TetherDatabase) you have a grid with a table of products, and fields on top of the grid that you can use to edit records from the grid.


In the client application (TetherDBClient) you have a list of products without enough units in stock. There is also a Connect button that you can use to connect to the server. When you connect to the server, a label shows the name of the connected server.


How to Use the Sample

  1. Navigate to the location given above and open TetherShopping.groupproj.
  2. On the Projects Window, double-click TetherDatabase to activate the server application.
  3. Select Run > Run to run the server application.
  4. On the Project Manager, double-click TetherDBClient to activate the client application.
  5. Select Run > Run to run the client application.


Each application in the project group contains a single source file that contains the class for the main form of the application.


Each application defines a single class that implements the main form of the application.


Server Application

  • The application defines the following methods:
    • CreateShoppingList iterates CDSProducts, builds a string list with the information from CDSProducts that clients need, and saves the information as the value of ResShoppingList.
  • The application defines the following event handlers:
    • actGetListExecute calls CreateShoppingList.
    • CDSProductsAfterPost calls CreateShoppingList.
    • TetherBDTestProfileResourceReceived increases in 100 the number of units in stock of the product with the same ID as the value of the incoming resource.
  • The application defines several controls (input fields and a grid) that provide read and write access to the data in CDSProducts.
  • The application defines the following nonvisual components:

Client Application

  • The application defines the following methods:
  • The application defines the following event handlers:
    • TetherBDTestProfileResources0ResourceReceived clears the list and adds new items to ListView1 with the updated data received on the ResShoppingList mirror resource.
    • tmCheckConnectionTimer calls CheckRemoteProfiles.
    • TetherBDTestManagerEndAutoConnect calls CheckRemoteProfiles.
    • TetherBDTestManagerRemoteManagerShutdown calls CheckRemoteProfiles.
    • CommandManagerRequestManagerPassword provides the password of the remote server application: "TetherBDTest".
  • The application defines the following controls:
    • Button1 (Connect) starts tmCheckConnection and calls AutoConnect on TetherBDTestManager.
    • When you click a Buy 100 button in ListView1, the list sends the product ID of the list item to the server application.
  • The application defines the following nonvisual components:


See Also