Selasa, 23 Maret 2010

EDIT LOG

EDIT LOG COMPILED BY IWAN,AGUS,UJANG & ME

unit CtrSingle;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
MDSingle, Menus, Db, ImgList, DBActns, ActnList, StdCtrls, Buttons,
wwdbedit, Grids, Wwdbigrd, Wwdbgrid, ComCtrls, Mask, Wwdotdot, Wwdbcomb,
ToolWin, ExtCtrls, ADODB, wwdbdatetimepicker, wwcheckbox, DBCtrls, AppConstt;

type
TfmCtrSingle = class(TfmMDSingle)
paBukti: TPanel;
laNoBuk: TLabel;
laTgl: TLabel;
laNoCtrl: TLabel;
laNoRef: TLabel;
deNoBuk: TwwDBEdit;
deTgl: TwwDBDateTimePicker;
deNoCtrl: TwwDBEdit;
deNoRef: TwwDBEdit;
paKet: TPanel;
quMASTER: TADOQuery;
quDETAIL: TADOQuery;
bbBukti: TBitBtn;
quMASTERKode: TStringField;
quMASTERNoBuk: TStringField;
quMASTERTgl: TDateTimeField;
quMASTERNoCtrl: TStringField;
quMASTERNoRef: TStringField;
quDETAILKode: TStringField;
quDETAILNoBuk: TStringField;
quDETAILTgl: TDateTimeField;
quDETAILStamp: TDateTimeField;
quDETAILUsr: TStringField;
quDETAILOwner: TStringField;
quDETAILOwnStamp: TDateTimeField;
quMASTERPrinted: TWordField;
quMASTEROtorisasi: TBooleanField;
quMASTEROtoStamp: TDateTimeField;
quMASTEROtoUsr: TStringField;
quMASTERBatal: TBooleanField;
quMASTERBatalStamp: TDateTimeField;
quMASTERBatalUsr: TStringField;
quMASTERStamp: TDateTimeField;
quMASTERUsr: TStringField;
quMASTEROwner: TStringField;
quMASTEROwnStamp: TDateTimeField;
quMASTERLvl: TStringField;
wmdMemo: TwwMemoDialog;
paOptions: TPanel;
cbShow: TComboBox;
cbShowSpecial: TComboBox;
cbOrderKey: TwwDBComboBox;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure quMASTERBeforeInsert(DataSet: TDataSet);
procedure quMASTERAfterInsert(DataSet: TDataSet);
procedure quMASTERBeforeEdit(DataSet: TDataSet);
procedure quMASTERBeforePost(DataSet: TDataSet);
procedure quMASTERAfterPost(DataSet: TDataSet);
procedure quMASTERBeforeDelete(DataSet: TDataSet);
procedure quDETAILAfterInsert(DataSet: TDataSet);
procedure quDETAILBeforePost(DataSet: TDataSet);
procedure quDETAILAfterPost(DataSet: TDataSet);
procedure quDETAILBeforeDelete(DataSet: TDataSet);
procedure acInfoExecute(Sender: TObject);
procedure quDETAILBeforeEdit(DataSet: TDataSet);
procedure quDETAILBeforeInsert(DataSet: TDataSet);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure acOtorisasiExecute(Sender: TObject);
procedure acVoidExecute(Sender: TObject);
procedure cbOrderKeyChange(Sender: TObject);
procedure cbShowChange(Sender: TObject);
procedure cbShowSpecialChange(Sender: TObject);
procedure acLocateExecute(Sender: TObject);
procedure dmKetKeyPress(Sender: TObject; var Key: Char);
protected
FPrinted2, FPrinted3: string;
FARNFormat: TAutoRunNoFmt;
FVoidDetail, FVoidSubDetail: TNotifyEvent;
FOnBeforePost : TDataSetNotifyEvent;
function CheckCanEdit(DataSet: TDataSet): Boolean;
function CheckCanDelete: Boolean;
procedure UpdateDetailNoBuk;
procedure DeleteDetailNoBuk;
procedure SetAutoRunNo;
procedure DoUpdateTotal; virtual; abstract;
procedure VoidDetail(Sender: TObject); virtual;
procedure SaveIntoEditLogBeforePost(DataSet: TDataSet);
procedure SetAllHistoryBeforePost(quQUERY : Array of TADOQuery); virtual; abstract;
private
{ Private declarations }
FBaseNoBuk: string;
FFilterShowSpecial: TFilterRecordEvent;
FEditOptionsProperty: TEditOptionsProperty;
procedure UpdateTotal;
procedure HapusLogDetail;
procedure SetHistoryBeforePost(DataSet: TDataSet);
public
{ Public declarations }
constructor CreateEFTrans(nEditTrust: Byte; sKodeMutasi: string; AutoRunNoFmt: TAutoRunNoFmt;
EditOptionsProperty: TEditOptionsProperty);
end;

