public ModifyEpensesPanel(int Id, Expenses ex) { InitializeComponent(); UserId = Id; expenses = ex; //global = new Global(); Page p1 = new InterfacePanel(); InterfaceFrame.NavigationService.Navigate(p1); DB db = new DB(); List <string> categories = db.GetCategoriesName(UserId); int i = 0; int temp = 0; foreach (string cat in categories) { if (expenses.CategoryName == cat) { i = temp; } temp = temp + 1; CategoryComboBox.Items.Add(cat); } CategoryComboBox.SelectedIndex = i; NameBox.Text = expenses.Name; AmountBox.Text = expenses.Value; DateBox.Text = expenses.Date; }
public ExpensesPanel(int Id, bool added) { InitializeComponent(); UserId = Id; //global = new Global(); Page p1 = new InterfacePanel(); InterfaceFrame.NavigationService.Navigate(p1); DB db = new DB(); string FirstCat = db.GetUserFirstCat(UserId); int CatExist = -1; int temp = 0; List <string> categories = db.GetCategoriesName(UserId); foreach (string cat in categories) { CategoryComboBox.Items.Add(cat); if (cat == FirstCat) { CatExist = temp; } temp++; } if (CatExist < 0) { CategoryComboBox.SelectedIndex = 0; } else { CategoryComboBox.SelectedIndex = CatExist; } if (added == true) { Added.Content = "Dodano wydatek"; } }