Order Form Project

0.e last sonic cnsily explo d vviih the simple components that we Viqvc. diDcuootd oq far, and titer's an appli,cation that uses a parent-child master-detail relationship between two or more tables. To explore this topic, we will use the OrderForm project. I. Start a project and create a form that is similar to that shown in Figure 5.8. You are going to use two Tables, two DataSources, and two DBGridsJ Save the project. i h . x -.i > ' . - ' ' - ' ss 3i& Sffs ) -iS v-v.' - . - . - - - - -...

TData Source Events

There are three event handlers exposed by the TDataSource class Each of the event handlers fires on a change in the dataset to which it is connected. It does not reflect any change in the DataSource the control remains a simple intermediary The OnDataChange event is triggered by the cursor moving to the next or previous record any method that results in a change in the cursor position will trigger this event. This event is especially useful for ma' ally synchronizing components. Whenever the...

The Dataset Objects

A dataset is the base building block of any database application. These are the objects that contain or access the data the facts that we are attempting to manage. The most immediately familiar dataset object the table, a structure that we have discussed at length in the precei pages. There are four components on the data access palette that are derived from the TDataSet base class Table, Query, Stored Procedure, and NestedTable. Before examining the individual classes, the uncle ing class from...

Putting Stored Procedures td Work

We will make use of the Local Intel Basel Server that ships with some versions of Delphi to explore the functioning of the StoredProd component and stored procedures in general. The project that we will build is called the Project Manager, and it works with the sample InterBase files in the IBLocal darabase. If you have not installed the LIBS, this database will not appear in the Database Explorer. Remember that the stored procedures are a part of the metadata of the database, so all of the...

Key Properties

The StoredProc component surfaces a familiar set of properties, all of which are detailed in Figure 5.10. Since the functionality is based on the remote server, there is little for the component to do except point to it and pass the appropriately formatted parameters. Determines if the stored procedure is to be executed. This setting determines when the event is fired. The name of the database to which this stored procedure belongs. The text string defining the current filtering condition. This...

OnCol Enter

The OnColEnter event fires when the focus shifts into a new cell in the grid including navigation by keyboard or mouse click. OnColExit events fire when the focus is in the process of leaving the cell. This event fires when dragging with the mouse moves a column. OnColumnMoved occurs just after the column has been moved. This event is provided to give the application an opportunity to repaint a cell. The OnEditButtonClick event fires when the ellipses button on a drop-down or pick list column...

DBCheck Box Component

The DBCheckBox component is a data-aware check box control used for input and representation of Boolean or other logical fields in a dataset. Unique to this control is that it does not strictly require that the values in the database be True or False. Using the ValueChecked and ValueUnchecked properties, your application can select any pair of characters or strings to represent the two states of the control. Using the attribute based on the values that best represent the data you are modeling...

The DBText Component

The DBText component is a data-aware version of the standard Label control and is used to display the contents of a dataset field when they will not be edited. By its nature, the representation of the data is read-only, making this control an excellent choice for displaying the data with a high degree of security, A common use for DBText is to display a key value, such as a customer account number or ID, items that cannot be modified without disrupting the relational integrity of the database....

The Nested Tablel Component TNested Tabie

The records in a nested detail set are represented in Delphi by nested datasetsl accessed by the TNestedTabld component. This type of data is found in Oracle 8 relations only and cannot be created through Delphi. The field's NestedDataSet property contains a reference to the nested datasetj BDE functionality is extended to the access and manipulation I 54 Port -The Delphi Database Tools of the nested table data. The nested table then has most of the functionality of a single table component...

Session Name

The Borland Database Engine uses a Session object to wrap all of the database connection, drivers, cursor, queries, etc., under a single name and separate them from other applications' use of the engine. By defaulr, every database application creates an object called Session and the BDE maintains a list of all of these objects called Sessions. The property SessionNamei allows you to associate a new session name with this table. You will create new session objects only under exceptional...

Putting DBGrid and DBNavigator to Work

