您的位置:首页 > 其它

使用ActiveReports for .net 进行报表开发(八)--显示合计

2007-11-20 20:55 423 查看
在报表开发中我们常常要显示合计,比如销售记录,要显示单价,售出件数,合计金额等。
我们可以在从数据库中提取数据的时候就使用SQL来产生一个合计字段,也可以在ActiveReport中进行,有两种方法可以使用。
1. 使用ActiveReport中的Label或TextBox控件的DataField属性。例如,要使一个TextBox显示合计,它的值是由单价和售出件数的乘积。设置TextBox的DataField值为“=单价*售出件数”。然后编写代码,加载数据,设置Field集合,然后在FetchData事件中给Field赋值,就可以完成了,例如:
[align=left]this.Fields["ProductName"].Value = row.productName;[/align]
[align=left]this.Fields["UnitPrice"].Value = row.unitPrice;[/align]
this.Fields["Quantity"].Value = row.quantity;
2. 不对DataField属性使用表达式,而是直接在FetchData中进行计算,例如:
[align=left]double quantity = Convert.ToDouble(this.Fields["Quantity"].Value);[/align]
[align=left]double unitPrice = Convert.ToDouble(this.Fields["UnitPrice"].Value);[/align]
this.Fields["ExtendedPrice"].Value = quantity * unitPrice;
当然要在报表上显示要设置Label或TextBox的DataField属性为ExtendedPrice
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: