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

📄 busstationtostation.asp

📁 简单的公交车查询系统
💻 ASP
字号:
<%@LANGUAGE="VBSCRIPT"%>
<% option explicit %>
<!--#include file="function.asp"-->
<%
function search()
dim busStart,busTo
dim busStateList,busInfo,busIdList
dim flag1,flag2,flag3,strTemp,arrBusId
dim i,j, Wstr
Wstr="<td align=""center"" width=""100"" height=""44"">"
flag1=false
flag2=false
busStart=trim((request("start")))
busTo=trim((request("to")))
'将所有站点读入数组当中
busStateList=getBusStateList
for i=0 to ubound(busStateList)
	if busStart=busStateList(i) then
		flag1=true
	end if
	
	if busTo=busStateList(i) then
	    flag2=true
	end if
	if (flag1 and flag2) then exit for
next

If not(flag1 and flag2) Then
    '至少有一个站点是不存在的
	if not flag1 then
	        response.write("<table border=""1"" width=""290"" cellspacing=""0"" cellpadding=""0"" background=""image/2.gif"" style=""border-collapse: collapse; font-family: Arial Black; font-size: 10pt; color: #666699"" bordercolordark=""#E5E5E5"">")
			response.write("<tr>")
			response.write("<td height=""44"" align=""center"">对不起!站点&nbsp;"&busStart&"&nbsp;不存在,请重新输入。</td>")
			response.write("</tr>")
			response.write("</table>")
	end if
	if not flag2 then
	        response.write("<p>")
	        response.write("<table border=""1"" width=""290"" cellspacing=""0"" cellpadding=""0"" background=""image/2.gif"" style=""border-collapse: collapse; font-family: Arial Black; font-size: 10pt; color: #666699"" bordercolordark=""#E5E5E5"">")
			response.write("<tr>")
			response.write("<td height=""44"" align=""center"">对不起!站点&nbsp;"&busTo&"&nbsp;不存在,请重新输入。</td>")
			response.write("</tr>")
			response.write("</table>")
	end if
