public bool DeleteDoctorById(int doctorId) { PatientManager patientManager = new PatientManager(); List<Patient> patientList = patientManager.GetPatientsByDoctorId(doctorId); if (patientList.Count>0) { return false; } else { return doctorGateway.DeleteDoctorById(doctorId); } }
public bool DeleteDoctorById(int doctorId) { PatientManager patientManager = new PatientManager(); List <Patient> patientList = patientManager.GetPatientsByDoctorId(doctorId); if (patientList.Count > 0) { return(false); } else { return(doctorGateway.DeleteDoctorById(doctorId)); } }
private void saveButton_Click(object sender, EventArgs e) { PatientManager patientManager=new PatientManager(); PatientDiseaseManager patientDiseaseManager=new PatientDiseaseManager(); Patient patient=new Patient(); patient.Id = patientId; patient.Name = patientsNameTextBox.Text; patient.DoctorId = int.Parse(doctorComboBox.SelectedValue.ToString()); if (mode == "Update" && patient.Name!="") { int row = patientManager.Update(patient); if (row == 1) { PatientDiseaseManager aPatientDiseaseManager=new PatientDiseaseManager(); aPatientDiseaseManager.DeleteExisting(patient); foreach (var index in diseaseCheckedListBox.CheckedItems) { Disease disease = (Disease)index; PatientDisease patientDisease = new PatientDisease(); patientDisease.PatientId = patient.Id; patientDisease.DiseaseId = disease.Id; patientDiseaseManager.Save(patientDisease); } Close(); MessageBox.Show("Patient Successfully Updated"); } } else if(patient.Name!="") { int retrievedPatientId = patientManager.Save(patient); if (retrievedPatientId > 0) { foreach (var index in diseaseCheckedListBox.CheckedItems) { Disease disease = (Disease) index; PatientDisease patientDisease = new PatientDisease(); patientDisease.PatientId = retrievedPatientId; patientDisease.DiseaseId = disease.Id; patientDiseaseManager.Save(patientDisease); } Close(); MessageBox.Show("Patient Successfully Saved"); } } else { MessageBox.Show("Name cannot be empty"); } }
private void showPatientsToolStripMenuItem_Click(object sender, EventArgs e) { if (doctorsListView.SelectedItems.Count > 0) { int doctorId = int.Parse(doctorsListView.SelectedItems[0].Tag.ToString()); List<Patient> patientList = new List<Patient>(); PatientManager patientManager = new PatientManager(); patientList = patientManager.GetPatientsByDoctorId(doctorId); PatientListForm patientListForm = new PatientListForm(patientList); patientListForm.Show(); } else { MessageBox.Show("You must Select a row"); } }