<%@ Language=VBScript%>
<%
Response.Buffer=false
Response.Expires=0
%>
<!-- #include file="../dsn.asp" -->
<!-- #include file="../links.asp" -->
<%
pageno=Request.QueryString("pageno")
id=Request.QueryString("id")
showok=Request.QueryString ("showok")
mode=Request.QueryString ("mode")
htmlname=linkcontactadmin&"?flag="&flag
'tablename="userinfo"
tabname="contact"
htmltitle="网站留言管理"
set cn=server.CreateObject("ADODB.Connection")
cn.Open mycnstr
set rs=server.CreateObject("ADODB.Recordset")
set rs2=server.CreateObject("ADODB.Recordset")

if id="" then
		id=0
	else
		id=cint(id)
end if
if id<>0 then		
sqltext="select * from contact where id="&id
rs.Open sqltext,cn,1,1
if not rs.EOF then
	title=trim(rs("title"))
	content=trim(rs("body"))
	myname=trim(rs("name"))
	address=trim(rs("add"))
	phone=trim(rs("tel"))	
	fax=trim(rs("fax"))
	corpname=trim(rs("compa"))
	email=trim(rs("email"))
	datedate=rs("creatdate")
	content=trim(rs("body"))
end if
rs.Close
end if
if Request.ServerVariables("REQUEST_METHOD")="POST" and mode="999" then
		if not isempty(request("sel")) then
     		idlist=request("sel")
     		if instr(idlist,",")>0 then
				dim idarr
				idArr=split(idlist)
				for i = 0 to ubound(idarr)
	       			delid=clng(idarr(i))
	       			call setupdate(delid,mode)
				next
			else
				delid=clng(idlist)
				call setupdate(delid,mode)
			end if	
		end if
		delid=0
		Response.Redirect htmlname
end if
  sub setupdate(id,mm)
    if mm="999" then
		sqltext3="delete from "+tabname+" where id="&id
		cn.Execute sqltext3 
	end if	  
  end sub  
