| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 878 人关注过本帖
标题:ASP一个难以解决的判断操作问题,小弟在线急切期待大家过招
只看楼主 加入收藏
kira007
Rank: 2
等 级:论坛游民
帖 子:294
专家分:27
注 册:2007-6-28
结帖率:50%
收藏
 问题点数:0 回复次数:12 
ASP一个难以解决的判断操作问题,小弟在线急切期待大家过招
我写了个 判断程序,结构如下 (最后附上目前还在设计的源代码)
IF 判断条件1 THEN
不符合条件弹出提示
END IF
......
IF 判断条件N THEN
不符合条件弹出提示
END IF

***以下为***

符合条件后要执行的程序

******************
现在的问题是,即使不符合条件弹出提示后,也会运行判断后的程序。尝试了在每个判断结束前加入response.end.,但这样的话,永远都不会运行判断后的程序!
请问大家有没有办法解决这个问题(只有符合所有条件才运行判断后的程序,即使一个数据不符合条件都要返回修改)

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!--#include file="conn.asp"-->
<%response.Buffer=true
response.Expires=0
%>
<% dim action
action=request.QueryString("action")
if action="makeorder" then'订单动作
dim YUE,quota
proid=request.form("proid")
'生成订单号码
ranNum=int(9*rnd)+10
goods=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum
goods=int(goods)
'生成当月编号
months= year(now)&month(now)
'建立部门联系信息
set rss=server.createobject("adodb.recordset")
rss.open"select * from company_bumen where bumenid="&strbumenid,conn,1,1
'**********************************调入商品订购条件判断**********************************************
'/////////////////////////////////////////////////////// 第一种情况判断(余额问题) ////////////////////////////////////////////
sums=Round(request.form("sums"),2)'获取当前订单中算入限额的总额
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
set rsFY=server.createobject("adodb.recordset")'统计该部门当月的费用
rsFY.open"select SUM(price) as sums from company_order where qt=1 and ordermonth="&int(months)&" and bumenid="&strbumenid,conn,1,1
if rsFY("sums")="" then'如果总额为空,则赋值为0
quota=0
else
quota=round(rsFY("sums"),2)
end if
YUE=Round(rss("bumenQuota")-quota,2)'算出可用余额
'1.余额的判断////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if YUE < sums then
response.write"<script LANGUAGE='javascript'>alert('对不起,该部门余额不足,当前余额为["&(Round(YUE,2))&"]请返回修改你的订单!');history.go(-1);</script>"
rsFY.CLOSE
SET RSfy=nothing
response.End()
end if
'/////////////////////////////////// 第一种情况判断结束,第二中情况判断开始 ///////////////////////////////////////////////////
if proid <> "" then
SET rs=server.createobject("adodb.recordset")
rs.open" select product.name,product.id,company_pro.pset,company_pro.Pxianzhi,company_pro.Pxianzhi,company_pro.Pnums from product inner join company_pro on product.id=company_pro.productid where company_pro.productid in ("&proid&") and company_pro.companyid="&companyid&"",conn,1,1
if not (rs.eof and rs.bof) then
do while not rs.eof
Quatity = CInt(Request( "num" & rs("id")))
'/////////////////////////////////////////////////属性1判断////////////////////////////////////////////////////////////////////
if rs("pset")=1 and rs("Pxianzhi")=0 then
'***************************************************查出当月订售数量***********************************************************
set rsyy=server.createobject("adodb.recordset")'统计该部门当月的订购数量
rsyy.open" select sum(productnums) as pnum from company_order where productid="&rs("id")&" and ordermonth="&int(months)&" and bumenid="&strbumenid,conn,1,1
if rsyy("pnum")="" then'如果总额为空,则赋值为0
quota=0
else
quota=round(rsyy("pnum"))
end if
'*******************************************************************************************************************************
if Cint(Quatity) > Cint( rss("bumennum")+ rs("Pnums")-quota) then' 购买量超出限制数量
response.write"<script LANGUAGE='javascript'>alert('对不起,商品["&rs("id")&"]["&rs("name")&"]超出月限制数量["&(rss("bumennum")+ rs("Pnums"))&"/部门],目前可订购数目为["&( Cint( rss("bumennum")+ rs("Pnums")-quota))&"],请返回修改你的订单!');history.go(-1);</script>"
end if
rsyy.close
set rsyy=nothing
end if
'/////////////////////////////////////////////////属性2判断////////////////////////////////////////////////////////////////////
if rs("Pxianzhi")<> 0 then
'***************************************************查出当月订售数量***********************************************************
set rsyy=server.createobject("adodb.recordset")'统计该部门当月的订购数量
rsyy.open" select sum(productnums) as pnum from company_order where productid="&rs("id")&" and ordermonth="&int(months)&" and bumenid="&strbumenid,conn,1,1
if rsyy("pnum")="" then'如果总额为空,则赋值为0
quota=0
else
quota=round(rsyy("pnum"))
end if
'*******************************************************************************************************************************
if Cint(Quatity) > Cint(rs("Pxianzhi")-quota) then' 购买量超出限制数量
response.write"<script LANGUAGE='javascript'>alert('对不起,商品["&rs("id")&"]["&rs("name")&"]超出月限制数量["&rs("pxianzhi")&"/PCS],目前可订购数量为["&(Cint(rs("Pxianzhi")-quota))&"],请返回修改你的订单!');history.go(-1);</script>"
end if
rsyy.close
set rsyy=nothing
end if
rs.movenext
loop
response.End()
end if
rs.close
set rs=nothing
'////////////////////////////////////////////////符合所有条件执行批量添加 ////////////////////////////////////////////////////////////

