private void AddDoctorBtn_Click(object sender, EventArgs e) { Doctor doctor = new Doctor(); if (!string.IsNullOrEmpty(TxtDoctorFirstName.Text) && !string.IsNullOrEmpty(TxtDoctorLastName.Text)) { try { doctor.Id = Convert.ToInt32(TxtDoctorId.Text); doctor.FirstName = TxtDoctorFirstName.Text; doctor.LastName = TxtDoctorLastName.Text; doctor.Department = CboDoctorDepartment.Text; if (true) { _doctorManager.AddDoctor(doctor); MessageBox.Show("New doctor record added!"); var xml = XDocument.Load(_xmlPath); xml.Element(Settings.SETTINGS).Element(Settings.DATA).Element(Settings.DOCTOR_ID).Value = doctor.Id.ToString(); xml.Save(_xmlPath); this.Close(); } } catch (Exception) { MessageBox.Show("Please fill empty fields"); } } else { MessageBox.Show("Please fill empty fields!"); } }