private void Button_Click(object sender, RoutedEventArgs e) { try { if (Item == null) { DataAccess da = new DataAccess(); bank_account ba = new bank_account(); ba.account = da.GetAccount(AccountID); int BankID = (edtBank.SelectedItem as bank).id; ba.bank = da.BankGet(BankID); ba.BankAccount = edtAccountNumber.Text; ba.Description = edtDescription.Text; AccountID = da.BankAccountCreate(ba).id; } else { DataAccess da = new DataAccess(); bank_account ba = da.bank_account_get(Item.id); int BankID = (edtBank.SelectedItem as bank).id; ba.bank = da.BankGet(BankID); ba.BankAccount = edtAccountNumber.Text; ba.Description = edtDescription.Text; da.BankAccountEdit(ba); } } catch (Exception) { } Close(); }