private void AddCardButton_Click(object sender, EventArgs e) { try { var user = AllUserData.GetSelectedUser(garageComboBox.SelectedItem.ToString()); AddUser.AddCardToUser(user, CardTextBox.Text); DialogResult result = MessageBox.Show("Успех!", "Успех!", MessageBoxButtons.OK); if (result == DialogResult.OK) { Close(); } } catch (Exception) { DialogResult result = MessageBox.Show("Ошибка!", "Ошибка!", MessageBoxButtons.OK); } }