DELPHI Catch Update, Delete, Create event from a TFDMemTable -
i create descendant component tfdmemtable. need catch event on update data (create, update, delete)... add more specific treatments.
unit _dataaccess; interface uses system.sysutils, system.types, system.uitypes, system.classes, system.variants, system.rtti, firedac.stan.intf, firedac.stan.option, firedac.stan.param, firedac.stan.error, firedac.dats, firedac.phys.intf, firedac.dapt.intf, data.db, firedac.comp.dataset, firedac.comp.client, rest.response.adapter, rest.client, system.json, rest.json,fmx.types, fmx.controls, fmx.forms, fmx.dialogs, _toaster; type // events type firedac.comp.client tfdupdaterecordevent = procedure (asender: tdataset; arequest: tfdupdaterequest; var aaction: tfderroraction; aoptions: tfdupdaterowoptions) of object; tfdupdateerrorevent = procedure (asender: tdataset; aexception: efdexception; arow: tfddatsrow; arequest: tfdupdaterequest; var aaction: tfderroraction) of object; tfdafterapplyupdatesevent = procedure (dataset: tfddataset; aerrors: integer) of object; tfdreconcileerrorevent = procedure(dataset: tfddataset; e: efdexception; updatekind: tfddatsrowstate; var action: tfddaptreconcileaction) of object; tdataaccess = class(tfdmemtable) private ftoaster : ttoaster; // component create toaster public constructor create(aowner: tcomponent); override; function doapplyupdates(atable: tfddatstable; amaxerrors: integer); override; published property activestoredusage; { tdataset } property active; property autocalcfields; property beforeopen; property afteropen; property beforeclose; property afterclose; property beforeinsert; property afterinsert; property beforeedit; property afteredit; property beforepost; property afterpost; property beforecancel; property aftercancel; property beforedelete; property afterdelete; property beforescroll; property afterscroll; property beforerefresh; property afterrefresh; property oncalcfields; property ondeleteerror; property onediterror; property onnewrecord; property onposterror; property fieldoptions; property filtered; property filteroptions; property filter; property onfilterrecord; property objectview default true; property constraints; property datasetfield; property fielddefs stored fstoredefs; { tfddataset } property cachedupdates; property filterchanges; property indexdefs stored fstoredefs; property indexes; property indexesactive; property indexname; property indexfieldnames; property aggregates; property aggregatesactive; property constraintsenabled; property mastersource; property masterfields; property detailfields; property onupdaterecord; property onupdateerror; property onreconcileerror; property beforeapplyupdates; property afterapplyupdates; // tfddataset --> : tfdafterapplyupdatesevent; property beforegetrecords; property aftergetrecords; property aftergetrecord; property beforerowrequest; property afterrowrequest; property beforeexecute; property afterexecute; property fetchoptions; property formatoptions; property resourceoptions; property updateoptions; { tfdadapteddataset } property localsql; property changealerter; property changealertname; { tfdcustommemtable } property autocommitupdates; property adapter; property storedefs; property toaster : ttoaster read ftoaster write ftoaster; end; procedure register; implementation constructor tdataaccess.create(aowner: tcomponent); begin inherited create(aowner); // self.onnewrecord := // self.onupdaterecord := ondoapplyupdates; self.onafterapplyupdates := doapplyupdates; // self.onposterror := end; function tdataaccess.doapplyupdates(atable: tfddatstable; amaxerrors: integer); override; var t : ttoaster; begin inherited; t := ttoaster.create(application.activeform); t.show('this toaster test when apply post modifications'); end; end;
i did many try. last try made, it's not working either. when can compile without errors, event code never executed, if data updated in stringgrid.
i think i'm doing wrong way. can me please ? missing something...
i catch events when data updated keep inherited behaviour , add toast panel inform user such "data saved successfully".
Comments
Post a Comment