2014-01-23 23 views
3

我想加載父子關係的非零帳戶餘額。
如果子女平衡> 0,則需要顯示其父級和嵌套父級的相應詳細信息。
我需要顯示孩子的父母的非零帳戶餘額。 該關係是嵌套的
所以,請我需要在這個問題上的幫助。
我正在使用DevExpress樹列表。
將非零餘額帳戶加載到DevExpress樹列表

這裏是我的樹

private void populateTree(Account account, TreeListNode parentNode) 
{  
    Account[] children = account.children; 
    if (account.header == "True") 
    { 
     TreeListNode currentNode = addNode(account, parentNode); 
     foreach (Account childAccount in children) 
     { 
      populateTree(childAccount, currentNode); 
     } 
    } 
    else if (account.header == "False" && account.currentBalance > 0) 
    { 
     TreeListNode currentNode = addNode(account, parentNode);        
    } 
} 

我的屏幕截圖填充計費代碼。 enter image description here

我的樹視圖
**My-Tree View**

回答

1

使用這種方法,你就能巫婆帳戶作爲非零子賬戶餘額。

public bool IsAcountOrSubAccountNonZeroBalance(Account account) 
{ 
    if (account.currentBalance > 0) 
    return true; 
    foreach (var child in account.children) 
    { 
     if (IsAcountOrSubAccountNonZeroBalance(child)) 
      return true; 
    } 
    return false; 
} 

在您的屏幕截圖上,紅色剝離的帳戶將返回false。

您可以將這個方法添加到您之前的邏輯是這樣

else if (account.header == "False" && IsAcountOrSubAccountNonZeroBalance(account)) 
{ 
    TreeListNode currentNode = addNode(account, parentNode);        
}