在Stimulsoft中创建只读变量
我是Stimulsoft的Noobie.我在Visual Studio 2013中为我们的应用程序运行了Stimulsoft版本2015.3.
I'm a Noobie to Stimulsoft. I have Stimulsoft Version 2015.3 running for our apps in Visual Studio 2013.
在YouTube上找到的示例视频都是过时的,而且我还没有找到任何示例来说明如何使用其内置的条件逻辑来创建变量.
Example videos found on YouTube are all old, and I have not found any to show how to create a variable using their built-in conditional logic.
有一本创建变量的字典:
There is a dictionary where variables are created:
当前,如果我尝试编译,则有10个错误,如下所示:
Currently, if I try to compile, I have 10 errors as shown here:
我将专注于第一个:decInvoiceCost
.
错误显示为;"预期,并提供以下预览:
The error says ";" expected, and gives this little preview:
使用其编辑器输入的代码是:
The code for it, entered using their editor, is:
{if (blnUseMarketCost) { VwInvoice.MarketCost } else { VwInvoice.AverageCost } }
其中blnUseMarketCost
是布尔值,而两(2)个十进制值MarketCost
和AverageCost
来自数据库视图.
where blnUseMarketCost
is a Boolean, and the two (2) decimal values MarketCost
and AverageCost
come from the database view.
如果我单击转到代码",请返回错误:
Back in the error, if I click "Go to Code":
...我被他们的设计师渲染的源代码所吸引:
...I am taken to the source code which is rendered by their designer:
public virtual decimal decInvoiceCost
{
get
{
// CheckerInfo: Value decInvoiceCost
return {if (blnUseMarketCost) { VwInvoiceDetail.MarketCostInInvPricingUnit } else { VwInvoiceDetail.AverageCostInInvPricingUnit } }m;
}
}
我认为最后"m" 会引起一些问题,但我真的不知道.
I think that "m" on the end is causing some issues, but I don't really know.
更新
报告的C#代码由设计人员生成.我可以用它来查看设计者正在尝试做什么,但是我不了解所有细微差别.
The C# code of the report is generated by the designer. I can use it to see what the designer is trying to do, but I do not understand all of the nuances.
namespace Reports
{
public class Report : Stimulsoft.Report.StiReport
{
public Report() {
this.InitializeComponent();
}
#region StiReport Designer generated code - do not modify
//
// {snip}
//
public virtual decimal decMarkup
{
get
{
// CheckerInfo: Value decMarkup
return ((decInvoiceCost==0) ? 0 : (decInvoiceProfit / decInvoiceCost))m;
}
}
//
// {snip}
//
#endregion StiReport Designer generated code - do not modify
}
}
decInvoiceCost
get实现的代码无效.您应该改用以下任一实现方式:
The code for the decInvoiceCost
get implementation is invalid. You should use either of these implementations instead:
public virtual decimal decInvoiceCost
{
get
{
// CheckerInfo: Value decInvoiceCost
if (blnUseMarketCost)
return VwInvoiceDetail.MarketCostInInvPricingUnit;
else
return VwInvoiceDetail.AverageCostInInvPricingUnit;
}
}
这将基于if语句返回两个值之一.
this will return either one of the two values based on an if statement.
或
public virtual decimal decInvoiceCost
{
get
{
// CheckerInfo: Value decInvoiceCost
return blnUseMarketCost
? VwInvoiceDetail.MarketCostInInvPricingUnit
: VwInvoiceDetail.AverageCostInInvPricingUnit;
}
}
使用三元运算符<boolExpr> ? <valueifTrue> : <valueIfFalse>;