Beispiel #1
0
        public AvailableTime GetDoctorAvailability(int docId, string date)//date format: yyyymmdd
        {
            //List<AvailableTime> list = new List<AvailableTime>();
            SqlCommand cmdSelect = new SqlCommand("SELECT * FROM DoctorAvailability WHERE DoctorId = @DocId AND convert(varchar(10), AvailableDate, 120) = @AppDate ORDER BY Id ", conn);

            cmdSelect.Parameters.AddWithValue("DocId", docId);
            cmdSelect.Parameters.AddWithValue("AppDate", date);
            AvailableTime at = null;

            using (SqlDataReader reader = cmdSelect.ExecuteReader())
            {
                if (reader.Read())
                {
                    try
                    {
                        //int id = (int)reader["Id"];
                        //int docid = (int)reader["DoctorId"];
                        int starthour = (int)reader["StartHour"];
                        int endhour   = (int)reader["EndHour"];
                        //string availabledate = (string)reader["AvailableDate"];

                        //list.Add(new AvailableTime() { StartTime = starthour, EndTime = endhour  });
                        at = new AvailableTime()
                        {
                            StartTime = starthour, EndTime = endhour
                        };
                    }
                    catch (InvalidCastException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            return(at);
        }
Beispiel #2
0
        private void ReloadAvailableTimeList()
        {
            try
            {
                List <Appointment> list = Globals.Db.GetAllAppointsByDoctorDate(selecteddocid, selecteddocdate);

                AvailableTime docWorkHours = Globals.Db.GetDoctorAvailability(selecteddocid, selecteddocdate);
                if (docWorkHours == null)
                {
                    System.Windows.MessageBox.Show("Doctor schedule hasn't been set for date: " + selecteddocdate);

                    AvailableTimeList.Clear();
                }
                else
                {
                    AvailableTimeList = GetDoctorAvailableTimes(list, docWorkHours);
                }
                //if (list.Count > 0)


                lvAvailableTimes.ItemsSource = AvailableTimeList;
                lvAvailableTimes.Items.Refresh();
            }
            catch (SqlException ex)
            {
                System.Windows.MessageBox.Show("Error executing SQL query:\n" + ex.Message,
                                               "Easy Appointment", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #3
0
        private void Wizard_Next(object sender, Xceed.Wpf.Toolkit.Core.CancelRoutedEventArgs e)
        {
            if ((sender as Wizard).CurrentPage.Name == "Page1")
            {
                if ((lvDoctors.SelectedValue as Doctor) == null)
                {
                    System.Windows.MessageBox.Show("Please select doctor", "Easy Appointment", MessageBoxButton.OK, MessageBoxImage.Stop);
                    e.Cancel = true;
                    return;
                }

                selecteddocid = (lvDoctors.SelectedValue as Doctor).Id;
                ReloadAvailableTimeList();
            }
            else if ((sender as Wizard).CurrentPage.Name == "Page2")
            {
                AvailableTime att = lvAvailableTimes.SelectedValue as AvailableTime;
                if (att == null)
                {
                    System.Windows.MessageBox.Show("Please select available time", "Easy Appointment", MessageBoxButton.OK, MessageBoxImage.Stop);
                    e.Cancel = true;
                    return;
                }
                if (!cldAppointmentDate.SelectedDate.HasValue)
                {
                    System.Windows.MessageBox.Show("Please select date", "Easy Appointment", MessageBoxButton.OK, MessageBoxImage.Stop);
                    e.Cancel = true;
                    return;
                }
                selecteddocdate = cldAppointmentDate.SelectedDate.Value.ToString("yyyy-MM-dd");
                selecteddoctime = att.StartTime;
            }
        }
Beispiel #4
0
        private List <AvailableTime> GetDoctorAvailableTimes(List <Appointment> appointmentlist, AvailableTime worktime)
        {
            List <AvailableTime> availList = new List <AvailableTime>();

            // if (appointmentlist == null || worktime == null)
            //     return null;
            for (int i = worktime.StartTime; i < worktime.EndTime; i++)
            {
                bool isBooked = false;
                foreach (Appointment a in appointmentlist)
                {
                    if (a.AppointmentTime == i)
                    {
                        isBooked = true;
                    }
                }
                if (!isBooked)
                {
                    availList.Add(new AvailableTime()
                    {
                        StartTime = i, EndTime = i + 1
                    });
                }
            }
            return(availList);
        }