⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bus_show.asp

📁 是一个公交信息查询系统
💻 ASP
📖 第 1 页 / 共 2 页
字号:
<!-- #include file="inc/config.asp" -->
<%
if request.QueryString.count>0 then
station1=request.QueryString("q")
station2=request.QueryString("q1")
end if
if station1="" or station2="" then
  call ShowErr("请输入站点!","1")
end if
response.Write("<title>"& station1 &"--"& station2 &"</title>")
%>
<!-- #include file="top.asp" -->
<%
response.Write("<div id='div_1'>所有与公交换乘""<span style='color:#FF0000'>"& station1 &"--"& station2 &"</span>""有关的信息</div>")
'下面通过数据库找到过station1这个站点的所有公交线路
sqlstr="select * from [Station] where qmstation_name='"& station1 &"'"
rs.open sqlstr,conn,1,3
if not rs.eof then
  qmroute_ahead_old=rs("qmstation_bus")
  '拆封qmroute_ahead_old.
  qmroute_ahead_first_1=split(qmroute_ahead_old,"-")
  Num_ahead_1=ubound(qmroute_ahead_first_1)
else
  response.Redirect("bus_suggestion.asp?q="&station1&"&q1="&station2&"")
  response.End()
end if
rs.close

'下面通过数据库找到过station2这个站点的所有公交线路
sql="select * from [Station] where qmstation_name='"& station2 &"'"
rs.open sql,conn,1,3
if not rs.eof then
  qmroute_end_old=rs("qmstation_bus")
  '拆封qmroute_end_old.
  qmroute_end_first_1=split(qmroute_end_old,"-")
  Num_end_1=ubound(qmroute_end_first_1)
else
  response.Redirect("bus_suggestion.asp?q="&station1&"&q1="&station2&"")
  response.End()
end if
rs.close
response.Write("<div id='div_3'>")
response.Write("本系统查找从<a href='station_show.asp?q="&station1&"'><font color='#FF0000'>"&station1&"</font></a>到<a href='station_show.asp?q="&station2&"'><font color='#FF0000'>"&station2&"</font></a>的线路有:<br>")
'判断是否有重复的线路,有则说明可以直达
Check_1=""
for i=0 to Num_ahead_1
  for j=0 to Num_end_1
	if qmroute_ahead_first_1(i)=qmroute_end_first_1(j) then
	  response.Write("<li>可坐 <a href='qmroute_show.asp?q="&qmroute_ahead_first_1(i)&"'><font color='#FF0000'>"& qmroute_ahead_first_1(i) &"</font></a> 直达!"&"</li>")
	  call SearchRate1(qmroute_ahead_first_1(i))
      Check_1="qm"
	end if
  next
next
'---------------------------------------------------------------------------------
'通过判断Check_1的值来知道是否有直达车,有则停止,反之继续
if Check_1="qm" then
  response.Write("<br>这是本系统查到可以直达的车!")
  response.Write("</div>")
%>
<!-- #include file="bottom.asp" -->
<%
  response.End()
end if
'---------------------------------------------------------------------------------
'能够执行到这里说明没有直达的车,则需进一步搜索相交的站点来找到一次换乘方案
'---------------------------------------------------------------------------------
'这里组合出sqlstr字符串,再通过各条件生成sqlstr语句,查过station1的所有车经过的所有站点
'-----------------------------------
sqlstr=""
if Num_ahead_1=0 then
  sqlstr="select * from [Route] where qmroute_name='"& qmroute_ahead_old &"'"
else
  sqlstr="select * from [Route] where qmroute_name='"& qmroute_ahead_first_1(0) &"'"
  for i=1 to Num_ahead_1
    sqlstr=sqlstr&" or qmroute_name='"& qmroute_ahead_first_1(i) &"'"
  next
end if
dim qmroute_ahead_name,station_ahead_second_1,station_ahead_second_2
redim qmroute_ahead_name(i)
redim station_ahead_second_1(i)
station_ahead_second_2="@#$%&"
rs.open sqlstr,conn,1,3
if not rs.eof then
  p=0
  while not rs.eof
    qmroute_ahead_name(p)=rs("qmroute_name")
	station_ahead_second_1(p)=rs("qmroute_address")
	station_ahead_second_2=station_ahead_second_2&"-"&rs("qmroute_address")
	p=p+1
  rs.movenext
  wend
else
 response.Write("数据库数据出错1!")
 response.End()
end if
rs.close
'-----------------------------------
'这里组合出sql字符串,再通过各条件生成sql语句,查过station2的所有车经过的所有站点
'-----------------------------------
sql=""
if Num_end_1=0 then
  sql="select * from [Route] where qmroute_name='"& qmroute_end_old &"'"
else
  sql="select * from [Route] where qmroute_name='"& qmroute_end_first_1(0) &"'"
  for i=1 to Num_end_1 
    sql=sql&" or qmroute_name='"& qmroute_end_first_1(i) &"'"
  next 
end if
dim qmroute_end_name,station_end_second_1,station_end_second_2
redim qmroute_end_name(i)
redim station_end_second_1(i)
station_end_second_2="&%$#@"
rs.open sql,conn,1,3
if not rs.eof then
  q=0
  while not rs.eof
    qmroute_end_name(q)=rs("qmroute_name")
	station_end_second_1(q)=rs("qmroute_address")
	station_end_second_2=station_end_second_2&"-"&rs("qmroute_address")
	q=q+1
  rs.movenext
  wend
