unit Security;
interface
uses
Windows, Messages, SysUtils, Classes, DBCtrls,
DB;
type
TSecurity =
class(TComponent)
private
FDataLink: TFieldDataLink;
FUserNameDataLink: TFieldDataLink;
FPasswordDataLink: TFieldDataLink;
function GetDataSource: TDataSource;
function GetField(
const Index: Integer):
string;
procedure SetDataSource(
const Value: TDataSource);
procedure SetField(
const Index: Integer;
const Value:
string);
protected
public
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
published
property UserNameField:
string index 2
read GetField
write SetField;
property PasswordField:
string index 1
read GetField
write SetField;
property DataField:
string index 0
read GetField
write SetField;
property DataSource: TDataSource
read GetDataSource
write SetDataSource;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('
Beispiele', [TSecurity]);
end;
{ TSecurity }
constructor TSecurity.Create(AOwner: TComponent);
begin
inherited;
FDataLink := TFieldDataLink.Create;
FUserNameDataLink := TFieldDataLink.Create;
FPasswordDataLink := TFieldDataLink.Create;
end;
destructor TSecurity.Destroy;
begin
FreeAndNil(FDataLink);
FreeAndNil(FUserNameDataLink);
FreeAndNil(FPasswordDataLink);
inherited;
end;
function TSecurity.GetDataSource: TDataSource;
begin
Result := FDataLink.DataSource;
end;
function TSecurity.GetField(
const Index: Integer):
string;
begin
case Index of
0: Result := FDataLink.FieldName;
1: Result := FPasswordDataLink.FieldName;
2: Result := FUserNameDataLink.FieldName;
end;
end;
procedure TSecurity.SetDataSource(
const Value: TDataSource);
begin
if not (FDataLink.DataSourceFixed
and (csLoading
in ComponentState)
and
FUserNameDataLink.DataSourceFixed
and FPasswordDataLink.DataSourceFixed)
then
begin
FDataLink.DataSource := Value;
FUserNameDataLink.DataSource := Value;
FPasswordDataLink.DataSource := Value;
end;
if Value <>
nil then
Value.FreeNotification(Self);
end;
procedure TSecurity.SetField(
const Index: Integer;
const Value:
string);
begin
case Index of
0: FDataLink.FieldName := Value;
1: FPasswordDataLink.FieldName := Value;
2: FUserNameDataLink.FieldName := Value;
end;
end;
end.