Switch Statement

Stimulsoft Reports.NET discussion
Post Reply
jjc
Posts: 97
Joined: Mon Apr 19, 2010 10:14 pm

Switch Statement

Post by jjc »

Hi All,
in a field of the report i have a textbox and i use in the Condition this expression :
Switch(Hotel_Meals_TBL.CurrencyCode== "USD" && txtCurrency.Text == "USD",((((System.Convert.ToDecimal(Hotel_Meals_TBL.Dinner) * System.Convert.ToDecimal(txtGOLDENPALACE.Text)) / 100) + System.Convert.ToDecimal(Hotel_Meals_TBL.Dinner))+ System.Convert.ToDecimal(usdGOLDENPALACE.Text)).ToString("N0"),Hotel_Meals_TBL.CurrencyCode == "USD" && txtCurrency.Text == "VND",((((System.Convert.ToDecimal(Hotel_Meals_TBL.Dinner) * System.Convert.ToDecimal(txtGOLDENPALACE.Text)) / 100) + System.Convert.ToDecimal(Hotel_Meals_TBL.Dinner)+ System.Convert.ToDecimal(usdGOLDENPALACE.Text))* System.Convert.ToDecimal(txtReferenceCur.Text)).ToString("N0"))
when i run the report if i use the Switch statement the first condition
Hotel_Meals_TBL.CurrencyCode== "USD" && txtCurrency.Text == "USD",((((System.Convert.ToDecimal(Hotel_Meals_TBL.Dinner) * System.Convert.ToDecimal(txtGOLDENPALACE.Text)) / 100) + System.Convert.ToDecimal(Hotel_Meals_TBL.Dinner))+ System.Convert.ToDecimal(usdGOLDENPALACE.Text)).ToString("N0")
the report will send a error :Text97 Input string was not in a correct format.

instead if i use the second condition
Hotel_Meals_TBL.CurrencyCode == "USD" && txtCurrency.Text == "VND",((((System.Convert.ToDecimal(Hotel_Meals_TBL.Dinner) * System.Convert.ToDecimal(txtGOLDENPALACE.Text)) / 100) + System.Convert.ToDecimal(Hotel_Meals_TBL.Dinner)+ System.Convert.ToDecimal(usdGOLDENPALACE.Text))* System.Convert.ToDecimal(txtReferenceCur.Text)).ToString("N0")
it is right .
Do you know where i wrong in my code ?I am trying to understand but not luck.

Thanks for your attention.

Have a good day.

Cheers
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Switch Statement

Post by Ivan »

Hello,

Can you please send us a sample report with data or a simple test application, which reproduces the issue?

Thank you.
jjc
Posts: 97
Joined: Mon Apr 19, 2010 10:14 pm

Switch Statement

Post by jjc »

Hi Ivan,
i found out the solution it is the code that i insert in the Conditions of the field:
Switch(Hotel_Meals_TBL.CurrencyCode== "USD" && txtCurrency.Text == "USD",(((((System.Convert.ToDecimal(Hotel_Meals_TBL.Dinner) * System.Convert.ToDecimal(txtGOLDENPALACE.Text)) / 100) + System.Convert.ToDecimal(Hotel_Meals_TBL.Dinner))+ System.Convert.ToDecimal(usdGOLDENPALACE.Text))*System.Convert.ToDecimal(txtReferenceCur.Text)).ToString("N0"),Hotel_Meals_TBL.CurrencyCode == "USD" && txtCurrency.Text == "VND",((((System.Convert.ToDecimal(Hotel_Meals_TBL.Dinner) * System.Convert.ToDecimal(txtGOLDENPALACE.Text)) / 100) + System.Convert.ToDecimal(Hotel_Meals_TBL.Dinner)+ System.Convert.ToDecimal(usdGOLDENPALACE.Text))* System.Convert.ToDecimal(txtReferenceCur.Text)).ToString("N0"))
In the first condition i added this line
*System.Convert.ToDecimal(txtReferenceCur.Text)
so the first Condition shoudl be so:
Hotel_Meals_TBL.CurrencyCode== "USD" && txtCurrency.Text == "USD",(((((System.Convert.ToDecimal(Hotel_Meals_TBL.Dinner) * System.Convert.ToDecimal(txtGOLDENPALACE.Text)) / 100) + System.Convert.ToDecimal(Hotel_Meals_TBL.Dinner))+ System.Convert.ToDecimal(usdGOLDENPALACE.Text))*System.Convert.ToDecimal(txtReferenceCur.Text)).ToString("N0")
so when i choose the second condition the textBox97 did not show error more.

Thanks so much for your support and fast reply .:blush:

Have a good day.

Cheers
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Switch Statement

Post by Ivan »

Hello,

We are always glad to help you.
Let us know if you need any additional help.

Thank you.
Post Reply