private void btnAddBooking_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrWhiteSpace(txtPhone.Text)) { List <Equipment> eqlist = crbkList.GetCurrentItems(); datafac.AddBooking(new Logic.Booking( eqlist, Convert.ToDateTime(crbkList.GetStartdate()), Convert.ToDateTime(crbkList.GetEnddate()), txtPhone.Text, false )); MessageBox.Show("Booking er nu oprettet"); Edit ed = Edit.Instance; ed.runAlarm(); (Application.Current.MainWindow.FindName("FrameFilter") as Frame).Source = null; (Application.Current.MainWindow.FindName("FrameChart") as Frame).Source = null; (Application.Current.MainWindow.FindName("FrameContent") as Frame).Source = new Uri(@"\Views\FrontPage.xaml", UriKind.RelativeOrAbsolute); } else { txtPhoneError.Content = "Du mangler at udfylde et nr"; } }
//Bookingpage code private void BookingSubmitBtn_Click(object sender, RoutedEventArgs e) { //Setting booking ref try { bookingInstance.BookingRef = Convert.ToInt32(BookingRefBox.Text); } catch (Exception excep) { MessageBox.Show(excep.Message); return; } //Setting Customer_num try { //The customer num is generated/determined in the previous step and then saved to the CustomerNumberBox bookingInstance.CustomerNum = Convert.ToInt32(CustomerNumberBox.Text); } catch (Exception excep) { MessageBox.Show(excep.Message); return; } //Start/Arrival Date try { bookingInstance.ArrivalDate = StartDatePicker.SelectedDate.GetValueOrDefault(); } catch (Exception excep) { MessageBox.Show(excep.Message); return; } //End/Departure Date try { bookingInstance.DepartureDate = EndDatePicker.SelectedDate.GetValueOrDefault(); } catch (Exception excep) { MessageBox.Show(excep.Message); return; } //Breakfast Meals try { if (BreakfastCheck.IsChecked.HasValue && BreakfastCheck.IsChecked.Value) { bookingInstance.BreakfastMeals = true; } else { bookingInstance.BreakfastMeals = false; } } catch (Exception excep) { MessageBox.Show(excep.Message); return; } //Evening Meals try { if (EveningCheck.IsChecked.HasValue && EveningCheck.IsChecked.Value) { bookingInstance.EveningMeals = true; } else { bookingInstance.EveningMeals = false; } } catch (Exception excep) { MessageBox.Show(excep.Message); return; } //Setting ChaletID try { bookingInstance.ChaletID = ChaletListBox.SelectedIndex; } catch (Exception excep) { MessageBox.Show(excep.Message); return; } //1 - Add new booking, 2 - Update existing booking, determined during button click on startpage switch (caseSwitch) { case 1: db.AddBooking(bookingInstance); break; case 2: foreach (int guestRef in guestToDelete) { db.DeleteGuest(guestRef); } foreach (int carHireRef in carHireToDelete) { db.DeleteCarHire(carHireRef); } db.UpdateBooking(bookingInstance); break; } lastBookingRef += 1; //Update last booking ref bookingInstance.ClearBookingLists(); //Clear guest and car hire list so the instance can be used again //Reset UI to startpage BookingPage.Visibility = Visibility.Hidden; StartPage.Visibility = Visibility.Visible; }