⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 manage_sort.asp

📁 还是同学录 功能较为的简单点 挺好用的
💻 ASP
字号:
<!--#include file="conn.asp"-->
<!--#include file="error.asp"-->
<%
  if member="" then
      founderr=true
      errinfo="<li>你还没有登陆,请先 <a href='login.asp'>登陆</a><br>"
  end if
%>
<title><%=sitename%>-分类管理</title>
<%
  if founderr=true then
      call errweb()
  else
%>
<table border="1" align="center" width="<%=width%>">
  <tr>
    <td width="20%" height="182" valign="top" align="center"><%call left()%></td>
    <td width="80%" height="182" valign="top" align="center">
<%
      select case request("action")
      case "saveadd"
          call saveadd()
      case "edit"
          call edit()
      case "saveedit"
          call saveedit()
      case "move"
          call move()
      case "moving"
          call moving()
      case "del"
          call del()
      case "tidy"
          call tidy()
      case else
          call list()
      end select
%>
    </td>
  </tr>
</table>
<%
  end if
  
  sub list()
%>
<table border="1" width="100%" height="400" align="center">
  <tr>
    <td width="100%" height="400" valign="top">
    <table border="1" width="100%">
      <tr>
        <td width="15%" align="center" height="20">ID</td>
        <td width="30%" align="center" height="20">分类名</td>
        <td width="15%" align="center" height="20">联系人</td>
        <td width="40%" align="center" height="20">编辑</td>
      </tr>
<%
      set rs=conn.execute("select * from address_class where user='"&member&"'")
      if rs.eof and rs.bof then
          response.write"<tr><td width='100%' align='center' height='80' colspan='5'>暂时没有分类,请先添加分类</td></tr>"
      else
          do while not rs.eof
%>
      <tr>
        <td width="15%" align="center" height="20"><%=rs("id")%></td>
        <td width="30%" align="center" height="20"><%=rs("classname")%></td>
        <td width="15%" align="center" height="20"><%=rs("classtotal")%></td>
        <td width="40%" align="center" height="20"><a href="?action=edit&id=<%=rs("id")%>">改名</a> <a href="?action=move&id=<%=rs("id")%>">移动</a> <a href="?action=del&id=<%=rs("id")%>">删除</a></td>
      </tr>
<%
              rs.movenext
          loop
      end if
      set rs=nothing
%>
      <tr>
        <td width="15%" align="center" height="20"></td>
        <td width="30%" align="center" height="20"></td>
        <td width="15%" align="center" height="20"></td>
        <td width="40%" align="center" height="20"></td>
      </tr>
    </table>

    <table border="1" width="100%">
      <tr>
        <td width="100%" height="20">添加分类</td>
      </tr>
      <form method="POST" action="?action=saveadd">
      <tr>
        <td width="100%" align="center" height="80">分类名: <input type="text" name="classname" size="20"> <input type="submit" value="添 加" name="B1"> <input type="button" value="返 回" name="B1" onclick="javascript:history.go(-1)"></td>
      </tr>
      </form>
    </table>
    <table border="1" width="100%">
      <tr>
        <td width="100%" height="20">分类联系人整理</td>
      </tr>
      <tr>
        <td width="100%" align="center" height="80">重新计算各分类下的联系人总数
          <p><input type="button" value="整 理" name="B1" onclick=location.href="?action=tidy"></p>
        </td>
      </tr>
    </table>
    </td>
  </tr>
</table>
<%
  end sub
  
  sub edit()
      set rs=conn.execute("select classname from address_class where id="&request("id")&"")
%>
<form method="POST" action="?action=saveedit&id=<%=request("id")%>">
<table border="1"  width="100%" align="center">
  <tr>
    <td width="100%" height="20" colspan="2">更改分类名 [<%=rs("classname")%>]</td>
  </tr>
  <tr>
    <td width="50%" align="right" height="20">分类名&nbsp;</td>
    <td width="50%" height="20">&nbsp;<input type="text" name="classname" size="20"></td>
  </tr>
  <tr>
    <td width="100%" height="80" colspan="2" align="center"><input type="submit" value="更 新" name="B1">&nbsp;&nbsp;&nbsp; 
      <input type="reset" value="重 写" name="B2">&nbsp;&nbsp;&nbsp; <input type="button" value="返 回" name="B1" onclick="javascript:history.go(-1)"></td> 
  </tr>
</table>
</form>
<%
      set rs=nothing
  end sub
  
  sub move()
      set rs=conn.execute("select classname from address_class where id="&request("id")&"")
%>
<form method="POST" action="?action=moving&id=<%=request("id")%>">
<table border="1"  width="100%" align="center">
  <tr>
    <td width="100%" height="20" colspan="2">分类名 [<%=rs("classname")%>] <input type="hidden" name="classname" size="10" value="<%=rs("classname")%>"></td> 
  </tr>
  <tr>
    <td width="50%" align="right" height="20">移动该分类到&nbsp;</td>
    <td width="50%" height="20">&nbsp;<select size="1" name="class_id">
<%
  'set rs=nothing
  set rs=conn.execute("select id,classname from address_class where user='"&member&"'")
  do while not rs.eof
      response.write"<option value='"&rs("id")&"'>"&rs("classname")&"</option>"
      rs.movenext
  loop
  set rs=nothing
