开发者

I can't get this page to stop subtracting the xl sales from the total. classic asp

So this page gets all the sales for todays date in a query and then sums them up, but if a sale get's canceled it also subtracts the canceled amount from the total amount, i don't want it to do this and i have tryed many things and still cant get it.

set RScontest = Server.CreateObject("ADODB.Recordset")
    RScontest.ActiveConnection = ""
    RScontest.Source = SelectData
    RScontest.CursorType = 3
    RScontest.CursorLocation = 2
    RScontest.LockType = 1
    RScontest.Open()
    if not(rscontest.bof) and not(rscontest.eof) then%><font face="Arial,Helvetica,sans-serif" size=4"><b>
                 Sales</b>

                <table width="100%">

    <%
    st = ""
    pax = 0
    sales = 0
    PAXTotal = 0
    SALESTotal = 0


                while not rscontest.eof

                    if st <> rscontest.fields.item("status") THEN
                        if st <> "" then
                            response.write("<tr bgcolor='#F2F2F2'><td >")
                            %><font face="Arial,Helvetica,sans-serif" size="-1"><%
                            response.write("Sub Total")%>
                            </td>

                            <td>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            </td>

                            <td>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            </td>

                            <td>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            </td>

                            <td>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            </td>

                            <td>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            </td>
    <td>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            </td>

                            <td align='right'>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            <%response.write(PAX)%>
                            </td>
                            <td align='right'>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            <%response.write(formatnumber(Sales,2))%>
                            </td>
                            </tr>
                        <%PAXTotal = PAXTotal + PAX
                        SALESTotal = SALESTotal + Sales
                        PAX = 0
                        Sales = 0
                        end if%>

                        <%response.write("<tr bgcolor='#FADFA0'><td >")
                        %><font face="Arial,Helvetica,sans-serif" size="-1"><%
                        response.write(rscontest.fields.item("status") & " Bookings")%>
                        </td>
                        <td>
                        <font face="Arial,Helvetica,sans-serif" size="-1">
                        Departure</td>
                        <td>
                        <font face="Arial,Helvetica,sans-serif" size="-1">
                        Passenger</td>
                        <td>
                        <font face="Arial,Helvetica,sans-serif" size="-1">
                        Source</td>
                        <td>
                        <font face="Arial,Helvetica,sans-serif" size="-1">
                        Campaign</td>
    <td>
                        <font face="Arial,Helvetica,sans-serif" size="-1">
                        Tour</td>
                        <td>
                        <font face="Arial,Helvetica,sans-serif" size="-1">
                        Agent</td>
                        <td>
                        <font face="Arial,Helvetica,sans-serif" size="-1">
                        PAX</td>
                        <td>
                        <font face="Arial,Helvetica,sans-serif" size="-1">
                        Amount</td>
                        </tr>
                        <%st = rscontest.fields.item("status")
                    END IF

                    response.write("<tr><td&g开发者_开发百科t;")

                    %><font face="Arial,Helvetica,sans-serif" size="-2"><%
                    response.write(rscontest.fields.item("book7") & " - " & rscontest.fields.item("BTIME"))
                    response.write("</td><td>")

                    %><font face="Arial,Helvetica,sans-serif" size="-2"><%
                    response.write(rscontest.fields.item("dep7"))
                    response.write("</td><td>")

                    %><font face="Arial,Helvetica,sans-serif" size="-2"><%
                    response.write(rscontest.fields.item("lead"))
                    response.write("</td><td>")

                    %><font face="Arial,Helvetica,sans-serif" size="-2"><%
                    response.write(rscontest.fields.item("hear"))
                    response.write("</td><td>")

                    %><font face="Arial,Helvetica,sans-serif" size="-2"><%
                    response.write(rscontest.fields.item("cname"))
                    response.write("</td><td>")

    %><font face="Arial,Helvetica,sans-serif" size="-2"><%
                response.write(rscontest.fields.item("theme") & " - " & rscontest.fields.item("tour"))
                    response.write("</td><td align='right'>")

                    %><font face="Arial,Helvetica,sans-serif" size="-2"><%
                    response.write(rscontest.fields.item("userid"))
                    response.write("</td><td align='right'>")

                    %><font face="Arial,Helvetica,sans-serif" size="-2"><%
                    response.write(rscontest.fields.item("pax_count"))
                    pax = pax + rscontest.fields.item("pax_count")
                    response.write("</td><td align='right'>")

                    %><font face="Arial,Helvetica,sans-serif" size="-2"><%
                    IF rscontest.fields.item("status") = "XL" then
                        response.write(formatnumber(rscontest.fields.item("CXVALUE"),2))
                        sales = sales - formatnumber(rscontest.fields.item("CXVALUE"),2)
                    ELSE
                        response.write(formatnumber(rscontest.fields.item("AMOUNT"),2))
                        sales = sales + formatnumber(rscontest.fields.item("AMOUNT"),2)
                    END IF

                response.write("<tr><td rowspan=1>")    
                %><font face="Arial,Helvetica,sans-serif" size="-2"></style><%
                    response.write(rscontest.fields.item("description"))




                    rscontest.movenext

                wend


                        if st <> "" then
                            response.write("<tr bgcolor='#F2F2F2'><td >")
                            %><font face="Arial,Helvetica,sans-serif" size="-1"><%
                            response.write("Sub Total")%>
                            </td>
                            <td>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            </td>
                            <td>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            </td>
                            <td>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            </td>
                            <td>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            </td>
    <td>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            </td>

                            <td>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            </td>
                            <td align='right'>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            <%response.write(PAX)%>
                            </td>
                            <td align='right'>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            <%response.write(formatnumber(Sales,2))%>
                            </td>
                            </tr>

                            <%
                            PAXTotal = PAXTotal + PAX
                            SALESTotal = SALESTotal + Sales
                            PAX = 0
                            Sales = 0

                            response.write("<tr bgcolor='#D3FFA1'><td >")
                            %><font face="Arial,Helvetica,sans-serif" size="-1"><%
                            response.write("Total")%>
                            </td>
                            <td>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            </td>
                            <td>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            </td>

                            <td>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            </td>
                            <td>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            </td>
    <td>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            </td>
                            <td>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            </td>
                            <td align='right'>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            <%response.write(PAXTotal)%>
                            </td>
                            <td align='right'>
                            <font face="Arial,Helvetica,sans-serif" size="-1">
                            <%response.write(formatnumber(SalesTotal,2))%>
                            </td>
                            </tr>
                        <%end if%>

                </table>
    <%else%>
            No sales for this date...<BR><BR>
    <%end if
    RScontest.Close()%>




    </td>
    </tr>
    </table>


Improving your Code

Here's a list of things to help you neaten your code up. Without spending much more time on it, I can't see exactly what is wrong (or what you are asking) but following these steps should help you pinpoint the error:

  • Remove all <font> tags, use CSS
  • Your record loop would be better by taking values from the recordset into variables first, not calling them repeatedly throughout the loop, IE:

    Dim strTitle
    Dim intValue1
    Dim intTotal
    
    intTotal = 0
    
    while not rscommon.eof
    
        //Take your variables
        strTitle = rsCommon("title")
        intValue1 = rsCommon("value")
    
        //Process values here, referencing variables not recordset
        intTotal = intTotal + intValue1
    
        //Loop your table here
        response.write("<tr>")
    rsCommon.close
    wend
    

These changes will improve the speed of your loop (significantly) and also make it a lot more structured, helping you pinpoint errors in your logic a lot faster and easier.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