Try OpenEdge Now
skip to main content
Introducing the Progress Developer Studio for OpenEdge Visual Designer
Creating the Purchase Order Window : Adding the data binding code
 

Adding the data binding code

The data binding code includes open and close query methods, updates to the CONSTRUCTOR and DESTRUCTOR, and also a variable definition for the service adapter.
To add the data binding code:
1. Add the open and close query methods by copying and pasting the following code before the DESTRUCTOR statement:
METHOD PRIVATE VOID openQuery():
bindingSource1:handle = fServiceAdapter:getDatasetHandle().
btnFirst:Enabled = FALSE.
btnPrev:Enabled = FALSE.
btnNext:Enabled = TRUE.
btnLast:Enabled = TRUE.
btnSave:Enabled = FALSE.
btnCancel:Enabled = FALSE.
END METHOD.
METHOD PRIVATE VOID closeQuery():
fServiceAdapter:closeQuery().
END METHOD.
2. Update the existing CONSTRUCTOR and DESTRUCTOR methods by adding the code shown in bold:
CONSTRUCTOR PUBLIC purchaseOrderForm ( ):
SUPER().
fServiceAdapter = NEW openedge.tutorial.services.ServiceAdapter("PurchOrder").
InitializeComponent ( ).
OpenQuery().
CATCH e AS Progress.Lang.Error:
    UNDO, THROW e.
END CATCH.
END CONSTRUCTOR.

DESTRUCTOR PUBLIC purchaseOrderForm ( ):
closeQuery().
IF VALID-OBJECT(components) THEN DO:
CAST(components, System.IDisposable):Dispose().
END.

END DESTRUCTOR.
3. Save the file.