www.gusucode.com > 维六酷博客管理系统 1.1源码程序 > master/friends.asp

    <!--#include file="check.asp"-->
<!-- #include file="../inc/conn.asp" -->
<!-- #include file="../inc/function.asp" -->
<!--#include file="../inc/asppage.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>friends</title>
<link href="css.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
function del(id)
{
	var ok;
	ok=confirm("删除后不可恢复!您确定要删除此相片吗?");
	if (ok==true)
	{
		window.location="friends.asp?action=del&id="+id;
	}
	else
	{}
}
</script>
</head>
<body topmargin="10" background="images/bg1024.gif">
<%
action=RequestSafeStr("action")
Select Case action
	Case "add"
		Call add()
	Case "save"
		Call save()
	Case "edit"
		Call edit()
	Case "editsave"
		Call editSave()
	Case "del"
		Call del()
	Case "top"
		Call top()
	Case else
		Call show()
End Select
%>

<%
Sub save()
	name=RequestFormStr("name")
	sex=RequestFormNum("sex")
	content=RequestFormStr("content")
	Profession=RequestFormStr("Profession")
	area=RequestFormStr("area")
	If Profession="" Then
		Call MessageBox("请上传图片!","")
		Response.End
	End If
	If area="" Then
		Call MessageBox("请上传图片!","")
		Response.End
	End If

	set rs=Server.CreateObject("ADODB.Recordset")
	sql="select * from friends"
	rs.open sql,conn,1,3
	rs.addnew
		rs("name")=name
		rs("sex")=sex
		rs("content")=content
		rs("Profession")=Profession
		rs("area")=area
	rs.update
	rs.close
	Call MessageBox("添加图片成功!","friends.asp")
End Sub

Sub editSave()
	id=RequestFormNum("id")
	If id<>0 then
	name=RequestFormStr("name")
	sex=RequestFormNum("sex")
	content=RequestFormStr("content")
		set rs=Server.CreateObject("ADODB.Recordset")
		sql="select * from friends Where id="& id &""
		rs.open sql,conn,2,3
		If Not rs.eof then
			rs("name")=name
			rs("sex")=sex
			rs("content")=content
		rs.update
		End If
		rs.close
		Call MessageBox("修改图片成功!","friends.asp")
	End If
End Sub
'del
Sub del()
Dim Profession,area
	id=RequestQueryNum("id")
	If id<>0 Then
		Set rs=conn.Execute("Select Profession,area from friends Where id="& id &"")
		Profession="../"& rs("Profession")
		area="../"& rs("area")
		Call delFile(Profession)
		Call delFile(area)
		Set rs=nothing
		conn.Execute("delete From friends Where id="& id &"")
		Call MessageBox("删除成功!","friends.asp")
	End If
End Sub
'top
Sub top()
	id=RequestQueryNum("id")
	intTop=RequestQueryNum("top")
	If id<>0 Then
		conn.Execute("Update friends set [top]="& intTop &",toptime=Now() Where id="& id &"")
		If intTop=1 Then
			strMsg="置顶成功!"
		Else
			strMsg="取消置顶成功!"
		End If
		Call MessageBox(strMsg,"friends.asp")
	End If
End Sub
Sub show()
	sql="Select * From friends Order by id desc"
	Set mypage=new xdownpage   '创建对象
	mypage.getconn=conn    '得到数据库连接
	mypage.getsql=sql
	mypage.pagesize=20    '设置每一页的记录条数据为5条
	set rs=mypage.getrs()    '返回Recordset
%>
	<table width="98%" border="0" class="tableBorder" align=center cellpadding="2" cellspacing="1" bgcolor="#FFFFFF">
		<tr> 
		  <th height="25" colspan="11">交友资料</th>
		</tr>
		<tr>
			<th class=Forumrow width="50">编号</td>
			<th class=Forumrow>相片</td>
			<th class=Forumrow>姓名</td>
			<th class=Forumrow>性别</td>
			<th class=Forumrow>年龄</td>
			<th class=Forumrow>职业</td>
			<th class=Forumrow>地区</td>
			<th class=Forumrow width="50">QQ</td>
			<th class=Forumrow >msn/email</td>
			<th class=Forumrow >tel</td>
			<th class=Forumrow align="center" width="200">操作</td>
		</tr>
		<%
		for i=1 to mypage.pagesize 
			If rs.eof Then
				Exit for
			End If 
			If rs("sex")=1 Then
				sexStr="男"
			Else
				sexStr="女"
			End If
			age=rs("age")
			If age=0 Then
				age=""
			End If
		%>
		<tr> 
		  <td class=Forumrow><%=rs("id")%></td>
		  <td class=Forumrow><%If rs("photo")<>"" then%><a href="../<%=rs("photo")%>" target="_blank"><img src="../<%=rs("photo")%>" border="0" alt="查看大图" width="50" height="50"></a><%End if%></td>
		  <td class=Forumrow align="left"><%=rs("name")%></td>
		  <td class=Forumrow align="left"><%=sexStr%></td>
		  <td class=Forumrow ><%=age%></td>
		  <td class=Forumrow ><%=rs("profession")%></td>
		  <td class=Forumrow ><%=rs("area")%></td>
		  <td class=Forumrow ><%=rs("qq")%></td>
		  <td class=Forumrow ><%=rs("msn")%><br><%=rs("email")%></td>
		  <td class=Forumrow ><%=rs("tel")%></td>
		  <td class=Forumrow align="center" width="200">
			<a href="javascript:del(<%=rs("id")%>)">删除</a></td>
		</tr>

		<%
			rs.MoveNext
		Next
		%>
		<tr align="center"><td colspan="11" class=Forumrow><%mypage.showpage() %></td></tr>
	</table>
	
