Page 1 of 1

How to calculate percentage increase..

Posted: Wed Jun 23, 2010 11:48 pm
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


How to calculate percentage increase..

Posted: Thu Jun 24, 2010 3:51 am
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.

How to calculate percentage increase..

Posted: Fri Jun 25, 2010 4:14 am
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

How to calculate percentage increase..

Posted: Fri Jun 25, 2010 7:43 am
by Andrew
Great!