implementation

uses AppSet, DataSys, Error, InfoMD, LocateData, MiscFunc, Secure, StdDlg;

{$R *.DFM}

constructor TfmCtrSingle.CreateEFTrans(nEditTrust: Byte; sKodeMutasi: string; AutoRunNoFmt: TAutoRunNoFmt;
EditOptionsProperty: TEditOptionsProperty);
begin
FKodeMutasi := sKodeMutasi;
CreateEditForm(nEditTrust);

{ Assign Form Property }
FARNFormat := AutoRunNoFmt;
FEditOptionsProperty := EditOptionsProperty;

{ Setelah selesai, pindahkan field di bawah ke private }
with quMASTER do
if Assigned(OnFilterRecord) then begin
FFilterShowSpecial := OnFilterRecord;
OnFilterRecord := nil;
end;


{ Assign Masking }
AssignMask(quMASTERNoBuk, FARNFormat.Mask);
end;

{ Form Event }

procedure TfmCtrSingle.FormCreate(Sender: TObject);
var i : integer;
begin
inherited;
{ Set Cara Table dibuka }
quMASTER.Tag := Ord(otRangeMutasi);
quDETAIL.Tag := Ord(otNoCheckLvl);

if not bVoidOtoSecurity then begin
cbShow.Visible := False;
cbOrderKey.Left := cbShowSpecial.Left - cbOrderKey.Width - 1;
end;

with dsInfo do
if DataSet <> nil then
DataSet.Tag := Ord(otOpenOnly);

// with FindGlobalComponent(self.Name) do
for i := 0 to ComponentCount - 1 do
if Components[i] is tADOQuery then
With (Components[i] as TADOQuery) do begin
if (tag <> Ord(otNone)) then begin
FOnBeforePost := BeforePost;
BeforePost := SetHistoryBeforePost;
FOnBeforePost := Nil;
end;
end;
end;

procedure TfmCtrSingle.FormShow(Sender: TObject);
begin
inherited;
cbOrderKey.ItemIndex := 0;
cbShow.ItemIndex := 0;
cbShowSpecial.ItemIndex := 0;

ActiveControl := deNoBuk;
end;

procedure TfmCtrSingle.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin

if (Shift = []) and (Key = VK_F2) and (ActiveControl is TDBMemo) then begin
wmdMemo.DataField := (ActiveControl as TDBMemo).DataField;
wmdMemo.Execute;
end
else

inherited;
end;

procedure TfmCtrSingle.acLocateExecute(Sender: TObject);
begin
// inherited;
PostEdit;
LocateDataShow(False, quMASTER, cbOrderKey.Value);
end;

procedure TfmCtrSingle.acOtorisasiExecute(Sender: TObject);
begin
inherited;
with quMASTER, FEditOptionsProperty do begin
Try Refresh Except End;

if RecordCount > 0 then begin
if quMASTEROtorisasi.Value then
ErrorShow(ERR_DATA_OTO)
else if quMASTERBatal.Value then
ErrorShow(ERR_DATA_CANCELLED)
else if DlgConfirm('Otorisasi dijalankan ?', [mbYES, mbCANCEL]) = mrYES then
try
nCallerID := ID_SUPER;

Edit;
quMASTEROtorisasi.Value := True;
AssignMark(quMASTEROtoUsr, quMASTEROtoStamp);
Post;
finally
nCallerID := ID_EMPTY;
end;
end;
end;
end;

procedure TfmCtrSingle.acVoidExecute(Sender: TObject);
begin
inherited;
with quMASTER, FEditOptionsProperty do begin
Try Refresh Except End;

if RecordCount > 0 then begin
if quMASTERBatal.Value then
ErrorShow(ERR_DATA_CANCELLED)
else if quMASTEROtorisasi.Value and not OtoCanCancel then
ErrorShow(ERR_DATA_OTO)
else if DlgConfirm('Data ini akan dibatalkan ?', [mbYES, mbCANCEL]) = mrYES then
with dmDataSys.acDataSys do
try
nCallerID := ID_SUPER;

try
BeginTrans;