%>
<html>
<head>
<title><%=htmltitle%></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
body {font-size: 12px; color: #000000; font-family: 宋体}
td {font-size: 12px; color: #000000; font-family: 宋体;line-height:130%}
.t1 {font:12px 宋体;color=000000} 
.t2 {font:12px 宋体;color:ffffff} 
.t3 {font:12px 宋体;color:336699} 
.t4 {font:12px 宋体;color:ff0000} 
.t4 {font:12px 宋体;color:ff0000} 
.t5 {font:12px 宋体;color:ff6600} 

.bt1 {font:14px 宋体;color=000000} 
.bt2 {font:12px 宋体;color:ffffff} 
.bt3 {font:14px 宋体;color:336699} 
.bt4 {font:14px 宋体;color:ff0000} 
.bt5 {font:14px 宋体;color:0000ff}
.bt10 {font:14px 宋体;color:0000ff}

.td1 {font-size:12px;background-color:#3388bb;color:#ffffff}
.td2 {font-size:12px;background-color:#ffffff;color:#000000;}

A:link {color: #000077}
A:visited {color: #000077}
A:hover {color: #ff0000}

A.title1:link {text-decoration:none;color:#336699;}
A.title1:visited {text-decoration:none;color:#336699;}
A.title1:active {text-decoration:none;color:#336699;}
A.title1:hover {text-decoration:none;color:#336699;}
-->
</style>
</head>
<body topmargin=5>
<table width="100%" align=center height="100%">
	<tr>
	<td valign="top" align="left" width="100%">
		<table width="100%" height="20" border="0">
			<tr>
			<td style="font-size:12px;"></td>
			<td><font class=t5>当前位置：<%=htmltitle%></font></td>
			<td align="right">
			</td>
			</tr>
		</table>
		<table width="100%" height="20" border="0">
		<form action="<%=htmlname%>" method=post name="listform">
			<tr>
		<%
		sqltext="select * from contact order by creatdate desc "
		'Response.Write sqltext
		rs.Open sqltext,cn,1,1
		listcs=5
		rs.PageSize=listcs
		if pageno="" then 
			pageno=1
		else
			pageno=cint(pageno)	
		end if	
		if rs.PageCount>0 then rs.AbsolutePage=pageno
	%>
		<td class=t1 align="left" width=200>
			<a href="Javascript:window.location.reload()">[刷新列表]</a>
			<a href="javascript:delrows()">[删除]</a>
		</td>
		<td  align="right">
		<%if rs.PageCount>1 then%>
			[第<b><%=pageno%></b>页, 共<b><%=rs.PageCount%></b>页<b><%=rs.RecordCount%></b>条记录]		              
			<%if pageno>1 then%>
				<a class=r href="<%=htmlname%>&pageno=1">首页</a>              
				<a class=r href="<%=htmlname%>&pageno=<%=pageno-1%>">上页</a>              
			<%end if              
			if pageno<rs.PageCount then%>              
				<a class=r href="<%=htmlname%>&pageno=<%=pageno+1%>">下页</a>              
				<a class=r href="<%=htmlname%>&pageno=<%=rs.PageCount%>">末页</a>              
			<%end if%>              
		<%end if              
		%>              
		</td>
		</tr>
		</table>
		<table width="100%" border="0" cellspacing="1" cellpadding="1" style="font-size:14.5px;line-height:100%">
				<tr bgcolor="666690" style="color:#ffffff" align="center">
				<td class=bt2></td>
				<%if flag=0 then%>
						<td class=bt2>标题</td><td class=bt2>留言给</td>
						<td class=bt2>姓名</td><td class=bt2>电话</td>
					<%else%>
						<td class=bt2>姓名</td><td class=bt2>性别</td>
						<td class=bt2>中考分数</td><td class=bt2>毕业学校</td>
				<%end if%>	
				<td class=bt2>提交时间</td></tr>
		<%
		i=0
		do while not rs.EOF and i<listcs 
			if (i mod 2)=1 then
				Response.Write("<tr bgcolor=fefefe>")
			else
				Response.Write("<tr bgcolor=efefef>")
			end if	
			if keyno1="" then keyno1=rs("id")
		%>
			<td width="35" align="center"><input type="checkbox" name="sel" value="<%=(rs("id"))%>"></td>
			<td align="left"><a href="<%=htmlname%>&id=<%=rs("id")%>&showok=1"><%=trim(rs(1))%></a></td>
			<%if flag=0 then%>
			<td width="180" align="center"><%=trim(rs("toname"))%></td>
			<td width="100" align="center"><%=trim(rs("name"))%></td>
			<td width="100" align="center"><%=trim(rs("tel"))%></td>
			<%else%>
			<td width="30" align="center"><%=trim(rs("sex"))%></td>
			<td width="50" align="center"><%=trim(rs("fs"))%></td>
			<td align="left"><%=trim(rs("school"))%></td>
			<%end if%>
			<td width="140" align="center"><%=rs("creatdate")%></td>
			</tr>
		<%	
			i=i+1
			rs.MoveNext
		loop
		%>
		</form>
		</table>
		</td></tr>
<%if showok="1" then%>
	<tr><td>	
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
		  <tr align="center" bgcolor=666699>
		    <td height=1></td>
		  </tr>
		  <tr><td>&nbsp;</td></tr>
		</table>
		<table width="100%"> 
		<tr><td height=200  bgcolor="efefef">
	<%if flag=0 then%>	
		<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center" height=100%>
		  <tr><td height="5"></td></tr>
          <tr><td class=t1>标题：&nbsp;<%=title%></td></tr>
		  <tr><td class=t1>时间：&nbsp;<%=datedate%></td></tr>
		  <tr><td class=t1>姓名：&nbsp;<%=myname%></td></tr>
		  <tr><td class=t1>单位：&nbsp;<%=corpname%></td></tr>
		  <tr><td class=t1>电话：&nbsp;<%=phone%></td></tr>
		  <tr><td class=t1>地址：&nbsp;<%=address%></td></tr>
		  <tr><td class=t1>Email：&nbsp;<a href="mailto:<%=email%>" class=td><%=email%></a></td></tr>
		  <tr><td class=t1>传真：&nbsp;<%=fax%></td></tr>
		  <tr><td class=t1>&nbsp;<%=checkstr(content)%></td></tr>
		  <tr><td height="10">&nbsp;</td></tr>
		</table>		
	<%else%>
		<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center" height=100%>
		  <tr><td height="5"></td></tr>
          <tr><td class=t1>姓名：&nbsp;<%=myname%></td></tr>
		  <tr><td class=t1>提交时间：&nbsp;<%=datedate%></td></tr>
		  <tr><td class=t1>性别：&nbsp;<%=sex%></td></tr>
		  <tr><td class=t1>家庭住址：&nbsp;<%=address%></td></tr>
		  <tr><td class=t1>电话：&nbsp;<%=telphone%></td></tr>
		  <tr><td class=t1>毕业学校：&nbsp;<%=school%></td></tr>
		  <tr><td class=t1>中考分数：&nbsp;<%=fs%></td></tr>
		  <tr><td class=t1>&nbsp;<%=checkstr(content)%></td></tr>
		  <tr><td height="10">&nbsp;</td></tr>
		</table>		
	<%end if%>	
		</td></tr>
		</table>
	</td></tr>
<%end if%>		
<table>
</td></tr><table>
</body>
</html>

<script language="Javascript">

    function delrows()
    {
        if (confirm('您确认要删除你所选中的项目吗？')==true)
        {        
        document.listform.action="<%=htmlname%>&mode=999";
        document.listform.submit();
        }
    }

</script>

<%
function checkstr(str)
	dim i,xx1,xx2,ttt
	ttt="&nbsp;&nbsp;&nbsp;&nbsp;"
	xx1=1
	xx2=instr(xx1,str,chr(13))
	do while xx2>0
		ttt=ttt+mid(str,xx1,xx2-xx1)+"<br>&nbsp;&nbsp;&nbsp;&nbsp;"		
		xx1=xx2+1
		xx2=instr(xx1,str,chr(13))
	loop
	ttt=ttt+mid(str,xx1)
	checkstr=ttt
end function	
%>	