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

📄 admin_list.asp

📁 我们的课程设计是一个工资管理系统
💻 ASP
字号:
<!--#include file="conn.asp"-->
<!--#include file="chkuser.asp"-->
<% if not poweruser then
Response.Write("您不是管理员或无此权限,请不要进入管理中心,3秒后系统将自动返回。")
Response.write("<meta HTTP-EQUIV=REFRESH CONTENT='4; URL=admin.asp'>")
Response.end()
end if %>


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新闻管理</title>
<link href="main.css" rel="stylesheet" type="text/css">
</head>

<body>
<% call main() %>
</body>
</html>
<%sub main()%>
<table cellpadding=0 cellspacing=0 border=0 width=450  align=center>
  <tr>
    <td>
      <table cellpadding=3 cellspacing=1 border=0 width=100%>
        <tr >
        <td><font color="#000000">欢迎<b>您</b>进入管理页面</font>
        </td>
        </tr>
            <tr bgcolor="#e0e0e0">
          <td width="100%" valign=top><font color="#000000">
<%
	if request("action") = "del" then 
		call del()
	elseif request("action")="edit" then
		call edit()
	elseif request("action")="savedit" then
		call savedit()
	elseif request("action")="add" then
		call add()
	elseif request("action")="save" then
		call save()
	else
		call list()
	end if
%>
	</td>
  </tr>
</table>
        </td>
    </tr>
</table>
<%end sub%>
<% sub del()
sql = " delete from news where id="&request("id")
conn.execute(sql)
Response.Write("删除成功,2秒后系统将自动返回。")
Response.write("<meta HTTP-EQUIV=REFRESH CONTENT='2; URL=admin_list.asp'>") 
end sub%>
<% sub edit()
sql = "select * from news where id="&request("id")
set rs= Server.CreateObject("adodb.recordset")
rs.open sql,conn,0,1
%>
<table width="450" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td><form name="main" method="post" action="admin_list.asp?action=savedit">
        <table width="450" border="0" cellspacing="0" cellpadding="0">
		<tr>
		<td>
		<select name="newstype">
			<% 
			dim sql1,rs1
			sql1 = "select * from type"
			set rs1 = Server.CreateObject("adodb.recordset")
			rs1.open sql1,conn,0,1
			do while not rs1.eof %>
			<option value="<% =rs1("id") %>" <% if rs("type")=rs1("id") then %>selected<% end if %>><%= rs1("type") %></option>
			<% rs1.movenext
			loop
			rs1.close
			set rs1 = nothing %>
			</select>
		</td>
		</tr>
          <tr>
            <td height="25" align="center" valign="top"><input name="id" type="hidden" value="<%=rs("id")%>"> 
              新闻标题<input name="topic" type="text" id="topic" size="50" maxlength="50" value="<%= rs("topic") %>">
            </td>
          </tr>
          <tr>
            <td align="center">
新闻内容<textarea name="content" cols="48" rows="15" id="content"><%= rs("content") %></textarea></td>
          </tr>
          <tr>
            <td height="25" align="center"> 
              <input type="submit" name="Submit" value="提交">
              &nbsp;&nbsp; 
              <input name="reset" type="reset" id="reset" value="重置">
            </td>
          </tr>
        </table>
      </form></td>
  </tr>
</table>
<% rs.close
set rs = nothing
end sub %>
<% sub savedit() 
sql = " select * from news where id="&request.form("id")
set rs = Server.CreateObject("adodb.recordset")
rs.open sql,conn,3,3
if rs.eof and rs.bof then
Response.Write("参数错误,2秒后系统自动返回。")
Response.write("<meta HTTP-EQUIV=REFRESH CONTENT='2; URL=admin_list.asp'>")
else
rs("topic")=Trim(Request.Form("topic"))
rs("content")=Trim(Request.Form("content"))
rs("datetime")=now()
rs("type")=Trim(Request.Form("newstype"))
rs.update
rs.close
set rs = nothing
Response.Write("更新成功,2秒后系统自动返回。")
Response.write("<meta HTTP-EQUIV=REFRESH CONTENT='2; URL=admin_list.asp'>")
end if
end sub
%>
<% sub list()%>            
<table width="100%" border="0" cellspacing="3" cellpadding="0">
  <tr> 
    <td>
	<a href="admin_list.asp?action=add">添加新闻</a>
    </td>
  </tr>
  <tr> 
    <td><font color="#000000" size="2">注意事项: <br>
      在下面,您将看到目前所有的新闻。您可以编辑或删除目前存在的新闻。</font> 
    </td>
  </tr>
