Пример #1
0
        /// <summary>
        /// Submit the edits for a room when submit button is clicked.
        /// </summary>
        /// <param name="sender">A reference to the control/object that raised the event.</param>
        /// <param name="e">State information and event data associated with a routed event.</param>
        private void Submit_Click(object sender, RoutedEventArgs e)
        {
            int temp;
            int index = roomRepo.Rooms.Count;

            if (enterRoomName.Text != "")
            {
                RoomName = enterRoomName.Text;
            }
            else
            {
                nameError.Visibility = Visibility.Visible;
                return;
            }

            if (Int32.TryParse(enterCapacity.Text, out temp))
            {
                Capacity = temp;
            }
            else
            {
                capacityError.Content    = "The capacity must be an integer.";
                capacityError.Visibility = Visibility.Visible;
                return;
            }
            Details = enterDetails.Text;
            type    = (string)enterType.SelectedItem;

            bool success = roomRepo.AddNewRoom(index, RoomName, Capacity, Details, type);

            if (success)
            {
                MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("The submitted room has been added", "SUCCESS!", System.Windows.MessageBoxButton.OK);
                this.Close();
            }
            else
            {
                MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("The submitted Room Name is already a room in use", "ERROR: Room Already Exists", System.Windows.MessageBoxButton.OK);
            }
        }