-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuickStat.Selection.pas
More file actions
155 lines (134 loc) · 3.86 KB
/
Copy pathQuickStat.Selection.pas
File metadata and controls
155 lines (134 loc) · 3.86 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
unit QuickStat.Selection;
interface
uses
EPR.QA.SQL,
{General}
Emetra.Interfaces.ListBox,
Emetra.Database.Interfaces,
{Standard}
Classes, Db;
type
TPackagedSelection = class( TInterfacedPersistent, IListBoxBase )
private
fCaption: string;
fCollectorNames: TStringList;
fComment: string;
fPopulationId: integer;
fRowId: integer;
fStudyId: integer;
protected
{ IListBoxBase }
function V: string;
function DN: string;
function OT: string;
function IsCurrent: boolean;
function AsListBox( const ASimple: boolean = false ): string;
{ Property accessors }
function Get_CollectorCount: integer;
function Get_Collector( AIndex: integer ): string;
public
{ Initialization }
constructor Create( const AStudyId, AProcId: integer; const ATitle, AComment: string ); overload;
procedure AfterConstruction; override;
procedure BeforeDestruction; override;
{ Other members }
procedure AddCollector( const AName: string );
procedure Load( ADataset: TDataset );
procedure Save( const ASQL: ISQL );
procedure Delete( const ASQL: ISQL );
{ Properties }
property Collector[AIndex: integer]: string read Get_Collector;
property CollectorCount: integer read Get_CollectorCount;
property Comment: string read fComment;
property PopulationId: integer read fPopulationId;
property RowId: integer read fRowId;
property StudyId: integer read fStudyId;
property Title: string read fCaption;
end;
implementation
uses
SysUtils;
{ TDataElementSelection }
constructor TPackagedSelection.Create( const AStudyId, AProcId: integer; const ATitle, AComment: string );
begin
inherited Create;
fComment := AComment;
fStudyId := AStudyId;
fPopulationId := AProcId;
fCaption := ATitle;
end;
procedure TPackagedSelection.AfterConstruction;
begin
inherited;
fCollectorNames := TStringList.Create;
fCollectorNames.Delimiter := ';';
fCollectorNames.StrictDelimiter := true;
fCollectorNames.Sorted := true;
fCollectorNames.Duplicates := dupIgnore;
end;
procedure TPackagedSelection.BeforeDestruction;
begin
fCollectorNames.Free;
inherited;
end;
procedure TPackagedSelection.AddCollector( const AName: string );
begin
fCollectorNames.Add( AName );
end;
function TPackagedSelection.Get_Collector( AIndex: integer ): string;
begin
Result := fCollectorNames[AIndex];
end;
function TPackagedSelection.Get_CollectorCount: integer;
begin
Result := fCollectorNames.Count;
end;
procedure TPackagedSelection.Load( ADataset: TDataset );
begin
with ADataset do
begin
fStudyId := FieldByName( FLD_STUDY_ID ).AsInteger;
fRowId := FieldByName( FLD_ROW_ID ).AsInteger;
fPopulationId := FieldByName( FLD_PROC_ID ).AsInteger;
fCaption := FieldByName( FLD_TITLE ).AsString;
fComment := FieldByName( FLD_COMMENT ).AsString;
fCollectorNames.DelimitedText := FieldByName( FLD_DATA_ELEMENTS ).AsString;
end;
end;
procedure TPackagedSelection.Save( const ASQL: ISQL );
begin
with ASQL.FastQuery( CMD_ADD_PACKAGE, [fStudyId, fPopulationId, fCaption, fCollectorNames.DelimitedText, fComment] ) do
try
fRowId := FieldByName( FLD_ROW_ID ).AsInteger;
finally
CLose;
end;
end;
function TPackagedSelection.V: string;
begin
Result := IntToStr( fRowId );
end;
procedure TPackagedSelection.Delete( const ASQL: ISQL );
begin
ASQL.ExecuteCommand( 'EXEC QuickStat.DeletePackage :RowId', [fRowId] );
end;
function TPackagedSelection.DN: string;
begin
Result := fCaption;
end;
function TPackagedSelection.OT: string;
begin
Result := Format( 'Pop#%d', [fPopulationId] );
end;
function TPackagedSelection.IsCurrent: boolean;
begin
Result := true;
end;
function TPackagedSelection.AsListBox( const ASimple: boolean ): string;
begin
Result := V + #9 + fCaption + #9;
if not ASimple then
Result := Result + fComment;
Result := Result + #9 + OT;
end;
end.