Esempio n. 1
0
        public bool Run()
        {
            ReservationWindow sw = new ReservationWindow();

            sw.DataContext = this;
            if (sw.ShowDialog() == true)
            {
                return(true);
            }
            return(false);
        }
Esempio n. 2
0
        private void Reservation(TOPModel top, DataGrid TOPsDataGrid)
        {
            ReservationWindow reservation = new ReservationWindow();

            if (reservation.ShowDialog() == true)
            {
                top.Reserved        = true;
                top.ReservationEnds = reservation.ReservationEndDate.SelectedDate.Value;
                UpdateTOP(top, TOPsDataGrid);
                return;
            }
            MessageBox.Show("TOP is not reserved!", "Info", MessageBoxButton.OK, MessageBoxImage.Warning);
        }
Esempio n. 3
0
        private void OpenNewReserve(object sender, EventArgs e)
        {
            _reservationViewModel                     = new ReservationViewModel(_service);
            _reservationViewModel.Canceled           += (o, args) => { OpenMenu(_reservationWindow); };
            _reservationViewModel.MessageApplication += ViewModel_MessageApplication;
            _reservationViewModel.Success            += (o, args) =>
            {
                OpenMenu(_reservationWindow);
                ShowMsgBox("Successfully sold");
            };

            _reservationWindow = new ReservationWindow {
                DataContext = _reservationViewModel
            };

            _reservationWindow.Show();
            _menuWindow.Close();
        }
        private void OnReservateButtonClicked(object sender, RoutedEventArgs e)
        {
            DateTime start = new DateTime(1970, 1, 1, 9, 0, 0);
            DateTime end   = new DateTime(1970, 1, 1, 17, 30, 0);

#if DEBUG
            var isDebug = true;
#else
            var isDebug = false;
#endif

            if (isDebug || !isUserMode || (start.TimeOfDay <= DateTime.Now.TimeOfDay && DateTime.Now.TimeOfDay <= end.TimeOfDay))
            {
                if (ReservationStatusPerDay.IsSelectedAlreadyOccupied())
                {
                    MessageBox.Show("이미 예약 되어 있습니다", "예약 불가", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                else
                {
                    ReservationWindow window = new ReservationWindow(isUserMode);
                    window.onReservationSuccess = (item) => {
                        refresh();
                        if (item.classroom.Contains("과도관"))
                        {
                            MessageBox.Show("예약에 성공했습니다\n꼭 예약 종이에 도장을 받아가 주세요", "예약 성공", MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                        else
                        {
                            MessageBox.Show("예약에 성공했습니다", "예약 성공", MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                    };
                    window.ShowInTaskbar = false;
                    window.ShowDialog();
                }
            }
            else
            {
                MessageBox.Show("강의실 예약은 아침 9시 부터 오후 5시 반 까지만 가능합니다.", "예약 불가", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
        public static bool AddReservation(AppointmentItem appointment)
        {
            ReservationWindow wnd = null;
            bool success          = false;

            DisplayManager.ShowSplashScreen();
            try
            {
                wnd         = new ReservationWindow(appointment.Application.Session.CurrentUser.Name, "", appointment.Start, appointment.End, appointment.IsRecurring ? appointment.GetRecurrencePattern() : null);
                wnd.Loaded += (s, e) => { DisplayManager.HideSplashScreen(); };
            }
            catch (System.Exception ex)
            {
                DisplayManager.HideSplashScreen();
                LogManager.LogException(ex);
                DisplayManager.ShowErrorWindow("Failed to load MRBS Window", ex.Message);
            }

            if ((wnd != null) && (wnd.ShowDialog() == true))
            {
                DisplayManager.ShowMessageWindow("Reserving Conference Room");
                if (wnd.Request.Description == "")
                {
                    string requestor = wnd.Request.Requestor;

                    if (requestor.Contains(", "))
                    {
                        requestor = requestor.Substring(0, requestor.IndexOf(", "));
                    }

                    wnd.Request.Description = requestor;
                }

                try
                {
                    DisplayManager.UpdateMessageScreen("Saving entry to MRBS...");
                    string mtg_id = Database.ReserveConferenceRoom(wnd.Request);

                    UpdateOutlookAppointment(appointment, mtg_id, wnd.Request);
                    success = true;
                    DisplayManager.UpdateMessageScreen("Reservation was successful!");
                    Thread.Sleep(1200);
                }
                catch (System.Exception ex)
                {
                    string msg = ex.Message;

                    while (ex.InnerException != null)
                    {
                        ex   = ex.InnerException;
                        msg += "\n" + ex.Message;
                    }

                    LogManager.LogException(ex);
                    DisplayManager.ShowErrorWindow("Error reserving conference room", msg);
                    success = false;
                }
                finally
                {
                    DisplayManager.HideMessageScreen();
                }
            }

            return(success);
        }
        public static bool ModifyReservation(AppointmentItem appointment)
        {
            ReservationWindow wnd = null;
            MeetingRequest    existing_request = null;
            string            mrbs_uid         = appointment.UserProperties["MJ-MRBS-ID"].Value.ToString();
            int    mrbs_id  = -1;
            string ical_uid = "";

            string[] splits  = mrbs_uid.Split(';');
            bool     success = false;

            if (splits.Length > 0)
            {
                int.TryParse(splits[0], out mrbs_id);
            }
            if (splits.Length > 1)
            {
                ical_uid = splits[1];
            }

            DisplayManager.ShowSplashScreen();
            DisplayManager.UpdateSplashScreen("Retrieving reservation from MRBS...");
            try
            {
                existing_request = Database.GetRequestByEntry(mrbs_id, ical_uid, appointment.RecurrenceState == OlRecurrenceState.olApptMaster);
            }
            catch (KeyNotFoundException)
            {
                DisplayManager.HideSplashScreen();
                if (DisplayManager.ShowQuestionWindow("Reservation not found in MRBS", "The reservation linked with this appointment could not be found in MRBS.", "Do you want to remove the link?") == true)
                {
                    DisassociateAppointment(appointment);
                }

                return(false);
            }
            catch (System.Exception ex)
            {
                string msg = ex.Message;

                while (ex.InnerException != null)
                {
                    ex   = ex.InnerException;
                    msg += "\n" + ex.Message;
                }

                LogManager.LogException(ex);
                DisplayManager.HideSplashScreen();
                DisplayManager.ShowErrorWindow("Error reserving conference room", msg);
                return(false);
            }

            wnd         = new ReservationWindow(existing_request, mrbs_id);
            wnd.Loaded += (s, e) => { DisplayManager.HideSplashScreen(); };
            if (wnd.ShowDialog() == true)
            {
                bool roomChanged    = existing_request.RoomId != wnd.Request.RoomId;
                bool timeChanged    = (existing_request.Start != wnd.Request.Start) || (existing_request.End != wnd.Request.End);
                bool patternChanged = IsMRBSPatternDifferent(existing_request, wnd.Request);

                DisplayManager.ShowMessageWindow("Reserving Conference Room");
                if (wnd.Request.Description == "")
                {
                    string requestor = wnd.Request.Requestor;

                    if (requestor.Contains(", "))
                    {
                        requestor = requestor.Substring(0, requestor.IndexOf(", "));
                    }

                    wnd.Request.Description = requestor;
                }

                try
                {
                    DisplayManager.UpdateMessageScreen("Saving entry to MRBS...");
                    string mtg_id = "";

                    if (appointment.RecurrenceState == OlRecurrenceState.olApptMaster)
                    {
                        if (roomChanged || timeChanged || patternChanged)
                        {
                            Database.RemoveRepeatingEntry(mrbs_id, ical_uid);
                            mtg_id = Database.ReserveConferenceRoom(wnd.Request);
                        }
                        else
                        {
                            mtg_id = Database.UpdateRepeat(mrbs_id, ical_uid, wnd.Request);
                        }
                    }
                    else
                    {
                        mtg_id = Database.UpdateEntry(mrbs_id, ical_uid, wnd.Request);
                    }

                    UpdateOutlookAppointment(appointment, mtg_id, wnd.Request, patternChanged);
                    success = true;
                    DisplayManager.UpdateMessageScreen("Reservation was successful!");
                    Thread.Sleep(1200);
                }
                catch (System.Exception ex)
                {
                    string msg = ex.Message;

                    while (ex.InnerException != null)
                    {
                        ex   = ex.InnerException;
                        msg += "\n" + ex.Message;
                    }

                    LogManager.LogException(ex);
                    DisplayManager.ShowErrorWindow("Error reserving conference room", msg);
                    success = false;
                }
                finally
                {
                    DisplayManager.HideMessageScreen();
                }
            }

            return(success);
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ReservationWindow win2 = new ReservationWindow();

            win2.ShowDialog();
        }