Exemplo n.º 1
0
        private void btTakeAppointment_Click(object sender, RoutedEventArgs e)
        {
            using (clinicEntities context = new clinicEntities())
            {
                // get the selected spot from grid
                display_available_slots slot = (display_available_slots)display_available_slotsDataGrid.SelectedItem;
                int slotId = slot.TimeSoltId;
                MessageBox.Show(string.Format("you have chosen slot: {0}", slotId.ToString()));

                //get the selected patient id from list
                patient p         = (patient)patientListView.SelectedItem;
                int     patientId = p.Id;
                MessageBox.Show(string.Format("you have chosen patient with Id: {0}", patientId.ToString()));
                appointment app = new appointment(slotId, patientId);
                MessageBox.Show(string.Format("this appointment will be made {0}", app.ToString()));
                context.appointments.Add(app);
                context.SaveChanges();

                //load the view, need to find out how to refresh the viw of display_available_slots??
                context.display_available_slots.Load();
                display_available_slotsViewSource.Source = context.display_available_slots.Local;
                MessageBoxResult messageBoxResult = MessageBox.Show("you have sucessfully made an appointment, do you need to make another appointment?", "Make more?", System.Windows.MessageBoxButton.YesNo);
                if (messageBoxResult == MessageBoxResult.Yes)
                {
                    tbPatientName.Text = "";
                    tbName.Text        = "";
                    dpFrom.Text        = "";
                    dpTo.Text          = "";
                }
                if (messageBoxResult == MessageBoxResult.No)
                {
                    Close();
                }
            }
        }
Exemplo n.º 2
0
        private void btSearch_Click(object sender, RoutedEventArgs e)
        {
            using (clinicEntities context = new clinicEntities())
            {
                display_available_slotsViewSource.View.Filter = item =>
                {
                    string txt = tbName.Text.ToString().ToLower();
                    display_available_slots m = item as display_available_slots;

                    if (m != null)
                    {
                        if (!string.IsNullOrWhiteSpace(txt) && dpFrom.SelectedDate == null && dpTo.SelectedDate == null)// only doctor box has input
                        {
                            if (m.Doctor.ToLower().Contains(txt) && m.Start >= DateTime.Today)
                            {
                                return(true);
                            }
                        }


                        if (!string.IsNullOrWhiteSpace(txt) && dpTo.SelectedDate == null && dpFrom.SelectedDate != null)// doctor and dpFrom has input
                        {
                            if (m.Doctor.ToLower().Contains(txt) && m.Start >= dpFrom.SelectedDate)
                            {
                                return(true);
                            }
                        }

                        if (!string.IsNullOrWhiteSpace(txt) && dpTo.SelectedDate != null && dpFrom.SelectedDate == null) // doctor and dpTo has input
                        {
                            if (m.Doctor.ToLower().Contains(txt) && m.Start <= dpTo.SelectedDate.Value.AddDays(1) && m.Start >= DateTime.Today)
                            {
                                return(true);
                            }
                        }


                        if (!string.IsNullOrWhiteSpace(txt) && dpFrom.SelectedDate != null && dpTo.SelectedDate != null)// doctor, dpFrom, dpTo has input
                        {
                            if (m.Doctor.ToLower().Contains(txt) && m.Start >= dpFrom.SelectedDate && m.End <= dpTo.SelectedDate.Value.AddDays(1))
                            {
                                return(true);
                            }
                        }
                    }

                    if (string.IsNullOrWhiteSpace(txt) && dpFrom.SelectedDate != null && dpTo.SelectedDate != null)    // doctor empty, dpTo, doFrom filled
                    {
                        if (m.Start >= dpFrom.SelectedDate && m.End <= dpTo.SelectedDate.Value.AddDays(1))
                        {
                            return(true);
                        }
                    }


                    return(false);
                };
            }
        }
