Procedure

TfrmRemCoverSheet.btnViewClick

Module

fRemCoverSheet

Last Modified

7/15/2014 3:26:38 PM

Visibility

Public/Published

Owner

TfrmRemCoverSheet

Declaration

procedure btnViewClick(Sender: TObject);

Calls Hierarchy


TfrmRemCoverSheet.btnViewClick
 ├TfrmBase508Form.Create
 │ ├TfrmBase508Form.UpdateAccessibilityActions
 │ ├UnfocusableControlEnter
 │ └AdjustControls
 │   ├TfrmBase508Form.ModifyUnfocusableControl
 │   └..(rec)..
 ├TfrmRemCoverSheet.RPad
 ├GetAllChildren
 │ ├..(rec)..
 │ └TfrmRemCoverSheet.RPad
 └TfrmRemCoverSheet.ActiveControlChanged
   └TfrmRemCoverSheet.UpdateButtons
     ├TfrmRemCoverSheet.GetCurrent
     │ └TfrmRemCoverSheet.GetCoverSheetLvlData
     │   └GetCoverSheetLevelData
     ├TfrmRemCoverSheet.GetIndex
     └TfrmRemCoverSheet.LockButtonUpdate
       ├TfrmRemCoverSheet.btnLockClick
       │ └TfrmRemCoverSheet.ChangeStatus
       │   ├TfrmRemCoverSheet.GetCurrent...
       │   ├TfrmRemCoverSheet.GetIndex
       │   ├TfrmRemCoverSheet.MarkListAsChanged
       │   │ └TfrmRemCoverSheet.UpdateView
       │   │   └TfrmRemCoverSheet.GetCurrent...
       │   ├TfrmRemCoverSheet.SetupItem
       │   └TfrmRemCoverSheet.LockButtonUpdate...
       └TfrmRemCoverSheet.btnAddClick
         └TfrmRemCoverSheet.ChangeStatus...

Calls

Name Declaration Comments
TfrmRemCoverSheet.ActiveControlChanged procedure ActiveControlChanged(Sender: TObject); -
TfrmBase508Form.Create constructor Create(AOwner: TComponent); override; -
GetAllChildren procedure GetAllChildren(PNode: TTreeNode; const ASeq, ASortID: string); -
TfrmRemCoverSheet.RPad function RPad(Str: String): String; -


Source