SET rs=server.createobject("adodb.recordset")
rs.open" select product.name,product.id,company_pro.pset,company_pro.Pxianzhi,company_pro.price,company_pro.Pnums from product inner join company_pro on product.id=company_pro.productid where company_pro.productid in ("&proid&") and company_pro.companyid="&companyid&"",conn,1,1
if not (rs.eof and rs.bof) then
do while not rs.eof
Q = CInt( Request( "Q" & rs("id")) )
Qs = CInt( Request( "P" & rs("id")) )
set rsm=server.createobject("adodb.recordset")
rsm.open" select productnums from company_shoplist where productid="&rs("id")&" and userid="&companyUserID ,conn,1,1
set rs1=server.createobject("adodb.recordset")
rs1.open"select * from company_order",conn,1,3
rs1.addnew
rs1("goodsid")=goods
rs1("companyid")=companyid
rs1("companyname")=companyname
rs1("bumenid")=strbumenid
rs1("bumenname")=rss("bumenname")
rs1("userid")=int(companyUserID)
rs1("username")=strusername
rs1("usermobile")=strusermobile
rs1("tel")=rss("bumentel")
rs1("fax")=rss("bumenfax")
rs1("address")=rss("bumenadd")
rs1("productid")=rs("id")
rs1("productnums")=rsm("productnums")
rs1("ordermonth")=int(months)
rs1("price")=rs("price")
rs1("realname")=strrealname
rs1("qt")=Q
rs1("pset")=Qs
rs1.update
rs1.close
set rs1=nothing'结束添加操作
rs.movenext
loop
end if'结束记录集不为空,开始清除临时存放区的数据
Set rs2= Server.CreateObject("ADODB.Recordset")
sql="select ID from company_shoplist where userid="&companyUserID&" and productid in ("&proid&")"
rs2.open sql,conn,1
if not rs2.eof then
do while not rs2.eof
conn.Execute("delete from company_shoplist where ID="&rs2(0))
rs2.movenext
loop
end if
rs2.close
set rs2=nothing
end if'结束PID不为空
response.write"<script LANGUAGE='javascript'>alert('订单提交成功,我们将在24内作出审核!');location='myorder.asp';</script>"
end if
%>

搜索更多相关主题的帖子: 期待 判断 过招 ASP 
2007-06-28 12:48
hangxj
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:2045
专家分:0
注 册:2006-4-10
收藏
得分:0 
'/////////////////////////////////////////////////属性2判断////////////////////////////////////////////////////////////////////
if rs("Pxianzhi")<> 0 then
'***************************************************查出当月订售数量***********************************************************
set rsyy=server.createobject("adodb.recordset")'统计该部门当月的订购数量
rsyy.open" select sum(productnums) as pnum from company_order where productid="&rs("id")&" and ordermonth="&int(months)&" and bumenid="&strbumenid,conn,1,1
if rsyy("pnum")="" then'如果总额为空,则赋值为0
quota=0
else
quota=round(rsyy("pnum"))
end if
'*******************************************************************************************************************************
if Cint(Quatity) > Cint(rs("Pxianzhi")-quota) then' 购买量超出限制数量
response.write"<script LANGUAGE='javascript'>alert('对不起,商品["&rs("id")&"]["&rs("name")&"]超出月限制数量["&rs("pxianzhi")&"/PCS],目前可订购数量为["&(Cint(rs("Pxianzhi")-quota))&"],请返回修改你的订单!');history.go(-1);</script>"
end if
rsyy.close
set rsyy=nothing
end if
rs.movenext
loop
response.End() '这句放错地方了吧
end if
rs.close
set rs=nothing
'////////////////////////////////////////////////符合所有条件执行批量添

