Exemple #1
0
 /// <summary>
 /// handles edit centre click.Checks all inputs and update data if pass. otherwise popup message window w2ith general info about data format.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void EditMeetingCentreButton_Click(object sender, RoutedEventArgs e)
 {
     if (MeetingCentres.SelectedItem != null)
     {
         InputTester checker = new InputTester();
         //checking inputs
         if (checker.ensureName(editCentreName.Text) && checker.ensureCode(editCentreCode.Text) && checker.ensureDescription(editCentreDescription.Text))
         {
             MeetingCentre selected = (MeetingCentre)MeetingCentres.SelectedItem;
             selected.centreName        = editCentreName.Text;
             selected.centreCode        = editCentreCode.Text;
             selected.centreDescription = editCentreDescription.Text;
             Globals.needSave           = true;
             MeetingCentres.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 Centre first!");
     }
 }
Exemple #2
0
        /// <summary>
        /// Handle createCentreButtonClick
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void createCentreButton_Click(object sender, RoutedEventArgs e)
        {
            string      description = new TextRange(centreDescriptionText.Document.ContentStart, centreDescriptionText.Document.ContentEnd).Text;
            InputTester checker     = new InputTester();

            //Checkiung input
            if (checker.ensureName(centreNameBox.Text) && checker.ensureCode(centreCodeBox.Text) && checker.ensureDescription(description))
            {
                MeetingCentre newMeetingCentre = new MeetingCentre(centreNameBox.Text, centreCodeBox.Text, description);
                Globals.meetingCentresList.Add(newMeetingCentre);
                Globals.needSave = true;
                MainWindow newMain = new MainWindow();
                newMain.Show();
                this.Close();
            }
            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);
            }
        }
Exemple #3
0
        /// <summary>
        /// Handle Create button click. Should check user input and redirect me back to main window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void createRoomButton_Click(object sender, RoutedEventArgs e)
        {
            MeetingCentre cent     = (MeetingCentre)test;
            InputTester   checker  = new InputTester();
            int           capacity = 0;

            int.TryParse(roomCapacity.Text, out capacity);
            string description = new TextRange(roomDescription.Document.ContentStart, roomDescription.Document.ContentEnd).Text;

            //checking user input
            if (checker.ensureName(roomName.Text) && checker.ensureCode(roomCode.Text) && checker.ensureDescription(description) && checker.ensureCapacity(capacity))
            {
                cent.meetingRoomsList.Add(new MeetingRoom(roomName.Text, roomCode.Text, description, capacity, (bool)videoCheck.IsChecked, cent.centreCode));
                Globals.needSave = true;
                MainWindow newMain = new MainWindow();
                newMain.Show();
                this.Close();
            }
            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);
            }
        }
Exemple #4
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;
        }
Exemple #5
0
        /// <summary>
        /// Handles selecting data.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void changeSelectionCentre(object sender, SelectionChangedEventArgs e)
        {
            MeetingCentre selected = (MeetingCentre)MeetingCentres.SelectedItem;

            try
            {
                editCentreName.Text        = selected.centreName;
                editCentreCode.Text        = selected.centreCode;
                editCentreDescription.Text = selected.centreDescription;
                MeetingRooms.ItemsSource   = selected.meetingRoomsList;
            }
            catch (Exception ex)
            {
                editCentreName.Text        = "";
                editCentreCode.Text        = "";
                editCentreDescription.Text = "";
            }
        }
Exemple #6
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!");
     }
 }
Exemple #7
0
 /// <summary>
 /// Takes care about deleting selected items.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DeleteMeetingCentreButton_Click(object sender, RoutedEventArgs e)
 {
     if (MeetingCentres.SelectedItem != null)
     {
         MeetingCentre    selected = (MeetingCentre)MeetingCentres.SelectedItem;
         MessageBoxResult myResult;
         myResult = MessageBox.Show("Really Delete " + selected.centreName + " ?", "Delete Confirmation", MessageBoxButton.OKCancel);
         if (myResult == MessageBoxResult.OK)
         {
             Globals.meetingCentresList.Remove(selected);
             Globals.needSave = true;
             MeetingCentres.Items.Refresh();
             MeetingRooms.ItemsSource = null;
             MeetingRooms.Items.Clear();
         }
     }
     else
     {
         MessageBox.Show("Select Meeting Centre first!");
     }
 }
Exemple #8
0
        private void CentreSelector_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            MeetingCentre selected = (MeetingCentre)CentreSelector.SelectedItem;

            RoomSelector.ItemsSource = selected.meetingRoomsList;
        }
Exemple #9
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);
            }
        }