WPF project for UWS

This Academic Projects section is from the first version of this site and stays for historical completeness.

To gain academic credits during my time with UWS, as well as passing the MCTS exam I had to complete a WPF/ADO project as follows...


You are a developer for Northwind Traders and you have been asked to write a new application for the Customer Service department, as part of an upgrade of their application software to use .NET technologies.

This WPF application will be used to deal with customer enquiries about the progress of their order. The person dealing with the call retrieves the recent orders from a customer, focusing particularly on the fields relating to what has been ordered, when, and what the shipping date was. As requested by the customer, if the order has not yet been shipped, the clerk can make alterations to the order, for example to the date required, or the shipping address.

The application will later conform to Northwind's house style, which is under development by another team. Your design should use styles so that these can be brought into line with this standard.

This came down to a single screen with two grids, one to allow the user to select a customer, display their orders and select one, the other to edit the shipping details if the order hadn't already been shipped.

For this project I used the ADO Entity Data Model for the back end. Once a customer was selected, the Linq to Entities to populate the customer grid came down to this snippet...

Dim custOrders As ObjectQuery(Of Order) = _
		northwindContext.Order.Where _
		("it.Customer.CustomerID = @custID", _
		New ObjectParameter (("custID", custID)). _
		Include(("Order_Details"). _

That's everything from four tables in one wrapped line. Neat.

Finding the shipped-date field to see whether the edit grid should be enabled was a bit more tricky but the answer's at MSDN...

Dim ordersListBoxItem As ListBoxItem =  _
			ListBoxOrders.Items.CurrentItem), ListBoxItem)

' Get ContentPresenter for selected order by walking visual tree
Dim shipDatePresenter As ContentPresenter = _ 
	FindVisualChild(Of ContentPresenter)(ordersListBoxItem)

' Get the DataTemplate for the ContentPresenter
Dim OrdersDataTemplate As DataTemplate = _

' Get the required templated control
Dim TextBlockShippedDate As TextBlock = 	
	CType (OrdersDataTemplate.FindName(_ 
	("TextBlockShippedDate", shipDatePresenter), TextBlock)

' If date string is empty then order not yet shipped
If TextBlockShippedDate.Text = String.Empty Then
     isOrderShippable = True
     isOrderShippable = False
End If
' Set the grid appropriately
GridShippingEditor.IsEnabled = isOrderShippable

The rest was mostly reams of xaml that I'll spare you a screen shot of, but I also wrote an implementation of IValueConverter so that if the ship date was empty the order row would be highlighted in green, otherwise grey...

Public Function Convert(ByVal value As Object, _
		ByVal targetType As System.Type, _
		ByVal parameter As Object, _
		ByVal culture As System.Globalization.CultureInfo) _
		As Object Implements IValueConverter.Convert
    Dim d As DateTime = CDate (value)
    ' If the date is db null highlight it
    If d = Nothing Then
       'A light green brush
       Return New SolidColorBrush(Color.FromArgb(255, 90, 200, 90))
       'A light grey brush
       Return New SolidColorBrush (Color.FromArgb(255, 215, 215, 215))
    End If
End Function

Despite the brief, I couldn't resist playing about with the styles so you'll have to forgive the noob garishness of the following screenshot that shows a selected customer's orders with an unshipped order selected and the edit grid active (image).