http://www./
2007-06-28 12:56
kira007
Rank: 2
等 级:论坛游民
帖 子:294
专家分:27
注 册:2007-6-28
收藏
得分:0 
多谢回复,这个response.End(),我尝试了放入其他地方,只要通过了 余额的判断(第一个)就都会结束,所以到现在还没能找到更好到方法去控制这些判断。
loop
response.End() '这句放错地方了吧
end if
rs.close
set rs=nothing
'////////////////////////////////////////////////符合所有条件执行批量添

生活的理想,就是为了理想的生活。
2007-06-28 13:35
shdyh977
Rank: 1
等 级:新手上路
威 望:1
帖 子:109
专家分:0
注 册:2007-5-22
收藏
得分:0 
if
...
else if
...
else if
...
...
else
...
end if
...
...
end if

注意end if不要漏了
2007-06-28 13:41
kira007
Rank: 2
等 级:论坛游民
帖 子:294
专家分:27
注 册:2007-6-28
收藏
得分:0 

多谢回复!但商品的属性与数量上限制都在
if pid<>"" then
.....
.....
end if
这个判断块中执行,所以用不上 ELSE .


生活的理想,就是为了理想的生活。
2007-06-28 13:51
hangxj
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:2045
专家分:0
注 册:2006-4-10
收藏
得分:0 
'/////////////////////////////////////////////////属性2判断////////////////////////////////////////////////////////////////////
if rs("Pxianzhi")<> 0 then
'***************************************************查出当月订售数量***********************************************************
set rsyy=server.createobject("adodb.recordset")'统计该部门当月的订购数量
rsyy.open" select sum(productnums) as pnum from company_order where productid="&rs("id")&" and ordermonth="&int(months)&" and bumenid="&strbumenid,conn,1,1
if rsyy("pnum")="" then'如果总额为空,则赋值为0
quota=0
else
quota=round(rsyy("pnum"))
end if
'*******************************************************************************************************************************
if Cint(Quatity) > Cint(rs("Pxianzhi")-quota) then' 购买量超出限制数量
response.write"<script LANGUAGE='javascript'>alert('对不起,商品["&rs("id")&"]["&rs("name")&"]超出月限制数量["&rs("pxianzhi")&"/PCS],目前可订购数量为["&(Cint(rs("Pxianzhi")-quota))&"],请返回修改你的订单!');history.go(-1);</script>"
response.End() '这句放在这不行吗?

end if
rsyy.close
set rsyy=nothing
end if
rs.movenext
loop
end if
rs.close
set rs=nothing
'////////////////////////////////////////////////符合所有条件执行批量添

http://www./
2007-06-28 13:54
kira007
Rank: 2
等 级:论坛游民
帖 子:294
专家分:27
注 册:2007-6-28
收藏
得分:0 
我试过了,不行阿!那些该放的位置我都试过了。如判断属性1 的这个END IF 结束前的位置'*******************************************************************************************************************************
if Cint(Quatity) > Cint( rss("bumennum")+ rs("Pnums")-quota) then' 购买量超出限制数量
response.write"<script LANGUAGE='javascript'>alert('对不起,商品["&rs("id")&"]["&rs("name")&"]超出月限制数量["&(rss("bumennum")+ rs("Pnums"))&"/部门],目前可订购数目为["&( Cint( rss("bumennum")+ rs("Pnums")-quota))&"],请返回修改你的订单!');history.go(-1);</script>"
end if
rsyy.close
set rsyy=nothing
end if

