private void btn_updatePatient_Click(object sender, EventArgs e) { try { // Get the values from input/selection fields. patient.PatientId = int.Parse(txtbx_patientID.Text); patient.FirstName = txtbx_patientFName.Text; patient.LastName = txtbx_patientLName.Text; patient.ContactNo = txtbx_patientContact.Text; patient.Dob = dtp_patientDOB.Text; patient.Sex = cmb_patientSex.Text; patient.BloodType = cmb_patientBloodType.Text; patient.Address = txtbx_patientAddress.Text; // Update data in the database bool success = patient.Update(patient); if (success) { // Successfully updated MessageBox.Show("Patient updated successfully."); // Call the method to load DataGrid view LoadPatientDgvData(); // Call the clear method Clear(); } else { // Failed to update contact MessageBox.Show("Failed to update patient. Try again."); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }