How to calculate percentage increase..

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

How to calculate percentage increase..

Post by jjc »

Hi all,
i am trying to increase the price in some datafield in a databand with this method:
in a form i have a TextBoxControl (TextBox1) where i input the number after in the Condition of the DataFiled i use this Expression:

Code: Select all


Transport_TBL._2Pax_RealContractCost  /  TextBox1.Text  *100
but when i run the report i receive this message : error CS0019: Operator '/' cannot be applied to operands of type 'decimal' and 'string'.

and this one too:

Code: Select all


(Transport_TBL._2Pax_RealContractCost  /  System.Convert.ToDecimal(TextBox1.Text)  * 100)
and i get this error CS0029: Cannot implicitly convert type 'decimal' to 'bool'

My purpose is to increase the real price of the field in the database with a percentage that input in the TextBox1 for all rows refering to the column of the datafield(Transport_TBL._2Pax_RealContractCost) as Transport_TBL._2Pax_RealContractCost + 5% and show in the datafield the result of the calculation.



Do you know how can work out this error ?

p.s . I not need the total of the column of the datafield Transport_TBL._2Pax_RealContractCost.

Thanks so much for your attention.

Have a good time.

Cheers

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

How to calculate percentage increase..

Post by Ivan »

Hello,

If we diagnose the issue in the correct way, you do not need to use Condition.
Just write your expression in the Text property of DataField:

Code: Select all

     {Transport_TBL._2Pax_RealContractCost  /  System.Convert.ToDecimal(TextBox1.Text)  * 100}
If the issue is still present, please send to us a mrt file with data, which reproduce the issue, for analysis.

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

How to calculate percentage increase..

Post by jjc »

Hi Ivan ,
your advice is right , infact i follow your way and it is right with this code in the TextProperty of Datafield :

Code: Select all

{IIF(TextBox1.Text == null,Transport_TBL._2Pax_RealContractCost,(((Transport_TBL._2Pax_RealContractCost *  System.Convert.ToDecimal(TextBox1.Text)) / 100) + Transport_TBL._2Pax_RealContractCost).ToString("N0")) }
Thanks so much for your fast support and help.:biggrin:

Have a good work.

Cheers
Andrew
Posts: 4109
Joined: Fri Jun 09, 2006 3:58 am

How to calculate percentage increase..

Post by Andrew »

Great!
Post Reply