Beispiel #1
0
 private void PopulateTreeView()
 {
     using (var db = new FinantialDbContext())
     {
         AccountsTreeView.DataContext = db.Account.ToList();
     }
 }
Beispiel #2
0
 private void PopulateAccountTypeComboBox()
 {
     using (var db = new FinantialDbContext())
     {
         ComboBoxAccountType.ItemsSource       = db.AccountType.ToList();
         ComboBoxAccountType.DisplayMemberPath = "AccountTypeName";
         ComboBoxAccountType.SelectedValuePath = "Id";
     }
 }
Beispiel #3
0
        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();
            }
        }