示例#1
0
        ///-------------------------------------------------------------------------------------------------
        /// \fn private void LstRequests_SelectionChanged(object sender, SelectionChangedEventArgs e)
        ///
        /// \brief  Whenever a new item is selected, update the buttons based on what they can do
        ///				o cannot book if the date is already full of appointments
        ///				o cancel (always available)
        ///
        /// \author Bailey
        /// \date   2019-04-18
        ///-------------------------------------------------------------------------------------------------
        private void LstRequests_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int i = lstRequests.SelectedIndex;

            if (i >= 0)
            {
                btnCancel.IsEnabled = true;

                // Only allow booking if there are enough slots
                if (SchedulingSupport.GetAppointmentCountForDay(requests[i].Date) < SchedulingSupport.MaxAppointmentsForDay(requests[i].Date))
                {
                    btnBook.IsEnabled = true;
                }
                else
                {
                    btnBook.IsEnabled = false;
                }
            }
            else
            {
                btnBook.IsEnabled   = false;
                btnCancel.IsEnabled = false;
            }
        }