private void BtnCreate_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(TxtName.Text) || string.IsNullOrEmpty(TxtUsername.Text) || string.IsNullOrEmpty(TxtPassword.Password) || string.IsNullOrEmpty(TxtPasswordAgain.Password)) { MessageBox.Show("Make sure you've filled out all the fields!", "Oops", MessageBoxButton.OK, MessageBoxImage.Hand); return; } if (TxtPassword.Password != TxtPasswordAgain.Password) { MessageBox.Show("Passwords don't match, make sure you enter the same password twice.", "Password mismatch", MessageBoxButton.OK, MessageBoxImage.Hand); return; } if (!_modifying) { CredentialManager.AddCredentials(TxtName.Text, TxtUsername.Text, TxtPassword.Password); MessageBox.Show( string.Format("Added user {0} under name {1} successfully.", TxtUsername.Text, TxtName.Text), "Success!", MessageBoxButton.OK, MessageBoxImage.Information); } else { CredentialManager.UpdateCredentials(_modifyIndex, TxtName.Text, TxtUsername.Text, TxtPassword.Password); MessageBox.Show( string.Format("Modified user {0} successfully.", TxtUsername.Text), "Success!", MessageBoxButton.OK, MessageBoxImage.Information); } Close(); }