注册 登录
编程论坛 ASP技术论坛

关于分页显示后的求和、小写转大写问题!!

greatyollow 发布于 2007-10-05 12:53, 1865 次点击

问题之一:和值永远为空,什么也没有。
问题之二:小写转大写永远是贰佰贰拾贰亿贰仟贰佰贰拾贰万贰仟贰佰贰拾贰元(也就是22222222222)

代码如下:
<TD height="25" align="center">列表标题</TD>
<td width="12%" height="25" align="center" class="but" onMouseDown="this.className='tddown'" onMouseUp="this.className='but'" onMouseOut="this.className='but'">内容</td>
……
<%
uptime=cstr(trim(request("uptime")))
uptime1=cstr(trim(request("uptime1")))
PageShowSize = 10 '每页显示多少个页
MyPageSize = 20 '每页显示多少条
If Not IsNumeric(Request("page")) Or IsEmpty(Request("page")) Or Request("page") <=0 Then
Page=1
Else
Page=Int(Abs(Request("page")))
End if

set rs=server.CreateObject("ADODB.RecordSet")
if Request("user_zhuozhe_name")="" and Request("user_dangwei_file")="" and Request("user_fashong_fangshi")="" then
rs.Source="select * from client where kfsj between #"&uptime&"# and #"&uptime1&"# order by id desc"
else
if Request("user_fashong_fangshi")="" then
if Request("user_dangwei_file")="" then
rs.Source="select * from client where zhuozhe_name like '%"&Request("user_zhuozhe_name")&"%' and (kfsj between #"&uptime&"# and #"&uptime1&"#) order by id desc"
else
rs.Source="select * from client where client_adr like '%"&Request("user_dangwei_file")&"%' and (kfsj between #"&uptime&"# and #"&uptime1&"#) order by id desc"
end if
else
rs.Source="select * from client where fashong_fangshi like '%"&request("user_fashong_fangshi")&"%' and (kfsj between #"&uptime&"# and #"&uptime1&"#) order by id desc"
end if
end if
rs.Open rs.Source,conn,1,1

if not rs.EOF then
rs.PageSize = MyPageSize
MaxPages = rs.PageCount
rs.absolutepage = Page
total = rs.RecordCount
for i=1 to rs.PageSize
if not rs.EOF then
%>

<tr>
<td height="18" class="but" onMouseDown="this.className='tddown'" onMouseUp="this.className='but'" onMouseOut="this.className='but'"><input name="selBigClass" type="checkbox" id="selBigClass" value="<%=rs("ID")%>"><a href="invoice_search03.Asp?id=<%=rs("ID")%>&action=edit"><%=rs("kfsj")%></a></td>
<td height="18" class="but" onMouseDown="this.className='tddown'" onMouseUp="this.className='but'" onMouseOut="this.className='but'">&nbsp;<%for j=1 to 3-len(rs("kfbm_person"))%>0<%next%><%=rs("kfbm_person")%></a></td>
<td height="18" align="left" class="but" onMouseDown="this.className='tddown'" onMouseUp="this.className='but'" onMouseOut="this.className='but'">&nbsp;<%=rs("zhuozhe_name")%></td>
<td height="18" class="but" onMouseDown="this.className='tddown'" onMouseUp="this.className='but'" onMouseOut="this.className='but'">&nbsp;<%=rs("client_adr")%></td>
<td height="18" class="but" onMouseDown="this.className='tddown'" onMouseUp="this.className='but'" onMouseOut="this.className='but'">&nbsp;<%=rs("client_file")%></td>
<td height="18" class="but" onMouseDown="this.className='tddown'" onMouseUp="this.className='but'" onMouseOut="this.className='but'">&nbsp;<%=rs("fashong_fangshi")%></td>
<td height="18" align="right" class="but" onMouseDown="this.className='tddown'" onMouseUp="this.className='but'" onMouseOut="this.className='but'">&nbsp;<%=rs("freight")%></td>
</TR>
<%
rs.MoveNext
end if
next
%>

