private void AddRequest(object sender, RoutedEventArgs e) { try { if (PoolComboxBox.SelectedItem == null || PublicTransportationComboxBox.SelectedItem == null || JacuzziComboxBox.SelectedItem == null || ViewComboxBox.SelectedItem == null || smokingComboxBox.SelectedItem == null || RoomServiceComboxBox.SelectedItem == null || AreaComboxBox.SelectedItem == null || GardenComboxBox.SelectedItem == null || ChildrensAttractionComboxBox.SelectedItem == null || WifiComboxBox.SelectedItem == null || TelevisionComboxBox.SelectedItem == null || SnackBarComboxBox.SelectedItem == null || LastNameTextBox.Text == "" || FirstNameTextBox.Text == "" || EmailTextBox.Text == "" || AdultTextBox.Text == "" || ChildrenTextBox.Text == "" || EntryDateDatePicker.SelectedDate == null || RealeaseDateDatePicker.SelectedDate == null) { throw new NullReferenceException("please fill out all of the fields"); } if (!Regex.IsMatch(this.AdultTextBox.Text.ToString(), @"^\d+$")) { throw new InvalidOperationException("invaild number of adults"); } if (!Regex.IsMatch(this.ChildrenTextBox.Text.ToString(), @"^\d+$")) { throw new InvalidOperationException("invaild number of Children"); } request.pool = (BE.Pool)PoolComboxBox.SelectedItem; request.publicTransportation = (BE.PublicTransportation)PublicTransportationComboxBox.SelectedItem; request.jacuzzi = (BE.Jacuzzi)JacuzziComboxBox.SelectedItem; request.view = (BE.View)ViewComboxBox.SelectedItem; request.smoking = (BE.Smoking)smokingComboxBox.SelectedItem; request.roomService = (BE.RoomService)RoomServiceComboxBox.SelectedItem; request.area = (BE.Area)AreaComboxBox.SelectedItem; request.garden = (BE.Garden)GardenComboxBox.SelectedItem; request.childrensAttractions = (BE.ChildrensAttractions)ChildrensAttractionComboxBox.SelectedItem; request.wifi = (BE.Wifi)WifiComboxBox.SelectedItem; request.tv = (BE.Television)TelevisionComboxBox.SelectedItem; request.snackBar = (BE.SnackBar)SnackBarComboxBox.SelectedItem; //request.area = (BE.Area)AreaComboxBox.SelectedItem; request.FamilyName = this.LastNameTextBox.Text; request.PrivateName = this.FirstNameTextBox.Text; request.MailAddress = this.EmailTextBox.Text; request.Adults = int.Parse(this.AdultTextBox.Text); request.Children = int.Parse(this.ChildrenTextBox.Text); string date1, date2; // date1 = EntryDateDatePicker.SelectedDate.ToString(); request.EntryDate = Convert.ToDateTime(EntryDateDatePicker.SelectedDate.ToString()); // date2 = RealeaseDateDatePicker.SelectedDate.ToString(); request.ReleaseDate = Convert.ToDateTime(RealeaseDateDatePicker.SelectedDate.ToString()); this.DataContext = request; bl.AddGuestRequest(request); request = new BE.GuestRequest(); MessageBoxResult result = MessageBox.Show("Thank You, your request has been received. Would you like to make another request?", "Status", MessageBoxButton.YesNo, MessageBoxImage.Information); switch (result) { case MessageBoxResult.Yes: this.Close(); Window AddGuestRequestWindow = new AddGuestRequestWindow(); AddGuestRequestWindow.Show(); break; case MessageBoxResult.No: this.Close(); break; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void GuestRequestButtonClick(object sender, RoutedEventArgs e) { Window AddGuestRequestWindow = new AddGuestRequestWindow(); AddGuestRequestWindow.Show(); }