或者是商品属性2判断END IF 结束前的位置都是不行的。都会终止执行程序
'*******************************************************************************************************************************
if Cint(Quatity) > Cint(rs("Pxianzhi")-quota) then' 购买量超出限制数量
response.write"<script LANGUAGE='javascript'>alert('对不起,商品["&rs("id")&"]["&rs("name")&"]超出月限制数量["&rs("pxianzhi")&"/PCS],目前可订购数量为["&(Cint(rs("Pxianzhi")-quota))&"],请返回修改你的订单!');history.go(-1);</script>"
end if
rsyy.close
set rsyy=nothing
end if

生活的理想,就是为了理想的生活。
2007-06-28 14:03
阳光白雪
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:39
帖 子:2220
专家分:0
注 册:2005-11-18
收藏
得分:0 
回复:(kira007)ASP一个难以解决的判断操作问题,小...

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!--#include file="conn.asp"-->
<%
response.Buffer=true
response.Expires=0

dim action
action=request.QueryString("action")
if action="makeorder" then'订单动作
dim YUE,quota
proid=request.form("proid")
'生成订单号码
ranNum=int(9*rnd)+10
goods=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum
goods=int(goods)
'生成当月编号
months= year(now)&month(now)
'建立部门联系信息
set rss=server.createobject("adodb.recordset")
rss.open"select * from company_bumen where bumenid="&strbumenid,conn,1,1
'**********************************调入商品订购条件判断**********************************************
'/////////////////////////////////////////////////////// 第一种情况判断(余额问题) ////////////////////////////////////////////
sums=Round(request.form("sums"),2)'获取当前订单中算入限额的总额
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
set rsFY=server.createobject("adodb.recordset")'统计该部门当月的费用
rsFY.open"select SUM(price) as sums from company_order where qt=1 and ordermonth="&int(months)&" and bumenid="&strbumenid,conn,1,1
if rsFY("sums")="" then'如果总额为空,则赋值为0
quota=0
else
quota=round(rsFY("sums"),2)
end if
YUE=Round(rss("bumenQuota")-quota,2)'算出可用余额
'1.余额的判断////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if YUE < sums then
response.write"<script LANGUAGE='javascript'>alert('对不起,该部门余额不足,当前余额为["&(Round(YUE,2))&"]请返回修改你的订单!');history.go(-1);</script>"
rsFY.CLOSE
SET RSfy=nothing
response.End()
end if
'/////////////////////////////////// 第一种情况判断结束,第二中情况判断开始 ///////////////////////////////////////////////////
if proid <> "" then
SET rs=server.createobject("adodb.recordset")
rs.open" select product.name,product.id,company_pro.pset,company_pro.Pxianzhi,company_pro.Pxianzhi,company_pro.Pnums from product inner join company_pro on product.id=company_pro.productid where company_pro.productid in ("&proid&") and company_pro.companyid="&companyid&"",conn,1,1
if not (rs.eof and rs.bof) then
do while not rs.eof
Quatity = CInt(Request( "num" & rs("id")))
'/////////////////////////////////////////////////属性1判断////////////////////////////////////////////////////////////////////
if rs("pset")=1 and rs("Pxianzhi")=0 then
'***************************************************查出当月订售数量***********************************************************
set rsyy=server.createobject("adodb.recordset")'统计该部门当月的订购数量
rsyy.open" select sum(productnums) as pnum from company_order where productid="&rs("id")&" and ordermonth="&int(months)&" and bumenid="&strbumenid,conn,1,1
if rsyy("pnum")="" then'如果总额为空,则赋值为0
quota=0
else
quota=round(rsyy("pnum"))
end if
'*******************************************************************************************************************************
if Cint(Quatity) > Cint( rss("bumennum")+ rs("Pnums")-quota) then' 购买量超出限制数量
response.write"<script LANGUAGE='javascript'>alert('对不起,商品["&rs("id")&"]["&rs("name")&"]超出月限制数量["&(rss("bumennum")+ rs("Pnums"))&"/部门],目前可订购数目为["&( Cint( rss("bumennum")+ rs("Pnums")-quota))&"],请返回修改你的订单!');history.go(-1);</script>"
Response.End()
end if
rsyy.close
set rsyy=nothing
end if
'/////////////////////////////////////////////////属性2判断////////////////////////////////////////////////////////////////////
if rs("Pxianzhi")<> 0 then
'***************************************************查出当月订售数量***********************************************************
set rsyy=server.createobject("adodb.recordset")'统计该部门当月的订购数量
rsyy.open" select sum(productnums) as pnum from company_order where productid="&rs("id")&" and ordermonth="&int(months)&" and bumenid="&strbumenid,conn,1,1
if rsyy("pnum")="" then'如果总额为空,则赋值为0
quota=0
else
quota=round(rsyy("pnum"))
end if
'*******************************************************************************************************************************
if Cint(Quatity) > Cint(rs("Pxianzhi")-quota) then' 购买量超出限制数量
Response.write"<script LANGUAGE='javascript'>alert('对不起,商品["&rs("id")&"]["&rs("name")&"]超出月限制数量["&rs("pxianzhi")&"/PCS],目前可订购数量为["&(Cint(rs("Pxianzhi")-quota))&"],请返回修改你的订单!');history.go(-1);</script>"
Response.End()
end if
rsyy.close
set rsyy=nothing
end if
rs.movenext
loop
'response.End()
end if
rs.close
set rs=nothing
'////////////////////////////////////////////////符合所有条件执行批量添加 ////////////////////////////////////////////////////////////

