/// <remarks> /// Confirms _selectedBooking booking on button click event /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> private void ConfirmBtn_Click(object sender, RoutedEventArgs e) { _selectedBooking = (BookingBO)UnconfBookingsGrid.SelectedItem; _bookingSrv.confirmBooking(_selectedBooking); // reloads page to remove newly confirmed booking from table updateWindow(); }
////constructor, is used to update existing booking details. public BookingUpdateV(BookingBO selectedBooking, string adminName) { InitializeComponent(); this._selectedBooking = selectedBooking; // pre-fill text boxes with booking data txtCustomer.Text = selectedBooking.CustomerCompany; txtParticipants.Text = selectedBooking.Participants.ToString(); txtAdditionalInfo.Text = selectedBooking.AdditionalInfo; txtDate.SelectedDate = selectedBooking.Date; //searches List<CustomersBO> by Customer Name listCustomers.ItemsSource = _custSrv.searchCustomerByCompany(txtCustomer.Text); listCustomers.SelectAll(); //limit DatePicker choice to "starting from Today" only txtDate.DisplayDateStart = DateTime.Today; //fill combobox with active rooms from DB _rooms = _roomSrv.getActiveRooms(); cboxRoom.ItemsSource = _rooms; // in case room is inactive leave combobox empty if (_roomSrv.getRoomIndexFromList(_rooms, selectedBooking.Room) != -1) { cboxRoom.SelectedValue = selectedBooking.Room; cboxRoom.SelectedIndex = _roomSrv.getRoomIndexFromList(_rooms, selectedBooking.Room); } _admin = (AdministratorBO)_adminSrv.getAdminByName(adminName); }
/// <remarks> /// Deletes (actually, archives) selected booking. /// It is removed from current list, with assigned "archived" timestamp. /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> private void DeleteBtn_Click(object sender, RoutedEventArgs e) { _selectedBooking = (BookingBO)UnconfBookingsGrid.SelectedItem; // Messagebox appears to prevent accidental user events. OK button confirms user intention to delete MessageBoxResult dialogResult = MessageBox.Show("Kustutan valitud broneeringu?", "Oled sa kindel?", MessageBoxButton.OKCancel, MessageBoxImage.Question); if (dialogResult == MessageBoxResult.OK) { _bookingSrv.archiveBooking(_selectedBooking); //window is reloaded after booking is deleted updateWindow(); } }
/// <remarks> /// Navigates to booking update view (BookingUpdateV) pre-filled with selected booking details /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> private void ChangeBtn_Click(object sender, RoutedEventArgs e) { _selectedBooking = (BookingBO)UnconfBookingsGrid.SelectedItem; this.NavigationService.Navigate(new BookingUpdateV(_selectedBooking, _admin)); }
/// <remarks> /// Fills the Booking detailed view on bottom of the page with the _selectedBooking info. /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> private void UnconfBookingsGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { CultureInfo culture = new CultureInfo("de-DE"); _selectedBooking = (BookingBO)UnconfBookingsGrid.SelectedItem; // if there is a booking with active selection in the DataGrid, textBlocks are filled with booking info if (_selectedBooking != null) { txtID.Text = _selectedBooking.BookingID.ToString(); txtDate.Text = _selectedBooking.Date.ToString("d", culture); txtRoom.Text = _selectedBooking.Room; txtParticipants.Text = _selectedBooking.Participants.ToString(); txtCustomer.Text = _selectedBooking.CustomerCompany; txtCustomerPIC.Text = _selectedBooking.CustomerContactPerson; txtCreated.Text = _selectedBooking.Created.ToString("d", culture); txtAdmin.Text = _selectedBooking.Admin; txtAdditional.Text = _selectedBooking.AdditionalInfo; //in ideal world must never execute first condition if (_selectedBooking.Confirmed != null) { txtConfirmed.Text = ((DateTime)_selectedBooking.Confirmed).ToString("g", culture); } else txtConfirmed.Text = "";// must always execute this condition, as this is Unconfirmed Booking View // displays first available contact value, if there is any in the table ContactService contactSrv = new ContactService(); List<ContactBO> contacts = contactSrv.getAllFromTableByCustomerID(_selectedBooking.CustomerID); if (contacts.Count > 0) { txtContact.Text = contacts[0].Value.ToString(); } else txtContact.Text = ""; } }
/// <remarks> /// Sets existing DB booking entry property Archived to current DateTime value /// </remarks> /// <param name="booking"></param> public void archiveBooking(BookingBO booking) { _log.Trace("in archiveBooking()"); using (Keskus_baasEntities db = new Keskus_baasEntities()) { DAL.Booking toArchive = (from x in db.Bookings where x.BookingID == booking.BookingID select x).FirstOrDefault(); toArchive.Archived = DateTime.Now; try { db.SaveChanges(); _userlog.Trace(string.Format("Booking {0} is archived on {1} ", toArchive.BookingID, toArchive.Archived)); } catch (Exception ex) { _log.Trace(string.Format("archiveBooking() - An error occurred: '{0}'", ex)); } } }
public ExportBO(BookingBO booking) { this.BookingID = booking.BookingID; this.Date = booking.Date; this.Participants = booking.Participants; this.CustomerCompany = booking.CustomerCompany; this.Room = booking.Room; this.Admin = booking.Admin; }