Procedure

TfrmConsults.tvCsltNotesExpanded

Module

fConsults

Last Modified

7/15/2014 3:26:34 PM

Visibility

Public/Published

Owner

TfrmConsults

Declaration

procedure tvCsltNotesExpanded(Sender: TObject; Node: TTreeNode);

Calls Hierarchy


TfrmConsults.tvCsltNotesExpanded
 ├SortByTitle
 └SortByDate

Calls

Name Declaration Comments
SortByDate function SortByDate(Node1, Node2: TTreeNode; Data: Longint): Integer; stdcall; -
SortByTitle function SortByTitle(Node1, Node2: TTreeNode; Data: Longint): Integer; stdcall; -


Source

4229  procedure TfrmConsults.tvCsltNotesExpanded(Sender: TObject; Node: TTreeNode);
4230  
4231    function SortByTitle(Node1, Node2: TTreeNode; Data: Longint): Integer; stdcall;
4232    begin
4233      { Within an ID parent node, sorts in ascending order by title
4234      BUT - addenda to parent document are always at the top of the sort, in date order}
4235      if (Copy(PDocTreeObject(Node1.Data)^.DocTitle, 1, 8) = 'Addendum') and
4236         (Copy(PDocTreeObject(Node2.Data)^.DocTitle, 1, 8) = 'Addendum') then
4237        begin
4238          Result :=  AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocFMDate),
4239                                  PChar(PDocTreeObject(Node2.Data)^.DocFMDate));
4240        end
4241      else if Copy(PDocTreeObject(Node1.Data)^.DocTitle, 1, 8) = 'Addendum' then Result := -1
4242      else if Copy(PDocTreeObject(Node2.Data)^.DocTitle, 1, 8) = 'Addendum' then Result := 1
4243      else
4244        begin
4245          if Data = 0 then
4246            Result :=  AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocTitle),
4247                                    PChar(PDocTreeObject(Node2.Data)^.DocTitle))
4248          else
4249            Result := -AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocTitle),
4250                                    PChar(PDocTreeObject(Node2.Data)^.DocTitle));
4251        end
4252    end;
4253  
4254    function SortByDate(Node1, Node2: TTreeNode; Data: Longint): Integer; stdcall;
4255    begin
4256      { Within an ID parent node, sorts in ascending order by document date
4257      BUT - addenda to parent document are always at the top of the sort, in date order}
4258      if (Copy(PDocTreeObject(Node1.Data)^.DocTitle, 1, 8) = 'Addendum') and
4259         (Copy(PDocTreeObject(Node2.Data)^.DocTitle, 1, 8) = 'Addendum') then
4260        begin
4261          Result :=  AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocFMDate),
4262                                  PChar(PDocTreeObject(Node2.Data)^.DocFMDate));
4263        end
4264      else if Copy(PDocTreeObject(Node1.Data)^.DocTitle, 1, 8) = 'Addendum' then Result := -1
4265      else if Copy(PDocTreeObject(Node2.Data)^.DocTitle, 1, 8) = 'Addendum' then Result := 1
4266      else
4267        begin
4268          if Data = 0 then
4269            Result :=  AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocFMDate),
4270                                    PChar(PDocTreeObject(Node2.Data)^.DocFMDate))
4271          else
4272            Result := -AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocFMDate),
4273                                    PChar(PDocTreeObject(Node2.Data)^.DocFMDate));
4274        end;
4275    end;
4276  
4277  begin
4278    with Node do
4279      begin
4280        if Assigned(Data) then
4281          if (Pos('<', PDocTreeObject(Data)^.DocHasChildren) > 0) then
4282            begin
4283              if (PDocTreeObject(Node.Data)^.OrderByTitle) then
4284                CustomSort(@SortByTitle, 0)
4285              else
4286                CustomSort(@SortByDate, 0);
4287            end;
4288        if (ImageIndex in [IMG_GROUP_SHUT, IMG_IDNOTE_SHUT, IMG_IDPAR_ADDENDA_SHUT]) then
4289          ImageIndex := ImageIndex + 1;
4290        if (SelectedIndex in [IMG_GROUP_SHUT, IMG_IDNOTE_SHUT, IMG_IDPAR_ADDENDA_SHUT]) then
4291          SelectedIndex := SelectedIndex + 1;
4292      end;
4293  end;