else
	'两个站点都有,判断有没有直达车
	busIdList=getBusIdList
	'遍历所有车次
	strTemp=""
	for i=0 to ubound(busIdList)
		busInfo=getInfoByBusid(busIdList(i))
		flag3=0
		for j=3 to ubound(busInfo)		'数组的第四个元素才开始记录站点名
			if busInfo(j)=busStart then
				flag3=flag3+1
			end if
			if busInfo(j)=busTo then
				flag3=flag3+1
			end if
			if flag3=2 then exit for
		next
		if flag3=2 then
			strTemp=strTemp+cstr(busInfo(0))+"||"  'strTemp 保存查到的有效车次
		end if
	next
	if strTemp="" then '无直达车
	        response.write("<table border=""1"" width=""400"" cellspacing=""0"" cellpadding=""0"" background=""image/2.gif"" style=""border-collapse: collapse; font-family: Arial Black; font-size: 10pt; color: #666699"" bordercolordark=""#E5E5E5"">")
			response.write("<tr>")
			response.write("<td height=""44"" align=""center"">&nbsp;"&busStart&"&nbsp;到&nbsp;"&busTo&"&nbsp;没有直达车,请参照下列换乘建议</td>")
			response.write("</tr>")
			response.write("</table>")
			response.write("<p>")
	
		'查询一级中转站点
		'起点站 busStart
		'终点站 busTo
		'
		dim passStartStationBusID
		dim passToStationBusID
		dim ii,jj,mm,nn,kk
		dim busInfoA,busInfoB
		'dim flagII		'转车成功标志
		dim firstBusID
		dim secondBusID
		dim changeStation
		dim ResultII
		'flagII=false
		ResultII=""
		passStartStationBusID=getBusIDInfoByStation(busStart)
		passToStationBusID=getBusIDInfoByStation(busTo)
		'得到经过起点站和终点站的全部组合
		for ii=0 to ubound(passStartStationBusID)
			for jj=0 to ubound(passToStationBusID)
				'判断两辆车有没有交叉点
				busInfoA=getInfoByBusid(passStartStationBusID(ii))
				busInfoB=getInfoByBusid(passToStationBusID(jj))
				for mm=3 to ubound(busInfoA)
					for nn=3 to ubound(busInfoB)
						if busInfoA(mm)=busInfoB(nn) then
							'成功找到两辆车的交汇处
							'flagII=true
							firstBusID=passStartStationBusID(ii)
							secondBusID=passToStationBusID(jj)
							changeStation=busInfoA(mm)
							'保存转乘信息
							ResultII=ResultII+firstBusID+";"+secondBusID+";"+changeStation+"||"
							'response.Write("<br>")
							'response.Write(firstBusID+"==>"+changeStation+"==>"+secondBusID)
							'response.Write("<br>")
						end if
					next
				next
			next
		next
		if ResultII="" then
			'无中转车
			response.write("<table border=""1"" width=""400"" cellspacing=""0"" cellpadding=""0"" background=""image/2.gif"" style=""border-collapse: collapse; font-family: Arial Black; font-size: 10pt; color: #666699"" bordercolordark=""#E5E5E5"">")
			response.write("<tr>")
			response.write("<td height=""44"" align=""center"">&nbsp;"&busStart&"&nbsp;到&nbsp;"&busTo&"&nbsp;没有直达车,换乘一次也无法到达!</td>")
			response.write("</tr>")
			response.write("</table>")
		else
			'去掉最后一个分割符
			ResultII=left(ResultII,len(ResultII)-2)
			dim arrChangeI
			dim arrChangeII
			arrChangeI=split(ResultII,"||")
			response.write("<table border=""1"" height=""44"" width=""614"" cellspacing=""0"" cellpadding=""0"" background=""image/2.gif"" style=""border-collapse: collapse; font-family: Arial Black; font-size: 10pt; color: #666699"" bordercolordark=""#E5E5E5"">")
		    response.write("<tr>")
		    response.write(Wstr&"起点"&"</td>")
		    response.write(Wstr&"车次"&"</td>")
			response.write(Wstr&"中转点"&"</td>")
			response.write(Wstr&"车次"&"</td>")
			response.write(Wstr&"终点"&"</td>")
			response.write("</tr>")
			
			for kk=0 to ubound(arrChangeI)
				arrChangeII=split(arrChangeI(kk),";")
				'arrChangeII 保存了一条转乘信息
				'arrChangeII(0)  firstBusID
				'arrChangeII(1)  secondBusID
				'arrChangeII(2)	 changeStation
			    response.Write ("<tr>")
			    response.Write (Wstr& busStart &"</td>")
			    response.Write (Wstr& arrChangeII(0) & "</td>")
			    response.Write (Wstr& arrChangeII(2) & "</td>")
			    response.Write (Wstr& arrChangeII(1) & "</td>")
			    response.Write (Wstr& busTo & "</td>")
			    response.Write ("</tr>")
			next
			response.Write ("</table>")
		end if
	else   '有直达车
	        response.write("<table border=""1"" height=""44"" width=""614"" cellspacing=""0"" cellpadding=""0"" background=""image/2.gif"" style=""border-collapse: collapse; font-family: Arial Black; font-size: 10pt; color: #666699"" bordercolordark=""#E5E5E5"">")
		    response.write("<tr>")
		    response.write(Wstr&"车次</td>")
            response.write(Wstr&"起点</td>")
            response.write(Wstr&"经过</td>")
            response.write(Wstr&"经过</td>")
            response.write(Wstr&"终点</td>")
            response.write(Wstr&"详情</td>")
			response.write("</tr>")
		'去掉最后一个分割符
		strTemp=left(strTemp,len(strTemp)-2)
		arrBusId=split(strTemp,"||")
		for i=0 to (ubound(arrBusId))
			busInfo=getInfoByBusid(arrBusid(i))
		    response.write("<tr>")
		    response.write(Wstr&busInfo(0) &"</td>")
            response.write(Wstr&busInfo(1)&"</td>")
            response.write(Wstr&busStart&"</td>")
            response.write(Wstr&busTo&"</td>")
            response.write(Wstr&busInfo(2)&"</td>")
            response.write(Wstr&"详情</td>")
			response.write("</tr>")
		next
		response.Write ("</table>")
	end if
end if
end function
%>

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>公交线路查询结果</title>
</head>

<body>

<html>

<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">

<div align="center">
	<table border="0" width="100%" height="101%" cellspacing="0" cellpadding="0" style="font-size: 0">
		<tr>
			<td align="center" height="146" background="image/top1.jpg">
			
			 </td>
		</tr>
		<tr>
			<td align="center" height="14">
			
			</td>
		</tr>
		<tr>
			<td align="center" height="260" style="font-family: Arial Black; font-size: 10pt; color:#666699"">
			
             <%search%>
			
			</td>
		</tr>
		<tr>
			<td align="center" height="156" background="image/buttom1.jpg">
			 </td>
		</tr>
		<tr>
			<td align="center" bgcolor="#f3f2ef" style="font-size: 8" width="100%" height="8">
			 </td>
		</tr>
		</table>
		
</div>

</body>

</html>


</body>

</html>

⌨️ 快捷键说明

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