Beispiel #1
0
        private void TestData_Click(object sender, RoutedEventArgs e)
        {
            MeetingRoom selectedRoom = (MeetingRoom)RoomSelector.SelectedItem;
            DateTime    date         = new DateTime(2018, 12, 12);
            TimeSpan    start        = new TimeSpan(10, 00, 00);
            TimeSpan    end          = new TimeSpan(11, 00, 00);
            Reservation res1         = new Reservation(date, start, end, 1, "Jan Koranda", false, "nic", selectedRoom.roomCode);

            selectedRoom.reservationsList.Add(res1);
            Reservation added = selectedRoom.reservationsList.First();

            testLabel.Content = selectedRoom.reservationsList.Count;
        }
Beispiel #2
0
        private void MeetingDatePicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            DateTime           selectedDate         = (DateTime)meetingDatePicker.SelectedDate;
            List <Reservation> selectedReservations = new List <Reservation>();
            MeetingCentre      selectedCentre       = (MeetingCentre)CentreSelector.SelectedItem;
            MeetingRoom        selectedRoom         = (MeetingRoom)RoomSelector.SelectedItem;

            foreach (Reservation reservation in selectedRoom.reservationsList)
            {
                if (reservation.meetingDate == selectedDate)
                {
                    selectedReservations.Add(reservation);
                }
            }

            meetingsBox.ItemsSource = selectedReservations;
        }
Beispiel #3
0
 /// <summary>
 /// method to handle deleting room. works only if room is selected
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void deleteRoomButton_Click(object sender, RoutedEventArgs e)
 {
     if (MeetingRooms.SelectedItem != null)
     {
         MeetingRoom      selected = (MeetingRoom)MeetingRooms.SelectedItem;
         MessageBoxResult myResult;
         myResult = MessageBox.Show("Confirm deleting " + selected.roomName + " ?", "Delete Confirmation", MessageBoxButton.OKCancel);
         if (myResult == MessageBoxResult.OK)
         {
             MeetingCentre selectedCentre = (MeetingCentre)MeetingCentres.SelectedItem;
             selectedCentre.meetingRoomsList.Remove(selected);
             Globals.needSave = true;
             MeetingRooms.Items.Refresh();
         }
     }
     else
     {
         MessageBox.Show("Select Meeting Room first!");
     }
 }
Beispiel #4
0
        /// <summary>
        /// Handles meeting rooms selection
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MeetingRooms_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            MeetingRoom selected = (MeetingRoom)MeetingRooms.SelectedItem;

            try
            {
                editRoomName.Text        = selected.roomName;
                editRoomCode.Text        = selected.roomCode;
                editRoomDescription.Text = selected.roomDescription;
                editRoomCapacity.Text    = selected.roomCapacity.ToString();
                editVideo.IsChecked      = selected.roomVideo;
            }
            catch (Exception ex)
            {
                editRoomName.Text        = "";
                editRoomCode.Text        = "";
                editRoomDescription.Text = "";
                editRoomCapacity.Text    = "";
                editVideo.IsChecked      = false;
            }
        }
Beispiel #5
0
        /// <summary>
        /// Method to handle edit room button, works only if room is selected
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void editRoomButton_Click(object sender, RoutedEventArgs e)
        {
            if (MeetingRooms.SelectedItem != null)
            {
                MeetingRoom selected = (MeetingRoom)MeetingRooms.SelectedItem;
                InputTester checker  = new InputTester();
                int         capacity = 0;
                int.TryParse(editRoomCapacity.Text, out capacity);

                //ensure correct inputs
                if (checker.ensureName(editRoomName.Text) &&
                    checker.ensureCode(editRoomCode.Text) &&
                    checker.ensureDescription(editRoomDescription.Text) &&
                    checker.ensureCapacity(capacity))
                {
                    selected.roomName        = editRoomName.Text;
                    selected.roomCode        = editRoomCode.Text;
                    selected.roomDescription = editRoomDescription.Text;
                    selected.roomCapacity    = capacity;
                    selected.roomVideo       = (bool)editVideo.IsChecked;
                    Globals.needSave         = true;
                    MeetingRooms.Items.Refresh();
                }
                else
                {
                    string message = "Bad data format:" +
                                     Environment.NewLine + "Name – text in 2 - 100 characters." +
                                     Environment.NewLine + "Code - unique code length 5 to 50, can contain numbers, letters a-z and A-Z, also special characters (. : - _)" +
                                     Environment.NewLine + "Description - length 10 - 300 characters" +
                                     Environment.NewLine + "Capacity - integer 1 to 100 if requested";
                    MessageBox.Show(message);
                }
            }
            else
            {
                MessageBox.Show("Select Meeting Room first!");
            }
        }
Beispiel #6
0
        /// <summary>
        /// Imports CSV into app data.
        /// </summary>
        /// <param name="file"></param>
        public void parseCSV(string file)
        {
            try
            {
                using (var reader = new StreamReader(@file))
                {
                    List <string> centreList = new List <string>();
                    List <string> roomList   = new List <string>();
                    bool          centre     = true;
                    bool          isFirst    = true;

                    while (!reader.EndOfStream)
                    {
                        var line   = reader.ReadLine();
                        var values = line.Split(',');

                        //skip First Line
                        if (isFirst)
                        {
                            isFirst = false;
                            continue;
                        }

                        //skip MEETING_ROOMS line
                        if (values[0] == "MEETING_ROOMS")
                        {
                            centre = false;
                            continue;
                        }

                        //Nevim proc, nicmene obcas mi importer tendenci vyrtvaret prazdny objekt centra (prazdne stringy) a toto tomu zamezi. Byl bych rad, kdybych se dovedel, proc se tak deje
                        if (values[0] == "")
                        {
                            continue;
                        }

                        //Porcess meeting centres.
                        if (centre)
                        {
                            MeetingCentre newCentre = new MeetingCentre(values[0], values[1], values[2]);
                            Globals.meetingCentresList.Add(newCentre);
                        }
                        //process meeting rooms
                        else
                        {
                            MeetingCentre thisCentre = Globals.meetingCentresList.Find(mc => mc.centreCode == values[5]);
                            int           capacity   = 0;
                            int.TryParse(values[3], out capacity);
                            bool hasVideo = false;
                            if (values[4] == "YES")
                            {
                                hasVideo = true;
                            }
                            MeetingRoom newRoom = new MeetingRoom(values[0], values[1], values[2], capacity, hasVideo, values[5]);
                            thisCentre.meetingRoomsList.Add(newRoom);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }