<!--#include file="setup.asp"-->
<!--#include file="hunconn.asp"-->
<%
dim total
top
membername=request.cookies("username")
toname=request.form("sBride")
content=request.form("sLoveWord")
guige=request.form("iStandard")
theyear=request.form("wed_b_y")
them=request.form("wed_b_m")
thed=request.form("wed_b_d")
theh=request.form("wed_b_h")
lasttime=request.form("sLastTime")
fumoney=request.form("cPayMethod")
total=guige*100+lasttime*100+400

set rs=server.createobject("adodb.recordset")
rs.open "select * from [user] where username='"&membername&"'",conn,1,3
	yourmoney=rs("savemoney")
	
rs.close

if total>yourmoney then error("<li>很抱歉！你银行里没有那么多存款")

rs.open "select * from [qiuhun] where UserName='"&membername&"' and dlg=true",connj,3,1
if rs.eof then
	rs.close
	error("<li>你还没有向任何人求婚或是没人答应你的求婚")

else
if rs("jiehun") =true then error("<li>你们都已经登记结婚了，怎么还来登记啊？")

	name2=rs("tousername")
	rs.close
	if toname<>name2 then error("<li>你是不是找错人了？")
	connj.execute"update [qiuhun] set jiehun=true where username='"&membername&"' " 
	set rs1=server.createobject("adodb.recordset")
	rs1.open"select * from [jie]",connj,3,3
	rs1.addnew
	rs1("username")=membername
	rs1("thename")=name2
	rs1("long")=lasttime
	rs1("content")=content
	'rs1("year")=theyear&"-"&them&"-"&thed
	rs1("year")=now()
	rs1("type")=guige
	rs1.update
	rs1.close
	total=cint(total)
	
	if fumoney=1 then
		conn.execute("update [user] set savemoney=savemoney-"&total&", consort='"&name2&"' where username='"&membername&"'" )
		rs.Open "select consort from [user] where username='"&name2&"'",Conn,1,3		
		rs("consort")=membername
		rs.update
		rs.close
	
	end if
	if fumoney=2 then 
		
		conn.execute"update [user] set consort='"&name2&"' where username='"&membername&"' " 
		rs.Open "select consort,savemoney from [user] where username='"&name2&"'",Conn,1,3		
		
		rs("savemoney")=rs("savemoney")-total
		rs("consort")=membername
		rs.update
		rs.close
	end if
	if fumoney=3 then
		total=total/2
		conn.execute"update [user] set savemoney=savemoney-"&total&", consort='"&name2&"' where username='"&membername&"' " 
		rs.Open "select consort,savemoney from [user] where username='"&name2&"'",Conn,1,3		
		rs("savemoney")=rs("savemoney")-total
		rs("consort")=membername
		rs.update
		rs.close
	end if
	
	message="<li>祝贺你呵呵，结婚了，请你去邀请你的朋友，记得要准时哦"
	succeed(message&"<meta http-equiv=refresh content=3;url='hunindex.asp'")
end if %>