USING Progress.Lang.*.
BLOCK-LEVEL ON ERROR UNDO, THROW. CLASS dsCustomer: {"dsCustomer.i"} DEFINE DATA-SOURCE srcCustomer FOR Customer. METHOD PUBLIC VOID ReaddsCustomer( INPUT filter AS CHARACTER, OUTPUT DATASET dsCustomer): THIS-OBJECT:applyFillMethod (INPUT filter). END METHOD. METHOD PUBLIC VOID CreatedsCustomer(INPUT-OUTPUT DATASET dsCustomer): THIS-OBJECT:commitCustomers(INPUT "", ROW-CREATED). END METHOD. METHOD PUBLIC VOID UpdatedsCustomer(INPUT-OUTPUT DATASET dsCustomer): THIS-OBJECT:commitCustomers(INPUT "", ROW-MODIFIED). END METHOD. METHOD PUBLIC VOID DeletedsCustomer(INPUT-OUTPUT DATASET dsCustomer): THIS-OBJECT:commitCustomers(INPUT "", ROW-DELETED). END METHOD. METHOD PRIVATE VOID commitCustomers(INPUT pcFieldMapping AS CHARACTER, INPUT piRowState AS INTEGER ): DEFINE VARIABLE skipList AS CHARACTER NO-UNDO. BUFFER eCustomer:ATTACH-DATA-SOURCE (DATA-SOURCE srcCustomer:HANDLE, pcFieldMapping). FOR EACH eCustomer. BUFFER eCustomer:MARK-ROW-STATE (piRowState). IF piRowState = ROW-DELETED THEN DELETE eCustomer. END. /* NOTE: ** For the ROW-CREATED case, the database has a trigger that generates ** the key value for the new CustNum field. The name of this field is ** passed to SAVE-ROW-CHANGES( ) so it will not overwrite the ** database-generated value with the unneeded input value. */ IF piRowState = ROW-CREATED THEN skipList = "CustNum". FOR EACH beCustomer: BUFFER beCustomer:SAVE-ROW-CHANGES(1, skipList). END. FINALLY: BUFFER eCustomer:DETACH-DATA-SOURCE(). RETURN. END FINALLY. END METHOD. METHOD PRIVATE VOID applyFillMethod(INPUT pcWhere AS CHARACTER): EMPTY TEMP-TABLE eCustomer. /* Get rid of any existing data */ BUFFER eCustomer:ATTACH-DATA-SOURCE(DATA-SOURCE srcCustomer:HANDLE). IF pcWhere NE "" AND pcWhere NE ? THEN DATA-SOURCE srcCustomer:FILL-WHERE-STRING = pcWhere. DATASET dsCustomer:FILL(). FINALLY: BUFFER eCustomer:DETACH-DATA-SOURCE(). DATA-SOURCE srcCustomer:FILL-WHERE-STRING = ?. RETURN. END FINALLY. END METHOD. END CLASS. |
DEFINE TEMP-TABLE eCustomer NO-UNDO BEFORE-TABLE beCustomer
FIELD CustNum AS INTEGER FIELD Name AS CHARACTER FORMAT "X(20)" FIELD Address AS CHARACTER FIELD Phone AS CHARACTER FIELD SalesRep AS CHARACTER FIELD CreditLimit AS DECIMAL FIELD Balance AS DECIMAL FIELD State AS CHAR FIELD numOrders AS INT INDEX CustNum IS UNIQUE PRIMARY CustNum INDEX Name NAME. DEFINE DATASET dsCustomer FOR eCustomer. |