Decimal minimums and Maximums using .NET Reports

STGI-01
Member Posts: 3
Hello,
Was trying to figure out how to best go about solving this problem. We have a customer who has prices that occasionally will need 3 decimal places. They want to print only when the 3rd decimal place is actually <> 0. So for example.
1.50
or
1.505
The first prints because the price is only $1.50, the second the price is $1.505. They want them to print exactly that way. Anyone seen anything on how to do this in .NET? Currently everything we have done in .NET requires it to either be 2 or 3 decimals, not a variable amount.
Was trying to figure out how to best go about solving this problem. We have a customer who has prices that occasionally will need 3 decimal places. They want to print only when the 3rd decimal place is actually <> 0. So for example.
1.50
or
1.505
The first prints because the price is only $1.50, the second the price is $1.505. They want them to print exactly that way. Anyone seen anything on how to do this in .NET? Currently everything we have done in .NET requires it to either be 2 or 3 decimals, not a variable amount.
0
Comments
-
To create a string if eigthter 2 or 3 decimal places you could use the method suggested in this link:
http://stackoverflow.com/questions/6092243/c-sharp-check-if-a-decimal-has-more-than-3-decimal-places
Detext if the decimal has 3 decimal places then format it that way (#.000) otherwise (#.00)
Does that help you?
EDIT: What do you mean by .NET Reports? RDLC Reports use ind Navision? If so we're talking about another thing0 -
In .NET you can easily format a decimal or float by using ToString(string format)
I read your question as:
If the number has 2 or less decimals I want to format is as X,XX (e.g 1,55 // 3,50 // 7,00)
If the number has 3 decimals (or more), I want to format the number as X,XXX (e.g 1,123)
The above can be done like this in .NET (C# and VB)static void Main(string[] args) { decimal d = 2.3m; string s = d.ToString("0.00#"); // 1 -> 1.00 // 2,3 -> 2.30 // 3,33 -> 3.33 // 4,333 -> 4.333 // 7,3333 -> 7.333 Console.WriteLine(s); Console.ReadLine(); }
I'm not quite sure if this is what you were looking for, if not - just yell...Thomas Hejlsberg
CTO, Architect - Microsoft Dynamics NAV0 -
deV.ch wrote:To create a string if eigthter 2 or 3 decimal places you could use the method suggested in this link:
http://stackoverflow.com/questions/6092243/c-sharp-check-if-a-decimal-has-more-than-3-decimal-places
Detext if the decimal has 3 decimal places then format it that way (#.000) otherwise (#.00)
Does that help you?
EDIT: What do you mean by .NET Reports? RDLC Reports use ind Navision? If so we're talking about another thing
Yes, my apologies, so used to calling them .NET on our side, but I am talking about RDLC Reports for use in Nav 2009 R2.0 -
just set the DecimalPlaces Property to 2:3 and on the RDLC Side set the Format Property of the TextBox to "Field!<DataSetFieldName>Format.Value"
if setting decimalplaces property is not working on classic and on rtc side, you are maybe using AutoFormatExpr which ignores the DecimalPlaces feature.
@ThomasHej_MSFT Thanks for the info! It must have been friday... ](*,) Of course this is the right way to do such thing in .net0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions