forked from academiadocodigo/TBGWebCharts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Image.DataSet.pas
97 lines (81 loc) · 1.96 KB
/
Image.DataSet.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
unit Image.DataSet;
{$I TBGWebCharts.inc}
interface
uses
Interfaces, DB, Classes, Generics.Collections;
Type
TModelImageDataSet = class(TInterfacedObject, iModelImageDataSet)
private
[weak]
FParent : iModelImage;
FDataSet : TDataSet;
FField : String;
public
constructor Create(Parent : iModelImage);
destructor Destroy; override;
class function New(Parent : iModelImage) : iModelImageDataSet;
function DataSet (Value : TDataSet) : iModelImageDataSet;
function ResultScript : String;
function Field(Value : String) : iModelImageDataSet;
function &End : iModelImage;
end;
implementation
uses
SysUtils,
{$IFDEF HAS_FMX}
FMX.ExtCtrls,
{$ELSE}
{$IF RTLVERSION > 27 }
VCL.ExtCtrls,
{$IFEND}
{$IF RTLVERSION < 28 }
ExtCtrls,
{$IFEND}
{$ENDIF}
Injection;
{ TModelImageDataSet }
function TModelImageDataSet.&End: iModelImage;
begin
Result := FParent;
end;
function TModelImageDataSet.Field(Value: String): iModelImageDataSet;
begin
Result := Self;
FField := Value;
end;
constructor TModelImageDataSet.Create(Parent : iModelImage);
begin
{$IF RTLVERSION > 27 }
TInjection.Weak(@FParent, Parent);
{$ELSE}
FParent := Parent;
{$IFEND}
end;
function TModelImageDataSet.DataSet(Value: TDataSet): iModelImageDataSet;
begin
Result := Self;
FDataSet := Value;
end;
destructor TModelImageDataSet.Destroy;
begin
inherited;
end;
class function TModelImageDataSet.New(Parent : iModelImage) : iModelImageDataSet;
begin
Result := Self.Create(Parent);
end;
function TModelImageDataSet.ResultScript: String;
var
I: Integer;
begin
Result := '';
FDataSet.First;
for I := 0 to Pred(FDataSet.RecordCount) do
begin
Result := Result + '<img class="'+FParent.ImageClass.ResultClass+'" ';
Result := REsult + 'src="'+FDataSet.FieldByName(FField).AsString+'" ' ;
Result := Result + 'data-holder-rendered="true">';
FDataSet.Next;
end;
end;
end.