//actions for adding new booking directly from customer's window private void btnAddBooking_Click(object sender, RoutedEventArgs e) { BookingWin bookingWindow = new BookingWin(); bookingWindow.canvBookingMainWindow.Visibility = Visibility.Hidden; bookingWindow.canvNewBooking.Visibility = Visibility.Visible; bookingWindow.setBookingWindow(customerInUse); bookingWindow.Owner = this; bookingWindow.ShowDialog(); }
//actions for editing existing booking private void btnEditBooking_Click(object sender, RoutedEventArgs e) { try { //this line will look for reference number in the selected item string reference = Regex.Match(lstBookings.SelectedItem.ToString(), @"\d+").Value; BookingWin bookingWin = new BookingWin(); //this method uses reference number to setup the new window with proper data bookingWin.setBookingWindow(reference); bookingWin.ShowDialog(); } catch (Exception) { MessageBox.Show("Please select a Booking from the list in order to edit it", "Make selection first.", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
//this method will open booking window after doubleclick on the list private void lstBookings_MouseDoubleClick(object sender, MouseButtonEventArgs e) { try { //this line will look for reference number part in the whole line to put the correct details in booking window string reference = Regex.Match(lstBookings.SelectedItem.ToString(), @"\d+").Value; BookingWin bookingWin = new BookingWin(); bookingWin.Owner = this; //this method uses reference number to setup the new window with proper data bookingWin.setBookingWindow(reference); bookingWin.ShowDialog(); } catch (Exception) { //If booking is on the list but missing in DB we want to search again and inform user MessageBox.Show("This Booking no longer exists.", "Missing booking", MessageBoxButton.OK, MessageBoxImage.Exclamation); this.btnBookSearch_Click(sender, e); } }