コード例 #1
0
        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);
        }
コード例 #2
0
        public DataTable GetTransactionsView(TransactionsView view)
        {
            DataTable result = GetTransactionsViewTable();

            FillTransactionsViewTable(result, view);
            return(result);
        }
コード例 #3
0
        public DataTable GetStatisticsView(TransactionsView view)
        {
            DataTable result = GetStatisticsTable();

            FillStatisticsTable(result, view);
            return(result);
        }
コード例 #4
0
 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);
     }
 }
コード例 #5
0
 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);
         }
     }
 }