private void btCancelAppointment_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (clinicEntities context = new clinicEntities())
                {
                    display_appointements_for_Patient app = (display_appointements_for_Patient)display_appointements_for_PatientListView.SelectedItem;
                    int timeslot      = app.TimeSlotId;
                    int appointmentId = app.appointmentId;
                    var app1          = context.appointments.Find(appointmentId);
                    // check if the appointment to be cancelled is 48 hours away, if it is less then 48 hours away, it cannot be canncelled
                    int hoursAhead = (app.Start - DateTime.Now).Value.Hours;
                    if (hoursAhead < 48)
                    {
                        MessageBox.Show("you cannot cancel this appointment which is within 48 hours, please contact office");
                    }

                    else
                    {
                        context.timeslots.Find(timeslot).IsAvailable = true;
                        context.appointments.Remove(app1);
                        MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure to delete this appointment?", "Delete Confirmation", MessageBoxButton.YesNo);
                        if (messageBoxResult == MessageBoxResult.Yes)
                        {
                            context.SaveChanges();
                            MessageBox.Show("the appointment cancelled");
                            context.display_appointements_for_Patient.Load();
                            display_appointements_for_PatientViewSource.Source      = context.display_appointements_for_Patient.Local;
                            display_appointements_for_PatientViewSource.View.Filter = item =>
                            {
                                display_appointements_for_Patient m = item as display_appointements_for_Patient;
                                if (m != null)
                                {
                                    if (m.PatientId.Equals(Globals.SessionId))
                                    {
                                        return(true);
                                    }
                                }
                                return(false);
                            };
                        }
                    }
                }
            }
            catch
            {
                MessageBox.Show("there is no appointment selected");
            }
        }
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     context.display_appointements_for_Patient.Load();
     display_appointements_for_PatientViewSource.Source      = context.display_appointements_for_Patient.Local;
     display_appointements_for_PatientViewSource.View.Filter = item =>
     {
         display_appointements_for_Patient m = item as display_appointements_for_Patient;
         if (m != null)
         {
             if (m.PatientId.Equals(Globals.SessionId))
             {
                 return(true);
             }
         }
         return(false);
     };
 }
Example #3
0
 private void btNext_Click(object sender, RoutedEventArgs e)
 {
     if (patientViewSource.View.CurrentPosition < ((CollectionView)patientViewSource.View).Count - 1)
     {
         patientViewSource.View.MoveCurrentToNext();
     }
     display_appointements_for_PatientViewSource.View.Filter = item =>
     {
         display_appointements_for_Patient m = item as display_appointements_for_Patient;
         if (m != null)
         {
             if (m.PatientId.Equals(int.Parse(idLabel.Content.ToString())))
             {
                 return(true);
             }
         }
         return(false);
     };
 }
Example #4
0
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     context.patients.Load();
     patientViewSource.Source = context.patients.Local;
     context.display_appointements_for_Patient.Load();
     display_appointements_for_PatientViewSource.Source      = context.display_appointements_for_Patient.Local;
     display_appointements_for_PatientViewSource.View.Filter = item =>
     {
         display_appointements_for_Patient m = item as display_appointements_for_Patient;
         if (m != null)
         {
             if (m.PatientId.Equals(int.Parse(idLabel.Content.ToString())))
             {
                 return(true);
             }
         }
         return(false);
     };
 }