if Assigned(FVoidDetail) then FVoidDetail(Sender);
if Assigned(FVoidSubDetail) then FVoidSubDetail(Sender);

Edit;
quMASTERBatal.Value := True;
AssignMark(quMASTERBatalUsr, quMASTERBatalStamp);
Post;

CommitTrans;
except
RollBackTrans;
raise;
end;
finally
nCallerID := ID_EMPTY;
end;
end;
end;
end;

procedure TfmCtrSingle.acInfoExecute(Sender: TObject);
begin
// inherited;
TfmInfoMD.CreateInfoMD(paCenter, tbInfo, quMASTER, quDETAIL, nil, nil, True, False, FPrinted2, FPrinted3);
end;

procedure TfmCtrSingle.cbOrderKeyChange(Sender: TObject);
begin
inherited;
with cbOrderKey, quMASTER do
try
Screen.Cursor := crHourGlass;
Close;

with SQL do begin
if Pos('ORDER', Text) > 0 then
Delete(Count-1);

if ItemIndex > 0 then
Add('ORDER BY ' + IIf(ItemIndex > 0, cbOrderKey.Value + ', ', '') + 'NoBuk');
end;

Open;
finally
Screen.Cursor := crDefault;
end;
end;

procedure TfmCtrSingle.cbShowChange(Sender: TObject);
begin
inherited;
with cbShow, quMASTER do
try
Screen.Cursor := crHourGlass;

if ItemIndex = OS_ALL then
Filter := ''
else begin
case ItemIndex of
OS_CANCELLED : Filter := 'Batal = 1';
OS_UNCANCELLED : Filter := 'Batal = 0';
OS_AUTHORIZED : Filter := 'Otorisasi = 1 and Batal = 0';
OS_UNAUTHORIZED : Filter := 'Otorisasi = 0 and Batal = 0';
OS_CLOSED : Filter := 'Closed = 1';
end;

Filtered := True;
end;

Try Refresh Except End;
finally
Screen.Cursor := crDefault;
end;
end;

procedure TfmCtrSingle.cbShowSpecialChange(Sender: TObject);
begin
inherited;
with cbShowSpecial, quMASTER do
try
Screen.Cursor := crHourGlass;

if (ItemIndex = TT_ALL) then begin
OnFilterRecord := nil;

if cbShow.ItemIndex = OS_ALL then
Filtered := False;
end
else begin
OnFilterRecord := FFilterShowSpecial;
Filtered := True;
end;

Try Refresh Except End;
finally
Screen.Cursor := crDefault;
end;
end;

