【发布时间】:2011-05-26 20:23:05
【问题描述】:
出于学习目的,我正在使用 WPF 构建现金管理软件,但在正确建模现金账户以便在每次交易后查看余额时遇到了一些麻烦。
这是我现在所拥有的总结版本:
一个帐户类:
public class Account {
public long Id { get; set; }
public string Name { get; set; }
public decimal StartingBalance { get; set; }
}
一个类别类:
public class Category {
public long Id { get; set; }
public string Name { get; set; }
}
一个事务类:
public class Transaction {
public long Id { get; set; }
public DateTime Date { get; set; }
public Account Account { get; set; }
public Category Category { get; set; }
public string Description { get; set; }
public decimal TransactionValue { get; set; }
}
我想要实现的是,仅使用 WPF 绑定功能,填充数据网格并查看给定日期间隔和帐户的以下数据:
Date Account Category Description Value Balance
02/02/10 A1 C1 D1 22.30 230.00
02/03/10 A1 C1 D2 -30.00 200.00
我希望能够选择“所有帐户”选项,并在余额栏中查看所有帐户的余额总和。
到目前为止,代码运行良好,但我在数据网格中没有 Balance 字段,也看不到对此建模的优雅方法,我需要你的帮助!
非常感谢您的帮助。
【问题讨论】:
-
@jim,这实际上不是“家庭作业”,而是自学。
-
@jim - 永远不要仅仅为了添加作业标签而编辑问题。见meta.stackexchange.com/questions/10811/…