%>
      </select></td>
  </tr>
  <tr>
    <td width="100%" height="80" colspan="2" align="center"><input type="submit" value="移 动" name="B1">&nbsp;&nbsp;&nbsp; 
      <input type="button" value="返 回" name="B1" onclick="javascript:history.go(-1)"></td>  
  </tr>
</table>
</form>
<%

  end sub

  sub saveadd()
      set rs=conn.execute("select count(id) from address_class where user='"&member&"'")
      if rs(0)>=10 then
          errinfo="<li>你的分类已经达到最大数10个,无法添加新分类<br>"
          call errweb()
      else
          dim classname
          classname=trim(request.form("classname"))
          if classname="" then
              founderr=true
              errinfo="<li>分类名不能为空<br>"
          elseif len(classname)>10 then
              founderr=true
              errinfo="<li>分类名只能在10个字符以内<br>"
          end if
          if founderr then
              call errweb()
          else
              conn.execute("insert into address_class(user,classname,classtotal) values('"&member&"','"&classname&"',0)")
              success="<li>你成功地添加了一个分类——“"&classname&"”<br><li><a href='?'>返回分类管理</a><br><li><a href='main.asp'>返回"&sitename&"</a><br>"
              call successweb()
          end if
      end if
      set rs=nothing
  end sub
  
  sub del()
      dim id
      id=request("id")
      if request("deling")="now" then
          conn.execute("delete * from address_list where class_id="&id&" and user='"&member&"'")
          conn.execute("delete * from address_class where id="&id&" and user='"&member&"'")
          success="<li>你已经删除了一个分类及该分类下的联系人<br><li><a href='?'>返回分类管理</a><br><li><a href='main.asp'>返回"&sitename&"</a><br>"
          call successweb()
      else
          set rs=conn.execute("select id from address_list where class_id="&id&"")
          if not (rs.eof and rs.bof) then
              errinfo="<li>该分类联系人数不为零,无法直接删除,请选择以下操作<br><li><a href='?action=move&id="&id&"'>移动该分类的联系人到其他分类</a><br><li><a href='?action=del&deling=now&id="&id&"'>直接删除该分类及该分类下的联系人</a><br>"
              call errweb()
          else
              conn.execute("delete * from address_class where id="&id&" and user='"&member&"'")
              success="<li>你已经删除了一个分类<br><li><a href='?'>返回分类管理</a><br><li><a href='main.asp'>返回"&sitename&"</a><br>"
              call successweb()
          end if
          set rs=nothing
      end if
  end sub
  
  sub saveedit()
      dim classname
      classname=request.form("classname")
      if classname="" or len(classname)>10 then
          errinfo="<li>分类名不能为空,且在10个字符以内<br>"
          call errweb()
      else
          conn.execute("update address_class set classname='"&classname&"' where id="&request("id")&" and user='"&member&"'")
          success="<li>你已经更新了一个分类名<br><li><a href='?'>返回分类管理</a><br><li><a href='main.asp'>返回"&sitename&"</a><br>"
          call successweb()
      end if
  end sub
  
  sub moving()
      dim id,class_id
      id=request("id")
      class_id=request.form("class_id")
      if id="" then
          founderr=true
          errinfo="<li>请选择需要移动的分类<br>"
      end if
      if class_id="" then
          founderr=true
          errinfo=errinfo&"<li>请选择移动到哪个分类<br>"
      end if
      if id=class_id then
          founderr=true
          errinfo=errinfo&"<li>不能在同一个分类内移动<br>"
      end if
      
      if founderr then
          call errweb()
      else
          '将原来联系人的分类ID改为新分类的ID
          conn.execute("update address_list set class_id="&class_id&" where class_id="&id&" and user='"&member&"'")
          '将原分类的通讯总数置0
          conn.execute("update address_class set classtotal=0 where id="&id&" and user='"&member&"'")
          '对新分类的联系人进行统计,并更新该分类联系人总数
          set rs=conn.execute("select count(id) from address_list where class_id="&class_id&" and user='"&member&"'")
          conn.execute("update address_class set classtotal="&rs(0)&" where id="&class_id&" and user='"&member&"'")
          set rs=nothing
          success="<li>将分类 "&request.form("classname")&" 下的所有联系人移到了其他分类<br><li><a href='?'>返回分类管理</a><br><li><a href='main.asp'>返回"&sitename&"</a><br>"
          call successweb()
      end if
  end sub
  
  sub tidy()
      dim rs_list,i
      i=0
      set rs=conn.execute("select id from address_class where user='"&member&"'")
      do while not rs.eof
          i=i+1
          set rs_list=conn.execute("select count(id) from address_list where class_id="&rs("id")&" and user='"&member&"'")
          conn.execute("update address_class set classtotal="&rs_list(0)&" where id="&rs("id")&"")
          set rs_list=nothing
          rs.movenext
      loop
      set rs=nothing
      success="<li>重新对 "&i&" 个分类的联系人数作了统计<br><li><a href='?'>返回分类管理</a><br><li><a href='main.asp'>返回"&sitename&"</a><br>"
      call successweb()
  end sub

  conn.close
  set conn=nothing
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -