Esempio n. 1
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!");
            }
        }
Esempio n. 2
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);
            }
        }