<% if rs.eof Then
’//以下这一段是按上面的查询条件进行求和
set rs=server.CreateObject("ADODB.RecordSet")
if Request("user_zhuozhe_name")="" and Request("user_dangwei_file")="" and Request("user_fashong_fangshi")="" then
rs.Source="select sum(freight) as num from client where kfsj between #"&uptime&"# and #"&uptime1&"# order by id desc"
else
if Request("user_fashong_fangshi")="" then
if Request("user_dangwei_file")="" then
rs.Source="select sum(freight) as num from client where zhuozhe_name like '%"&Request("user_zhuozhe_name")&"%' and (kfsj between #"&uptime&"# and #"&uptime1&"#) order by id desc"
else
rs.Source="select sum(freight) as num from client where client_adr like '%"&Request("user_dangwei_file")&"%' and (kfsj between #"&uptime&"# and #"&uptime1&"#) order by id desc"
end if
else
rs.Source="select sum(freight) as num from client where fashong_fangshi like '%"&request("user_fashong_fangshi")&"%' and (kfsj between #"&uptime&"# and #"&uptime1&"#) order by id desc"
end if
end if
rs.Open rs.Source,conn,1,1
’//以下是小写转大写
thenumber=num
call Money(22222222222)
function Money(thenumber)
dim n,String1,String2,length
dim one(),onestr()
String1="零壹贰叁肆伍陆柒捌玖"
String2="万仟佰拾亿仟佰拾万仟佰拾元"
length=len(thenumber)
redim one(length-1)
redim onestr(length-1)
for n=0 to length-1
one(n)=mid(thenumber,n+1,1)
one(n)=mid(string1,one(n)+1,1)
onestr(n)=mid(string2,14-length+n,1)
one(n)=one(n)&onestr(n)
next
Money=replace(join(one)," ","")
Money=replace(Money,"零元","元")
Money=replace(Money,"零万","万")
Money=replace(Money,"零亿","亿")
Money=replace(Money,"零仟","零")
Money=replace(Money,"零佰","零")
Money=replace(Money,"零拾","零")
do while not instr(Money,"零零")=0
Money=replace(Money,"零零","零")
loop
end function
%>
’//以下是显示合计值
<tr>
<td width="12%" height="22" class="but" onMouseDown="this.className='tddown'" onMouseUp="this.className='but'" onMouseOut="this.className='but'">&nbsp;&nbsp;&nbsp;&nbsp;合&nbsp;&nbsp;&nbsp;计</a></td>
<td width="7%" height="18" align="left" class="but" colspan="5" onMouseDown="this.className='tddown'" onMouseUp="this.className='but'" onMouseOut="this.className='but'">&nbsp;&nbsp;大&nbsp;写:&nbsp;<%=rs("Money")%></td>
<td width="8%" height="18" align="right" class="but" onMouseDown="this.className='tddown'" onMouseUp="this.className='but'" onMouseOut="this.className='but'">&nbsp;<%=num%></td>
<%end if %>
</tr>

<%end if%>
&nbsp;共 <%=total%> 条,当前第 <%=page%>/<%=Maxpages%>页,每页 <%=MyPageSize%> 条

……
以下是页码的显示(没问题)

22 回复
#2
greatyollow2007-10-05 13:08
#3
greatyollow2007-10-05 13:25
#4
yms1232007-10-05 14:03

楼主是想在最后一页来求和吗?

#5
greatyollow2007-10-05 14:34
终于等到你了
#6
greatyollow2007-10-05 14:35
最后一页,最后一行,
#7
greatyollow2007-10-05 14:38
几经思考,发现首先是NUM没得东西出来;然后就是CALL这里有问题。但就是不知道问题该怎么解决。
#8
greatyollow2007-10-05 14:50
#9
madpbpl2007-10-05 15:07
call Money(22222222222)
改成
<%num=rs("num")%>
call Money(num)
试试
后面的function不要改动
合计用<%=rs("num")%>表示
#10
yms1232007-10-05 15:10

