Пример #1
0
 protected void DeletePatientAppointButton_Click(object sender, EventArgs e)
 {
     if (ShowPatientAppointments.SelectedRow != null) // if appointment selected to delete on gridview, do this
     {
         AppointmentsTable delete = new AppointmentsTable();
         string            input  = ShowPatientAppointments.SelectedValue.ToString(); // gets AppointmentID of selected row
         int appointmentID        = Convert.ToInt32(input);
         delete = UtilitiesClass.createAppointment(appointmentID);                    // creates copy of appointment object to delete
         foreach (AppointmentsTable appointment in dbcon.AppointmentsTables)          // check if appointment exists
         {
             if (appointment.AppointmentID == delete.AppointmentID)                   // if appointment exists, delete it
             {
                 dbcon.AppointmentsTables.Remove(appointment);
             }
         }
         dbcon.SaveChanges();                         // save changes to database
         ShowPatientAppointments.DataBind();          // update changes to grid view displaying patient appointment
         if (ShowPatientAppointments.Rows.Count == 0) // if no appointments, display message
         {
             DisplayNoAppointMessage.Text       = "You have no appointments set up.";
             DisplayNoAppointMessage.Visible    = true;
             DeletePatientAppointButton.Visible = false; // makes delete appointment button invisible
         }
     }
 }
Пример #2
0
 protected void DeleteDoctorAppointButton_Click(object sender, EventArgs e) // same logic for deleting patient appointments
 {
     if (ShowDoctorAppointments.SelectedRow != null)
     {
         AppointmentsTable delete = new AppointmentsTable();
         string            input  = ShowDoctorAppointments.SelectedValue.ToString();
         int appointmentID        = Convert.ToInt32(input);
         delete = UtilitiesClass.createAppointment(appointmentID);
         foreach (AppointmentsTable appointment in dbcon.AppointmentsTables)
         {
             if (appointment.AppointmentID == delete.AppointmentID)
             {
                 dbcon.AppointmentsTables.Remove(appointment);
             }
         }
         dbcon.SaveChanges();
         ShowDoctorAppointments.DataBind();
         if (ShowDoctorAppointments.Rows.Count == 0)
         {
             DisplayNoAppointMessage.Text      = "You have no appointments set up.";
             DisplayNoAppointMessage.Visible   = true;
             DeleteDoctorAppointButton.Visible = false;
         }
     }
 }