private void PopulateTreeView() { using (var db = new FinantialDbContext()) { AccountsTreeView.DataContext = db.Account.ToList(); } }
private void PopulateAccountTypeComboBox() { using (var db = new FinantialDbContext()) { ComboBoxAccountType.ItemsSource = db.AccountType.ToList(); ComboBoxAccountType.DisplayMemberPath = "AccountTypeName"; ComboBoxAccountType.SelectedValuePath = "Id"; } }
private void BtnSave_OnClick(object sender, RoutedEventArgs e) { if (!(GridItems.DataContext is Account item)) { return; } item.IsGroup = BtnIsMain.IsChecked; using (var db = new FinantialDbContext()) { if (item.Id <= 0) { db.Account.Add(item); } else { db.Account.Update(item); } db.SaveChanges(); } }