个人的思路利用rs.PageCount判断是否为最后一页,然后用SQL语句完成求和。

#11
greatyollow2007-10-05 15:10

我试一试,先谢谢了

#12
yms1232007-10-05 15:12
if Request("user_zhuozhe_name")="" and Request("user_dangwei_file")="" and Request("user_fashong_fangshi")="" then
rs.Source="select sum(freight) as num from client where kfsj between #"&uptime&"# and #"&uptime1&"# order by id desc"
else
if Request("user_fashong_fangshi")="" then
if Request("user_dangwei_file")="" then
rs.Source="select sum(freight) as num from client where zhuozhe_name like '%"&Request("user_zhuozhe_name")&"%' and (kfsj between #"&uptime&"# and #"&uptime1&"#) order by id desc"
else
rs.Source="select sum(freight) as num from client where client_adr like '%"&Request("user_dangwei_file")&"%' and (kfsj between #"&uptime&"# and #"&uptime1&"#) order by id desc"
end if
else
rs.Source="select sum(freight) as num from client where fashong_fangshi like '%"&request("user_fashong_fangshi")&"%' and (kfsj between #"&uptime&"# and #"&uptime1&"#) order by id desc"
end if
end if
个人觉得楼主的查询条件处理的不是很好。
#13
greatyollow2007-10-05 15:13
我看了,判断已经认定是最后一而,就是SQL语句有问题了!
谢谢。
我也正在看SQL到底哪点有问题!
#14
greatyollow2007-10-05 15:15
你说得很对!没想得细,就是想思路最简,结果写下来才发现操作难
#15
greatyollow2007-10-05 15:22
madpbpl:
谢谢你!小写问题已经解决了.再一次谢谢你!!
#16
greatyollow2007-10-05 15:25
yms123:

你好,是不是selsct求和语句没把数据库打开。所以没法求字段freight的和??
#17
greatyollow2007-10-05 15:28
………………………………………………
个人觉得楼主的查询条件处理的不是很好。
………………………………………………

这是一段按条件的求和语句,是不是什么地方错得离谱了!!
#18
yms1232007-10-05 15:32

我觉得楼主的查询条件处理代码写的太混乱,或者直接使用sql字符串而不要用rs.Source试试看。

#19
greatyollow2007-10-05 15:35
你说得对,我才学ASP不到10天,没办法。请多指教!
#20
greatyollow2007-10-05 15:36
能不能帮忙改一句,我实在不知道该怎么写!真的是初学!
#21
yms1232007-10-05 15:49

if Request("user_zhuozhe_name")="" and Request("user_dangwei_file")="" and Request("user_fashong_fangshi")="" then
rs.Source="select sum(freight) as num from client where kfsj between #"&uptime&"# and #"&uptime1&"# order by id desc"
else
if Request("user_fashong_fangshi")="" then
if Request("user_dangwei_file")="" then
rs.Source="select sum(freight) as num from client where zhuozhe_name like '%"&Request("user_zhuozhe_name")&"%' and (kfsj between #"&uptime&"# and #"&uptime1&"#) order by id desc"
else
rs.Source="select sum(freight) as num from client where client_adr like '%"&Request("user_dangwei_file")&"%' and (kfsj between #"&uptime&"# and #"&uptime1&"#) order by id desc"
end if
else
rs.Source="select sum(freight) as num from client where fashong_fangshi like '%"&request("user_fashong_fangshi")&"%' and (kfsj between #"&uptime&"# and #"&uptime1&"#) order by id desc"
end if
end if
楼主的client表是做什么用的?

#22
greatyollow2007-10-05 16:10
#23
greatyollow2007-10-05 16:15
各位朋友,大家好!在大家的帮助下,我已经解决了这个两个问题。
致谢!再三致谢!!
1