<%
'==========================================================
'功能：得到评估价格或评语
'参数：  type2  (返回结果，如果是"jiage"则返回价格，如果是"pingyu"则返回评语)
function getPriceMess(type2,carId,pgsId)
	dim arr_all, tmp

	tmp = exportMess(carId,pgsId)
	
	if tmp = "" then
		getPriceMess = ""
	else
		arr_all = split(tmp,"|")
		
		if ubound(arr_all) <= 0 then
			getPriceMess = ""
			exit function
		end if
		
		if type2 = "jiage" then
			getPriceMess = arr_all(0)
			exit function
		elseif type2 = "pingyu" then
			getPriceMess = arr_all(1)
			exit function
		end if
	end if
end function

'==========================================================
'功能：输入汽车ID号和评估师ID号得到 评估价格和评语
'参数：  carId   (汽车ID号)
'        pgdId   (评估师ID号)
function exportMess(carId,pgsId)
	
	dim rs_tmp, sql_tmp								'记录集变量
	dim tmp, tmp_return								'临时使用变量
	dim tmp_allPgs, tmp_allPrice, tmp_allMess		'三个所有量
	dim arr_pgs, arr_price, arr_mess				'三个所有量的字符数组
	dim ubound_xiabiao								'数组下标位置
	
	set rs_tmp = server.CreateObject("adodb.recordset")
	sql_tmp = "select top 1 * from product where id = "& carId &" "
	rs_tmp.open sql_tmp,conn,1,1
	if not rs_tmp.eof then
		tmp_allPgs   = rs_tmp("pgshiId")
		tmp_allPrice = rs_tmp("pgPrice")
		tmp_allMess  = rs_tmp("pgMes")
		tmp_return   = false
	else
		tmp_allPgs   = ""
		tmp_allPrice = ""
		tmp_allMess  = ""
		tmp_return   = true
	end if
	rs_tmp.close
	set rs_tmp = nothing
	
	if tmp_return = true then
		exportMess = ""
		exit function
	end if	
	
	arr_pgs   = split(tmp_allPgs,"|")
	arr_price = split(tmp_allPrice,"|")
	arr_mess  = split(tmp_allMess,"|")	
		
	ubound_xiabiao = getXiaBiao(tmp_allPgs,pgsId)
	
	if ubound_xiabiao = -1 then
		exportMess = ""
		exit function
	end if
	
	exportMess = arr_price(ubound_xiabiao) & "|" & arr_mess(ubound_xiabiao)
	
end function

'=================
'功能：在字符串中找特定字符，未找到返回false，否则返回下标
'参数：   str1   (字符串)
'         str2   (字串)
function getXiaBiao(str1,str2)
	dim str1_arr, str1_arr_i
	if str1 = "" or isnull(str1) = true then
		getXiaBiao = -1
		exit function
	end if
	if instr(str1,str2) = 0 then
		getXiaBiao = -1
		exit function
	end if
	
	str1_arr = split(str1,"|")
	
	for str1_arr_i = 0 to ubound(str1_arr)
		if cstr(str1_arr(str1_arr_i)) = cstr(str2) then
			getXiaBiao = str1_arr_i
			exit function
		end if
	next
	getXiaBiao = -1
end function


'response.write getPriceMess("pingyu","1154","822")
%>