<%
	
End Sub

Sub add()
%>
<table width="98%" border="0" class="tableBorder" align=center cellpadding="2" cellspacing="1" bgcolor="#FFFFFF">
	<form name="add" method="post" action="friends.asp">
	<input type="hidden" name="action" value="save">
    <tr> 
		<th height="25" colspan="2">上传相片</th>
    </tr>
    <tr> 
      <td height="25" align="right" class=Forumrow>选择上传到分类:</td>
      <td  align="left" class=Forumrow>&nbsp;
      <Select name="sex">
	  <%
	  Set rs=conn.Execute("Select * From friendscategory order by id asc")
	  Do While Not rs.eof
	  %>
		<option value="<%=rs("id")%>"><%=rs("category")%></option>
	  <%
	  rs.MoveNext
	  Loop
	  rs.close
	  Set rs=nothing
	  %>
	  </select></td>
    </tr>
    <tr> 
		<td height="25" align="right" class=Forumrow>上传:</td>
		<td align="left" class=Forumrow style="padding-left:15px;">
			<input name="Profession" type="hidden" size="30" style="width:300">
			<input name="area" type="hidden" size="30" style="width:300">
			<iframe border=0 frameborder=0 framespacing=0 height=22 width="310" marginheight=0 marginwidth=0 name=new_date noresize scrolling=no  src="uploadForm.asp?upFolder=friends&inputName=Profession" vspale="0"></iframe>
				</td>
    </tr>
    <tr> 
		<td width="15%" height="25" align="right" class=Forumrow>姓名:</td>
		<td align="left" class=Forumrow>&nbsp;
			<input name="name" type="text" value="" size="25" style="width:300">&nbsp;</td>
    </tr>
    <tr> 
		<td height="25" align="right" class=Forumrow>相片描述:</td>
		<td align="left" class=Forumrow style="padding-left:15px;">
			<textarea name="content" rows="5" cols="40"></textarea>
			<span id="picsmall"></span>
				</td>
    </tr>

	<tr>
		<td class=Forumrow></td>
		<td height="30" class=Forumrow>&nbsp;
			<input type="submit" name="Submit" value="添加相片" class="input1">
			<input type="reset" name="Submit" class="input1"></td>
	</tr>
  </form>
</table>
<%
End Sub

Sub edit()
	id=RequestQueryNum("id")
	Set rs=conn.Execute("Select * From friends Where id="& id &"")
	If Not rs.eof Then
%>
<table width="98%" border="0" class="tableBorder" align=center cellpadding="2" cellspacing="1" bgcolor="#FFFFFF">
  <form name="add" method="post" action="friends.asp">
  <input type="hidden" name="action" value="editsave">
  <input type="hidden" name="id" value="<%=id%>">
    <tr> 
		<th height="25" colspan="2">修改相片</th>
    </tr>
    <tr> 
      <td height="25" align="right" class=Forumrow>分类:</td>
      <td  align="left" class=Forumrow>&nbsp;
      <Select name="sex">
	  <%
	  Set rsC=conn.Execute("Select * From friendscategory order by id asc")
	  Do While Not rsC.eof
	  %>
		<option value="<%=rsC("id")%>" <%If rs("sex")=rsC("id") Then Response.Write "selected=""true""" End If %>><%=rsC("category")%></option>
	  <%
	  rsC.MoveNext
	  Loop
	  rsC.close
	  Set rsC=nothing
	  %>
	  </select></td>
    </tr>
    <tr> 
		<td width="15%" height="25" align="right" class=Forumrow>姓名:</td>
		<td align="left" class=Forumrow>&nbsp;
			<input name="name" type="text" value="<%=rs("name")%>" size="25" style="width:300">&nbsp;</td>
    </tr>
    <tr> 
		<td height="25" align="right" class=Forumrow>相片描述:</td>
		<td align="left" class=Forumrow style="padding-left:15px;">
			<textarea name="content" rows="5" cols="40"><%=rs("content")%></textarea>
			<span id="picsmall"></span>
				</td>
    </tr>

	<tr>
		<td class=Forumrow></td>
		<td height="30" class=Forumrow>&nbsp;
			<input type="submit" name="Submit" value="修改" class="input1">
			<input type="reset" name="reset" class="input1"></td>
	</tr>
  </form>
</table>
<%
	End If
End Sub
%>
</body>
</html>