0

我不声称自己是一个典型的 ASP 人,但有时你必须做你必须做的事情。我的问题是这是一个通过 ASP 自定义构建的报告,用户希望运行 SubTotals 并显示总计,老实说,我只是不知道如何去做。目前整个报告都是这样包装的,它的显示方式与问题无关。

<%do while (adoRsTrade.AbsolutePage = iPageCurrent) and (not adoRsTrade.EOF)
NewRep = adoRsTrade("calIncludedRep")

if CurRep <> NewRep or FirstTime="T" and (not adorsTrade.BOF) then %>

添加该 CurRep 的值并将它们显示为“小计”

<%

FirstTime="F"
CurRep = adoRsTrade("calIncludedRep")
adoRsTrade.MoveNext
loop %>

我能得到的任何帮助都将不胜感激,因为我提到我无论如何都不是 ASP 大师。谢谢你,尼克

更新小计的东西;总计已完成,因为我可以在循环外重新运行 do while 循环显示所有数据并将其总计,现在我遇到的是 .MoveNext 之前被击中让我能够检查 NewRep;这是小计的总计以及检查它是否是新代表,这意味着显示前代表的小计

<%do while (adoRsTrade.AbsolutePage = iPageCurrent) and (not adoRsTrade.EOF)
NewRep = adoRsTrade("calIncludedRep")

if CurRep = NewRep then
        curPrincipal = adoRsTrade("mPrincipal")
        totPrincipal = totPrincipal + curPrincipal
            curInterest = adoRsTrade("mInterest")
            totInterest = totInterest + curInterest
        curCommission = adoRsTrade("calCommission")
        totCommission = totCommission + curCommission
            curSECFee = adoRsTrade("mSECFee")
            totSECFee = totSECFee + curSECFee
        curSvcFee = adoRsTrade("mSvcCharge")
        totSvcFee = totSvcFee + curSvcFee
            curNet = adoRsTrade("mNetAmount")
            totNet = totNet + curNet
end if    
if CurRep <> NewRep or FirstTime="T" and (not adorsTrade.BOF) then
  If FirstTime <> "T" then%>
      <TR>
        <td>
            <table class='FontStandardMinus1' border=0 cellPadding=0 align='left' cellSpacing=0 width="100%" bgcolor='#ffffff'>
                 <TR>
                    <td width="59%" align="left"><b>SubTotals<!-- for <%Response.Write(CurRep) %>-->:</b></td>
                    <td width="10%" valign=top align=right><%=FormatNumber(totPrincipal,2)%></td>
                    <td width="7%" valign=top align=right><%=FormatNumber(totInterest,2)%></td>
                    <td width="7%" valign=top align=right><%=FormatNumber(totCommission,2)%></td>
                    <td width="5%" valign=top align=right><%=FormatNumber(totSECFee,2)%></td>
                    <td width="4%" valign=top align=right><%=FormatNumber(totSvcFee,2)%></td>
                    <td width="9%" valign=top align=right><%=FormatNumber(totNet,2)%></td>
                </TR>
            </table>
        </td>
    </TR>
<%end if      
curPrincipal = 0
totPrincipal = 0
curInterest = 0
totInterest = 0
curCommission = 0
totCommission = 0
curSECFee = 0
totSECFee = 0
curSvcFee = 0
totSvcFee = 0
curNet = 0
totNet = 0 %>
<TR>
<TD width="100%">
<table class='FontStandardMinus1' border=0 cellPadding=0 align='left' cellSpacing=0 width="100%" bgcolor='#ffffff'>
<tr>
<td width=100%><b><%=adoRsTrade("calIncludedRep")%></b></td>

</tr>
</table>
</TD>
</TR>
<%end if%>
<%

FirstTime="F"
'CalCom = CalCom + adoRsTrade("calCommission")
CurRep = adoRsTrade("calIncludedRep")
adoRsTrade.MoveNext

loop%>

所以你可以看到我在表格中显示它们后尝试将值重置为 0,但该表格仅在命中 .MoveNext 后显示,这意味着即使我想显示记录 1-5 加起来,记录 6 已被 .MoveNext 击中,并且正在从值集中丢弃。很抱歉这个冗长,但我讨厌评论不能包含更新的代码。谢谢你的帮助

4

1 回答 1

1

假设您在循环之后输出变量 totPrincipal、totInterest、totCommission,我能想到的唯一问题是数据类型和 rs.MoveFirst。

顺便说一句:出于性能原因,请尝试在单个循环中执行此操作!

Dim subtotPrincipal: subtotPrincipal = 0
Dim totPrincipal: totPrincipal = 0
Dim CurRep: CurRep = 0
Dim NewRep: NewRep = 0

adoRsTrade.MoveFirst
Do 
    NewRep = adoRsTrade("calIncludedRep")       
    ...
    subtotPrincipal = subtotPrincipal + CLng(adoRsTrade("mPrincipal"))
    totPrincipal = totPrincipal + CLng(adoRsTrade("mPrincipal"))
    ...

    If (CurRep <> NewRep And Not adorsTrade.BOF) Or adoRsTrade.EOF Then
        Response.Write subtotPrincipal
        subtotPrincipal = 0
    End If

    CurRep = NewRep
    adorsTrade.MoveNext
Loop Until adoRsTrade.EOF

Response.Write totPrincipal
于 2013-03-18T14:10:30.723 回答