예제 #1
0
        private void DayBox_DoubleClick(object sender, MouseButtonEventArgs e)
        {
            //-- call to FindVisualAncestor to make sure they didn't click on existing appointment (in which case,
            //   that appointment window is already opened by handler Appointment_DoubleClick)

            if (e.Source is DayBoxControl && Utilities.FindVisualAncestor(typeof(DayBoxAppointmentControl), (Visual)e.OriginalSource) == null)
            {
                NewAppointmentEventArgs ev = new NewAppointmentEventArgs();
                if (((DayBoxControl)e.Source).Tag != null)
                {
                    ev.StartDate = new System.DateTime(_DisplayYear, _DisplayMonth, Convert.ToInt32(((DayBoxControl)e.Source).Tag), 10, 0, 0);
                    ev.EndDate   = Convert.ToDateTime(ev.StartDate).AddHours(2);
                }
                if (OnDayDoubleClicked != null)
                {
                    OnDayDoubleClicked(ev);
                }
                e.Handled = true;
            }
        }
예제 #2
0
 private void DayBoxDoubleClicked_event(NewAppointmentEventArgs e)
 {
     MessageBox.Show("You double-clicked on day " + Convert.ToDateTime(e.StartDate).ToShortDateString(), "Calendar Event", MessageBoxButton.OK);
 }
예제 #3
0
        private void DayBoxDoubleClicked_event(NewAppointmentEventArgs e)
        {
            if (e.StartDate < DateTime.Today)
            {
                MessageBox.Show("Sorry. No reservations can be made in the past.", "Message", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            //MessageBox.Show("You double-clicked on day " + Convert.ToDateTime(e.StartDate).ToShortDateString(), "Calendar Event", MessageBoxButton.OK);
            Reservation reservation = new Reservation();
            reservation.StartDate = Convert.ToDateTime(e.StartDate).Date + DateTime.Now.TimeOfDay;
            reservation.EndDate = Convert.ToDateTime(e.StartDate).Date + DateTime.Now.TimeOfDay;

            ReservationFrm reservationFrm = new ReservationFrm(reservation);
            bool result = (bool)reservationFrm.ShowDialog();

            if (result)
            {
                try
                {
                    Generic<Reservation> gen = new Generic<Reservation>();
                    if (reservation.Id == 0)
                        gen.Add(reservation);
                    else
                        gen.Update(reservation, reservation.Id);

                    gen.Dispose();
                    MessageBox.Show("The reservation was saved successfully", "Reservation saved", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                catch (Exception ex)
                {
                    Console.Write(ex.ToString());
                    MessageBox.Show("There was a problem saving this Reservation to the database. Please try again later or contact a sysadmin.", "Database Error", MessageBoxButton.OK, MessageBoxImage.Information);
                }

                // reload companies and refresh ListBox
                loadCalendar();
            }
        }
        private void DayBox_DoubleClick(object sender, MouseButtonEventArgs e)
        {
            //-- call to FindVisualAncestor to make sure they didn't click on existing appointment (in which case,
            //   that appointment window is already opened by handler Appointment_DoubleClick)

            if (e.Source is DayBoxControl && Utilities.FindVisualAncestor(typeof(DayBoxAppointmentControl), (Visual)e.OriginalSource) == null) {
            NewAppointmentEventArgs ev = new NewAppointmentEventArgs();
            if (((DayBoxControl)e.Source).Tag != null) {
                ev.StartDate = new System.DateTime(_DisplayYear, _DisplayMonth, Convert.ToInt32(((DayBoxControl)e.Source).Tag), 10, 0, 0);
                ev.EndDate = Convert.ToDateTime(ev.StartDate).AddHours(2);
            }
            if (DayBoxDoubleClicked != null) {
                DayBoxDoubleClicked(ev);
            }
            e.Handled = true;
            }
        }