<!--#include file="setup.asp"-->
<!--#include file="hunconn.asp"-->

<%
 top
membername=request.cookies("username")
agree=request("agree")
id=request("id") 
set rs=server.createobject("adodb.recordset")
rs.open"select * from qiuhun where toUserName='"&membername&"'",connj,3,1
if rs.bof then 
	rs.close 
	error2("靠边站，这里没你的事儿")
else
	name=rs("username")
	rs.close
	if agree="yes" then
		set rs1 = Server.CreateObject("ADODB.recordset")
		rs1.open"Select * From [qiuhun] where id="&id&" ",connj,3,3
		if rs1("tousername")<>membername then error2("靠边站，这里没你的事儿")
		rs1("dlg")=true
		name=rs1("username")
		rs1.update
		rs1.close
		sql="select * from message"
		rs.Open sql,Conn,1,3
		rs.addnew
		rs("author")=membername
		rs("incept")=name
		rs("content")=membername&"答应了你的求婚,你们商量个好日子然后去结婚登记中心登记吧"
		rs("time")=now
		rs.update
		rs.close
		rs.Open "select * from [user] where username='"&name&"'",Conn,1,3
		rs("newmessage")=rs("newmessage")+1
		rs.update
		rs.close	
		connj.execute("delete from [qiuhun] where (username='"&membername&"' or tousername='"&membername&"') and id<>"&id&"")	
		message="<li>成功，系统已经发信息给"&name&"了，请你们商量好去登记吧"
		succeed(message&"<meta http-equiv=refresh content=8;url='hunindex.asp'")
	else
		set rs1 = Server.CreateObject("ADODB.recordset")
		rs1.open"Select * From [qiuhun] where id="&id&" ",connj,3,3
		if rs1("tousername")<>membername then error2("靠边站，这里没你的事儿")
		if rs1("dlg") then error2("非法操作")
		rs1.close
		connj.execute"delete from [qiuhun]  where id="&id&" " 

		sql="select * from message"
		rs.Open sql,Conn,1,3
		rs.addnew
		rs("author")=membername
		rs("incept")=name
		rs("content")=membername&"拒绝了你的求婚，忘了吧，天涯何处无芳草。"
		rs("time")=now
		rs.update
		rs.close
		rs.Open "select * from [user] where username='"&name&"'",Conn,1,3
		rs("newmessage")=rs("newmessage")+1
		rs.update
		rs.close
		message="<li>成功，系统已经发信息给"&name&"了，多情自古空余恨"
		succeed(message&"<meta http-equiv=refresh content=3;url='hunindex.asp'")
	
	end if
end if %>


