Switch() in Expression versus Switch() in a variable
Posted: Fri Apr 04, 2014 2:57 pm
Hi Stimulsoft,
I am trying to assign a value to a variable ("TaxCharge") using an Expression. The value is conditional, so I am using Switch(Condition,value...).
My code is:
When I attempt this in a variable, I get a compilation error with this output:
If I put the same in a text field as an expression, it will output the desired result:
Is it possible to do conditional calculations in the Switch function within a variable?
Am I doing something wrong?
I have attached an example with the expression field and the non-compiling "TaxCharge" variable. If you clear out "TaxCharge" you'll see the expression field works.
Thanks.
I am trying to assign a value to a variable ("TaxCharge") using an Expression. The value is conditional, so I am using Switch(Condition,value...).
My code is:
Code: Select all
Switch(Products.Taxable > 0,Products.UnitPrice * Products.UnitsInStock * TaxRate,
Products.Taxable == 0,0)
; expected
Code: Select all
public virtual decimal TaxCharge
{
get
{
return Stimulsoft.Report.Dictionary.StiFunctionsProgrammingShortcut.Switch(Products.Taxable > 0.Products.UnitPrice * Products.UnitsInStock * TaxRate.
Products.Taxable == 0.0)m;
}
}
Code: Select all
{Switch(Products.Taxable > 0,Products.UnitPrice * Products.UnitsInStock * TaxRate,
Products.Taxable == 0,0)}
Am I doing something wrong?
I have attached an example with the expression field and the non-compiling "TaxCharge" variable. If you clear out "TaxCharge" you'll see the expression field works.
Thanks.