zoukankan      html  css  js  c++  java
  • delphi利用指针,结构或component存储数据表数据

    方法一: component 释放时候有自动垃圾回收功能
    type
      TDepartMent 
    = class(TComponent)
      
    private
        FName: 
    string;
        FID: 
    string;
        FPARENT_ID: 
    string;
        FCompanyID: 
    string;
        FType: TDepartType;
        FWareID: 
    string;
        FEnabled: Boolean;
      
    public
        
    property DepartmentName: string read FName write FName;
        
    property ID: string read FID write FID;
        
    property PARENT_ID: string read FPARENT_ID write FPARENT_ID;
        
    property CompanyID: string read FCompanyID write FCompanyID;
        
    property DepartmentType: TDepartType read FType write FType;
        
    property WareID: string read FWareID write FWareID;
        
    property Enabled: Boolean read FEnabled write FEnabled;
        
    constructor Create(AOwner: TComponent); override;
      
    end;
     
     
      
    procedure LoadNodes(ParetNode: TTreeNode);
      
    var
        Node            : TTreeNode;
        CDS             : TClientDataSet;
        DepartMent      : TDepartMent;
      
    begin
        CDS :
    = TClientDataSet.Create(nil);
        CDS.XMLData :
    = ADataSet.XMLData;
        CDS.Filter :
    = 'PARENT_ID=' + '''' + TDepartMent(ParetNode.Data).ID + '''';
        CDS.Filtered :
    = False;
        CDS.Filtered :
    = True;
        
    with CDS do
        
    begin
          First;
          
    while not EOF do
          
    begin
            DepartMent :
    = TDepartMent.Create(ATree);
            DepartMent.ID :
    = FieldByName('DEPA_ID').AsString;
            DepartMent.PARENT_ID :
    = FieldByName('PARENT_ID').AsString;
            DepartMent.DepartmentName :
    = FieldByName('NAME').AsString;
            DepartMent.CompanyID :
    = FieldByName('COMP_ID').AsString;
            DepartMent.DepartmentType :
    = dtDepartment;
            DepartMent.FWareID :
    = FieldByName('WARE_EXTENDED_ID').AsString;
            Node :
    = ATree.Items.AddChild(ParetNode, DepartMent.DepartmentName);
            Node.Data :
    = DepartMent;
            
    if DepartMent.ID = OldID then
              ATree.Selected :
    = Node;
            LoadNodes(Node);
            Node.Expanded :
    = False;
            Next;
          
    end;
        
    end;
        CDS.Free;
      
    end;
  • 相关阅读:
    小希的迷宫(hdu1272 并查集)
    How many Fibs?(poj 2413)大数斐波那契
    图练习-BFS-从起点到目标点的最短步数(sdut 2830)邻接边表
    最大流(EK)
    趣写算法系列之--匈牙利算法(真的很好理解)
    Saving Princess claire_(hdu 4308 bfs模板题)
    Knight Moves(hdu1372 bfs模板题)
    The Die Is Cast(poj 1481简单的双dfs)
    Oil Deposits(poj 1526 DFS入门题)
    WTL:下载、安装、初见
  • 原文地址:https://www.cnblogs.com/innwin/p/1415271.html
Copyright © 2011-2022 走看看