壹佰网|ERP100 - 企业信息化知识门户

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1125|回复: 1

[安装|配置|入门|资料] 产生每页合计的办法

[复制链接]
发表于 2008/10/24 19:18:28 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622  。

您需要 登录 才可以下载或查看,没有帐号?注册

x
前几天帮一朋友实现了在每页页脚上生成合计的功能,现给大家分享一下。
代码写在了DATASTREAM的FETCH()方法和合计控件的ONROW()方法里,欢迎大家指正。
pageqty 为一DOUBLE型全局变量,isendrow 为一布尔型全局变量
Function Fetch( ) As AcDataRow
Dim row As DataRow1
Set row = Super::Fetch( )
If row Is Nothing Then
isendrow = true
Exit Function
End If

pageqty = pageqty + row.orderqty
Set Fetch = row
End Function

Sub OnRow( row As AcDataRow )
Super::OnRow( row )
' 在此处插入代码
if not isendrow then
datavalue = pageqty - row.getvalue("orderqty")
pageqty = row.getvalue("orderqty")
end if
End Sub

PAGECOUNT.rar

5.3 KB, 下载次数: 4, 下载积分: 努力值 -5 点

 楼主| 发表于 2008/10/24 19:19:10 | 显示全部楼层
每页统计数据
功能需求:每页显示四条记录,每页统计一次[MATRECTRANS.LINECOST]字段
解决如下:
在报表Tool->Parameters中定义变量:
Sum1 Double
在DataStream中建立变量如下:
aConnection AcDBConnection
aCursor AcDBCursor
aDataSource AcDatabaseSource
aRow AcDataRow
aStmt AcDBStatement
tmp1 Integer '记录总数与4取余的值
tmp2 Integer
i1 Integer

新建函数


Function SetSql( str As String ) As AcDBCursor
' Insert your code here
' 数据库操作
set aStmt = aConnection.prepare(str)
if aStmt is nothing then
exit function
end if
set aCursor = aStmt.allocateCursor()
if aCursor is nothing then
exit function
end if
if Not aCursor.openCursor() then
aDataSource.getDBConnection().raiseError()
set aCursor = nothing
end if
Set SetSql = aCursor
End Function

Function GetSum(code as String,xend as Integer) As Double
' Insert your code here
'统计前xend的总数
Dim str as String
str = "select Sum(matrectrans.LINECOST) from " & Schema & ".matrectrans"
str = str & " where MATRECTRANS.ITIN1 = '工程采购' and matrectrans.ponum='" & CODE & "' "
str = str & " and rownum<=" & xend & " "
str = str & " and TRANSDATE >to_date('" & aStart & "','YYYY-MM-DD') "
str = str & " and TRANSDATE 'showfactorystatus(str)
Set aCursor = SetSql(str)
aCursor.BindColumn(1, "NewReportApp:ataRow3","sum_1")
aCursor.Fetch(aRow)
GetSum= aRow.GetValue("sum_1")
End Function

Function GetCount( code as String ) As Integer
' Insert your code here
Dim str as String
str = "select count(*) from " & Schema & ".matrectrans"
str = str & " where MATRECTRANS.ITIN1 = '工程采购' and matrectrans.ponum='" & CODE & "' "
str = str & " and TRANSDATE >to_date('" & aStart & "','YYYY-MM-DD') "
str = str & " and TRANSDATE
'showfactorystatus(str)
Set aCursor = SetSql(str)
aCursor.BindColumn(1, "NewReportApp:ataRow3","count_1")
aCursor.Fetch(aRow)
GetCount= aRow.GetValue("count_1")
End Function



修改Start( )


Function Start( ) As Boolean
Start = Super::Start( )
' Insert your code here
Dim count1,i as Integer
Set aConnection = new Connection
aConnection.connect()
Set aRow = New DataRow3
count1=GetCount(code)'求列数
if (count1 mod 4) >=1 then
tmp1=4-(count1 mod 4)
tmp2=1
else
tmp2=5
end if
i1=0

'showfactorystatus("tmp1 "&tmp1)
’此处赋最后一页的总数
if count1 <4 then
sum3=GetSum(code,4)
'showfactorystatus("sum3 "&sum3)
elseif (count1 mod 4) <> 0 then
i=count1 mod 4
sum3=GetSum(code,count1) - GetSum(code,count1-i)
'showfactorystatus("sum3 "&sum3)
elseif (count1 mod 4) = 0 then
sum3=GetSum(code,count1) - GetSum(code,count1-4)
end if
End Function


修改Fetch( )



Function Fetch( ) As AcDataRow
'Set Fetch = Super::Fetch( )
' Insert your code here
Dim myrow as DataRow3
Dim ponum as String
Dim i2 as Integer
Dim count1,i as Integer
Set myrow = Super::Fetch()
if(not myrow is nothing) then
ponum = myrow.GetValue("PO_PONUM")
'计算总计数,每页总计
if i1<4 then
i1=i1+1
'showfactorystatus("**i1 "&i1 &"RowNumber "&myrow.GetValue("RowNumber"))
elseif i1=4 then
i2=myrow.GetValue("RowNumber")
sum1=GetSum(ponum,i2-1)-GetSum(ponum,i2-5)
i1=1
'showfactorystatus("sum1 "&sum1)
'showfactorystatus("i1 "&i1 &"RowNumber "&myrow.GetValue("RowNumber"))
end if
elseif (myrow is nothing) and tmp2 <= tmp1 then
Set myrow = new DataRow3
'showfactorystatus(code)
myrow.SetValue("PO_PONUM",code)
myrow.SetValue("MATRECTRANS_QUANTITY",null)
myrow.SetValue("MATRECTRANS_ACTUALCOST",null)
myrow.SetValue("MATRECTRANS_LINECOST",null)
myrow.SetValue("deptment_wappr","")
myrow.SetValue("name_wappr","")
myrow.SetValue("name_appr","")
myrow.SetValue("name_enterby","")
tmp2=tmp2+1
end if
Set Fetch=myrow
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|手机版|壹佰网 ERP100 ( 京ICP备19053597号-2 )

Copyright © 2005-2012 北京海之大网络技术有限责任公司 服务器托管由互联互通
手机:13911575376
网站技术点击发送消息给对方83569622   广告&合作 点击发送消息给对方27675401   点击发送消息给对方634043306   咨询及人才点击发送消息给对方138011526

GMT+8, 2025/11/30 17:22 , Processed in 0.013108 second(s), 15 queries , File On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表