You won't find general purpose code for CRUD. That's absolutely
dependent on your data access architecture and client modell.
Tell us more so that we can help you.
Mike,
I am trying to create a general object that I can use for almost any interface. When I click the Add, Save,Edit,Cancel buttons I would like to have the same result as a smart object Update Panel. I am trying to learn the .net technology and I want to write good code (ProBindingSource, ProDataSet), to not use the old smart object code. I loved the John Sadd presentation for the Navigation Panel and I would like to have the same presentation for the Update Panel or something similar.
Thank you,
Romica Toma
Chief Informatics Office | Bureau de l'informatique
Small Business and Marketplace Services | Services axés sur le marché et les petites entreprises
Industry Canada | Industrie Canada
300 Slater Street, Ottawa ON K1A 0C8 | 300, rue Slater, Ottawa ON K1A 0C8
romica.toma@ic.gc.ca
Telephone | Téléphone 613-952-0403
Facsimile | Télécopieur 613-946-3939
Teletypewriter | Téléimprimeur 1-866-694-8389
Government of Canada | Gouvernement du Canada
There is sample code (almost a full chapter) in the "GUI for .NET"
developers guide. You'll have to modify it to match your way of
dealing with ProDatasets on the UI / Backend and bring it into a
structure that matches your panel concept.
The panel should be rather passive, just sending messages (method
calls/events) to another object manipulating the ProDataset and
BindingSource.
There is sample code (almost a full chapter) in the "GUI for .NET"
developers guide.
I was referring to the "Example of an updatable grid" in the "OpenEdge Development: GUI for .NET Programming" PDF.
This is how I am doing CRUD at the moment.
I use an MVC pattern and drop the CRUD user control onto a form, in this case a person/contact is the application context.
/* ucCRUDTool - user control */
/* contactView constructor - subscribeToButtonEvents(). */
METHOD PUBLIC VOID subscribeToButtonEvents():
ucCRUDTool:addButton:Click:Subscribe( oContactControl:addButtonChoose ).
ucCRUDTool:saveButton:Click:Subscribe( oContactControl:saveButtonChoose ).
ucCRUDTool:deleteButton:Click:Subscribe( oContactControl:deleteButtonChoose ).
ucCRUDTool:cancelButton:Click:Subscribe( oContactControl:cancelButtonChoose ).
ucCRUDTool:searchButton:Click:Subscribe( oContactControl:searchButtonChoose ).
RETURN.
END METHOD.
/* contactControl methods - */
METHOD PUBLIC VOID addButtonChoose(o AS System.Object, e AS System.EventArgs):
oContactModel:addRecord(). /* hContactBuffer:buffer-create() , etc */
END METHOD.
In the model, the view has previously registered as an observer and is notified appropriately:
for each ttObserver:
cast(ttObserver.oObserver, interface.iObserver):addRecord().
end.
METHOD PUBLIC VOID saveButtonChoose(o AS System.Object, e AS System.EventArgs):
oContactView:assignRecord().
oContactModel:saveRecord().
END METHOD.
METHOD PUBLIC VOID deleteButtonChoose(o AS System.Object, e AS System.EventArgs):
IF oContactView:preDeleteRecord() THEN
oContactModel:deleteRecord().
END METHOD.
METHOD PUBLIC VOID cancelButtonChoose(o AS System.Object, e AS System.EventArgs):
oContactModel:cancelChanges().
END METHOD.
METHOD PUBLIC VOID searchButtonChoose(o AS System.Object, e AS System.EventArgs):
oContactView:searchKeyPressed().
END METHOD.
Thank you for your answer.
What I want, is the code for the methods addRecord(), saveRecord(), deleteRecord() and cancelChanges().
Thank you.