<!--#include file="conn.asp"-->
<%
jdid = request.QueryString("jd")
if jdid = "" then call wrong("参数传递错误！")

if session("userId23") = "" then call tiaozhuan("请先登录系统！","login_2.asp")


'判断是否是这个用户发布的车
	set rs_jd = server.createobject("adodb.recordset")   
	sql_jd = "select userId from product where id=" & jdid
	rs_jd.open sql_jd,conn,1,1
	if rs_jd("userId")<>session("userId23") then 
		response.write "<script>alert('您不是该车的发布者，不能邀请评估团鉴定！');window.close();</script>" 		
		rs_jd.close
		set rs_jd = nothing
		response.End
	end if	


'判断用户帐户的易卡贝贝是否够用
set rs_bb = server.CreateObject("adodb.recordset")
rs_bb.open "select * from userJiFen where userId = "& session("userId23") &" ",conn,1,3

if not rs_bb.eof then
	
	tmp = 0
	tmp = rs_bb("yikabeibei")
	if tmp <= 9 then
		call wrong("对不起，您的易卡贝贝数量不足十枚，无法提交此邀请信息！")
	else
		rs_bb("yikabeibei") = tmp - 10
		rs_bb.update
	end if	
else
	call tiaozhuan("未找到您的积分信息，请重新注册本系统！","reg1.asp")
end if

rs_bb.close
set rs_bb = nothing



'判断是否已经发送过邀请
	set rs_jd = server.createobject("adodb.recordset")    
	sql_jd = "select top 1 * from product where id=" & cint(jdid)
	rs_jd.open sql_jd,conn,1,1
	
	if rs_jd.eof then call wrong("参数传递错误！")
	if rs_jd("ifpg") = "yes" then 
		response.write "<script>alert('您已经邀请过评估团对本车辆进行鉴定！');window.close();</script>"
		rs_jd.close
		set rs_jd = nothing
		response.End
	end if

'如果没有发送邀请则在所有评估师的待评估车辆字段插入id	 
	set rs=server.createobject("adodb.recordset")      
	sql="select * from member where ifpinggushi='1' "
	rs.open sql,conn,1,3
	
	do while not (rs.eof or err)   'nothing为waitpgCarId字段的初值，表示该评估师没有待评估车辆
		if trim(rs("waitpgCarId"))="nothing" then
			rs("waitpgCarId")=jdid
		else
			rs("waitpgCarId")=trim(rs("waitpgCarId")) & "|" & jdid 			
		end if
		rs.update
		rs.moveNext
	loop	
	rs.close
	
'设定已经发送过邀请
	conn.execute("update product set ifpg='yes' where id="& jdid &"")
	response.write "<script>alert('恭喜您，您的鉴定邀请成功，请等待评估团对其评价！');window.close();</script>"
%>