Ejemplo n.º 1
0
 private void LoadData()
 {
     using (var db = new ExpenseManager())
     {
         expenses = db.GetSomeItems(startDate, endDate, selectedCatName);
     }
 }
Ejemplo n.º 2
0
        private void Spinner_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
        {
            var    mySpinner       = (Spinner)sender;
            string selectedCatName = string.Format("{0}", mySpinner.GetItemAtPosition(e.Position));

            using (var db = new ExpenseManager())
            {
                catSum = db.GetSomeItems(startDate, endDate, selectedCatName)
                         .Sum(a => a.Amount);
            }

            catTV.Text = catSum.ToString();
        }
Ejemplo n.º 3
0
        private void CountBalance()
        {
            double bills;
            double expenses;
            float  balance;

            DateTime today       = DateTime.Today;
            DateTime startDate   = new DateTime(today.Year, today.Month, 1);
            DateTime endDate     = startDate.AddMonths(1).AddDays(-1);
            int      daysOfMonth = endDate.Day;
            int      dayOfMonth  = today.Day;

            using (var db = new ExpenseManager())
            {
                bills    = db.GetSomeItems(startDate, endDate, "Rachunki").Sum(a => a.Amount);
                expenses = db.GetItemsByDates(startDate, endDate)
                           .Where(a => a.CategoryId != 1)
                           .Sum(a => a.Amount);
            }



            balance = (((monthLimit - (float)bills - estBills) / daysOfMonth) * dayOfMonth) - (float)expenses;

            if (balance > 0)
            {
                textBalance.Text   = balance.ToString();
                textPlusMinus.Text = " zł do przodu.";
            }
            else if (balance == 0)
            {
                textBalance.Text   = "";
                textPlusMinus.Text = "na zero";
            }
            else
            {
                balance            = Math.Abs(balance);
                textBalance.Text   = balance.ToString();
                textPlusMinus.Text = " zł do tyłu.";
            }
        }