else
  response.Write("数据库数据出错2!")
  response.End()
end if
rs.close
'------------------------------------------------------------------------------------------------
'这里来个小程序进行赋值,这些数据之后查询二次换乘的时候能够用到
i=100
dim qmroute_ahead_info,qmroute_end_info
dim NumAheadFirstMax,NumAheadSecondMax,NumEndFirstMax,NumEndSecondMax
redim qmroute_ahead_info(i),qmroute_end_info(i),NumAheadSecondMax(i),NumEndSecondMax(i)
NumAheadFirstMax=p-1
NumEndFirstMax=q-1
for i=0 to NumAheadFirstMax
  qmroute_ahead_info(i)=split(station_ahead_second_1(i),"-")
  NumAheadSecondMax(i)=ubound(qmroute_ahead_info(i))
next
for i=0 to NumEndFirstMax
  qmroute_end_info(i)=split(station_end_second_1(i),"-")
  NumEndSecondMax(i)=ubound(qmroute_end_info(i))
next



'下面进行循环对比,如有相同的站点这说明两辆公交车可在这个站点上连接上
'-----------------------------------
i=100
dim station_ahead_second_3,Num_ahead_2,station_end_second_3,Num_end_2
redim station_ahead_second_3(i),Num_ahead_2(i),station_end_second_3(i),Num_end_2(i)
for i=0 to p-1
  station_ahead_second_3(i)=split(station_ahead_second_1(i),"-")
  Num_ahead_2(i)=ubound(station_ahead_second_3(i))
next
for i=0 to q-1
  station_end_second_3(i)=split(station_end_second_1(i),"-")
  Num_end_2(i)=ubound(station_end_second_3(i))
next
Check_2=""
for i=0 to p-1
  for m=0 to q-1
    station_change=""
    for j=0 to Num_ahead_2(i)
	  for n=0 to Num_end_2(m)
	    if station_ahead_second_3(i)(j)=station_end_second_3(m)(n) then
		  station_change=station_change&"/"&station_ahead_second_3(i)(j)
		  Check_2="qm"
		end if
	  next
	next
	if station_change<>"" then
	  station_change_new=split(station_change,"/")
	  if ubound(station_change_new)=1 then
	    station_change="<a href=station_show.asp?q="&station_change_new(1)&">"&station_change_new(1)&"</a>"
	  else
	    station_change="<a href=station_show.asp?q="&station_change_new(1)&">"&station_change_new(1)&"</a>"
	    for k=2 to ubound(station_change_new)
	      station_change=station_change&"<font color='#FF0000'>/</font><a href=station_show.asp?q="&station_change_new(k)&">"&station_change_new(k)&"</a>"
	    next
	  end if
	  response.Write("<br><li>可坐 <a href='qmroute_show.asp?q="&qmroute_ahead_name(i)&"'><font color='#FF0000'>"&qmroute_ahead_name(i)&"</font></a> 到 ("&station_change&") 再坐 <a href='qmroute_show.asp?q="&qmroute_end_name(m)&"'><font color='#FF0000'>"&qmroute_end_name(m)&"</font></a> 便可到达!</li><br>")
	  call SearchRate2(qmroute_ahead_name(i),qmroute_end_name(m))
	end if
  next
next
'---------------------------------------------------------------------------------
'通过判断Check_2的值来知道是否有一次换乘方案,有则停止,反之继续
if Check_2="qm" then
  response.Write("<br>由于没有查到有直达的车,所以本系统给出一次换乘的乘车方案!")
  response.Write("</div>")
%>
<!-- #include file="bottom.asp" -->
<%
  response.End()
end if
'---------------------------------------------------------------------------------
'能够执行到这里说明没有一次换乘方案,则需进一步搜索相交的站点来找到二次换乘方案
'---------------------------------------------------------------------------------
'进行数据的优化,把相同的站点去掉
'-------------------
'前面数据优化
station_ahead_second_4=split(station_ahead_second_2,"-")
Num_ahead_3=ubound(station_ahead_second_4)
station_ahead_second_5=station_ahead_second_4(1)  '前面可知station_ahead_second_4(0)是为了连接方便加上去的一段字符串,故不需要
for i=2 to Num_ahead_3
  Check_3=""
  station_ahead_second_6=split(station_ahead_second_5,"-")
  Num_ahead_4=ubound(station_ahead_second_6)
  for k=0 to Num_ahead_4
    if station_ahead_second_6(k)=station_ahead_second_4(i) then '有相同的数据则删掉
	  Check_3="qm"
	end if
  next
  if Check_3="" then
    station_ahead_second_5=station_ahead_second_5&"-"&station_ahead_second_4(i)
  end if
next
'-------------------
'后面数据优化
station_end_second_4=split(station_end_second_2,"-")
Num_end_3=ubound(station_end_second_4)
station_end_second_5=station_end_second_4(1)  '前面可知station_end_second_4(0)是为了连接方便加上去的一段字符串,故不需要
for i=2 to Num_end_3
  Check_4=""
  station_end_second_6=split(station_end_second_5,"-")
  Num_end_4=ubound(station_end_second_6)
  for k=0 to Num_end_4
    if station_end_second_6(k)=station_end_second_4(i) then '有相同的数据则删掉

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -