<!--#include file="../Inc.asp"-->
<!--#include file="../ydzq.asp"-->


<%call head()
Call saycardc("申请离婚")
'检查有几条新留言
dim newguest
newguest = 0
IF myid > 0 THEN
  newguest = ForNewGuest(myid)
END IF
if newguest > 0 then
Response.write "<a href='../msgview.asp?url="&Replace(Replace(R_url(),"sid=","sidoo="),"sid=","sidoo=")&"&amp;saytk="&saytk&"&amp;sid="&sid&"'>您有"&newguest&"条新消息</a><br/>"& chr(13)
end if
    Set objgbrs=Server.CreateObject("ADODB.Recordset")
    sql="select merry from users where id=" & myid
    objgbrs.open sql,conn,1,1
if objgbrs("merry")=0 then
  Call Error("晕哦，你都还没结婚呢！")
  end if
  
  id=Request("ids")
  Action=Request("Action")
  if Action<>"" then
	if id="" or IsNumeric(id)=False then 
	Call Error("ID无效！<br/>")
  end if
   if clng(id)=myid then
   	Call Error("自己和自己离婚？")
  end if
  
    Set rs=Server.CreateObject("ADODB.Recordset")
    sqls="select merry from users where id=" & id
    rs.open sqls,conn,1,1
    if rs.eof then
      Call Error("会员不存在！<br/>")
  end if
       rs.close
   set rs=nothing
   
  set objgbrss=Server.CreateObject("ADODB.Recordset")
  ssql="select * from marry where [userid]=" & myid &" and [about]='J' and [op]=0"
  objgbrss.open ssql,conn,1,2

	if not objgbrss.eof then
  Call Error("已经发送离婚了，请耐心等待！<br/>")
  end if
  
objgbrss.addnew
objgbrss("userid")=MYID
objgbrss("reuserid")=id
objgbrss("about")="L"
objgbrss.update
objgbrss.close
set objgbrss=nothing
set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select * from [guest]",conn,1,2
rs.addnew
rs("sid")=id
rs("fid")=0
rs("fnr")="会员:" & myni& "ID:" & myid & "向你提出离婚，请到婚姻殿堂看看吧。"
rs.update
rs.close
set rs=Nothing
response.write "申请离婚成功!<br/>"

ELSE
dim objgbrr,ssql
  set objgbrs=Server.CreateObject("ADODB.Recordset")
  ssql="select * from marry where [reuserid]=" & myid & " and [about]='L' and [op]=0 order by id desc"
  objgbrs.open ssql,conn,1,1
if not objgbrs.eof then
Call Error("离婚已申请,系统将一个星期后自动解除你们的婚姻关系！")
  end if
  objgbrs.close
set objgbrs=nothing
    Set objgbrs=Server.CreateObject("ADODB.Recordset")
    sql="select merry from users where id=" & myid
    objgbrs.open sql,conn,1,1
if objgbrs("merry")=0 then
  Call Error("晕哦，你都还没结婚呢！")
  end if

    dim username
set rs1=Server.CreateObject("ADODB.Recordset")
  rs1.open"select name from Users where id="&objgbrs("merry"),conn,1,1
  if rs1.eof then
    Call Error("会员不存在！<br/>")
  end if
username=rs1("name")
  rs1.close
  set rs1=nothing
Response.write "你确定要申请离婚吗？<br/>"
Response.write "你当前的配偶:<br/>"
Response.write "配偶ID:"&objgbrs("merry")&"<br/>"
Response.write "配偶昵称:"& username &"<br/>"
Response.write "<anchor>确认离婚"
Response.write "<go href=""marryno.asp?Action=ok&amp;sid="& sid &""" method=""post"" accept-charset=""utf-8"">"
Response.write "<postfield name=""ids"" value="""&objgbrs("merry")&"""/>"
Response.write "</go></anchor>"
objgbrs.close
set objgbrs=nothing
END IF
conn.close
set conn=nothing
response.write "<br/>---------"
response.write "<br/><a href=""index.asp?saytk="&saytk&"&amp;sid="&sid&""">返回婚姻殿堂</a><br/>"
Response.write "<a href=""/bbs/show.asp?saytk="&saytk&"&amp;sid="&sid&""">空间</a>>>"
Response.write "<a href=""/bbs/index.asp?saytk="&saytk&"&amp;sid="&sid&""">社区</a>>>"
Response.write "<a href=""/index.asp?saytk="&saytk&"&amp;sid="&sid&""">首页</a><br/>(c) "&Request.ServerVariables("SERVER_NAME")&"["&String(2-Len(hour(now)),"0") & hour(now) &":"&String(2-len(minute(now)),"0") & minute(now)&"]"

%>

<%
call headsay()
%>
