Skip to content

Commit

Permalink
ManageMember LocateMember and filters WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Artanemus committed Mar 19, 2024
1 parent 89d2b91 commit 134cc61
Show file tree
Hide file tree
Showing 10 changed files with 492 additions and 41 deletions.
19 changes: 18 additions & 1 deletion MEMBERS/dmManageMemberData.pas
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,17 @@ implementation
vcl.Dialogs, System.UITypes, vcl.Forms, System.DateUtils;

constructor TManageMemberData.Create(AOwner: TComponent);
var
IniFileName: string;
begin
inherited;
fHandle := AllocateHWnd(WndProc);
prefChartMaxRecords := CHARTMAXRECORDS;

// r e a d p r e f e r e n c e .
IniFileName := SCMUtility.GetSCMPreferenceFileName();
if (FileExists(IniFileName)) then
ReadPreferences(IniFileName);
end;

constructor TManageMemberData.CreateWithConnection(AOwner: TComponent;
Expand Down Expand Up @@ -625,7 +632,8 @@ procedure TManageMemberData.ReadPreferences(aIniFileName: string);
if not FileExists(aIniFileName) then exit;
iFile := TIniFile.Create(aIniFileName);
// 2024.03.18
prefChartMaxRecords := iFile.ReadInteger('ManageMemberData', 'ChartMaxRecords', CHARTMAXRECORDS);
prefChartMaxRecords := iFile.ReadInteger('ManageMemberData', 'MemberChartDataPoints', CHARTMAXRECORDS);

iFile.Free;
end;

Expand Down Expand Up @@ -750,10 +758,19 @@ procedure TManageMemberData.WndProc(var wndMsg: TMessage);
dt, currDt: TDateTime;
fldName: string;
st: TSystemTime;
aMemberID: integer;

begin
if (wndMsg.WParam = 0) then
exit;

if (wndMsg.Msg = SCM_LOCATEMEMBER) then
begin
aMemberID := wndMsg.WParam;
LocateMember(aMemberID);
end;


if (wndMsg.Msg = SCM_DOBUPDATED) OR (wndMsg.Msg = SCM_ELECTEDONUPDATED) OR
(wndMsg.Msg = SCM_RETIREDONUPDATED) then
BEGIN
Expand Down
6 changes: 3 additions & 3 deletions MEMBERS/frmManageMember.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ object ManageMember: TManageMember
end
object cmboStroke: TComboBox
Left = 385
Top = 9
Top = 8
Width = 184
Height = 27
TabOrder = 1
Expand All @@ -1096,7 +1096,7 @@ object ManageMember: TManageMember
end
object chkbDoCurrSeason: TCheckBox
Left = 616
Top = 18
Top = 11
Width = 225
Height = 17
Caption = 'Current swimming season.'
Expand All @@ -1107,7 +1107,7 @@ object ManageMember: TManageMember
end
object btmPrintChart: TButton
Left = 1223
Top = 10
Top = 8
Width = 129
Height = 25
Anchors = [akTop, akRight]
Expand Down
31 changes: 24 additions & 7 deletions MEMBERS/frmManageMember.pas
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ TManageMember = class(TForm)
fHideNonSwimmer: Boolean;

fFilterDlg: TMemberFilter;
fMemberChartDataPoints: Integer;

function AssertConnection: Boolean;
function FindMember(MemberID: Integer): Boolean;
Expand Down Expand Up @@ -983,13 +984,23 @@ procedure TManageMember.ReadPreferences(aIniFileName: string);
fHideArchived := iFile.ReadBool(INIFILE_SECTION, 'HideArchived', true);
fHideInActive := iFile.ReadBool(INIFILE_SECTION, 'HideInActive', false);
fHideNonSwimmer := iFile.ReadBool(INIFILE_SECTION, 'HideNonSwimmer', false);
i := iFile.ReadInteger(INIFILE_SECTION, 'TabIndex', -1);
// test bounds
if ((i > -1) and (i < PageControl1.PageCount)) then
PageControl1.ActivePageIndex := i;

// 2024.03.18
i := iFile.ReadInteger('ManageMember', 'cmboDistanceItemIndex', 0);
if i < cmboDistance.Items.Count then cmboDistance.ItemIndex := i;
i := iFile.ReadInteger('ManageMember', 'cmboStrokeItemIndex', 0);
if i < cmboStroke.Items.Count then cmboStroke.ItemIndex := i;
chkbDoCurrSeason.Checked := iFile.ReadBool('ManageMember',
'chkbDoCurrSeason', false);

// 2024/03/19 Value used by TFDQuery qryChart to select TOP ###
fMemberChartDataPoints := iFile.ReadInteger('ManageMemberData', 'MemberChartDataPoints', 26);


iFile.Free;
end;

Expand Down Expand Up @@ -1086,9 +1097,6 @@ procedure TManageMember.Prepare(AConnection: TFDConnection;
// ----------------------------------------------------
PostMessage(Handle, SCM_UPDATE, 0, 0);

// Cue-to-member
if aMemberID > 0 then FindMember(aMemberID);

// prepare comboboxes - distance and stroke

if ManageMemberData.ManageMemberDataActive then
Expand All @@ -1112,6 +1120,14 @@ procedure TManageMember.Prepare(AConnection: TFDConnection;
cmboStroke.ItemIndex := 0;
end;

// TODO:
// DISABLE FILTERS IF REQUIRED TOO
// FindMember(MemberID: Integer): Boolean;
// Cue-to-member
if aMemberID > 0 then
PostMessage(ManageMemberData.Handle, SCM_LOCATEMEMBER,aMemberID, 0);


end;


Expand Down Expand Up @@ -1148,10 +1164,10 @@ procedure TManageMember.UpdateChart;
str := ManageMemberData.dsMember.DataSet.FieldByName('FName').AsString;
str := str + ' ' +cmboDistance.Text + ' ' + cmboStroke.Text;
if docurrseason then
str := str + ' - Start of season '
+ ManageMemberData.dsSwimClub.DataSet.FieldByName('StartOfSwimSeason').AsString
else
str := str + ' - (Max 26 events)';
str := str + ' - Start of season'
+ ManageMemberData.dsSwimClub.DataSet.FieldByName('StartOfSwimSeason').AsString;

str := str + ' - (Max ' + IntToStr(fMemberChartDataPoints) + ' events)';
DBChart1.Title.Text.Add(str);
// Reload chart data
DBChart1.RefreshData;
Expand Down Expand Up @@ -1196,6 +1212,7 @@ procedure TManageMember.WritePreferences;
iFile.WriteBool(INIFILE_SECTION, 'HideArchived', fHideArchived);
iFile.WriteBool(INIFILE_SECTION, 'HideInActive', fHideInActive);
iFile.WriteBool(INIFILE_SECTION, 'HideNonSwimmer', fHideNonSwimmer);
iFile.WriteInteger(INIFILE_SECTION, 'TabIndex', PageControl1.ActivePageIndex);

// 2024 03 18
if (cmboDistance.ItemIndex > -1) then
Expand Down
Loading

0 comments on commit 134cc61

Please sign in to comment.