<!-- #include file="setup.asp" -->
<!--#include file="hunconn.asp"-->
<%
top
if Request.Cookies("username")=empty then error("<li>您还未<a href=login.asp>登录</a>社区")
mmoney=Request("iMoney")
liuyan=HTMLEncode(Request("liuyan"))
idd=HTMLEncode(Request("id"))
lei=HTMLEncode(Request("who"))

set rs1=server.createobject("adodb.recordset") 
sql="select username,thename from jie where id="&idd&" "
rs1.Open sql,Connj,1,3
if rs1.eof and rs1.bof then error("<li>没有这对夫妇！")
hun1=rs1("username")
hun2=rs1("thename")
rs1.close

if hun1=request.cookies("username") or hun2=request.cookies("username") then error("<li>你脑子进水了，自己婚礼也随礼")
sql="select * from [user] where  username='"&request.cookies("username")&"'" 
	rs.Open sql,Conn,1,3
	if rs("money") -mmoney<0 then error("<li>你的现金不够你的随礼钱")
	rs("money")=rs("money")-mmoney
rs.update
rs.close

sql="select renyuan from jie where id="&idd&" "
rs1.Open sql,Connj,1,3
rs1("renyuan")= rs1("renyuan")&Request.Cookies("username")&":"&mmoney&","
rs1.update
rs1.close

if lei=0 then  
mmoney=fix(mmoney/2)
sql="select * from [user] where  username='"&hun1&"'" 
	rs.Open sql,Conn,1,3
	rs("money")=rs("money")+mmoney
	rs("newmessage")=rs("newmessage")+1
rs.update
rs.close
sql="select * from message"
rs.Open sql,Conn,1,3
	rs.addnew
	rs("author")=request.cookies("username")
	rs("incept")=hun1
	rs("time")=now
	rs("content")=request.cookies("username")&"参加了你的婚礼，给新郎新娘红包各“"&mmoney&"”社区币（请查收现金），并祝福到:" &liuyan
rs.update
rs.close
sql="select * from [user] where  username='"&hun2&"'" 
	rs.Open sql,Conn,1,3
	rs("money")=rs("money")+mmoney
	rs("newmessage")=rs("newmessage")+1
rs.update
rs.close
sql="select * from message"
rs.Open sql,Conn,1,3
	rs.addnew
	rs("author")=request.cookies("username")
	rs("incept")=hun2
	rs("time")=now
	rs("content")=request.cookies("username")&"参加了你的婚礼，给两个新人红包各“"&mmoney&"”社区币（请查收现金），并祝福到:" &liuyan
rs.update
rs.close


message="<li>婚礼参加完毕，你把祝福和红包送给了两位新人。"
succeed(message&"<meta http-equiv=refresh content=2;url='default.asp?'")


else 
if lei=1 then
hun=hun1
else
hun=hun2
end if
sql="select * from [user] where  username='"&hun&"'" 
	rs.Open sql,Conn,1,3
	rs("money")=rs("money")+mmoney
	rs("newmessage")=rs("newmessage")+1
rs.update
rs.close
sql="select * from message"
rs.Open sql,Conn,1,3
	rs.addnew
	rs("author")=request.cookies("username")
	rs("incept")=hun
	rs("time")=now
	rs("content")=request.cookies("username")&"参加了你的婚礼，给你红包“"&mmoney&"”社区币（请查收现金），并祝福到:" &liuyan
rs.update
rs.close


message="<li>婚礼参加完毕，你把祝福和红包送给了 "&hun&"。"
succeed(message&"<meta http-equiv=refresh content=2;url='default.asp?'")


end if



%>