1693  procedure TfrmRemCoverSheet.btnViewClick(Sender: TObject);
1694  var
1695    frmRemCoverPreview: TfrmRemCoverPreview;
1696    CurSortOrder: integer;
1697    CurSortDir: boolean;
1698    i, idx, SeqCnt: integer;
1699    Lvl, LastLvl, tmp, AddCode, IEN, Seq, SortID: string;
1700    RemList, LvlList: TORStringList; // IEN^Name^Seq^SortID^Locked
1701    ANode: TTreeNode;
1702  
1703    procedure GetAllChildren(PNode: TTreeNode; const ASeq, ASortID: string);
1704    var
1705      Node: TTreeNode;
1706  
1707    begin
1708      PNode.Expand(FALSE);
1709      Node := PNode.GetFirstChild;
1710      while assigned(Node) do
1711      begin
1712        tmp := TORTreeNode(Node).StringData;
1713        if copy(tmp,1,1) = CVCatCode then
1714          GetAllChildren(Node, ASeq, ASortID)
1715        else
1716        begin
1717          if RemList.IndexOfPiece(Piece(tmp,u,1)) < 0 then
1718          begin
1719            SetPiece(tmp,u,3,ASeq);
1720            inc(SeqCnt);
1721            SortID := copy(ASortID,1,7) + RPad(IntToStr(SeqCnt)) + copy(ASortID,15,MaxInt);
1722            SetPiece(tmp,u,4,SortID);
1723            RemList.Add(tmp);
1724          end;
1725        end;
1726        Node := Node.GetNextSibling;
1727      end;
1728    end;
1729  
1730  begin
1731    Screen.OnActiveControlChange := fOldFocusChanged;
1732    try
1733      frmRemCoverPreview := TfrmRemCoverPreview.Create(Application);
1734      try
1735        CurSortOrder := FTopSortTag;
1736        CurSortDir := FTopSortUp;
1737        lvView.Items.BeginUpdate;
1738        try
1739          FTopSortTag := 3;
1740          FTopSortUp := TRUE;
1741          lvView.CustomSort(nil, 0);
1742          RemList := TORStringList.Create;
1743          try
1744            LvlList := TORStringList.Create;
1745            try
1746              LastLvl := '';
1747              for i := 0 to lvView.Items.Count-1 do
1748              begin
1749                Lvl := lvView.Items[i].SubItems[IdxLvl2];
1750                if LvL <> LastLvl then
1751                begin
1752                  RemList.AddStrings(LvlList);
1753                  LvlList.Clear;
1754                  LastLvl := Lvl;
1755                end;
1756                IEN := lvView.Items[i].SubItems[IdxIEN];
1757                AddCode := lvView.Items[i].SubItems[IdxAdd];
1758                idx := RemList.IndexOfPiece(IEN);
1759                if AddCode = CVRemoveCode then
1760                begin
1761                  if(idx >= 0) and (piece(RemList[idx],U,5) <> '1') then
1762                    RemList.Delete(idx);
1763                end
1764                else
1765                begin
1766                  if idx < 0 then
1767                  begin
1768                    Seq := lvView.Items[i].SubItems[IdxSeq];
1769                    SortID := RPad(Seq) + '0000000' + lvl + copy(lvView.Items[i].SubItems[IdxTIEN] + '0000000000',1,10);
1770                    tmp := IEN + U + lvView.Items[i].Caption + U + Seq + U + SortID;
1771                    if AddCode = CVLockCode then
1772                      tmp := tmp + U + '1';
1773                    RemList.Add(tmp);
1774                  end
1775                  else
1776                  if (AddCode = CVLockCode) and (piece(RemList[idx],U,5) <> '1') then
1777                  begin
1778                    tmp := RemList[idx];
1779                    SetPiece(tmp,U,5,'1');
1780                    RemList[idx] := tmp;
1781                  end;
1782                end;
1783              end;
1784              RemList.AddStrings(LvlList);
1785              FTopSortTag := CurSortOrder;
1786              FTopSortUp := CurSortDir;
1787              lvView.CustomSort(nil, 0);
1788  
1789              LvlList.Clear;
1790              //LvlList.Assign(RemList);
1791              FastAssign(RemList, LvlList);
1792              RemList.Clear;
1793              FInternalExpansion := TRUE;
1794              try
1795                for i := 0 to LvlList.Count-1 do
1796                begin
1797                  IEN := piece(LvlList[i],U,1);
1798                  if (copy(LvlList[i],1,1) = CVCatCode) then
1799                  begin
1800                    ANode := tvAll.Items.GetFirstNode;
1801                    while assigned(ANode) do
1802                    begin
1803                      if IEN = piece(TORTreeNode(ANode).StringData,U,1) then
1804                      begin
1805                        SeqCnt := 0;
1806                        GetAllChildren(ANode, Piece(LvlList[i], U, 3), Piece(LvlList[i], U, 4));
1807                        ANode := nil;
1808                      end
1809                      else
1810                        ANode := ANode.GetNextSibling;
1811                    end;
1812                  end
1813                  else
1814                  if RemList.IndexOfPiece(IEN) < 0 then
1815                    RemList.Add(LvlList[i]);
1816                end;
1817              finally
1818                FInternalExpansion := FALSE;
1819              end;
1820            finally
1821              LvlList.Free;
1822            end;
1823  
1824            RemList.SortByPiece(4);
1825            for i := 0 to RemList.Count-1 do
1826            begin
1827              with frmRemCoverPreview.lvMain.Items.Add do
1828              begin
1829                tmp := RemList[i];
1830                Caption := Piece(tmp, U, 2);
1831                SubItems.Add(Piece(tmp, U, 3));
1832                SubItems.Add(Piece(tmp, U, 4));
1833              end;
1834            end;
1835          finally
1836            RemList.Free;
1837          end;
1838        finally
1839          lvView.Items.EndUpdate;
1840        end;
1841        frmRemCoverPreview.ShowModal;
1842      finally
1843        frmRemCoverPreview.Free;
1844      end;
1845    finally
1846      Screen.OnActiveControlChange := ActiveControlChanged;
1847    end;
1848  end;