예제 #1
0
        private List <ClassCalendarDay> ListOfOriginalDays()
        {
            ClassCalendar           calendar    = GetCalendarForCurrentDate();
            List <ClassCalendarDay> orignalDays = ClassSqlCalendar.ListOfCalendarDays(calendar.CalendarId);

            return(orignalDays);
        }
        private List <ClassCalendarDay> ListOfOriginalDays()
        {
            ClassCalendar           calendar    = GetCalendarForSelectedCalendarInComboboxFromDataBase();
            List <ClassCalendarDay> orignalDays = ClassSqlCalendar.ListOfCalendarDays(calendar.CalendarId);

            return(orignalDays);
        }
예제 #3
0
        //Add or edit calendar day
        private void ButtonAdd_Click(object sender, RoutedEventArgs e)
        {
            ClassCalendar    calendar;
            ClassCalendarDay day;

            try
            {
                calendar = GetCalendarForSelectedCalendarInComboboxFromDataBase();
                if (calendar.Status.StatusId != sql.SelectStatusId(EnumStatus.New))
                {
                    throw new Exception("Calendar status must be new");
                }
                day = GetCalendarDayOrGenerateIt(sender, calendar);
                WindowCalendarDayEdition window = new WindowCalendarDayEdition(day, calendar.Year, calendar.Month, sql.ListOfCalendarDays(calendar.CalendarId));
                if (!(sender is Button))
                {
                    window.createNew = false;
                }
                bool update = (bool)window.ShowDialog();
                if (!update)
                {
                    throw new Exception("Operation canceled");
                }
                if (sender is Button)
                {
                    sql.CreateCalendarDay(day.Day, calendar.CalendarId, day.StartTime, day.EndTime);
                    MessageBox.Show("Calendar day succesfully added");
                    ReloadData();
                    return;
                }
                sql.UpdateCalendarDay(day.Day, day.CalendarDayId, day.StartTime, day.EndTime);
                MessageBox.Show("Calendar day succesfully edited");
                ReloadData();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
                return;
            }
        }
        private ClassCalendarDay GetCalendarDayForSelectedCalendarDayInDataGridFromDataBase(int calendarId)
        {
            if (DataGridListOfDoctors.SelectedIndex == -1)
            {
                throw new Exception("Data grid row isn't selected");
            }
            //Get calendar from data base
            IEnumerable <ClassCalendarDay> query =
                from elem in ClassSqlCalendar.ListOfCalendarDays(calendarId)
                where elem.CalendarDayId == ((ClassCalendarDay)DataGridListOfDoctors.SelectedItem).CalendarDayId
                select elem;

            if (!query.Any())
            {
                throw new Exception("Unable to find selected calendar day in database");
            }
            return(query.First());
        }
        private void LoadDateToGrid()
        {
            if (ComboBoxPickCalendar.SelectedIndex == -1)
            {
                CurrentMonthDataGrid.ItemsSource = null;
                return;
            }
            try
            {
                ClassCalendar calendar = GetCalendarForSelectedCalendarInComboboxFromDataBase();

                CurrentMonthDataGrid.ItemsSource = ClassSqlCalendar.ListOfCalendarDays(calendar.CalendarId);
                days = ClassSqlCalendar.ListOfCalendarDays(calendar.CalendarId);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 private void ReloadData()
 {
     if (ComboBoxPickDate.SelectedIndex == -1)
     {
         DataGridListOfDoctors.ItemsSource        = null;
         DataGridListOfCalendarDoctor.ItemsSource = null;
         Status_Label.Text = "...";
         return;
     }
     try
     {
         ClassCalendar calendar = GetCalendarForSelectedCalendarInComboboxFromDataBase();
         DataGridListOfDoctors.ItemsSource        = ClassSqlCalendar.ListOfCalendarDays(calendar.CalendarId);
         DataGridListOfCalendarDoctor.ItemsSource = ClassSqlCalendar.ListOfCalendarDoctor(calendar.CalendarId);
         LoadStatusToLabel(calendar);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        private List <ClassCalendarDay> ListOfAvaiableDates()
        {
            ClassCalendar           calendar         = GetCalendarForCurrentDate();
            List <ClassCalendarDay> allAvailableDays = ClassSqlCalendar.ListOfCalendarDays(calendar.CalendarId);
            List <ClassTerm>        workingDays      = ClassSqlCalendar.GetListOfWorkingDayInCurrentMonth(ClassLoggedDoctor.Doctor_Id);

            List <ClassCalendarDay> avaiableDates = new List <ClassCalendarDay>();

            foreach (ClassTerm term in workingDays)
            {
                foreach (ClassCalendarDay day in allAvailableDays)
                {
                    if (term.Date == day.DateInDateTime)
                    {
                        avaiableDates.Add(day);
                    }
                }
            }

            avaiableDates = allAvailableDays.Except(avaiableDates).ToList();

            return(avaiableDates);
        }