Exemplo n.º 1
0
        private void LoadYearsSpinnerData()
        {
            int yearMax;
            int yearMin;

            using (var db = new ExpenseManager())
            {
                yearMax = db.GetAllItems().Max(a => a.Date).Year;
                yearMin = db.GetAllItems().Min(a => a.Date).Year;
            }
            while (yearMax >= yearMin)
            {
                years.Add(yearMin);
                yearMin++;
            }

            var categoryAdapter = new ArrayAdapter <int>(
                Activity, Android.Resource.Layout.SimpleSpinnerItem, years);

            categoryAdapter.SetDropDownViewResource
                (Android.Resource.Layout.SimpleSpinnerDropDownItem);
            yearsSpinner.Adapter = categoryAdapter;
        }
Exemplo n.º 2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(
                Resource.Layout.ShowReportView, container, false);

            var context = this.Activity;

            monthsSpinner   = view.FindViewById <Spinner>(Resource.Id.spinnerRep1);
            yearsSpinner    = view.FindViewById <Spinner>(Resource.Id.spinnerRep2);
            editStartAmount = view.FindViewById <EditText>(Resource.Id.editRepStart);
            editEndAmount   = view.FindViewById <EditText>(Resource.Id.editRepEnd);
            btnShowReport   = view.FindViewById <Button>(Resource.Id.btnRepShow);

            bool databaseEmpty = true;

            using (var db = new ExpenseManager())
            {
                if (db.GetAllItems().FirstOrDefault() != null)
                {
                    databaseEmpty = false;
                }
            }

            if (!databaseEmpty)
            {
                editStartAmount.KeyPress += EditStartAmount_KeyPress;
                editEndAmount.KeyPress   += EditEndAmount_KeyPress;
                btnShowReport.Click      += BtnShowReport_Click;

                LoadMonthsSpinnerData();
                LoadYearsSpinnerData();

                int monthNow = today.Month - 1;
                int yearNow  = today.Year;
                monthsSpinner.SetSelection(monthNow);
                yearsSpinner.SetSelection(years.FindIndex(y => y == yearNow));

                monthsSpinner.ItemSelected += MonthsSpinner_ItemSelected;
                yearsSpinner.ItemSelected  += YearsSpinner_ItemSelected;
                selectedMonth = today.Month;
                selectedYear  = today.Year;

                SetAmounts();
            }

            return(view);
        }
Exemplo n.º 3
0
        private void BtnShowReport_Click(object sender, EventArgs e)
        {
            Expense checkDate;

            using (var db = new ExpenseManager())
            {
                checkDate = (from a in db.GetAllItems()
                             where a.Date.Month == selectedMonth && a.Date.Year == selectedYear
                             select a).FirstOrDefault();
            }

            if (checkDate != null)
            {
                var dialog = ReportDialog.NewInstance(selectedMonth, selectedYear);
                dialog.DialogClosed += OnDialogClosed;
                dialog.Show(FragmentManager, "dialog");
            }
            else
            {
                Toast.MakeText(this.Activity, string.Format
                                   ("Brak wpisów w tym miesiącu"),
                               ToastLength.Short).Show();
            }
        }