/// <remarks> /// Displays customer details and contacts if any customer is selected in table /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> private void listCustomers_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (listCustomers.SelectedItem != null) { CustomerBO selectedCustomer = (CustomerBO)listCustomers.SelectedItem; lblCompanyName.Content = selectedCustomer.CompanyName; lblContactPerson.Content = selectedCustomer.ContactPerson; ContactService contactSrv = new ContactService(); List<ContactBO> customerContacts = contactSrv.getAllFromTableByCustomerID(selectedCustomer.CustomerID); ContactTypeService contactTypeSrv = new ContactTypeService(); //adding ContactType Name to ContactBO Obj. by ContactType ID foreach (ContactBO customerContact in customerContacts) { customerContact.ContactTypeName = contactTypeSrv.getNameById(customerContact.ContactTypeID); } listContacts.ItemsSource = customerContacts; } }
/// <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> /// updates Customer Contact list after adding/updating contacts. /// </remarks> private void updateListContacts() { ContactTypeService contactTypeSrv = new ContactTypeService(); ContactService contactSrv = new ContactService(); List<ContactBO> customerContacts = contactSrv.getAllFromTableByCustomerID(_selectedCustomer.CustomerID); //adding ContactType Name to ContactBO Obj. by ContactType ID foreach (ContactBO customerContact in customerContacts) { customerContact.ContactTypeName = contactTypeSrv.getNameById(customerContact.ContactTypeID); } listContacts.ItemsSource = customerContacts; }