SET rs=server.createobject("adodb.recordset")
rs.open" select product.name,product.id,company_pro.pset,company_pro.Pxianzhi,company_pro.price,company_pro.Pnums from product inner join company_pro on product.id=company_pro.productid where company_pro.productid in ("&proid&") and company_pro.companyid="&companyid&"",conn,1,1
if not (rs.eof and rs.bof) then
do while not rs.eof
Q = CInt( Request( "Q" & rs("id")) )
Qs = CInt( Request( "P" & rs("id")) )
set rsm=server.createobject("adodb.recordset")
rsm.open" select productnums from company_shoplist where productid="&rs("id")&" and userid="&companyUserID ,conn,1,1
set rs1=server.createobject("adodb.recordset")
rs1.open"select * from company_order",conn,1,3
rs1.addnew
rs1("goodsid")=goods
rs1("companyid")=companyid
rs1("companyname")=companyname
rs1("bumenid")=strbumenid
rs1("bumenname")=rss("bumenname")
rs1("userid")=int(companyUserID)
rs1("username")=strusername
rs1("usermobile")=strusermobile
rs1("tel")=rss("bumentel")
rs1("fax")=rss("bumenfax")
rs1("address")=rss("bumenadd")
rs1("productid")=rs("id")
rs1("productnums")=rsm("productnums")
rs1("ordermonth")=int(months)
rs1("price")=rs("price")
rs1("realname")=strrealname
rs1("qt")=Q
rs1("pset")=Qs
rs1.update
rs1.close
set rs1=nothing'结束添加操作
rs.movenext
loop
end if
'结束记录集不为空,开始清除临时存放区的数据

Set rs2= Server.CreateObject("ADODB.Recordset")
sql="select ID from company_shoplist where userid="&companyUserID&" and productid in ("&proid&")"
rs2.open sql,conn,1
if not rs2.eof then
do while not rs2.eof
conn.Execute("delete from company_shoplist where ID="&rs2(0))
rs2.movenext
loop
end if
rs2.close
set rs2=nothing
end if'结束PID不为空
response.write"<script LANGUAGE='javascript'>alert('订单提交成功,我们将在24内作出审核!');location='myorder.asp';</script>"
Response.End()
end if
%>


专注于WEB前端交互平台开发:[url=http://blog./]blog.[/url](富客户端技术(RIA)交流平台)
2007-06-28 14:05
SkyGull
Rank: 5Rank: 5
来 自:浙江杭州
等 级:贵宾
威 望:13
帖 子:839
专家分:324
注 册:2007-6-7
收藏
得分:0 
建议response.end()不要乱放

建议使用sub和call 在sub里加response.end
2007-06-28 14:06
kira007
Rank: 2
等 级:论坛游民
帖 子:294
专家分:27
注 册:2007-6-28
收藏
得分:0 
多谢大家的回复,如 “8楼的 阳光雪白”所标识的位置正式我初次使用的位置,即使所有判断都通过了,依然不会执行 添加和删除 的程序。
所以才觉得好棘手................头都大了。不知如何是好阿............

生活的理想,就是为了理想的生活。
2007-06-28 14:13
快速回复:ASP一个难以解决的判断操作问题,小弟在线急切期待大家过招
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025288 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved