2014-01-23 67 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);        
}