//-------------ACTIONS FOR CUSTOMER------------------------- //actions for adding new customer private void btnAddCustomer_Click(object sender, RoutedEventArgs e) { CustomerWin customerWindow = new CustomerWin(); customerWindow.canvCustomerWindowMain.Visibility = Visibility.Hidden; customerWindow.canvNewCustomer.Visibility = Visibility.Visible; customerWindow.Owner = this; customerWindow.ShowDialog(); }
//actions to take when adding new booking private void btnSave_Click(object sender, RoutedEventArgs e) { try { if (bookingInUse.Guests.Count > 0 && (bookingInUse.CustomerOwner != null)) { //checking dates if they match proper criteria if (!bookingInUse.checkDates(datePickArrivalCanvas.SelectedDate.Value, datePickDepartureCanvas.SelectedDate.Value)) { //if not, then changing the dates to current datePickArrivalCanvas.SelectedDate = DateTime.Today.Date; datePickDepartureCanvas.SelectedDate = DateTime.Today.Date.AddDays(1); } //if they do we proceed with storing current booking else { bookingInUse.Arrival = datePickArrivalCanvas.SelectedDate.Value; bookingInUse.Departure = datePickDepartureCanvas.SelectedDate.Value; //trying to store extras details if they were entered after adding extra try { bookingInUse.Breakfast.DietaryRequirements = txtBreakfastDietaryRequirements_Canvas.Text; bookingInUse.EveningMeal.DietaryRequirements = txtEveningDietaryRequirements_Canvas.Text; } catch (Exception) { } //looking for desired customer to add this booking to it's list bookingInUse.CustomerOwner.Bookings.Add(bookingInUse); dbAccess.saveFiles(); //if this booking was added directly from customer's window we want to update his list of bookings try { customerWindow = (CustomerWin)this.Owner; customerWindow.lstFutureBookings.Items.Clear(); customerWindow.readBookings(); } catch (Exception) { } this.Close(); } } else { MessageBox.Show("There has to be at least one guest and Customer must be selected.", "Missing Guest and/or Customer.", MessageBoxButton.OK, MessageBoxImage.Hand); } } catch (Exception) { MessageBox.Show("Please select dates and fill in all the fields correctly before saving.", "Missing Fields.", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
private void openCustomer() { //this line will look for reference number part in the whole line on the list to put the correct details in customer's window string reference = Regex.Match(lstCustomers.SelectedItem.ToString(), @"\d+").Value; //creating new customer window and passing the reference to get all the correct details CustomerWin customerWin = new CustomerWin(); //this method uses reference to fill in the new window with correct data customerWin.setCustomerWindow(reference); customerWin.canvNewCustomer.Visibility = Visibility.Hidden; customerWin.canvCustomerWindowMain.Visibility = Visibility.Visible; customerWin.Owner = this; customerWin.ShowDialog(); }