The project that we are going to build will be expanded throughout this chapter, adding capabilities as appropriate to the components being discussed. The program is a tool for the Portland Office of Theaters and Arenas which is going to be managing the Blue Sky Sporting Festival. We will utilize two tables provided by Borland in the DBDEMOS database in the development of the application. We are going to begin simply, placing the tables into grids and associating the navigation buttons. Chapter...

Putting DBLookup UstBo and DB Lookup Comb oBox to Work

After completing the sample project above you have a good working knowledge of how lookup fields work and the concept behind them based on some matching column between two dataset objects, other columns from that row can be displayed. The two data-aware lookup controls work on the same principle with one great advantage They are able to modify the contents of the underlying data set J This lets you look up the entries for a field from another dataset and build consistent data into the column....

The UpdateSQL Component TUpdateSQL

We discussed cached updates earlier in the context of the CachedUpdates property published by the dataset components. When cached updates are enabled, data is retrieved from a local or remote table and stored in local memory All operations that occur against the data work against this local dataset. When the modifications are written to the remote dataset, they are written as a large block rather than individually. This strategy serves to reduce transaction times and minimize network traffic...

Putting thd Database Component to Work

A demonstration of the usefulness of the Database component requires that you follow this project with an idea towards improvements that can be made in your applications. We will start by creating a local alias that is controlled from within the application rather than through the BDE configuration files. 1. Start a new application and save it. Name the unit file dbaseu.pasl and the project file dbasep.dprj 2. Place a Database component on the form. You may enter all of the property values...

The Query Component TQuery

The Query component is similar in nature to the Table component it provides a method of accessing table data from a wide variety of sources and making it available to the application. What makes it different from the table is that it uses SQL SELECT statements to build the dataset that it displays.

DBNavigator Events

Two events are native to the DBNavigator class, both allowing you to trap the push of one of its buttons and initiate any special processing that you want to implement. The BeforeAction fires when a button on the navigator is clicked but immediately before the default action for that particular button is executed. is fired when any type of click event occurs. This includes a mouse click, the spacebar being pressed when the navigator has focus, or the Btn Click method being called. The default...

OnFilter Record

Chapter 5 Data Access with Delphi The OnFilterRecord event fires each time a new record becomes the current record and filtering is enabled. This event handler is included so that you can set a filter condition that cannot be set in the Filter property due to its complexity. Each record is tested against this code to determine if the data is visible to the application. This event is fired when your application adds a new record to the dataset. Another of the error handling events, OnPostError...

The DBEdit Component

DBEdit is the basic building block of any type of data entry application This component is limited to a single line of text and both displays and opens the dataset field to modification. DBEdit offers some degree of control over the formatting of the data being input and displayed using a number of property settings. Similar to the previous component, DBEdit is a data-aware version of the TEdit class. Review the data type that needs to be supported to determine if this is the appropriate...

DBGrid

All of the fields, with the exception of the DBImage, are DBText controls so that they cannot be modified. 7. Set the SelectedColor property to clWhite so that the current record will really stand out on the screen. 8. Finally, this application will use the OnKeyPress event handler to emulate the touch screen. We will trap for the B bar key in the handler and simply pop up a message. Add the following code to the event handler procedure procedure TForml .DBCtrlGr id lKeyPress Sender TObject var...

The DBLookup ListBox and DBLookup ComboBox Components

This pair of components is so similar in nature that it makes sense to discuss them in tandem. DBLookupListBox and DBLookupComboBox are data-aware controls that build their display items lists from either of two sources The data can come from a lookup field defined in a dataset or from a secondary data source altogether. The controls present the user with a limited list of choices with which to fill the associated dataset field. Physically, these controls are the same as their non-lookup...

The DBNavigator Component

The DBNavigator control gives the users of your application a simple and friendly tool for navigating through the datasets used by your application. In addition to its navigational abilities, the DBNavigator provides a wealth of tools for manipulating the data by performing insertions, deletions, confirmation of the changes, or cancellation of the Chapter 6--Delphi's Data-Aware Components transaction. The toolbar takes the familiar shape of a VCR button set, giving the user visual clues as to...

Param Check

