private void OnDialogClosed(object sender, EventArgs e) { incomes.Clear(); using (var db = new IncomeManager()) { incomes = db.GetItemsByDates(startDate, endDate); } incomeLV.Adapter = new IncomesListAdapter(this.Activity, incomes); }
void OnEndDateSet(object sender, DatePickerDialog.DateSetEventArgs e) { editEnd.Text = e.Date.ToShortDateString(); endDate = e.Date; incomes.Clear(); using (var db = new IncomeManager()) { incomes = db.GetItemsByDates(startDate, endDate); } incomeLV.Adapter = new IncomesListAdapter(this.Activity, incomes); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { base.OnCreateView(inflater, container, savedInstanceState); var view = inflater.Inflate( Resource.Layout.ShowIncomesView, container, false); var context = this.Activity; incomeLV = view.FindViewById <ListView>(Resource.Id.incomesList); editStart = view.FindViewById <EditText>(Resource.Id.editStartDate); editEnd = view.FindViewById <EditText>(Resource.Id.editEndDate); DateTime today = DateTime.Today; startDate = new DateTime(today.Year, today.Month, 1); endDate = startDate.AddMonths(1).AddDays(-1); editStart.Text = startDate.ToShortDateString(); editEnd.Text = endDate.ToShortDateString(); editStart.Click += (sender, e) => { DateTime now = DateTime.Today; DatePickerDialog dialog = new DatePickerDialog(context, OnStartDateSet, now.Year, now.Month - 1, now.Day); dialog.DatePicker.MinDate = now.Millisecond; dialog.Show(); }; editEnd.Click += (sender, e) => { DateTime now = DateTime.Today; DatePickerDialog dialog = new DatePickerDialog(context, OnEndDateSet, now.Year, now.Month - 1, now.Day); dialog.DatePicker.MinDate = now.Millisecond; dialog.Show(); }; using (var db = new IncomeManager()) { incomes = db.GetItemsByDates(startDate, endDate); } incomeLV.Adapter = new IncomesListAdapter(context, incomes); incomeLV.ItemClick += IncomeLV_ItemClick; return(view); }
public override Dialog OnCreateDialog(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); var builder = new AlertDialog.Builder(Activity); var inflater = Activity.LayoutInflater; var dialogView = inflater.Inflate(Resource.Layout.ReportDialogView, null); if (dialogView != null) { monthTV = dialogView.FindViewById <TextView>(Resource.Id.textMonth); yearTV = dialogView.FindViewById <TextView>(Resource.Id.textYear); catTV = dialogView.FindViewById <TextView>(Resource.Id.textRepCategory); expensesTV = dialogView.FindViewById <TextView>(Resource.Id.textRepExpenses); realExpensesTV = dialogView.FindViewById <TextView>(Resource.Id.textRealExpenses); spinner = dialogView.FindViewById <Spinner>(Resource.Id.spinnerRep); GetTVText(); startDate = new DateTime(selectedYear, selectedMonth, 1); endDate = startDate.AddMonths(1).AddDays(-1); LoadSpinnerData(); spinner.ItemSelected += Spinner_ItemSelected; spinner.SetSelection(1); using (var db = new ExpenseManager()) { expensesSum = db.GetItemsByDates(startDate, endDate).Sum(a => a.Amount); } expensesTV.Text = expensesSum.ToString(); SetAmounts(); if (startAmount == -1 || endAmount == -1) { realExpensesTV.Text = "Brak wystarczających danych"; } else { using (var db = new IncomeManager()) { incomesSum = db.GetItemsByDates(startDate, endDate).Sum(a => a.Amount); } realSum = startAmount + (float)incomesSum - endAmount; realExpensesTV.Text = realSum.ToString(); } builder.SetView(dialogView); builder.SetNeutralButton("Wróć", HandleNeutralButtonClick); } var dialog = builder.Create(); return(dialog); }