I need to change the format of a Decimal
number depending on other values.
My customer is a performance venue and wants to charge usage of different expendable items in different formats, by example:
Replacement light globes - whole numbers only = Qty can only equal 1 or 2 or 3...
Man hours - charged in quarters - Qty could equal 1.25 (2 decimal points)
Electricity used - charged to 4 decimal points = Qty could equal 23.1234
So I want to be able to change to number format of Qty according to the type of item being charged:
if item = Light Globes, format = 0
if item = Man hours, format = 0.##
if item = Electricity, format = G4
Because of the dynamic nature of the number format, using something like DisplayFormat(DataFormatString = "{0:d}")]
is not appropriate (unless you know of a way to change this at run-time).
However I need to system to 'think' in whatever format is chosen, so if the format is '0.00' then I need all display formats, validations, number rounding etc as '0.00'.
I can store the relevant format of each item in the database.
Many thanks in advance.