private void cmnEditAccount_Click(object sender, RoutedEventArgs e) { if (SelectedAccount == null) { return; } var copy = SelectedAccount.Clone() as AccountInfo; var wnd = new wndAddBrokerAccount(copy); var res = wnd.ShowDialog(); if (!res.HasValue || !res.Value) { return; } if (Accounts.Any(p => p.ID.Equals(copy.ID)) && !SelectedAccount.ID.Equals(copy.ID)) { MessageBox.Show("Failed to update broker, account with same ID already exist."); return; } if (Accounts.Any(p => p.UserName.Equals(copy.UserName)) && !SelectedAccount.UserName.Equals(copy.UserName)) { MessageBox.Show("Failed to update broker, account with same User Name already exist."); return; } Accounts.Remove(SelectedAccount); Accounts.Add(copy); }
private void cmnAddAccount_Click(object sender, RoutedEventArgs e) { var account = new AccountInfo(); var wnd = new wndAddBrokerAccount(account); var res = wnd.ShowDialog(); if (!res.HasValue || !res.Value) { return; } if (Accounts.Any(p => p.ID.Equals(account.ID))) { MessageBox.Show("Failed to add broker account, account with same ID already exist."); return; } if (Accounts.Any(p => p.UserName.Equals(account.UserName))) { MessageBox.Show("Failed to add broker account, account with same User Name already exist."); return; } Accounts.Add(account); }