procedure TfmCtrSingle.dmKetKeyPress(Sender: TObject; var Key: Char);
begin
inherited;
if (Key = #13) then begin
Key := #0;
Perform(WM_NEXTDLGCTL, 0, 0)
end;
end;

{ Support Routine }

procedure TfmCtrSingle.VoidDetail(Sender: TObject);
var
nRecNo: Integer;
begin
inherited;
with quDETAIL do begin
Try Refresh Except End;
nRecNo := RecNo;
DisableControls;

try
First;

while not Eof do begin
Edit;
FieldByName('Batal').AsBoolean := True;
Next;
end;
finally
RecNo := nRecNo;
EnableControls;
end;
end;
end;

function TfmCtrSingle.CheckCanEdit(DataSet: TDataSet): Boolean;
begin
if nCallerID = ID_EMPTY then begin
Result := False;

with FEditOptionsProperty do
if quMASTERBatal.Value then
ErrorShow(ERR_DATA_CANCELLED)
else if quMASTEROtorisasi.Value and not OtoCanEdit then
ErrorShow(ERR_DATA_OTO)
else if not AfterPrintCanEdit and (quMASTERPrinted.Value > 0) and not FAppInfo.Supervisor and
not OtoUsrCanEdit and not acOtorisasi.Visible then
ErrorShow(ERR_BUKTI_PRINTED)
else if (DataSet.State = dsEdit) and not FAppDef.AutoEdit and (DlgConfirm('Data diubah ?', [mbYES, mbCANCEL]) <> mrYES) then
Abort
else
Result := True;
end
else
Result := True;
end;

function TfmCtrSingle.CheckCanDelete;
begin
Result := False;

with FEditOptionsProperty do
if quMASTERBatal.Value and not CancelCanDel then
ErrorShow(ERR_DATA_CANCELLED)
else if quMASTEROtorisasi.Value and not OtoCanDel then
ErrorShow(ERR_DATA_OTO)
else if not AfterPrintCanEdit and (quMASTERPrinted.Value > 0) and not FAppInfo.Supervisor and
not OtoUsrCanEdit and not acOtorisasi.Visible then
ErrorShow(ERR_BUKTI_PRINTED)
else
Result := ConfirmDelete;
end;

procedure TfmCtrSingle.UpdateDetailNoBuk;
begin
inherited;
UpdateDetail([quDETAIL.SQL[1]], FKodeMutasi, quMASTERNoBuk, quMASTERTgl);
end;

procedure TfmCtrSingle.DeleteDetailNoBuk;
begin
inherited;
DeleteDetail([quDETAIL.SQL[1]], FKodeMutasi, quMASTERNoBuk.Value, quMASTERTgl.Value);
end;

procedure TfmCtrSingle.SetAutoRunNo;
begin
quMASTERNoBuk.Value := GetAutoRunNo(quMASTER.SQL[1], FKodeMutasi, quMASTERNoBuk.Value,
FBaseNoBuk, quMASTERTgl.Value, FARNFormat);

if quMASTERNoRef.Value = FAppDef.AutoNo then
quMASTERNoRef.Value := quMASTERNoBuk.Value;
end;

procedure TfmCtrSingle.UpdateTotal;
var
nRecNo: Integer;
begin
with quDETAIL do begin
nCallerID := ID_SUPER;
nRecNo := RecNo;

try
DisableControls;
First;

quMASTER.Edit;
DoUpdateTotal;
quMASTER.Post;
finally
RecNo := nRecNo;
EnableControls;
nCallerID := ID_EMPTY;
end;
end;
end;

{ Query Master }

procedure TfmCtrSingle.SetHistoryBeforePost(DataSet: TDataSet);
begin
if Assigned(FOnBeforePost) then
FOnBeforePost(DataSet);
SaveIntoEditLogBeforePost(DataSet);
end;


procedure TfmCtrSingle.quMASTERBeforeInsert(DataSet: TDataSet);
begin
inherited;
FBaseNoBuk := quMASTERNoBuk.Value;
end;

procedure TfmCtrSingle.quMASTERAfterInsert(DataSet: TDataSet);
begin
inherited;
quMASTERNoBuk.FocusControl;

quMASTERKode.Value := FKodeMutasi;
quMASTERNoBuk.Value := FAppDef.AutoNo;
quMASTERTgl.Value := Date;
quMASTERPrinted.Value := 0;
quMASTERBatal.Value := False;
quMASTERLvl.Value := FAppInfo.Level;
quMASTEROwner.Value := FAppInfo.UserCode;
end;

procedure TfmCtrSingle.quMASTERBeforeEdit(DataSet: TDataSet);
begin
if nCallerID = ID_EMPTY then begin
inherited;

if InvalidPeriod(quMASTERTgl.Value) then
ErrorShow(ERR_INVALID_PERIOD)
else
CheckCanEdit(DataSet);
end;
end;

procedure TfmCtrSingle.SaveIntoEditLogBeforePost(DataSet: TDataSet);
var MySQL, s, sNoBuk : String;
i : integer;
begin
if not Assigned(TADOQuery(DataSet).FindField('NoBuk')) then exit;
sNoBuk := Quotedstr(TADOQuery(DataSet).FieldByName('NoBuk').AsString);
MySQL := 'Insert into EditLog (NoBuk, Tgl, Usr, Modul, Ket) values ('+sNoBuk+', getdate(), '+
QuotedStr(FAppInfo.UserName)+ ' , '''+Application.MainForm.ActiveMDIChild.Caption+' ('+IIF(TADOQuery(DataSet).Name='quMASTER', 'Header', IIF(TADOQuery(DataSet).Name='quDETAIL', 'Detail', 'Sub Detail')) + ')'', ' ;
s := '';

with TADOQuery(DataSet) do
begin
for I := 0 to FieldCount - 1 do
begin
if Fields[I].FieldKind = fkData then
begin
if Fields[I].DataType = ftString then
begin
With Fields[I] do
if OldValue <> NewValue then begin
if s <> '' then s := s + ', ' ;
s := s + Fields[I].FieldName + ' = ';
Try
s := s + VarToStr(Fields[I].oldvalue)+' -> ' ;
Except
s := s + ' '+' -> ';
End;
s := s + Fields[I].NewValue;
end ;
end
else
if Fields[I].DataType = ftDatetime then// i = 2 then
begin
With Fields[I] do
if Fields[I].FieldName <> 'Stamp' then
if OldValue <> NewValue then begin

if s <> '' then s := s + ', ' ;
s := s + Fields[I].FieldName + ' = ';
Try
s := s + DateTimeToStr(Fields[I].OldValue)+' -> ';
Except
s := s + ' '+' -> ';
End;
s := s + DateTimeToStr(Fields[I].NewValue);
end ;
end
else
begin
With Fields[I] do
begin
if VarToStr(OldValue) <> VarToStr(NewValue) then
begin
if s <> '' then s := s + ', ' ;
s := s + Fields[I].FieldName + ' = ';
Try
s := s + VarToStr(Fields[I].OldValue)+' -> ';
Except
s := s + ' '+' -> ';
end;
s := s + VarToStr(Fields[I].NewValue);
end;
end;
end;
end;
end;
End;

MySQL := MySQL+ ' '' '+s+ ' '' '+ ')';

if trim(s) <> '' then
With TADOQuery.create(nil), SQL do
begin
Try
Connection := dmDataSys.acDataSys;
close;
clear;
add(' '+ MySQL+' ' );
ExecSQL;
Finally
Free;
End;
end;
End;


procedure TfmCtrSingle.quMASTERBeforePost(DataSet: TDataSet);
begin
inherited;
CheckEmptyMask(quMASTERNoBuk);
CheckEmpty(quMASTERTgl);

if InvalidPeriod(quMASTERTgl.Value) then begin
quMASTERTgl.FocusControl;
ErrorShow(ERR_INVALID_PERIOD);
end;
quMASTEROtorisasi.Value := False;
quMASTEROtoUsr.Value := '';
AssignMark(quMASTERUsr, quMASTERStamp);
end;

procedure TfmCtrSingle.quMASTERAfterPost(DataSet: TDataSet);
begin
if nCallerID = ID_EMPTY then begin
inherited;
with dmDataSys.acDataSys do
if InTransaction then CommitTrans;
end;
end;

procedure TfmCtrSingle.quMASTERBeforeDelete(DataSet: TDataSet);
var s,MySQL : String;
I : integer;
judul : string;
begin
inherited;
judul := Screen.ActiveForm.Caption;
if InvalidPeriod(quMASTERTgl.Value) then
ErrorShow(ERR_INVALID_PERIOD);
if not CheckCanDelete then
Abort;

MySQL := 'Insert into HapusLog(Tgl,Usr,Modul,Ket) values( getdate(), '+
QuotedStr(FAppInfo.UserName)+ ' , '+ QuotedStr(judul+' (Header) ')+',' ;
s := '';

with quMASTER do
for I := 0 to FieldCount - 1 do
begin

if Fields[I].fieldkind = fkdata then begin
if Fields[I].DataType = ftstring then
begin
With Fields[I] do
begin
if s <> '' then s := s + '|' ;
s := s + Fields[I].FieldName ;
Try
s := s + ' = '+ VarToStr(Fields[I].oldvalue) ;
Except
s := s + ' = '+' ' ;
end;
end ;
end
else
if Fields[I].DataType = ftdatetime then
begin
With Fields[I] do
begin
if s <> '' then s := s + '|' ;
s := s + Fields[I].FieldName ;
Try
s := s + ' = '+DateTimeToStr(Fields[I].OldValue);
Except
s := s +' = '+ ' ';
End;
end ;
end
else
begin
With Fields[I] do
begin
if s <> '' then s := s + '|' ;
s := s + Fields[I].FieldName ;
Try
s := s + ' = '+VarToStr(Fields[I].OldValue);
Except
s := s +' = '+ ' ';
End;
end ;
end;

end;


end;

MySQL := MySQL+ ' '' '+s+ ' '' '+ ')';

if trim(s) <> '' then
With TADOQuery.create(nil), SQL do
begin
Try
Connection := dmDataSys.acDataSys;
close;
clear;
add(' '+ MySQL+' ' );
//SaveToFile('c:\editlog.txt');
ExecSQL;
Finally
Free;
End;
end;
if quDETAIL.RecordCount >0 then
begin
quDETAIL.First;
while not quDETAIL.Eof do
begin
HapusLogDetail;
quDETAIL.next;
end;

end;

end;

{ Query DETAIL }

procedure TfmCtrSingle.quDETAILBeforeInsert(DataSet: TDataSet);
begin
inherited;
quMASTERBeforeEdit(DataSet);
end;

procedure TfmCtrSingle.quDETAILBeforeEdit(DataSet: TDataSet);
begin
inherited;
quMASTERBeforeEdit(DataSet);
end;

procedure TfmCtrSingle.quDETAILAfterInsert(DataSet: TDataSet);
begin
inherited;
with dgDetail do
SetActiveField(Columns[0].FieldName);

quDETAILOwner.Value := FAppInfo.UserCode;
end;

procedure TfmCtrSingle.quDETAILBeforePost(DataSet: TDataSet);
begin
inherited;
with dgDetail do begin
if (quDETAILKode.Value = '') or (quDETAILNoBuk.Value = '') or (quDETAILTgl.Value = 0) then begin
SetActiveField(Columns[0].FieldName);
ErrorShow(ERR_DATA_MASTER_NOEXIST);
end;
if InvalidPeriod(quDETAILTgl.Value) then begin
SetActiveField(Columns[0].FieldName);
ErrorShow(ERR_INVALID_PERIOD);
end;

AssignMark(quDETAILUsr, quDETAILStamp);
end;
end;

procedure TfmCtrSingle.quDETAILAfterPost(DataSet: TDataSet);
begin
if nCallerID = ID_EMPTY then begin
inherited;

with dmDataSys.acDataSys do
try
UpdateTotal;
if InTransaction then CommitTrans;
except
if InTransaction then RollBackTrans;
raise;
end;
end;
end;

procedure TfmCtrSingle.quDETAILBeforeDelete(DataSet: TDataSet);
begin
if nCallerID = ID_EMPTY then begin
inherited;
if InvalidPeriod(quMASTERTgl.Value) then
ErrorShow(ERR_INVALID_PERIOD);
if CheckCanDelete then begin
With dmDataSys.acDataSys do
if not InTransaction then
Try BeginTrans; Except; End;
// HapusLogDetail;
end;
end;
end;

procedure TfmCtrSingle.HapusLogDetail;
var s,MySQL : String;
I : integer;
judul : string;
begin
judul := Screen.ActiveForm.Caption;

//quDETAIL.First;
//while not quDETAIL.Eof do
//begin
Try
MySQL := 'Insert into HapusLog(Tgl,Usr,Modul,Ket) values( getdate(), '+
QuotedStr(FAppInfo.UserName)+ ' , '+QuotedStr(judul+' (Detail) ') +',' ;
s := '';
with quDETAIL do //1
begin
for I := 0 to fieldcount - 1 do
begin // 2
if Fields[I].FieldKind = fkdata then begin
if Fields[I].DataType = ftstring then
begin
With Fields[I] do
begin
if s <> '' then s := s + '|' ;
s := s + Fields[I].FieldName + ' = ';
Try
s := s + VarToStr(Fields[I].oldvalue) ;
Except
s := s + ' ';
End;

end;
end
else
if Fields[I].DataType = ftBCD then
begin

With Fields[I] do
begin
if s <> '' then s := s + '|' ;
s := s + Fields[I].FieldName + ' = ';
Try
s := s + VarToStr(Fields[I].OldValue);
Except
s := s + ' ';
end;
end;
end
else
if Fields[I].DataType = ftdatetime then
begin
With Fields[I] do
begin

if s <> '' then s := s + '|' ;
s := s + Fields[I].FieldName + ' = ';
Try
s := s + DateTimeToStr(Fields[I].OldValue);
Except
s := s + ' ';
End;

end ;
end
else
begin
With Fields[I] do
begin

if s <> '' then s := s + '|' ;
s := s + Fields[I].FieldName + ' = ';
Try
s := s + VarToStr(Fields[I].OldValue);
Except
s := s + ' ';
End;

end ;
end ;

END;
end; // end 2
end; // end 1
MySQL := MySQL+ ' '' '+s+ ' '' '+ ')';

if trim(s) <> '' then
With TADOQuery.create(nil), SQL do
begin
Try
Connection := dmDataSys.acDataSys;
close;
clear;
add(' '+ MySQL+' ' );
//SaveToFile('c:\editlogdet.txt');
ExecSQL;
Finally
Free;
End;
end;
// try if dmDataSys.acDataSys.InTransaction then dmDataSys.acDataSys.CommitTrans; except; ENd;
Except
// IF dmDataSys.acDataSys.InTransaction then dmDataSys.acDataSys.RollbackTrans;
End;
//quDETAIL.next;
//end;
end;

end.

Tidak ada komentar:

Posting Komentar

INGIN KERJA DARI RUMAH?