views:

19

answers:

1

I am writing a "problem resolver" for a despatch app.

The despatch app prints labels using a piece of software supplied by the UKs Royal Mail postal service. The software ensures that the addresses on the labels are "correct" as per the Royal mail's database of valid addresses, it renders a trackable code in alphanumeric and barcoded format and it automatically bills our company for secure mail sent via the system without having to do very much paperwork.

It's the latter "feature" that causes a problem. If a label is printed and not required because a) the customer is in a foreign country we do not mail to or b) two orders are for the same person at the same address we want to either not print a label in the former case or print one of two in the latter.

The country thing is easy. If a customer really is in another country you just don't include it in the list of customers sent to the Royal Mail app for processing (but some customers get handy with the mouse wheel and end up pretending to be from the United Arab Emirates when they're really from Banbury) the "Duplicate Postcode" issue, however, is much more troublesome.

In the UK two people will have the same postcode if they live on the same street. So obviously if two people on the same street want something you must print two labels. Similarly if two brothers live at the same address we want to ensure that both brothers receive their individual mail items (in this case the postcode, house number and surname will all match). However if two orders exist at the same address for Mr AN Other then MR Other should only require one label and his despatches can be combined.

Believe it or not we do have cases where Mr AN Other orders twice and Mr Someother-Dude in the same street orders something as well. In this case the problem resolver rather than just needing to tweak a predefined field to some other known value needs to let the user decide how many labels to print out.

In order to model this scenario in a UI I have created a listbox with a dynamic datatemplate that either allows people to straight include/not include the country problem people but in the case of Postcode problems it presents a horizontally aligned listbox which should include all the orders that have the same postcode.

So simply this is as far as I have got with this:

   <DataTemplate x:Key="postcodeTemplate">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Label Grid.Row="0">This Order's Postcode matches the postcode of another order. Choose what to do.</Label>
                <RadioButton>Send all.</RadioButton>
                <RadioButton>Send this one only.</RadioButton>
                <ListBox Grid.Row="0" Grid.Column="1" Grid.RowSpan="2">
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <VirtualizingStackPanel
                                Orientation="Horizontal"
                                IsItemsHost="true" />
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                </ListBox>
            </Grid>
        </DataTemplate>

How do I pass the postcode of the current customer (contained in an Observable Collection) through to a method which will return a list of customers at the same postcode which will then display in the final listbox?

A: 

Looks like I will just have to completely rewrite my window using more old school methods... how irritating.

bert