<!--#include file="../head.asp"-->
  <!--#include file="../checkrole.asp"-->
 <%
      call checkuser("sh")
  Response.Buffer = true
  Response.ExpiresAbsolute=now()-1
  Response.Expires=0
  Response.CacheControl="no-cache"
if issession=0 then
username=Replace_Text(request.Cookies("Yxmember"))
else
username=session("user")
end if
if Not ChkPost then 
		response.write "<script language='javascript'>"
		response.write"parent.location.href='"&HOPE_InstallDir&"login/login1.asp';</SCRIPT>"
		response.end
end if
 
%>

<TABLE width=778 border=0 align="center" cellPadding=0 cellSpacing=0>
  <TBODY>
  <TR>
    <TD 
    style="BACKGROUND-POSITION: right 50%; BACKGROUND-IMAGE: url(i../mages/bg1.gif); BACKGROUND-REPEAT: repeat-y; BACKGROUND-COLOR: #ffffff" 
    vAlign=top align=middle>
      <BR>
      <TABLE cellSpacing=0 cellPadding=0 width=100% border=0>
        <TBODY>
        <TR>
              <TD width="15%"><IMG height=32 src="../images/myfriend.gif" 
            border=0></TD>
              <TD width="85%" background="../images/info_bg.gif">&nbsp;</TD>
        </TR></TBODY></TABLE>
<%
user=replace_text(request("user"))
relation=replace_text(request.form("relation"))

sql="select * from Websen_corporation where [user]='"&user&"'"
'response.write sql
Set rs= Server.CreateObject("ADODB.Recordset") 
rs.open sql,conn,1,3
if rs.eof or rs.bof then
response.write"<TABLE width=100% border=0 class=content_border align='center' cellPadding=0 cellSpacing=0>"
response.write"<TR><td Class=C><Br>"
response.write"<ul>"
response.write"<li><FONT color='ff0000'><B> 错误：<b><br>亲爱的会员，您要添加的商业伙伴是："&user&"，但不存在这个会员</font><br>"
response.write"</li>"
response.write"</ul>"
response.write"</TR></td></table>"
else 

if rs("user")=username then
response.write"<TABLE width=100% border=0 class=content_border align='center' cellPadding=0 cellSpacing=0>"
response.write"<TR><td Class=C><Br>"
response.write"<ul>"
response.write"<li><FONT color='ff0000'><B> 错误：<b><br>亲爱的会员，请不要将自已添加为商业伙伴</font><br>"
response.write"</li>"
response.write"</ul>"
response.write"</TR></td></table>"
else

sql2="Select addtime from Websen_memberRelation where [User]='"&username&"' and SecUser='"&rs("user")&"'"
set rs2=conn.execute(sql2)

if not (rs2.eof and rs2.bof) then
response.write"<TABLE width=100% border=0 class=content_border align='center' cellPadding=0 cellSpacing=0>"
response.write"<TR><td Class=C><Br>"
response.write"<ul>"
response.write"<li><FONT color='ff0000'><B> 错误：<b><br>亲爱的会员，您已经添加过该商业伙伴，请不要重复添加！<br>添加时间："&rs2("addtime")&"</font><br>"
response.write"</li>"
response.write"</ul>"
response.write"</TR></td></table>"
else
datets=now()
if relation<>"" then
sql3="Insert into Websen_memberRelation([user],secuser,relation,addtime) values('"&username&"','"&rs("user")&"',"&relation&",'"&datets&"')"
  conn.execute(sql3)
%>
<TABLE class=content_border cellSpacing=0 cellPadding=0 width=100% 
border=0>
        <TBODY>
        <TR>
          <TD align=middle><BR><BR>
            <TABLE cellSpacing=0 cellPadding=0 width="95%" border=0>
              <TBODY>
              <TR>
                <TD class=M>恭喜您！添加商业伙伴成功！</TD></TR></TBODY></TABLE><BR>
            
<%
end if

rs2.close
set rs2=nothing
end if
end if
end if
%>
<br>
<TABLE class=bdr3 cellSpacing=0 cellPadding=0 width=100% 
              border=0>
  <TBODY>
              <TR>
                <TD class=tbg1>现在您可以：</TD></TR>
              <TR>
                <TD class=lh15>
                  <UL>
                    <TABLE cellSpacing=0 cellPadding=9 width="95%" border=0>
                      <TBODY>
                      <TR>
                        <TD class=C>
                          <LI><A 
                          href="addfriend_new.asp">再增加一个商业伙伴</A></LI></TD>
                        <TD class=C>
              <LI><A 
                          href="index.asp">回到“我的商业伙伴”</A></LI></TD></TR></TBODY></TABLE></UL></TD></TR></TBODY></TABLE><BR><BR>
                <A 
            href="../../index.asp">返回<%=webname%>首页</A> </TD>
      </TR></TBODY></TABLE>
<BR>
<BR>
</TABLE>
<%
rs.close
set rs=nothing
conn.close
set conn=nothing
%>