English 中文(简体)
跟踪账户结余和资料
原标题:Tracking Account balance and information

I m使用MVVER & Linq ToSql进行简单的金融应用。 我试图找到最佳方法整理我的数据。 这里我已经做过(简化):

<><>Account>

  • AccountId (PK)
  • AccountName
  • AccountBalance (returns a sum on the transactions column)
  • Transactions (EntitySet)

我在为某个账户显示交易清单时工作,我会遇到一些麻烦。 我想做的是,在日期之前就显示所分类的交易。 为了做到这一点,我使用长子控制,允许进行分类。 用于控制的数据来源如下:

var transByDate = from trans in App.ViewModel.AllTransactions
                  trans by trans.TransDate.ToString("d") into t
                  t.Key ascending
                  new Transaction<Transaction>(t.Key, t);

this.lls_transByDate.ItemsSource = transByDate;

这项工作,我看见我的小组名称,其中附有当天的交易数据。

我所问的是,每个日期的头盔每天都有平衡。 我如何整理我的数据,以便能够方便地按日期获得账户余额,但可以更新(如果用户回头2周,改变现有交易)。

<><>Edit>/strong> 我希望看到:

[10/2/2011 -------------- $753.23]

Transaction 1 - Grocery - $30.00

[10/1/2011 -------------- $723.23]

银行——车辆——400.00美元

Store - Grocery - $35.00

[09/31/2011 -------------- $288.23]

等等

最佳回答

在我的<代码>Transaction<T>类别内,我添加了另一个称为TransAmount的财产。 因此,当建筑商从上述法典栏目中叫出来时,就看其做什么。

public Transaction(string transDate, IEnumerable<T> items)
{
    DateTime tmpDate = DateTime.Parse(transDate);

    var deposits = from t in App.ViewModel.AllTransactions
                        where t.TransDate <= new DateTime(tmpDate.Year, tmpDate.Month, tmpDate.Day, 23, 59, 59, 999)
                        where t.TransType == (int)TransType.Deposit
                        select t.TransAmount;

    var withdrawals = from t in App.ViewModel.AllTransactions
                        where t.TransDate <= new DateTime(tmpDate.Year, tmpDate.Month, tmpDate.Day, 23, 59, 59, 999)
                        where t.TransType == (int)TransType.Withdrawal
                        select t.TransAmount;

    decimal total = (deposits.Sum() - withdrawals.Sum());

    this.TransAmount = total;
    this.TransDate = transDate;
    this.Items = new List<T>(items);
}

然后,我只把我的XAML与这一财产联系起来。 也许有更清洁的方法这样做,但我认为重新计算平衡比储存他数据库中的平衡更为清洁。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签