<%
db="/data/fy2sc.mdb"'这里修改数据库路径或名称
Set conn = Server.CreateObject("ADODB.Connection")
dbpath="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
conn.Open dbpath

set rs = server.CreateObject("adodb.recordset")
%>
<!--#include file="config.asp"-->
<%
'===================================================
'功能：弹出提示并返回
function wrong(m)
	response.write "<script>alert('"& m &"');history.back();</script>"
	response.End()
end function

'===================================================
'功能：弹出或不弹出提示并跳转
function tiaozhuan(mes,web)
	if mes <> "" then
		response.write "<script>alert('"& mes &"');window.open('"& web &"','_self');</script>"
	else
		response.write "<script>window.open('"& web &"','_self');</script>"
	end if
	response.End()
end function

'===================================================
'功能：将文本框格式转换成HTML格式
function toHTML(ttt)
	if ttt = ""  or isNull(ttt)=true then
		toHTML = ""
	else
		ttt = replace(ttt," ","&nbsp;")
		ttt = replace(ttt,vbcrlf,"<br>")
		toHTML = ttt
	end if
end function

'===================================================
'功能：将HTML格式转换成文本框格式
function toText(ttt)
	if ttt = "" or isNull(ttt)=true then
		toText = ""
	else
		ttt = replace(ttt,"&nbsp;"," ")
		ttt = replace(ttt,"<br>",vbcrlf)
		ttt = replace(ttt,"<br />",vbcrlf)
		toText = ttt
	end if
end function

'===================================================
'功能：输出车辆信息的所有可能配置
'参数:checkBoxName         (检查框的名字)
'     checkBoxLength       (一个配置信息的长度，默认为130px)
function peizhi(checkBoxName,checkBoxLength)
	dim rs123, sql123
	if checkBoxLength = "" or instr(checkBoxLength,"px") = 0 then
		checkBoxLength = "130px"
	end if
	set rs123 = server.CreateObject("adodb.recordset")
	sql123 = "select * from peizhi order by id desc"
	
	rs123.open sql123,conn,1,1
	
	do while not rs123.eof
		response.write "<p style='float:left;width:"& checkBoxLength &";margin:0px;'><input name='"& checkBoxName &"' type='checkbox' value='"& rs123("id") &"'/>"& rs123("pzname") &"</p>"
	rs123.movenext
	loop
	response.write "<p style='clear:both; margin:0;'></p>"
	rs123.close
	set rs123 = nothing
end function

'===================================================
'功能：输出修改时的配置信息
'参数：carSelPZ        (车辆被选中的配置信息ID串)
'      chkName         (checkBox的名字)
'      chkLength       (每一个配置项的长度，默认为130px)
function exportModiPZ(carSelPZ,chkName,chkLength)
	dim rstmp, chkTmp
	carSelPZ = replace(carSelPZ &" "," ","")
	selPzArr = split(carSelPZ,",")
	
	set rstmp = server.CreateObject("adodb.recordset")
	rstmp.open "select * from peizhi",conn,1,1
	
	if carSelPZ = "," then
		do while not rstmp.eof
			response.write "<p style='float:left;margin:0;width:"& chkLength &"'><input name='"& chkName &"' type='checkbox' value='"& rstmp("id") &"' />"& rstmp("pzname") &"</p>"
		rstmp.movenext
		loop
		response.write "<p style='clear:both;margin:0;'></p>"
		rstmp.close
		set rstmp = nothing
	else
		do while not rstmp.eof
			for tmpi = 0 to ubound(selPzArr)
				if rstmp("id") = cint(selPzArr(tmpi)) then
					chkTmp = "checked='checked'"
					exit for
				else
					chkTmp = ""
				end if
			next
			response.write "<p style='float:left;margin:0;width:"& chkLength &"'><input name='"& chkName &"' type='checkbox' value='"& rstmp("id") &"' "& chkTmp &" />"& rstmp("pzname") &"</p>"
		rstmp.movenext
		loop
		response.write "<p style='clear:both;margin:0;'></p>"
		rstmp.close
		set rstmp = nothing
	end if
end function


'============================================
'功能：输出品牌和型号的名字
'示例：call exportpinp(rs("productSort"),"pinpai")
function exportpinp(tt,type1)
	dim tmp, arr

	if tt = "" then
		tmp = ""
	else
		
		arr = split(tt&"",",")
		
		set rs_tmp = server.CreateObject("adodb.recordset")

if type1 = "pinpaiandxinghao" then	
		rs_tmp.open "select * from carSort where id = "&arr(2),conn,1,1
		if not rs_tmp.eof then
			tmp = rs_tmp("sortName")
		else
			tmp = "未知品牌"
		end if
		rs_tmp.close
				
		rs_tmp.open "select * from carSort where id = "&arr(3),conn,1,1
		if not rs_tmp.eof then
			tmp = tmp & rs_tmp("sortName")
		else
			tmp = "未知型号"
		end if
		rs_tmp.close
		
elseif type1 = "pinpai" then
		rs_tmp.open "select * from carSort where id = "&arr(2),conn,1,1
		if not rs_tmp.eof then
			tmp = rs_tmp("sortName")
		else
			tmp = "未知品牌"
		end if
		rs_tmp.close
elseif type1 = "xinghao" then
		rs_tmp.open "select * from carSort where id = "&arr(3),conn,1,1
		if not rs_tmp.eof then
			tmp = rs_tmp("sortName")
		else
			tmp = "未知型号"
		end if 
		rs_tmp.close
end if
				
		set rs_tmp = nothing
		
end if
	exportpinp = tmp
end function

'========================================================
'功能：获得匹配到的品牌ID，在搜索时使用（可能已经没有用到该函数，因为搜索方法已经改变）
'参数：   keys   （传递进来的搜索关键字）
function getIds(keys)
	dim tmp
	tmp = ""
	
	set rs_sort = server.CreateObject("adodb.recordset")
	rs_sort.open "select * from carSort where sortName like '%"& keys &"%'",conn,1,1
	
	do while not rs_sort.eof
	
	tmp = tmp & " or instr(productSort,'"& rs_sort("id") &"') > 0 "
	
	rs_sort.movenext
	loop
	
	rs_sort.close()
	set rs_sort = nothing
	
	tmp = mid(tmp,4,len(tmp))
	
	getIds = tmp
end function

'===============================================================================================
'功能：根据ID串搜索品牌表，未找到任何信息则返回空，否则返回系列型号名称
function getCarSortName(idd)
	dim rs_56, idd_tmp, idd_arr, idd_i
	if idd = "" then
		getCarSortName = ""
		exit function
	end if
	
	idd = replace(idd," ","")
	idd_arr = split(idd,",")
	
	
	set rs_56 = server.CreateObject("adodb.recordset")
	idd_tmp = ""
	
	for idd_i = 0 to ubound(idd_arr)
		rs_56.open "select sortName from carSort where id = "& idd_arr(idd_i) &"",conn,1,1
		if not rs_56.eof and not rs_56.bof then
			idd_tmp = idd_tmp & rs_56("sortName") &"|"
		end if
		rs_56.close
	next
	
	set rs_56 = nothing
	
	getCarSortName = left(idd_tmp,len(idd_tmp)-1)
end function
%>
