<!--#include file="include/top.asp"-->
<HTMl>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<TITLE>通讯录首页</TITLE>
<LINK rel="stylesheet" href="include/css.css"  type="text/css">
</HEAD>
<BODY>
<CENTER>
<A href="addMessage.asp">添加联系人</A>&nbsp;|&nbsp;
<A href="editClass.asp">分类管理</A>
</CENTER>
<TABLE width="760" border="1" align="center" bordercolor="#000000">
  <TR class="tr" align="center"> 
    <TD>编号</TD>
    <TD>通讯人姓名</TD>
    <TD>性别</TD>
    <TD>分类</TD>
    <TD>手机</TD>
    <TD>QQ</TD>
    <TD>操作</TD>
  </TR>
  <%
dim conditionSql
classId=Request("classId")
searchLei=Request("searchLei")
key=Request("key")
If classId<>"" Then
 conditionSql=" And ClassId="&classId&""
End If
If key<>"" Then
 conditionSql=conditionSql & " And " & searchLei & " like '%" & key & "%'"
End If
getConn()
sql="SELECT MessageBook.*,Class.ClassName FROM MessageBook INNER JOIN Class ON MessageBook.ClassId=Class.id where MessageBook.UserName='"&session("userName")&"'"& conditionSql &" ORDER BY Name" 
rs.Open sql,conn,1,1

page = Request("page")
NoI=0    '名次排列数
'------分页
  If PageSize="" Then pageSize=10   '每页显示数量
  If Not(rs.Bof And rs.Eof) Then  '判别数据表中是否为空记录
	recordNum=rs.Recordcount
    rs.Pagesize=PageSize
    pageNum=rs.Pagecount
	If page=Empty Then 
	  curPage=1
	ElseIf Cint(page)<1 Then
	  curPage=1
	ElseIf Cint(Trim(page))>Cint(pageNum) Then
	  curPage=pageNum
	Else 
	  curPage=page
	End If
  Else
	recordNum=0
	pageNum=0
	curPage=0
  End If
  If Not(rs.Bof And rs.Eof) Then
	rs.Move (Cint(curPage)-1)*PageSize,1
	for i=1 to rs.pagesize
      NoI=(curPage-1)*PageSize+i
%>
  <TR class="td"> 
    <TD>&nbsp;<%=NoI%></TD>
    <TD>&nbsp;<%=rs("Name")%></TD>
    <TD>&nbsp;<%=rs("Sex")%></TD>
    <TD>&nbsp;<%=rs("ClassName")%></TD>
    <TD>&nbsp;<%=rs("Mobile")%></TD>
    <TD><%=rs("QQ")%></TD>
    <TD><A href="message.asp?nameId=<%=rs("id")%>">&nbsp;详情</A>
      <A href="editMessage.asp?nameId=<%=rs("id")%>">&nbsp;修改</A>
      <A href="deleteMessage.asp?nameId=<%=rs("id")%>" onclick="">&nbsp;删除</A>
	</TD>
  </TR>
<%
      rs.movenext
      If rs.eof Then exit for
    next
  Else
	response.write "<TR class='td' align='center'><TD colspan=7><FONT color=ff0000>没有联系人！</FONT></TD></TR>"
  End If	
rs.close
set rs=Nothing
%>
  <TR> 
    <TD colspan=7>
      <TABLE align="center"><FORM method=get action="">
	    <TR>
		  <TD>
<%
  If curPage>1 Then
	response.write "<A href=?page=1&classId="&classId&"&searchLei="&searchLei&"&key="&key&">首 页</A> | <A href=?page="&curPage-1&"&classId="&classId&"&searchLei="&searchLei&"&key="&key&">上一页</A> |&nbsp"
  Else
	response.write "首 页 | 上一页 |&nbsp"
  End If
  If Cint(Trim(curPage))<Cint(Trim(pageNum)) Then
	response.write " <A href=?page="&curPage+1&"&classId="&classId&"&searchLei="&searchLei&"&key="&key&">下一页</A> | <A href=?page="&pageNum&"&classId="&classId&"&searchLei="&searchLei&"&key="&key&">尾 页</A> "
  Else
	response.write " 下一页 | 尾 页 "
  End If
  response.write " &nbsp; &nbsp; 转到第<INPUT type='text' name='page' size=2 maxlength=10 value="&curPage&">"
  response.write " /"&pageNum&"页"
  response.write "<INPUT type='hidden' name='classId' value='"&classId&"'>"
  response.write "<INPUT type='hidden' name='searchLei' value='"&searchLei&"'>"
  response.write "<INPUT type='hidden' name='key' value='"&key&"'>"
  response.write "<INPUT type='submit' value='GO'>"
%>
            &nbsp;共&nbsp;<%=recordNum%>&nbsp;条记录&nbsp; 
		  </TD>
		</TR></FORM>
	  </TABLE>
    </TD>
  </TR>
</TABLE>
<p>
<TABLE width="760" border="1" align="center" bordercolor="#000000">
  <TR> 
    <TD class="tr" width="70" align="right">分类查询：</TD>
    <TD class="td">&nbsp;
    <%classNum=0
    Set classRs=Server.CreateObject("ADoDB.Recordset")
    sql="select * from Class where UserName='"&session("userName")&"'"
    classRs.Open sql,conn,1,1
    If classRs.eof And classRs.bof Then
      response.write "<div align=center><FONT color=ff0000>您还没有创建类别！</FONT></div><br>" 
    Else
      Do While Not classRs.eof
      classNum=classNum+1
    %>
      <IMG src="images/sort.gIf" width="12" height="12"><A href="index.asp?classId=<%=ClassRs("id")%>"><%=ClassRs("ClassName")%>&nbsp;&nbsp;&nbsp;&nbsp;</A>   
      <%If classNum=6 Then
		  Response.Write("<br>&nbsp;")
		  classNum=0
	    End If
	    classRs.movenext
      loop
    End If
    classRs.close
    set rs=Nothing
    set conn=Nothing%>
    </TD>
  </TR>
  <TR><FORM method=get action=""> 
    <TD class="tr" align="right">搜索：</TD>
    <TD class="td">&nbsp;&nbsp;按照：
      <SELECT name="searchLei">
        <OPTION value="Name" <%If searchLei="Name" Then Response.Write("selected")%>>姓名</OPTION>
        <OPTION value="Mobile" <%If searchLei="Mobile" Then Response.Write("selected")%>>手机</OPTION>
        <OPTION value="P_Telephone" <%If searchLei="P_Telephone" Then Response.Write("selected")%>>小灵通</OPTION>
        <OPTION value="QQ" <%If searchLei="QQ" Then Response.Write("selected")%>>QQ</OPTION>
        <OPTION value="HomeAdress" <%If searchLei="HomeAdress" Then Response.Write("selected")%>>住址</OPTION>
        <OPTION value="WorkName" <%If searchLei="WorkName" Then Response.Write("selected")%>>公司</OPTION>
      </SELECT>
      关键字：<INPUT type="text" name="key" value="<%=key%>" size=20>
      <INPUT type="submit" value="搜索">
    </TD></FORM>
  </TR>
</TABLE>
</BODY>
</HTML>
<!--#include file="include/bottom.htm" -->


