-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dmReports.pas
825 lines (750 loc) · 24.2 KB
/
dmReports.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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
unit dmReports;
interface
uses
System.SysUtils, System.Classes, FireDAC.Stan.Intf, FireDAC.Stan.Option,
FireDAC.Stan.Param, FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf,
FireDAC.DApt.Intf, FireDAC.Stan.Async, FireDAC.DApt, Data.DB,
FireDAC.Comp.DataSet, FireDAC.Comp.Client, dmSCM, dlgOptions, frxClass,
frxDBSet, frxPreview, frxExportBaseDialog, frxExportPDF;
type
TRtnError = (reNONE, reNoSessions, reSystem, reNotAssigned);
TRPTS = class(TDataModule)
qryRptHeader: TFDQuery;
frxDBDSRptHeader: TfrxDBDataset;
qryMemABS: TFDQuery;
frxMemABS: TfrxReport;
frxDSMemABS: TfrxDBDataset;
qryMemREL: TFDQuery;
frxDSMemREL: TfrxDBDataset;
frxMemREL: TfrxReport;
qryHouseABS: TFDQuery;
DSHouseABS: TfrxDBDataset;
frxHouseABS: TfrxReport;
qryHouseREL: TFDQuery;
DSHouseREL: TfrxDBDataset;
frxHouseREL: TfrxReport;
qrySessABS: TFDQuery;
DSSessABS: TfrxDBDataset;
frxSessABS: TfrxReport;
frxSessREL: TfrxReport;
qrySessREL: TFDQuery;
DSSessREL: TfrxDBDataset;
qryEventABS: TFDQuery;
DSEventABS: TfrxDBDataset;
frxEventABS: TfrxReport;
frxEventREL: TfrxReport;
qryEventREL: TFDQuery;
DSEventREL: TfrxDBDataset;
frxPDFExport1: TfrxPDFExport;
frxMemABSUno: TfrxReport;
qryMemABSUno: TFDQuery;
frxMemRELUno: TfrxReport;
qryMemRELUno: TFDQuery;
frxDSMemRELUno: TfrxDBDataset;
procedure DataModuleCreate(Sender: TObject);
procedure frxHouseABSBeforePrint(Sender: TfrxReportComponent);
procedure frxHouseRELBeforePrint(Sender: TfrxReportComponent);
procedure frxHouseRELHeatBeforePrint(Sender: TfrxReportComponent);
private
{ Private declarations }
fIsActive: Boolean;
fPreview: TfrxPreview;
fStartOfSwimmingSeason: TDateTime;
fSessionID: integer;
fSessionCount: integer;
fScoreMode: TScoreMode;
fCalcModeEntrantAge: TCalcMode;
fCalcModeSessionRange: TCalcMode;
fSwimClubID: integer;
fAgeSeedDate: TDateTime;
fCustomStartDT: TDateTime;
fCustomEndDT: TDateTime;
fIncludeLockedSession: Boolean;
function GetSessionCount(DTStart, DTEnd: TDateTime): integer;
procedure setPreviewCntrl(const Value: TfrxPreview);
procedure setEndlessHeight(report: TfrxReport; IsEndless: Boolean);
procedure CloseAllQry();
procedure ReadPreferences(iniFileName: string);
procedure AssignRangeValues(var DTStart: TDateTime; var DTEnd: TDateTime);
public
{ Public declarations }
function MemberScores(): TRtnError;
function HouseScores(): TRtnError;
function EventScores(): TRtnError;
// PRINTING AND EXPORTING PDF ETC
procedure PrintReport(rpt: TfrxReport);
procedure ExportReportToPDF(rpt: TfrxReport);
property IsActive: Boolean read fIsActive;
property Preview: TfrxPreview read fPreview write setPreviewCntrl;
end;
var
RPTS: TRPTS;
implementation
{%CLASSGROUP 'Vcl.Controls.TControl'}
{$R *.dfm}
{ TRPTS }
uses
vcl.Forms, System.IniFiles, System.DateUtils, vcl.Dialogs, SCMUtility,
System.UITypes;
procedure TRPTS.CloseAllQry;
begin
// HEADER
qryRptHeader.Close;
// MEMBER
qryMemABS.Close;
qryMemREL.Close;
qryMemABSUno.Close;
// HOUSE
qryHouseABS.Close;
qryHouseREL.Close;
// EVENT - MEMBER
qryEventABS.Close;
qryEventREL.Close;
// SESSION
qrySessABS.Close;
qrySessREL.Close;
end;
procedure TRPTS.DataModuleCreate(Sender: TObject);
begin
// I N I T I A L I Z E P A R A M S .
fIsActive := False;
fPreview := nil;
fSwimClubID := 1;
// C O N N E C T .
if Assigned(SCM) then
begin
qryRptHeader.Connection := SCM.scmConnection;
qryRptHeader.Open;
if qryRptHeader.Active then
fIsActive := True;
// MEMBER
qryMemABS.Connection := SCM.scmConnection;
qryMemREL.Connection := SCM.scmConnection;
qryMemABSUno.Connection := SCM.scmConnection;
qryMemRELUno.Connection := SCM.scmConnection;
// HOUSE
qryHouseABS.Connection := SCM.scmConnection;
qryHouseREL.Connection := SCM.scmConnection;
// EVENT
qryEventABS.Connection := SCM.scmConnection;
qryEventREL.Connection := SCM.scmConnection;
// CURRENT SESSION ONLY - USED BY AUTO-UPDATE
qrySessABS.Connection := SCM.scmConnection;
qrySessREL.Connection := SCM.scmConnection;
end;
end;
{$REGION '... EVENT SCORES'}
function TRPTS.EventScores: TRtnError;
var
rpt: TfrxReport;
qry: TFDQuery;
DoEvent: Boolean;
iniFileName, RangeStr, ModeStr, ModeSubStr: String;
DTStart, DTEnd: TDateTime;
begin
qry := nil;
rpt := nil;
DoEvent := True;
RangeStr := '';
ModeStr := '';
ModeSubStr := '';
result := TRtnError.reNONE;
// ----------------------------------------------------
// R E A D P R E F E R E N C E S .
// reload all of the user settings.
// ----------------------------------------------------
iniFileName := GetSCMPreferenceFileName;
if FileExists(iniFileName) then
ReadPreferences(iniFileName)
else
begin
// SCM SYSTEM ERROR : The preference file couldn't be created.
MessageDlg('An unexpected SCM error occurred.' + sLineBreak +
'Unable to read the LeaderBoard ini file!' + sLineBreak +
'The application will terminate!', mtError, [mbOk], 0);
Exit;
end;
// ----------------------------------------------------
// ASSIGN QUALIFIED RANGE VALUES (ADJUST CEIL/FLOOR)
// Adjustments are required else ranges are not 'inclusive'
// ----------------------------------------------------
AssignRangeValues(DTStart, DTEnd);
// ----------------------------------------------------
// SESSION COUNT - UNO reports used count = 1
// ----------------------------------------------------
fSessionCount := GetSessionCount(DTStart, DTEnd);
if fSessionCount = 0 then
begin
result := TRtnError.reNoSessions;
Exit;
end;
// S T R I N G A S S I G N M E N T - FOR HEADER BAR
// ----------------------------------------------------
if fSessionCount = 1 then
begin
RangeStr := 'Scores given on session: ' +
FormatDateTime('dd/mm/yyyy', DTStart);
ModeSubStr := 'Event Scores';
end
else
begin
RangeStr := 'Scores given on range: ' + FormatDateTime('dd/mm/yyyy',
DTStart) + ' - ' + FormatDateTime('dd/mm/yyyy', DTEnd) +
' (Session Count: ' + IntToStr(fSessionCount) + ')';
ModeSubStr := 'Accumulative Event Scores';
end;
// Calculation mode string
if fScoreMode in [smABSEvent, smABSHeat] then
ModeStr := 'Place given on ABSOLUTE for each '
else
ModeStr := 'Place given on RELATIVE TO DIVISION for each ';
if fScoreMode in [smABSEvent, smRELEvent] then
ModeStr := ModeStr + 'EVENT'
else
ModeStr := ModeStr + 'HEAT';
// -----------------------------------------------------------
// R A N G E - S I N G L E . . M U L T I S E S S I O N . . .
// -----------------------------------------------------------
case fScoreMode of
smNOTASSIGNED:
begin
qry := nil;
result := TRtnError.reNotAssigned;
Exit;
end;
smABSEvent, smABSHeat:
begin
qry := qryEventABS;
rpt := frxEventABS;
end;
smRELEvent, smRELHeat:
begin
qry := qryEventREL;
rpt := frxEventREL;
end;
end;
if Assigned(qry) then
begin
if not Assigned(qryRptHeader.Connection) then
qryRptHeader.Connection := SCM.scmConnection;
qryRptHeader.Close;
qryRptHeader.ParamByName('RANGESTR').AsString := RangeStr;
qryRptHeader.ParamByName('MODESTR').AsString := ModeStr;
qryRptHeader.ParamByName('MODESUBSTR').AsString := ModeSubStr;
qryRptHeader.Prepare;
qryRptHeader.Open;
if not Assigned(qry.Connection) then
qry.Connection := SCM.scmConnection;
qry.Close;
// Floor and ceiling (for dates) set prior to calling here.
qry.ParamByName('DTSTART').AsDateTime := DTStart;
qry.ParamByName('DTEND').AsDateTime := DTEnd;
qry.ParamByName('DOEVENT').AsBoolean := DoEvent;
qry.ParamByName('DOLOCKEDSESSION').AsBoolean := fIncludeLockedSession;
if fScoreMode in [smRELEvent, smRELHeat] then
qry.ParamByName('AGESEEDDATE').AsDateTime := fAgeSeedDate;
qry.Prepare;
qry.Open;
// -----------------------------------------------------------
// P R E V I E W T H E R E P O R T . . .
// -----------------------------------------------------------
if (qry.Active) AND Assigned(fPreview) and Assigned(rpt) then
begin
rpt.Preview := fPreview;
setEndlessHeight(rpt, True);
if (rpt.PrepareReport(True)) then
rpt.ShowPreparedReport();
end
else
result := TRtnError.reSystem;
end;
end;
{$ENDREGION}
procedure TRPTS.ExportReportToPDF(rpt: TfrxReport);
begin
if Assigned(rpt) then
begin
// frxSetHeaderVisibility(rpt, true);
rpt.PrepareReport();
rpt.ReportOptions.Author := 'SwimClubMeet (SCM)';
rpt.ReportOptions.Description.Clear;
rpt.ReportOptions.Description.Add('LeaderBoard Data');
rpt.ReportOptions.Name := 'SCM_LeaderBoard';
rpt.Export(frxPDFExport1);
// frxSetHeaderVisibility(rpt, false);
rpt.PrepareReport(); // export to PDF
rpt.ShowPreparedReport();
end;
end;
{$REGION '... SESSION SCORES'}
{$ENDREGION}
{$REGION 'frxBeforePrint - HOUSE COLORS'}
procedure TRPTS.frxHouseABSBeforePrint(Sender: TfrxReportComponent);
var
shape: TfrxShapeView;
begin
if (Sender.Name = 'Shape2') then
begin
shape := TfrxShapeView(Sender);
shape.Color := DSHouseABS.DataSet.FieldByName('Color').AsInteger;
end;
end;
procedure TRPTS.frxHouseRELBeforePrint(Sender: TfrxReportComponent);
var
shape: TfrxShapeView;
begin
if (Sender.Name = 'Shape2') then
begin
shape := TfrxShapeView(Sender);
shape.Color := DSHouseREL.DataSet.FieldByName('Color').AsInteger;
end;
end;
procedure TRPTS.frxHouseRELHeatBeforePrint(Sender: TfrxReportComponent);
begin
end;
{$ENDREGION}
function TRPTS.GetSessionCount(DTStart, DTEnd: TDateTime): integer;
begin
result := 0;
if Assigned(SCM) then
begin
// Calculate the number of sessions within range
result := SCM.GetSessionCount(1, DTStart, DTEnd);
end;
end;
{$REGION '... HOUSE SCORES'}
function TRPTS.HouseScores(): TRtnError;
var
rpt: TfrxReport;
qry: TFDQuery;
DoEvent: Boolean;
iniFileName, RangeStr, ModeStr, ModeSubStr: String;
DTStart, DTEnd: TDateTime;
begin
qry := nil;
rpt := nil;
DoEvent := True;
RangeStr := '';
ModeStr := '';
ModeSubStr := '';
result := TRtnError.reNONE;
// ----------------------------------------------------
// R E A D P R E F E R E N C E S .
// reload all of the user settings.
// ----------------------------------------------------
iniFileName := GetSCMPreferenceFileName;
if FileExists(iniFileName) then
ReadPreferences(iniFileName)
else
begin
// SCM SYSTEM ERROR : The preference file couldn't be created.
MessageDlg('An unexpected SCM error occurred.' + sLineBreak +
'Unable to read the LeaderBoard ini file!' + sLineBreak +
'The application will terminate!', mtError, [mbOk], 0);
Exit;
end;
// ----------------------------------------------------
// ASSIGN QUALIFIED RANGE VALUES (ADJUST CEIL/FLOOR)
// Adjustments are required else ranges are not 'inclusive'
// ----------------------------------------------------
AssignRangeValues(DTStart, DTEnd);
// ----------------------------------------------------
// SESSION COUNT - UNO reports used count = 1
// ----------------------------------------------------
fSessionCount := GetSessionCount(DTStart, DTEnd);
if fSessionCount = 0 then
begin
result := TRtnError.reNoSessions;
Exit;
end;
// S T R I N G A S S I G N M E N T - FOR HEADER BAR
// ----------------------------------------------------
if fSessionCount = 1 then
begin
RangeStr := 'Scores given on session: ' +
FormatDateTime('dd/mm/yyyy', DTStart);
ModeSubStr := 'Accumulative House Scores';
end
else
begin
RangeStr := 'Scores given on range: ' + FormatDateTime('dd/mm/yyyy',
DTStart) + ' - ' + FormatDateTime('dd/mm/yyyy', DTEnd) +
' (Session Count: ' + IntToStr(fSessionCount) + ')';
ModeSubStr := 'Accumulative House Scores';
end;
// Calculation mode string
if fScoreMode in [smABSEvent, smABSHeat] then
ModeStr := 'Place given on ABSOLUTE for each '
else
ModeStr := 'Place given on RELATIVE TO DIVISION for each ';
if fScoreMode in [smABSEvent, smRELEvent] then
ModeStr := ModeStr + 'EVENT'
else
ModeStr := ModeStr + 'HEAT';
// -----------------------------------------------------------
// R A N G E - S I N G L E . . M U L T I S E S S I O N . . .
// -----------------------------------------------------------
case fScoreMode of
smNOTASSIGNED:
begin
qry := nil;
result := TRtnError.reNotAssigned;
Exit;
end;
smABSEvent, smABSHeat:
begin
qry := qryHouseABS;
rpt := frxHouseABS;
end;
smRELEvent, smRELHeat:
begin
qry := qryHouseREL;
rpt := frxHouseREL;
end;
end;
if Assigned(qry) then
begin
if not Assigned(qryRptHeader.Connection) then
qryRptHeader.Connection := SCM.scmConnection;
qryRptHeader.Close;
qryRptHeader.ParamByName('RANGESTR').AsString := RangeStr;
qryRptHeader.ParamByName('MODESTR').AsString := ModeStr;
qryRptHeader.ParamByName('MODESUBSTR').AsString := ModeSubStr;
qryRptHeader.Prepare;
qryRptHeader.Open;
if not Assigned(qry.Connection) then
qry.Connection := SCM.scmConnection;
qry.Close;
// Floor and ceiling (for dates) set prior to calling here.
qry.ParamByName('DTSTART').AsDateTime := DTStart;
qry.ParamByName('DTEND').AsDateTime := DTEnd;
qry.ParamByName('DOEVENT').AsBoolean := DoEvent;
qry.ParamByName('DOLOCKEDSESSION').AsBoolean := fIncludeLockedSession;
if fScoreMode in [smRELEvent, smRELHeat] then
qry.ParamByName('AGESEEDDATE').AsDateTime := fAgeSeedDate;
qry.Prepare;
qry.Open;
// -----------------------------------------------------------
// P R E V I E W T H E R E P O R T . . .
// -----------------------------------------------------------
if (qry.Active) AND Assigned(fPreview) and Assigned(rpt) then
begin
rpt.Preview := fPreview;
setEndlessHeight(rpt, True);
if (rpt.PrepareReport(True)) then
rpt.ShowPreparedReport();
end
else
result := TRtnError.reSystem;
end;
end;
{$ENDREGION}
{$REGION '... MEMBER SCORE'}
function TRPTS.MemberScores(): TRtnError;
var
rpt: TfrxReport;
qry: TFDQuery;
DoEvent: Boolean;
iniFileName, RangeStr, ModeStr, ModeSubStr: String;
DTStart, DTEnd: TDateTime;
begin
qry := nil;
rpt := nil;
DoEvent := True;
RangeStr := '';
ModeStr := '';
ModeSubStr := '';
result := TRtnError.reNONE;
// ----------------------------------------------------
// R E A D P R E F E R E N C E S .
// reload all of the user settings.
// ----------------------------------------------------
iniFileName := GetSCMPreferenceFileName;
if FileExists(iniFileName) then
ReadPreferences(iniFileName)
else
begin
// SCM SYSTEM ERROR : The preference file couldn't be created.
MessageDlg('An unexpected SCM error occurred.' + sLineBreak +
'Unable to read the LeaderBoard ini file!' + sLineBreak +
'The application will terminate!', mtError, [mbOk], 0);
Exit;
end;
// ----------------------------------------------------
// ASSIGN QUALIFIED RANGE VALUES (ADJUST CEIL/FLOOR)
// Adjustments are required else ranges are not 'inclusive'
// ----------------------------------------------------
AssignRangeValues(DTStart, DTEnd);
// ----------------------------------------------------
// SESSION COUNT - UNO reports used count = 1
// ----------------------------------------------------
fSessionCount := GetSessionCount(DTStart, DTEnd);
if fSessionCount = 0 then
begin
result := TRtnError.reNoSessions;
Exit;
end;
// S T R I N G A S S I G N M E N T - FOR HEADER BAR
// ----------------------------------------------------
if fSessionCount = 1 then
begin
RangeStr := 'Scores given on session: ' +
FormatDateTime('dd/mm/yyyy', DTStart);
ModeSubStr := 'Stroke-Distance.Place.Score.Racetime';
end
else
begin
RangeStr := 'Scores given on range: ' + FormatDateTime('dd/mm/yyyy',
DTStart) + ' - ' + FormatDateTime('dd/mm/yyyy', DTEnd) +
' (Session Count: ' + IntToStr(fSessionCount) + ')';
ModeSubStr := 'Stroke-Distance.SubTotal';
end;
// Calculation mode string
if fScoreMode in [smABSEvent, smABSHeat] then
ModeStr := 'Place given on ABSOLUTE for each '
else
ModeStr := 'Place given on RELATIVE TO DIVISION for each ';
if fScoreMode in [smABSEvent, smRELEvent] then
ModeStr := ModeStr + 'EVENT'
else
ModeStr := ModeStr + 'HEAT';
// -----------------------------------------------------------
// R A N G E - S I N G L E S E S S I O N . . .
// these reports have additional details (race-times, place, score)
// R A N G E - M U L T I S E S S I O N . . .
// -----------------------------------------------------------
case fScoreMode of
smNOTASSIGNED:
begin
qry := nil;
result := TRtnError.reNotAssigned;
Exit;
end;
smABSEvent:
begin
if fSessionCount = 1 then
begin
qry := qryMemABSUno;
rpt := frxMemABSUno;
end
else
begin
qry := qryMemABS;
rpt := frxMemABS;
end;
end;
smABSHeat:
begin
if fSessionCount = 1 then
begin
qry := qryMemABSUno;
DoEvent := False; // switch to heat
rpt := frxMemABSUno;
end
else
begin
qry := qryMemABS;
DoEvent := False; // switch to heat
rpt := frxMemABS;
end;
end;
smRELEvent:
begin
if fSessionCount = 1 then
begin
qry := qryMemRELUno;
rpt := frxMemRELUno;;
end
else
begin
qry := qryMemREL;
rpt := frxMemREL;
end;
end;
smRELHeat:
begin
if fSessionCount = 1 then
begin
qry := qryMemRELUno;
DoEvent := False; // switch to heat
rpt := frxMemRELUno;
end
else
begin
qry := qryMemREL;
DoEvent := False; // switch to heat
rpt := frxMemREL;
end;
end;
end;
if Assigned(qry) then
begin
if not Assigned(qryRptHeader.Connection) then
qryRptHeader.Connection := SCM.scmConnection;
qryRptHeader.Close;
qryRptHeader.ParamByName('RANGESTR').AsString := RangeStr;
qryRptHeader.ParamByName('MODESTR').AsString := ModeStr;
qryRptHeader.ParamByName('MODESUBSTR').AsString := ModeSubStr;
qryRptHeader.Prepare;
qryRptHeader.Open;
if not Assigned(qry.Connection) then
qry.Connection := SCM.scmConnection;
qry.Close;
// Floor and ceiling (for dates) set prior to calling here.
qry.ParamByName('DTSTART').AsDateTime := DTStart;
qry.ParamByName('DTEND').AsDateTime := DTEnd;
qry.ParamByName('DOEVENT').AsBoolean := DoEvent;
qry.ParamByName('DOLOCKEDSESSION').AsBoolean := fIncludeLockedSession;
if fScoreMode in [smRELEvent, smRELHeat] then
qry.ParamByName('AGESEEDDATE').AsDateTime := fAgeSeedDate;
qry.Prepare;
qry.Open;
// -----------------------------------------------------------
// P R E V I E W T H E R E P O R T . . .
// -----------------------------------------------------------
if (qry.Active) AND Assigned(fPreview) and Assigned(rpt) then
begin
rpt.Preview := fPreview;
setEndlessHeight(rpt, True);
if (rpt.PrepareReport(True)) then
rpt.ShowPreparedReport();
end
else
result := TRtnError.reSystem;
end;
end;
{$ENDREGION}
procedure TRPTS.PrintReport(rpt: TfrxReport);
begin
if Assigned(rpt) then
begin
// SetHeaderVisibility(rpt, true);
// SetFooterVisibility(rpt, true);
setEndlessHeight(rpt, False);
rpt.PrepareReport();
rpt.Print();
// frxSetHeaderVisibility(rpt, false);
// frxSetFooterVisibility(rpt, false);
setEndlessHeight(rpt, False);
rpt.PrepareReport();
rpt.ShowPreparedReport();
end;
end;
procedure TRPTS.AssignRangeValues(var DTStart: TDateTime; var DTEnd: TDateTime);
begin
DTStart := 0;
DTEnd := 0;
// CALCULATE THE RANGE ADJUST - FLOOR/CEILING
if Assigned(SCM) then
begin
case fCalcModeSessionRange of
cmNOTASSIGNED:
;
cmStartOfSeason:
begin
DTStart := DateOf(fStartOfSwimmingSeason);
DTEnd := DateOf(SCM.GetStartOfSession(fSessionID));
end;
cmStartOfSession:
begin
DTStart := SCM.GetStartOfSession(fSessionID);
DTEnd := RecodeHour(DTStart, HourOf(DTStart) + 1);
end;
cmCustomDT:
begin
DTStart := DateOf(fCustomStartDT);
DTEnd := DateOf(fCustomEndDT) + 1; // Midnight of the next day...
end;
end;
end;
end;
procedure TRPTS.ReadPreferences(iniFileName: string);
var
iFile: TIniFile;
i: integer;
begin
fIncludeLockedSession := False;
iFile := TIniFile.Create(iniFileName);
// Determines what seed-date is used to calculate the age of entrants.
i := iFile.ReadInteger('LeaderBoard', 'CalcModeEntrantAge',
integer(TCalcMode(cmNOTASSIGNED)));
if (i >= Ord(Low(TCalcMode))) and (i <= Ord(High(TCalcMode))) then
fCalcModeEntrantAge := TCalcMode(i)
else
fCalcModeEntrantAge := cmNOTASSIGNED;
// Determines what range used to gather up sessions.
// ie. the swimming season (start of sesaon to selected session - inclusive)
// or ... selected session.
i := iFile.ReadInteger('LeaderBoard', 'CalcModeSessionRange',
integer(TCalcMode(cmNOTASSIGNED)));
if (i >= Ord(Low(TCalcMode))) and (i <= Ord(High(TCalcMode))) then
fCalcModeSessionRange := TCalcMode(i)
else
fCalcModeSessionRange := cmNOTASSIGNED;
// Determines the method for scoring ... ABSOLUTE, RELATIVE - EVENT, HEAT
i := iFile.ReadInteger('LeaderBoard', 'ScoreMode',
integer(TScoreMode(smNOTASSIGNED)));
if (i >= Ord(Low(TScoreMode))) and (i <= Ord(High(TScoreMode))) then
fScoreMode := TScoreMode(i)
else
fScoreMode := smNOTASSIGNED;
// Current selected session
fSessionID := iFile.ReadInteger('LeaderBoard', 'SessionID', 0);
// Custom seed-date used to determine the age of the member.
fAgeSeedDate := iFile.ReadDate('LeaderBoard', 'AgeSeedDate', Date);
// Select swimming sessions based on custom range.
fCustomStartDT := iFile.ReadDate('LeaderBoard', 'DateFrom', 0);
fCustomEndDT := iFile.ReadDate('LeaderBoard', 'DateTo', 0);
// Miscellaneous options
fIncludeLockedSession := iFile.ReadBool('LeaderBoard',
'IncludeLockedSessions', False);
iFile.Free;
end;
procedure TRPTS.setEndlessHeight(report: TfrxReport; IsEndless: Boolean);
var
page: TfrxReportPage;
begin
page := TfrxReportPage(report.Pages[1]);
page.EndlessHeight := IsEndless;
end;
procedure TRPTS.setPreviewCntrl(const Value: TfrxPreview);
begin
fPreview := Value;
end;
// {region FRX ... SET FUNCTIONS}
// ---------------------------------------------------------------------------
// F R X . . . F A S T R E P O R T
// ---------------------------------------------------------------------------
//
// void TLeaderBoard::frxSetRowCount(TfrxReport* aReport)
// TfrxComponent* frxObj;
// frxObj = aReport->FindObject("MasterData1");
// if (frxObj != NULL) {
// if (LBOptions->spinedtRowCount->Value > 0)
// reinterpret_cast<TfrxMasterData*>(frxObj)->RowCount =
// LBOptions->spinedtRowCount->Value;
// else
// reinterpret_cast<TfrxMasterData*>(frxObj)->RowCount = 0;
//
// void TLeaderBoard::frxSetFooterVisibility(TfrxReport* report, bool IsVisible)
// TfrxComponent *frxComp;
// frxComp = report->FindObject("PageFooter1");
// if (frxComp != NULL)
// reinterpret_cast<TfrxPageFooter*>(frxComp)->Visible = IsVisible;
// }
//
// void TLeaderBoard::frxSetHeaderVisibility(TfrxReport* report, bool IsVisible)
// TfrxComponent *frxComp;
// frxComp = report->FindObject("PageHeader1");
// if (frxComp != NULL)
// reinterpret_cast<TfrxPageHeader*>(frxComp)->Visible = IsVisible;
//
// ---------------------------------------------------------------------------
// {end_region}
{ *
DATA BASE VARIABLE....
IIF((<frxHeader."ScoreMode"> = 1) OR (<frxHeader."ScoreMode"> = 3) ,'EVENT','HEAT')
INLINE ...
// <IIF( [MemABS."GenderID"] = 1, 'XXX', 'YYYY')>
* }
end.