【问题标题】:Loading NonZero Balance Account in to DevExpress Tree list将非零余额帐户加载到 DevExpress 树列表
【发布时间】:2014-01-23 07:44:29
【问题描述】:

我想加载父子关系的非零账户余额。
如果子余额>0,则需要显示其父级和嵌套父级的各自详细信息。
我需要显示孩子与其父母的非零账户余额。 关系是嵌套的
所以请我在这个问题上需要帮助。
我正在使用 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);                             
    }
}

我的屏幕截图。

我的树视图

【问题讨论】:

    标签: c# .net list tree devexpress


    【解决方案1】:
    【解决方案2】:

    使用此方法,您将能够将帐户作为非零子帐户余额。

    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);                             
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-15
      • 1970-01-01
      • 2020-07-17
      相关资源
      最近更新 更多