Board index » delphi » Auditing file changes in D1 w/ PDox files

Auditing file changes in D1 w/ PDox files

This is a multi-part message in MIME format.
--------------E96A77C59BA09B269A9FDAD2
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I need an elegant way to track changes made to a record before the
record is posted, so that I can generate a transaction when critical
fields are altered, such as a serial or lot number.

I know that I can put a separate dataset on the form and retrieve the
original record separately and do a compare, but this seems a waste of
resources.

Any ideas would be appreciated.

--------------E96A77C59BA09B269A9FDAD2
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for John Wollner
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             John Wollner
n:              Wollner;John
org:            Wollner Associates
email;internet: jwoll...@ix.netcom.com
title:          President
x-mozilla-cpt:  ;0
x-mozilla-html: TRUE
end:            vcard

--------------E96A77C59BA09B269A9FDAD2--

 

Re:Auditing file changes in D1 w/ PDox files


Quote
John Wollner wrote:

> I need an elegant way to track changes made to a record before the
> record is posted, so that I can generate a transaction when critical
> fields are altered, such as a serial or lot number.

> I know that I can put a separate dataset on the form and retrieve the
> original record separately and do a compare, but this seems a waste of
> resources.

> Any ideas would be appreciated.

>     ---------------------------------------------------------------

>                                Name: vcard.vcf
>               Part 1.2         Type: text/x-vcard
>                            Encoding: 7bit
>                         Description: Card for John Wollner

With cached updates, you have access to the old and new values at the
time the updates are applied.

--
The reason people get lost in thought...
is because its unfamiliar territory.

------------------------------------
Email ID: cih.nott...@mindspring.com
(remove the '.notthis')

Re:Auditing file changes in D1 w/ PDox files


This is a multi-part message in MIME format.
--------------29143BEC1D097A9AAB5795DA
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Quote
Craig wrote:
> With cached updates, you have access to the old and new values at the
> time the updates are applied.

> --
> The reason people get lost in thought...
> is because its unfamiliar territory.

> ------------------------------------
> Email ID: cih.nott...@mindspring.com
> (remove the '.notthis')

Correct me if I'm wrong, but cached updates are only available in D2.
The application I am working with is D1.  Any other suggestions?

--------------29143BEC1D097A9AAB5795DA
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for John Wollner
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             John Wollner
n:              Wollner;John
org:            Wollner Associates
email;internet: jwoll...@ix.netcom.com
title:          President
x-mozilla-cpt:  ;0
x-mozilla-html: TRUE
end:            vcard

--------------29143BEC1D097A9AAB5795DA--

Re:Auditing file changes in D1 w/ PDox files


Quote
John Wollner wrote:

> I need an elegant way to track changes made to a record before the
> record is posted, so that I can generate a transaction when critical
> fields are altered, such as a serial or lot number.

> I know that I can put a separate dataset on the form and retrieve the
> original record separately and do a compare, but this seems a waste of
> resources.

Here's what I use.  At this time, it only can track the changes made to
TDBEdit fields, not combo boxes, etc...  Also, it doesn't track the
original value of the record, only the new value.  However, the original
value would be stored due to the new value of the original change (ie it
tracks all the changes, so looking back to the previous record will give
you the original value before the change).  I have my audit table keyed
on the clients tax id number and the changed timestamp, so looking back
to the previous record is quite easy.

Hope this helps...

procedure TForm1.Table1AfterPost(DataSet: TDataset);
var
  I: Integer;

begin
  for I := 0 to ComponentCount -1 do
    if Components[I] is TDBEdit then
      if TDBEdit(Components[I]).Modified = True then begin
        AuditTbl.Append;
        AuditTbl.FieldByName('Changed Client Tax ID').AsString :=
TaxIDEdit.Text;
        AuditTbl.FieldByName('Changed Timestamp').AsString :=
DateTimeToStr(Now);
        {the UserIDLabel.Caption is set at an earlier time}
        AuditTbl.FieldByName('Operator ID').AsString :=
UserIDLabel.Caption;
        AuditTbl.FieldByName('Field Name').AsString :=
TDBEdit(Components[I]).DataField;
        AuditTbl.FieldByName('New Value').AsString :=
TDBEdit(Components[I]).Text;
        AuditTbl.Post;
        TDBEdit(Components[I]).Modified := False;
      end;
 end;

Other Threads