private void FillStatisticsTable(DataTable table, TransactionsView view) { double total = 0; double positive = 0; double negative = 0; foreach (Transaction transaction in Transactions) { if (FilterTransactionByView(transaction, view)) { double value = transaction.Value; total += transaction.Value; if (value > 0) { positive += value; } else { negative += value; } } } DataRow row = table.NewRow(); row["total"] = total.ToString(); row["positive"] = positive.ToString(); row["negative"] = negative.ToString(); table.Rows.Add(row); }
public DataTable GetTransactionsView(TransactionsView view) { DataTable result = GetTransactionsViewTable(); FillTransactionsViewTable(result, view); return(result); }
public DataTable GetStatisticsView(TransactionsView view) { DataTable result = GetStatisticsTable(); FillStatisticsTable(result, view); return(result); }
private bool FilterTransactionByView(Transaction transaction, TransactionsView view) { if (CheckCategoryId(transaction.CategoryId, view.CategoryId) && CheckTargetId(transaction.TargetId, view.TargetId) && CheckStartDate(transaction.Date, view.StartDate) && CheckEndDate(transaction.Date, view.EndDate)) { return(true); } else { return(false); } }
private void FillTransactionsViewTable(DataTable table, TransactionsView view) { foreach (Transaction transaction in Transactions) { if (FilterTransactionByView(transaction, view)) { DataRow row = table.NewRow(); row["Name"] = transaction.Name; row["Value"] = transaction.Value; row["Date"] = transaction.Date.ToString(); row["Category"] = GetNameForCategoryId(transaction.CategoryId); row["Target"] = GetNameForTargetId(transaction.TargetId); table.Rows.Add(row); } } }