Ejemplo n.º 1
0
        private async void SaveButton_Clicked(object sender, EventArgs e)
        {
            float amount;
            int   month;

            try
            {
                amount = float.Parse(BudgetAmount.Text);
                var m = MonthPicker.Date;
                month = m.Month;
            }
            catch
            {
                amount = 0;
                month  = DateTime.Now.Month;
            }
            var   fileName     = "";
            Month updatedMonth = (Month)month;

            if (budget != null && budget.MonthInYear == updatedMonth)
            {
                fileName = budget.FileName;
            }
            //converting the enum value to enum
            Budget b = new Budget(amount, (Month)month)
            {
                FileName = fileName
            };

            ExpenseManager.SaveBudget(b);
            await Navigation.PushModalAsync(new MainPage
            {
                BindingContext = null
            });
        }
Ejemplo n.º 2
0
        protected override void OnAppearing()
        {
            var Expenses = ExpenseManager.GetExpenses();

            ExpenseManager.SaveBudget(500);
            Budget.Text          = budget.ToString();
            RemainingAmount.Text = ExpenseManager.RemainingBudget().ToString();
            if (budget > 0)
            {
                AddNewExpense.IsEnabled = true;
            }
            foreach (var expense in Expenses)
            {
                expenses.Add(expense);
            }
            ExpenseRecords.ItemsSource = expenses.OrderBy(n => n.Date).ToList();
        }