</table>
<%
dim pgsz,total,pageno,ScrollAction
dim pagebegin,pagend,position,rowcount
PgSz=5
dim totalPut   
dim CurrentPage, TotalPages
	if not isempty(request("page")) then
      		currentPage=cint(request("page"))
   	else
      		currentPage=1
   	end if	
	set rs= server.createobject ("adodb.recordset")
	sql = " select * from news order by id"
	rs.open sql,conn,1,3
	if rs.eof and rs.bof then
	Response.Write("目前数据库为空。")
	else
	RS.PageSize = Cint(PgSz)
Total=INT(RS.recordcount / PgSz * -1)*-1 ''计算可显示页面的总数
PageNo=Request("pageno")
if PageNo="" Then
PageNo=1
else
PageNo=PageNo+1
PageNo=PageNo-1
end if
ScrollAction=Request("ScrollAction")
if ScrollAction="上一页" Then
PageNo=PageNo-1
end if 
if ScrollAction="下一页" Then
PageNo=PageNo+1
end if
if PageNo<1 Then 
PageNo=1
end if
RS.AbsolutePage=PageNo
position=RS.PageSize*PageNo
pagebegin=position-RS.PageSize+1
if position < RS.RecordCount then
pagend=position
else 
pagend= RS.RecordCount
end if 
Response.Write "<font color=ffffff>共有["&RS.RecordCount&"]篇文章,显示["&pagebegin&"-"&pagend&"]篇</font>"
RowCount = RS.PageSize
Do While Not RS.EOF and rowcount > 0     
%>
<hr width=60% align=left color=black height=1>
            
<table width="100%" border="0" cellspacing="3" cellpadding="0">
  <tr> 
    <td height="20"><font size="2">序号:<b><font color=red><%=rs("id")%></font></b></font></td>
  </tr>
  <tr> 
    <td height="20"><font color="#000000" size="2">名称:<%=rs("topic")%></font></td>
  </tr>
  <tr align="left" valign="bottom"> 
    <td height="20"><font color="#000000" size="2"><a href="admin_list.asp?action=edit&id=<%=rs("id")%>">编辑</a> 
      | <a href="admin_list.asp?action=del&id=<%=rs("id")%>">删除</a></font></td>
  </tr>
</table>
<%
RowCount =RowCount -1
RS.MoveNext
Loop
rs.close
set rs=nothing
%>
<form method="post" action="admin_list.asp">
<input type="HIDDEN" name="pageno" value="<%=PageNo %>">
  <% 
if PageNo > 1 Then 
response.write "<input type=submit name=ScrollAction value=上一页 style=background-color:e0e0e0;color:000000;border: 1 double>"
end if 
if RowCount = 0 and PageNo <>Total then 
response.write "<input type=submit name=ScrollAction value=下一页 style=background-color:e0e0e0;color:000000;border: 1 double>"
end if 
%>
</FORM>
<%
end if
end sub%>
<% sub add() 
sql = " select * from type "
set rs = Server.CreateObject("adodb.recordset")
rs.open sql,conn,0,1%>
<table width="450" border="0" cellspacing="0" cellpadding="0">

  <tr> 
    <td><form name="main" method="post" action="admin_list.asp?action=save">
        <table width="450" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td align="center">
            <select name="newstype">
			<% do while not rs.eof %>
			<option value="<% =rs("id") %>"><%= rs("type") %></option>
			<% rs.movenext
			loop
			rs.close
			set rs = nothing %>
			</select>

            </td>
		  </tr>
		  <tr>
            <td height="25" align="center" valign="middle"> 
              新闻标题<input name="topic" type="text" id="topic" size="50" maxlength="50">
            </td>
          </tr>
          <tr>
            <td align="center" valign="middle">新闻内容
<textarea name="content" cols="48" rows="15" id="content"></textarea></td>
          </tr>
          <tr>
            <td height="25" align="center"> 
              <input type="submit" name="Submit" value="提交">
              &nbsp;&nbsp; 
              <input name="reset" type="reset" id="reset" value="重置">
            </td>
          </tr>
        </table>
      </form></td>
  </tr>
</table>
<% end sub %>
<% sub save() 
   sql = " insert into news (topic,content,hits,type) values ('"&request("topic")&"','"&request("content")&"',0,"&request("newstype")&") "
   conn.execute(sql)
   Response.Write("添加成功,2秒后系统自动返回。")
   Response.write("<meta HTTP-EQUIV=REFRESH CONTENT='2; URL=admin_list.asp'>")
   end sub%>

⌨️ 快捷键说明

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