Try OpenEdge Now
skip to main content
GUI for .NET Programming
Binding ABL Data to .NET Controls : Example of an updatable grid : Definitions
 

Definitions

Now that you have seen the procedure in action, take a look at the code. As shown here, the procedure starts with the expected definitions for the UI controls, the ProBindingSource, the ABL data source object, and the function prototypes.
/* UpdatableDataBindingGrid.p
   Bind to a ProDataSet for the Customer, Order, and Orderline tables. Display
the records hierarchically in an Infragistics UltraWinGrid. Add event logic
for adding, updating, and deleting. */

/* USING statements must be the first in the procedure. Note that you could
   have USING statements for the OpenEdge classes also.*/
USING System.Windows.Forms.*.
USING Infragistics.Win.UltraWinGrid.*.

DEFINE VARIABLE rMainForm   AS Progress.Windows.Form       NO-UNDO.
DEFINE VARIABLE rUpdateGrid AS UltraGrid                   NO-UNDO.
DEFINE VARIABLE rBindS      AS Progress.Data.BindingSource NO-UNDO.
DEFINE VARIABLE rControls   AS Control+ControlCollection   NO-UNDO.

DEFINE VARIABLE hTTCustomer  AS HANDLE                     NO-UNDO.
DEFINE VARIABLE hTTOrder     AS HANDLE                     NO-UNDO.
DEFINE VARIABLE hTTOrderLine AS HANDLE                     NO-UNDO.

DEFINE TEMP-TABLE ttCustomer NO-UNDO
    LIKE Customer  BEFORE-TABLE ttCustomerB.
DEFINE TEMP-TABLE ttOrder NO-UNDO
    LIKE Order     BEFORE-TABLE ttOrderB.
DEFINE TEMP-TABLE ttOrderLine NO-UNDO
    LIKE OrderLine BEFORE-TABLE ttOrderLineB.

DEFINE DATASET dsCustOrder FOR ttCustomer, ttOrder, ttOrderLine
  DATA-RELATION FOR ttCustomer, ttOrder
    RELATION-FIELDS(CustNum, CustNum)
  DATA-RELATION FOR ttOrder, ttOrderLine
    RELATION-FIELDS(OrderNum, OrderNum).

/* Define the data-sources with their queries */
DEFINE DATA-SOURCE dCust    FOR Customer.
DEFINE DATA-SOURCE dOrder   FOR Order.
DEFINE DATA-SOURCE dOrdLine FOR OrderLine.

FUNCTION GetCurrentQuery   RETURNS HANDLE
  (INPUT cBufferName AS CHARACTER) FORWARD.
FUNCTION DeleteRow         RETURNS INTEGER (INPUT cBufferName AS CHARACTER,
  INPUT hQuery AS HANDLE, INPUT rCurrentRow AS UltraGridRow) FORWARD.
FUNCTION CreateRow         RETURNS INTEGER
  (INPUT cBufferName AS CHARACTER) FORWARD.
FUNCTION ProcessRowChanges RETURNS LOGICAL
  (INPUT cBufferName AS CHARACTER) FORWARD.
The next section sets up the ProBindingSource, rBindS, the ABL data source object, dsCustOrder, and their navigation.
Note: For convenience, this example relies on the Sports2000 database trigger to prevent the user from deleting a Customer record that still has associated Order records.
/* Attach the data-sources */
BUFFER ttcustomer:ATTACH-DATA-SOURCE(DATA-SOURCE dCust:HANDLE,?,?,?).
BUFFER ttorder:ATTACH-DATA-SOURCE(DATA-SOURCE dOrder:HANDLE,?,?,?).
BUFFER ttorderline:ATTACH-DATA-SOURCE(DATA-SOURCE dOrdLine:HANDLE,?,?,?).

/* Fill the dataset from the data-sources */
DATASET dsCustOrder:FILL().
hTTCustomer  = TEMP-TABLE ttCustomer:HANDLE.
hTTOrder     = TEMP-TABLE ttOrder:HANDLE.
hTTOrderLine = TEMP-TABLE ttOrderLine:HANDLE.

hTTCustomer:TRACKING-CHANGES  = YES.
hTTOrder:TRACKING-CHANGES     = YES.
hTTOrderLine:TRACKING-CHANGES = YES.

/* Create the binding source and its navigation. */
DEFINE VARIABLE hTopQuery AS HANDLE NO-UNDO.
DEFINE VARIABLE hDataSet  AS HANDLE NO-UNDO.
DEFINE VARIABLE hTT       AS HANDLE NO-UNDO.

hDataSet  = DATASET dsCustOrder:HANDLE.

hTopQuery = hDataSet:TOP-NAV-QUERY(1). /* navigation query for customer */
hTopQuery:QUERY-PREPARE("PRESELECT EACH ttCustomer").
hTopQuery:QUERY-OPEN.  

hTT = BUFFER ttCustomer:HANDLE.

/* Create the binding source, excluding the ShipDate, PromiseDate, and Carrier
   fields. */
rBindS = NEW Progress.Data.BindingSource(hDataSet, hTT, "*",
  "ttOrder.ShipDate,ttOrder.PromiseDate,ttOrder.Carrier").