Exemplo n.º 3
0
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (clinicEntities context = new clinicEntities())
                {
                    display_available_slots s = (display_available_slots)display_available_slotsDataGrid.SelectedItem;
                    int slotId         = s.TimeSoltId;
                    int AvailabilityId = 0;

                    context.timeslots.Remove(context.timeslots.Find(slotId));


                    MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure to delete this time slot?", "Delete Confirmation", MessageBoxButton.YesNo);
                    if (messageBoxResult == MessageBoxResult.Yes)
                    {
                        context.SaveChanges();
                        MessageBox.Show("the slot is deleted");
                        context.display_available_slots.Load();
                        display_available_slotsViewSource.Source = context.display_available_slots.Local;
                    }
                    // check in timeslots table, if no more availabilityId exists, meaning that availability can be deleted
                    var list = context.timeslots;
                    foreach (timeslot t in list)
                    {
                        if (t.Id == slotId)
                        {
                            AvailabilityId = t.AvailabilityId;
                        }
                    }
                    if (AvailabilityId == 0)
                    {
                        context.availabilities.Remove(context.availabilities.Find(AvailabilityId));
                        context.SaveChanges();
                    }
                }
            }
            catch (System.InvalidCastException ex) { MessageBox.Show("Exception caught: {0}", ex.ToString()); }
            finally{ MessageBox.Show("nothing is selected"); }
        }
Exemplo n.º 4
0
        //private void tbName_TextChanged(object sender, TextChangedEventArgs e)
        //{

        //    if (tbName == null || string.IsNullOrWhiteSpace(tbName.Text))
        //    {
        //        display_available_slotsViewSource.View.Filter = null;
        //        return;
        //    }
        //    else
        //    {
        //        string txt = tbName.Text.ToString().ToLower();
        //        display_available_slotsViewSource.View.Filter = item =>
        //        {

        //            display_available_slots m = item as display_available_slots;

        //            if (m != null)
        //            {
        //                if (!string.IsNullOrWhiteSpace(m.Doctor) && m.Doctor.ToLower().Contains(txt) && m.Start==null && m.End==null) { return true; } // only doctor box has input
        //                if(!string.IsNullOrWhiteSpace(m.Doctor) && m.Doctor.ToLower().Contains(txt) && m.End==null && m.Start > dpFrom.SelectedDate) { return true; } // doctor and dpFrom has input
        //                if(!string.IsNullOrWhiteSpace(m.Doctor) && m.Doctor.ToLower().Contains(txt) && m.Start==null && m.End <dpTo.SelectedDate && m.End >DateTime.Today) { return true; } // doctor and dpTo has input
        //                if (!string.IsNullOrWhiteSpace(m.Doctor) && m.Doctor.ToLower().Contains(txt) && m.Doctor.ToLower().Contains(txt) && m.Start > dpFrom.SelectedDate && m.End < dpTo.SelectedDate)   { return true; }// doctor and dpFrom and dpTo all has input

        //            }
        //            return false;
        //        };
        //    }
        //}
        //private void dpFrom_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        //{
        //    if (dpFrom.SelectedDate == null)
        //    {
        //        display_available_slotsViewSource.View.Filter = null;
        //        return;
        //    }
        //    else
        //    {
        //        display_available_slotsViewSource.View.Filter = item =>
        //        {

        //            display_available_slots m = item as display_available_slots;

        //            if (m != null)
        //            {
        //                if (m.Start > dpFrom.SelectedDate)
        //                    return true;
        //            }
        //            return false;
        //        };
        //    }
        //}

        //private void dpTo_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        //{
        //    if (dpTo.SelectedDate == null)
        //    {
        //        display_available_slotsViewSource.View.Filter = null;
        //        return;
        //    }
        //    else
        //    {
        //        display_available_slotsViewSource.View.Filter = item =>
        //        {

        //            display_available_slots m = item as display_available_slots;

        //            if (m != null)
        //            {
        //                if (m.End < dpTo.SelectedDate)
        //                    return true;
        //            }
        //            return false;
        //        };
        //    }
        //}

        private void btTakeAppointment_Click(object sender, RoutedEventArgs e)
        {
            using (clinicEntities context = new clinicEntities())
            {
                // get the selected item from grid
                display_available_slots slot = (display_available_slots)display_available_slotsDataGrid.SelectedItem;
                int slotId = slot.TimeSoltId;
                // MessageBox.Show(slotId.ToString());
                //MessageBox.Show(Globals.SessionId.ToString());


                appointment app = new appointment(slotId, Globals.SessionId);
                // MessageBox.Show(app.ToString());
                context.appointments.Add(app);
                context.SaveChanges();

                //load the view, need to find out how to refresh the viw of display_available_slots??
                context.display_available_slots.Load();
                display_available_slotsViewSource.Source = context.display_available_slots.Local;
                MessageBox.Show("you have succefully taken an appointment, go to view appointment to see");
            }
        }