/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { Person selectedPerson = GetSelectedPersonFromDataGridView(); //check that the user input is a valid int age = 0; bool convertSucceeded = int.TryParse(txtAge.Text, out age); if (convertSucceeded) { if (selectedPerson != null) { selectedPerson.Age = age; selectedPerson.FirstName = txtFirstName.Text; selectedPerson.LastName = txtLastName.Text; selectedPerson.Position = txtPosition.Text; personDAO.UpdateObjectInDB(selectedPerson); RefreshList(); } } else { MessageBox.Show("Invalid input. Please check your inputs.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }