<!--#include file="top.asp"--><%usertopview%>
<%if userflag27=0 then
response.redirect"ok.asp?action=flag"
end if

if request("action")="save" then
SMT=request("SMT")
dlxf_name=request("dlxf_name")

set rs=server.createobject("adodb.recordset")
sql="select *  from dlxf_yp where "&SMT&"='"&dlxf_name&"'"
rs.open sql,conn,1,1
if rs.eof then
errstyle="·该企业不存在，请重新查询！"
scripterr
else
dlxf_id=rs("dlxf_id")
end if
rs.close
set rs=nothing
'==========================
set rs1=server.createobject("adodb.recordset")
sql1="select * from dlxf_friend where dlxf_yp_id="&session("id")
rs1.open sql1,conn,1,3
if not rs1.eof then

dlxf_f=split(rs1("dlxf_friend"),",")
for i=0 to ubound(dlxf_f)
if int(dlxf_id)=int(dlxf_f(i)) then
errstyle="·该名片已经存在，不能重复加入！"
scripterr
end if
next

dlxf_friend=rs1("dlxf_friend")&","&dlxf_id
if left(dlxf_friend,1)="," then dlxf_friend=right(dlxf_friend,len(dlxf_friend)-1)
if right(dlxf_friend,1)="," then dlxf_friend=left(dlxf_friend,len(dlxf_friend)-1)
dlxf_friend=replace(dlxf_friend,",,",",")
dlxf_sl=dlxf_friend
for i=0 to 9
dlxf_sl=replace(dlxf_sl,i,"")
next
dlxf_sl=len(dlxf_sl)

if userflag32<>0 then
if dlxf_sl >= cint(userflag32) then
errstyle="·您是"&vipshow&"，只能上传最多 "&userflag32&" 组企业名片！"
scripterr
end if
else
errstyle="·对不起，此功能已对"&vipshow&"关闭！"
scripterr
end if


rs1("dlxf_friend")=dlxf_friend
rs1.update

else

rs1.addnew
rs1("dlxf_yp_id")=session("id")
rs1("dlxf_friend")=dlxf_id
rs1.update
end if

rs1.close
set rs1=nothing
response.redirect"my_friend.asp"
'==========================
elseif request("action")="del" then
id=request("id")

set rs=server.createobject("adodb.recordset")
sql="select * from dlxf_friend where dlxf_yp_id="&session("id")
rs.open sql,conn,1,3
if not rs.eof then
dlxf_friend=rs("dlxf_friend")

dlxf_friend=split(dlxf_friend,",")
for i=0 to ubound(dlxf_friend)
if int(id)<>int(dlxf_friend(i)) then
dlxf_card=dlxf_card&","&dlxf_friend(i)
end if
next

if left(dlxf_card,1)="," then dlxf_card=right(dlxf_card,len(dlxf_card)-1)
if right(dlxf_card,1)="," then dlxf_card=left(dlxf_card,len(dlxf_card)-1)
dlxf_card=replace(dlxf_card,",,",",")

rs("dlxf_friend")=dlxf_card
rs.update

else
errstyle="·对不起，您还没有收藏名片哦！"
scripterr
end if
rs.close
set rs=nothing
response.redirect"my_friend.asp"
end if
%>
<script language="JavaScript">
<!--
function checkdata() {
if( addform.dlxf_name.value =="") {
alert("\操作错误，下面是产生错误的可能原因：\n\n·请输入企业名称或联系人")
return false;
}
return true;
}
// -->
</script>

<table width="760" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">
<tr>
<td width="150" valign=top bgcolor=#efefef>
<!--==============-->
<!--#include file="left.asp"-->
<!--==============-->
</td>
<td width="610" valign=top>
<!--==============-->
<table width="500" border="0" cellspacing="0" cellpadding="0" align="center">
<tr><td height=25>您现在的位置是：我的公文包 > 我的名片薄</td></tr>
  <tr>
    <td>
<!--####################################-->
<table width="100%" border="0" cellspacing="1" cellpadding="0" bgcolor=#6C94D1>
  <tr>
    <td height=25 bgcolor=#6C94D1>　　<font color=white>新增名片</font></td>
  </tr>
  <tr>
    <td bgcolor=#ffffff height=25>
<!--======-->
<table width="100%" border="0" cellspacing="0" cellpadding="0" align=center>
<form name="addform" method="post" action="my_friend.asp?action=save" onSubmit="return checkdata()">
  <tr>
    <td align=center height=30><select name="SMT">
<option value="dlxf_coname">企业名称</option>
<option value="dlxf_colxr">联系人</option>
</select>　<input name="dlxf_name" type="text" size="30" maxlength="50">　<input type="submit" name="Submit" value="添 加" class="input1"></td>
  </tr>
</form>
</table>
<!--======-->
	</td>
  </tr>
</table>
<!--####################################-->
	</td>
  </tr>
  <tr>
    <td height=10></td>
  </tr>
  <tr>
    <td>
<!--####################################-->
<table width="100%" border="0" cellspacing="1" cellpadding="0"bgcolor=#6C94D1>
  <tr>
    <td height=25 bgcolor=#6C94D1 colspan=2 style="border:1px #6c94d1 solid">　　<font color=white>名片管理</font></td>
  </tr>
  <tr>
    <td width="19%" valign=top bgcolor="#ffffff">
<!--======-->
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<%set rs=server.createobject("adodb.recordset")

sql="select * from dlxf_friend where dlxf_yp_id="&session("id")
rs.open sql,conn,1,1
if not rs.eof then
dlxf_friend=rs("dlxf_friend")
else
response.write "<td align=center>还没有收藏企业名片</td>"
end if
rs.close

if dlxf_friend<>"" then
dlxf_friend=split(dlxf_friend,",")
n=0
for i=0 to ubound(dlxf_friend)
n=n+1
sql="select * from dlxf_yp where dlxf_id=" &dlxf_friend(i)
rs.open sql,conn,1,1%>
<td width=45%><a href=<%=application("cityurl")%>card.asp?id=<%=rs("dlxf_id")%> target=_blank><%=rs("dlxf_coname")%></a></td><td width=5% align=center><a href=my_friend.asp?action=del&id=<%=dlxf_friend(i)%>>删</a></td>
<%if n mod 2=0 then response.write "</tr><tr>"
rs.close
next
else
response.write "<td align=center>还没有收藏企业名片</td>"
end if

set rs=nothing%>
</tr>
</table>
<!--======-->
	</td>
  </tr>
</table>
<!--####################################-->
	</td>
  </tr>
</table>
<!--####################################-->
	</td>
  </tr>
</table>
<!--==============-->
</td>
</tr>
</table>
<!--====== bottom ========-->
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" background="img/bottom_bg.gif">
<tr><td height=2 bgcolor=#6C94D1></td></tr>
  <tr>
    <td align="center" height=80><%=citybottom%></td>
  </tr>
</table>
</body>
</html>