protected void Page_Load(object sender, EventArgs e) { // If Patient, do this if (Convert.ToInt32(Session["IsDoctor"]) == 0) { // Doctor's appointments not visible to patient ShowDoctorAppointments.Visible = false; // Create Patient Object myPatient = UtilitiesClass.getPatient(Session["LoginName"].ToString()); Session["AppointmentPatientID"] = myPatient.PatientID; // Create a Doctor object that is paired to the patient myDoctor = UtilitiesClass.getPatientsDoctor(myPatient); // Adds users appointments to appointments list allAppointments = dbcon.AppointmentsTables.ToList(); foreach (AppointmentsTable appointment in allAppointments) { if (appointment.PatientID == myPatient.PatientID) { userAppointments.Add(appointment); } } // If no appointments are set up, display message if (userAppointments.Count == 0) { DisplayNoAppointMessage.Text = "You have no appointments set up yet."; DeletePatientAppointButton.Visible = false; } else // display patients appointments { DisplayNoAppointMessage.Visible = false; DeletePatientAppointButton.Visible = true; } } else // if Doctor, do this { AddAppointmentHyperLink.Visible = false; ShowDoctorAppointments.Visible = true; ShowPatientAppointments.Visible = false; DoctorsTable myDoctor = UtilitiesClass.getDoctor(Session["LoginName"].ToString()); Session["AppointmentDoctorID"] = myDoctor.DoctorID; allAppointments = dbcon.AppointmentsTables.ToList(); foreach (AppointmentsTable appointment in allAppointments) { if (appointment.DoctorID == myDoctor.DoctorID) { userAppointments.Add(appointment); } } if (userAppointments.Count == 0) { DisplayNoAppointMessage.Text = "You have no appointments set up yet."; DeleteDoctorAppointButton.Visible = false; } else { DisplayNoAppointMessage.Visible = false; DeleteDoctorAppointButton.Visible = true; } } }