Page 1 of 1

Switch Statement

Posted: Tue Jul 13, 2010 9:49 pm
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

Switch Statement

Posted: Wed Jul 14, 2010 3:54 am
by Ivan
Hello,

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

Thank you.

Switch Statement

Posted: Thu Jul 15, 2010 2:19 am
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

Switch Statement

Posted: Thu Jul 15, 2010 6:18 am
by Ivan
Hello,

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

Thank you.