- Recompilación en Delphi10 de todos los paquetes de RO para generar las DCU's en Lib\D10 - Recompilación en Delphi10 de todos los paquetes de DA para generar las DCU's en Lib\D10 git-svn-id: https://192.168.0.254/svn/Componentes.Terceros.RemObjects@9 b6239004-a887-0f4b-9937-50029ccdca16
271 lines
8.1 KiB
ObjectPascal
271 lines
8.1 KiB
ObjectPascal
unit uDAReconcileDialogDetails;
|
|
|
|
{----------------------------------------------------------------------------}
|
|
{ Data Abstract Library - Core Library }
|
|
{ }
|
|
{ compiler: Delphi 6 and up, Kylix 3 and up }
|
|
{ platform: Win32, Linux }
|
|
{ }
|
|
{ (c)opyright RemObjects Software. all rights reserved. }
|
|
{ }
|
|
{ Using this code requires a valid license of the Data Abstract }
|
|
{ which can be obtained at http://www.remobjects.com. }
|
|
{----------------------------------------------------------------------------}
|
|
|
|
{$I DataAbstract.inc}
|
|
|
|
interface
|
|
uses
|
|
SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, StdCtrls, ExtCtrls, uDADelta, uDADataTable, DB,
|
|
{$IFDEF FPC} buttons,LResources,{$ENDIF}
|
|
uDARemoteDataAdapter;
|
|
|
|
type
|
|
TReconcileDialogDetailsForm = class(TForm)
|
|
ScrollBox: TScrollBox;
|
|
BottomPanel: TPanel;
|
|
OkButton: TButton;
|
|
CloseButton: TButton;
|
|
TopPanel: TPanel;
|
|
lMessageError: TLabel;
|
|
CancelButton: TButton;
|
|
procedure FormCreate(Sender: TObject);
|
|
procedure OkButtonClick(Sender: TObject);
|
|
procedure CloseButtonClick(Sender: TObject);
|
|
procedure CancelButtonClick(Sender: TObject);
|
|
private
|
|
{ Private declarations }
|
|
dbeditHeight, labelheight: integer;
|
|
FChange: TDADeltaChange;
|
|
Datasource: TDADataSource;
|
|
procedure Setup;
|
|
procedure GenerateControls;
|
|
procedure OnFieldValueChanged(Sender: TObject);
|
|
public
|
|
{ Public declarations }
|
|
|
|
end;
|
|
|
|
var
|
|
ReconcileDialogDetailsForm: TReconcileDialogDetailsForm;
|
|
|
|
procedure ReconcileDialogShowDetails(AChange: TDADeltaChange; aTable: TDADataTable; aCaption: string; var AAction: TDAReconcileDialogAction);
|
|
implementation
|
|
uses
|
|
uDAInterfaces, uROClasses, dbCtrls;
|
|
|
|
{$IFNDEF FPC}
|
|
{$R *.dfm}
|
|
{$ENDIF}
|
|
|
|
const
|
|
labelWidth = 100;
|
|
editWidth = 200;
|
|
c_Color: TColor = clMoneyGreen;
|
|
|
|
procedure ReconcileDialogShowDetails(AChange: TDADeltaChange; aTable: TDADataTable; aCaption: string; var AAction: TDAReconcileDialogAction);
|
|
var
|
|
FFiltered: Boolean;
|
|
FMasterDS: TDADataSource;
|
|
FRemoteFetchEnabled: Boolean;
|
|
FMasterFields: string;
|
|
begin
|
|
with TReconcileDialogDetailsForm.Create(Application) do try
|
|
Caption := Format(Caption, [aCaption]);
|
|
FChange := AChange;
|
|
FFiltered := ATable.Filtered;
|
|
FMasterDS := aTable.MasterSource;
|
|
FMasterFields := aTable.MasterFields;
|
|
FRemoteFetchEnabled := aTable.RemoteFetchEnabled;
|
|
try
|
|
ATable.Filtered := False;
|
|
aTable.MasterSource := nil;
|
|
aTable.MasterFields := '';
|
|
aTable.RemoteFetchEnabled := False;
|
|
DataSource.DataTable := aTable;
|
|
Setup;
|
|
case ShowModal() of
|
|
mrOk: AAction := rdlgSkip;
|
|
mrCancel: AAction := rdlgCancel;
|
|
else AAction := rdlgNone;
|
|
end;
|
|
finally
|
|
aTable.RemoteFetchEnabled := FRemoteFetchEnabled;
|
|
aTable.Filtered := FFiltered;
|
|
aTable.MasterSource := FMasterDS;
|
|
aTable.MasterFields := FMasterFields
|
|
end;
|
|
finally
|
|
Release;
|
|
end;
|
|
end;
|
|
|
|
{ TShowDetailsForm }
|
|
|
|
procedure TReconcileDialogDetailsForm.Setup;
|
|
begin
|
|
if FChange.ChangeType <> ctDelete then
|
|
with DataSource.DataTable do
|
|
if not Locate(RecIDFieldName, FChange.RecID, []) then RaiseError('Couldn''t find record #' + FormatRecIDString(FChange.RecID));
|
|
GenerateControls;
|
|
lMessageError.Caption := FChange.Message;
|
|
//OkButton.Visible := FChange.ChangeType <> ctDelete;
|
|
case FChange.ChangeType of
|
|
ctInsert: OkButton.Caption := 'Skip Change';
|
|
ctUpdate: OkButton.Caption := 'Skip Change';
|
|
ctDelete: OkButton.Caption := 'Skip Change';
|
|
end;
|
|
end;
|
|
|
|
procedure TReconcileDialogDetailsForm.OnFieldValueChanged(Sender: TObject);
|
|
begin
|
|
OkButton.Caption := 'Update';
|
|
end;
|
|
|
|
procedure TReconcileDialogDetailsForm.GenerateControls;
|
|
var
|
|
i: integer;
|
|
aField: string;
|
|
aTop, aleft: integer;
|
|
FLabel: TLabel;
|
|
FdbEdit: TDBEdit;
|
|
FEdit: TEdit;
|
|
begin
|
|
aleft := 7;
|
|
aTop := 7;
|
|
for i := 0 to FChange.Delta.LoggedFieldCount - 1 do begin
|
|
aField := FChange.Delta.LoggedFieldNames[i];
|
|
aTop := 7 + (3 + dbeditHeight) * i;
|
|
aleft := 7;
|
|
|
|
FLabel := TLabel.Create(Self);
|
|
with FLabel do begin
|
|
Parent := ScrollBox;
|
|
Name := 'l_' + aField;
|
|
Caption := aField;
|
|
Left := aleft;
|
|
Top := (dbeditHeight - Height) div 2 + aTop + 1;
|
|
Width := labelWidth;
|
|
aleft := aleft + 7 + labelWidth;
|
|
Font.Name := 'Tahoma';
|
|
end;
|
|
|
|
if FChange.ChangeType in [ctInsert, ctUpdate] then begin
|
|
if Self.DataSource.DataTable.FieldByName(aField).DataType = datBlob then begin
|
|
FEdit := TEdit.Create(Self);
|
|
with FEdit do begin
|
|
Name := 'dbe_' + aField;
|
|
Parent := ScrollBox;
|
|
Left := aleft;
|
|
aleft := aleft + 7 + editWidth;
|
|
Top := aTop;
|
|
Width := editWidth;
|
|
ReadOnly := True;
|
|
Text := '[blob]';
|
|
Font.Name := 'Tahoma';
|
|
end;
|
|
end
|
|
else begin
|
|
FdbEdit := TDBEdit.Create(Self);
|
|
with FdbEdit do begin
|
|
Name := 'dbe_' + aField;
|
|
DataSource := Self.DataSource;
|
|
Parent := ScrollBox;
|
|
DataField := aField;
|
|
Left := aleft;
|
|
Top := aTop;
|
|
Width := editWidth;
|
|
aleft := aleft + 7 + editWidth;
|
|
OnChange := OnFieldValueChanged;
|
|
if (FChange.ChangeType = ctUpdate) and
|
|
not ROVariantsEqual(FChange.OldValues[i], FChange.NewValues[i]) then
|
|
Color := c_Color;
|
|
Font.Name := 'Tahoma';
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
if FChange.ChangeType in [ctUpdate, ctDelete] then begin
|
|
FEdit := TEdit.Create(Self);
|
|
with FEdit do begin
|
|
Name := 'e_' + aField;
|
|
Parent := ScrollBox;
|
|
Left := aleft;
|
|
aleft := aleft + 7 + editWidth;
|
|
Top := aTop;
|
|
Width := editWidth;
|
|
ReadOnly := True;
|
|
Color := clBtnFace;
|
|
Font.Name := 'Tahoma';
|
|
if Self.DataSource.DataTable.FieldByName(aField).DataType = datBlob then begin
|
|
Text := '[blob]'
|
|
end
|
|
else begin
|
|
case FChange.ChangeType of
|
|
ctDelete: text := VarToStr(FChange.OldValues[i]);
|
|
ctUpdate: begin
|
|
if not Self.DataSource.DataTable.HasReducedDelta then
|
|
text := VarToStr(FChange.OldValues[i])
|
|
else
|
|
if not VarIsEmpty(FChange.OldValues[i]) then
|
|
text := VarToStr(FChange.OldValues[i])
|
|
else text := Self.DataSource.DataTable.FieldByName(aField).AsString;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
inc(aTop, 20);
|
|
inc(aLeft, 7);
|
|
//ScrollBox.HorzScrollBar.Range := aleft;
|
|
Self.ClientWidth := aleft + ScrollBox.VertScrollBar.Size + 2;
|
|
Self.Constraints.MinWidth := Self.Width;
|
|
Self.Constraints.MaxWidth := Self.Width;
|
|
|
|
ScrollBox.VertScrollBar.Range := aTop;
|
|
if Screen.Height > Self.Height + (aTop - ScrollBox.Height) then
|
|
Self.Height := Self.Height + (aTop - ScrollBox.Height)
|
|
else
|
|
Self.Height := Screen.Height;
|
|
end;
|
|
|
|
procedure TReconcileDialogDetailsForm.FormCreate(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
with TDBEdit.Create(Self) do try
|
|
dbeditHeight := Height;
|
|
finally
|
|
free;
|
|
end;
|
|
with TLabel.Create(Self) do try
|
|
labelheight := Height;
|
|
finally
|
|
free;
|
|
end;
|
|
Datasource := TDADataSource.Create(Self);
|
|
end;
|
|
|
|
procedure TReconcileDialogDetailsForm.OkButtonClick(Sender: TObject);
|
|
begin
|
|
if DataSource.DataTable.State in [dsEdit, dsInsert] then DataSource.DataTable.Post;
|
|
end;
|
|
|
|
procedure TReconcileDialogDetailsForm.CancelButtonClick(Sender: TObject);
|
|
begin
|
|
if DataSource.DataTable.State in [dsEdit, dsInsert] then DataSource.DataTable.Cancel;
|
|
end;
|
|
|
|
procedure TReconcileDialogDetailsForm.CloseButtonClick(Sender: TObject);
|
|
begin
|
|
if DataSource.DataTable.State in [dsEdit, dsInsert] then DataSource.DataTable.Cancel;
|
|
end;
|
|
|
|
{$IFDEF FPC}
|
|
initialization
|
|
{$I uDAReconcileDialogDetails.lrs}
|
|
{$ENDIF}
|
|
end.
|
|
|