The ParamCheck property determines if the parameter list for the SQL statement is cleared and rebuilt when the SQL property is modified during execution of the application. The SQL property is easily modified during execution to run different SQL statements. If the statement is modified, it is important that the corresponding parameter list match the new query. To ensure that this occurs, the parameter list is cleared and rebuilt based on the current contents of the Params property. The Params...

The Session Component TSession

The Session component, like the Database, is created by default to manage the database connections in any Delphi database application. A session represents all of the database connections, drivers, cursors, queries, etc., that are activated as part of an application. All database and dataset components are associated with the automatically generated default session component, originally named Session. All sessions within an application are in turn automatically managed within a list called...

The Batch Move Component TBatch Move

Moving quantities of data records from one table to another is a corn-mon operation and Delphi offers two ways of performing this task. The first is to use the Table component's BatchMove method. This method is an import process in which the calling table seeks to add records from another source. The method takes two parameters the name of the source table from which the rows will be extracted and the mode. The use of the BatchMove method is limited, however, in comparison to the functionality...

OnEdit Error

The before and after events for TDataSet descendants surround a corresponding interaction with the dataset. For example, we have BeforeCancel and AfterCancel events. The event that will trigger both of these events is a request to cancel changes to a row. The BeforeCancel event is fired after the cancellation message is sent but before it is executed. The AfterCancel event is fired after the request has been executed. By utilizing the before and after events, you can wrap and control nearly...

Putting theBatch Move Component to Work

The BatchMove method and component are enormously useful addito your programming repertoire. For all of the additional functionality that the component offers, it is relatively simple to implement. The Copy Machine project that is built in the following steps wi experiment with the functions in two segments. The first will simply demonstrate the component and its copy mode. After this has been done, we will work with some of the error handling abilities of BatchMove. Chapter 5 Dotal Access with...

The DBCtrl Grid Component

Saving the DBCtrlGrid for last makes the most sense, as the component itself is a container for a select group of the other data-aware controls. DBCtrlGrid begins with the fundamental concept of the grid, that is, to display a number of columns of numerous rows simultaneously. This data is configured in a very familiar table layout that conveys the information to the user simply and clearly once they have divined the relationship between the rows and columns. The control grid begins with this...

The DBRadio Group Component

The DBRadioGroup component is a data-aware version of the RadioGroup control. Similar to the data-aware list components, it presents the user with a limited choice of selections for a data field. The user selects the value that they want to enter for the field by select ing one of a group of radio buttons. A radio button interface should only be used in situations where the number of choices is very limited. The mutually exclusive nature and default selection options of these controls require...

The DBMemo Component

The DBMemo component is the brother to the DBImage data-aware control it displays BLOB data from the associated database field. The BLOB data supported by this control is large blocks of text in Memo fields. Memo data is free-form text in which the user has the benefit of a variable length field. With no constraint placed on the maximum size of the field, the user is able to maintain lengthy collections of text, updating it as necessary. The text contained in the field can be subject to a...

The DBRich Edit Component

The DBRichEdit component is a data-aware control that can display formatted text stored in BLOB fields. Rich Text describes text fields that support the formatting of individual characters, words, and paragraphs. Text searching and printing functions are supported by Rich Text controls and by default they support the following types of formatting Font attributes such as typeface, size, color, etc. Text alignment, tabs, indentation, and list numbering The conversion of Rich Text to plain text...

Putting DBCtrl Grid to Work

The DBCtrlGrid is an esoteric component rife with possibilities, so any minor demonstration is going to seem insignificant. While this is certainly true, the ticket sales demo will, at the very least. give you an idea of how the component works so that you might consider it as a solution to your next design. The application that we are going to build is the last piece we will construct for the Venue Manager application. The program written here is a stand-alone application meant to run on a...

Hide Selection

The DBRichEdit component allows selection of blocks of text either with the mouse or through standard Windows keyboard methods and_ marks the text in the standard fashion with a colored block highlight it. Depending on the setting in the HideSelection property this selection-marking may remain or disappear when the focus shifts to another control. Setting this property to True will cause the selection marking to be visible only when the focus remains on this component. When the visual cue of...