ASP一个网页处理所有问题(添加,修改,删除,列表)框架

ASP编程 专栏收录该内容
10 篇文章 0 订阅

<!--#include file="conn.asp"-->
<%'本页配置
lanmusort="链接"

%>
<link href="css/style.css" rel="stylesheet" type="text/css">
<%
 ID=int(request("ID"))
 action=request("action")


 select case action
  Case "edit"
   call edit()
  Case "add"
   call add()
  Case "editok"
   call editok()
   call list()
  Case "addok"
   call addok()
   call list()
  Case "delok"
   call delok()
   call list()
  Case "list"
   call list()
  Case else
   call list()
 end select

%>
<%sub list()%>
<table class="Border" width="98%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
  <tr class="title">
    <td colspan="7"><%=lanmusort%>管理</td>
  </tr>
    <tr class="tr">
      <td colspan="6" align="center" nowrap="nowrap" ><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="17%"><input type="submit" name="Submit" value="添加<%=lanmusort%>" οnclick="window.location.href='?action=add'" /></td>
          <td width="52%">&nbsp;</td>
          <td width="31%"> <select name="SortID" onChange="if(this.options[this.selectedIndex].value!=''){location=this.options[this.selectedIndex].value;}" >
<option value="?sortid=''" >全部<%=lanmusort%></option>
<%
Set rsselect=Server.Createobject("Adodb.Recordset")
sql="select * from  LinkSort order by SortID"
rsselect.open sql,conn,1,1
for i=1 to rsselect.recordcount
if rsselect.eof then exit for
%>
<option value="?sortid=<%=rsselect("sortid")%>" <%if saferequest("sortid")<>"" then : if int(request("sortid"))=rsselect("sortid") then response.write " selected" end if%>><%=rsselect("txtSort")%></option>
<%
rsselect.movenext
next
%>
</select></td>
        </tr>
      </table></td>
    </tr>
    <tr class="tr">
      <td width="5%" align="center" nowrap="nowrap" >排序</td>
      <td width="13%" align="center" nowrap="nowrap" ><%=lanmusort%>名称</td>
      <td width="13%" align="center" nowrap="nowrap" ><%=lanmusort%>地址</td>
      <td width="54%" align="center" nowrap="nowrap" ><%=lanmusort%>图片</td>
      <td width="54%" align="center" nowrap="nowrap" ><%=lanmusort%>位置</td>
      <td width="9%" align="center" nowrap="nowrap" >操作</td>
    </tr>
<%
 set rs=server.CreateObject("adodb.recordset")
 sql="select * from Links as a,LinkSort as b where a.SortID=b.SortID "
 if SafeRequest("SortID")<>"" then sql=sql&" and  a.SortID="&SafeRequest("SortID")
 
 if SafeRequest("SortID")<>""  then
 sql=sql&" order by OrderID"
 else
 sql=sql&" order by a.id desc"
 end if
 
 rs.Open sql,conn,1,1
 for i=1 to rs.recordcount
 if rs.eof then exit for
%>
<form action="?action=edit" method="post">
<tr class="tr">
      <td align="center" nowrap="nowrap" ><input name="ID" type="hidden" value="<%=rs("a.ID")%>" /><%=rs("OrderID")%></td>
      <td align="center" nowrap="nowrap" ><%=rs("txtTitle")%></td>
      <td align="center" nowrap="nowrap" ><%=rs("Url")%></td>
      <td align="center" nowrap="nowrap" ><%=rs("Pic")%></td>
      <td align="center" nowrap="nowrap" ><%=rs("txtSort")%></td>
      <td align="center" nowrap="nowrap" ><input type="submit" name="Submit4" value="修改" />
      <input type="button" name="Submit5" value="删除" οnclick="if (confirm('您确定要删除嘛?')){window.location.href='?action=delok&id=& lt;%=rs("a.id")%>';}" /></td>
</tr></form>
<%
 rs.movenext
 next
%>
<form action="?action=addok" method="post"></form>
</table>
<%end sub%>

<%sub add()%>
<table class="Border" width="98%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
  <tr  class="title">
    <td colspan="2" align="center">添加<%=lanmusort%></td>
  </tr>
  <form action="?action=addok" method="post" name="form1" id="form1">
    <tr  class="tr">
      <td width="33%" align="center"><%=lanmusort%>名称</td>
      <td width="67%"><input name="txtTitle" type="text" id="txtTitle" size="24"></td>
    </tr>
 <tr  class="tr">
      <td align="center"><%=lanmusort%>地址</td>
      <td><input name="URL" type="text" id="URL" size="24"></td>
    </tr>
 <tr  class="tr">
      <td align="center"><%=lanmusort%>图片</td>
      <td><input name="Pic" type="text" id="Pic" size="24"></td>
    </tr>
 <tr  class="tr">
      <td align="center"><%=lanmusort%>排序</td>
      <td><input name="OrderID" type="text" id="OrderID" value="0" size="4" onKeypress="if (event.keyCode < 45 || event.keyCode > 57){alert('同志只能输入数字,谢谢'); event.returnValue = false;}" ></td>
    </tr>
 <tr  class="tr">
      <td align="center"><%=lanmusort%>位置</td>
      <td> <select name="SortID">
<%
Set rsselect=Server.Createobject("Adodb.Recordset")
sql="select * from  LinkSort order by SortID"
rsselect.open sql,conn,1,1
for i=1 to rsselect.recordcount
if rsselect.eof then exit for
%>
<option value="<%=rsselect("sortid")%>" ><%=rsselect("txtSort")%></option>
<%
rsselect.movenext
next
%>
</select></td>
 </tr>
    <tr  class="tr">
      <td>&nbsp;</td>
      <td><input type="submit" name="Submit3" value="添 加">
        <input type="reset" name="Submit" value="重 置" /></td>
    </tr>
  </form>
</table>
<%end sub%>

<%sub edit()%>
<%
Set rs=Server.Createobject("Adodb.Recordset")
sql="select * from Links  where id="&ID
rs.open sql,conn,1,1
if not rs.eof then

%>
<table class="Border" width="98%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
  <tr  class="title">
    <td colspan="2" align="center">修改<%=lanmusort%></td>
  </tr>
  <form action="?action=editok" method="post" name="form1" id="form1">
    <tr  class="tr">
      <td width="33%" align="center"><%=lanmusort%>名称</td>
      <td width="67%"><input name="txtTitle" type="text" id="txtTitle" value="<%=rs("txtTitle")%>" size="24"></td>
    </tr>
 <tr  class="tr">
      <td align="center"><%=lanmusort%>地址</td>
      <td><input name="URL" type="text" id="URL" value="<%=rs("URL")%>" size="24"></td>
    </tr>
 <tr  class="tr">
      <td align="center"><%=lanmusort%>图片</td>
      <td><input name="Pic" type="text" id="Pic" value="<%=rs("Pic")%>" size="24"></td>
    </tr>
 <tr  class="tr">
      <td align="center"><%=lanmusort%>排序</td>
      <td><input name="OrderID" type="text" id="OrderID" size="4"  value="<%=rs("OrderID")%>" onKeypress="if (event.keyCode < 45 || event.keyCode > 57){alert('同志只能输入数字,谢谢'); event.returnValue = false;}" ></td>
    </tr>
 <tr  class="tr">
      <td align="center"><%=lanmusort%>位置</td>
      <td> <select name="SortID">
<%
Set rsselect=Server.Createobject("Adodb.Recordset")
sql="select * from  LinkSort order by SortID"
rsselect.open sql,conn,1,1
for i=1 to rsselect.recordcount
if rsselect.eof then exit for
%>
<option value="<%=rsselect("sortid")%>" <%if rs("sortid")=rsselect("sortid") then response.write " selected"%>><%=rsselect("txtSort")%></option>
<%
rsselect.movenext
next
%>
</select></td>
 </tr>
    <tr  class="tr">
      <td align="center"><input type="hidden" name="id" value="<%=rs("id")%>" /></td>
      <td><input type="submit" name="Submit3" value="修 改">
        <input type="reset" name="Submit" value="重 置" /></td>
    </tr>
  </form>
</table>
<%end if%>
<%end sub%>
<%sub addok()%>
<%
 set rs=server.CreateObject("adodb.recordset")
 rs.Open "select * from Links",conn,1,3
 rs.addnew
 rs("txtTitle")=request.form("txtTitle")
 rs("SortID")=request.form("SortID")
 rs("URL")=request.form("URL")
 rs("Pic")=request.form("Pic")
 rs("OrderID")=request.form("OrderID")
 rs.Update
 rs.Close
 set rs=nothing
%>
<%end sub%>

<%sub editok()%>
<%
 set rs=server.CreateObject("adodb.recordset")
 rs.Open "select * from Links where ID = "&ID,conn,1,3
 rs("txtTitle")=request.form("txtTitle")
 rs("SortID")=request.form("SortID")
 rs("URL")=request.form("URL")
 rs("Pic")=request.form("Pic")
 rs("OrderID")=request.form("OrderID")
 rs.Update
 rs.Close
 set rs=nothing
%>
<%end sub%>

再来一个不要列表的

<!--#include file="../conn.asp"-->
<!--#include file="../function.asp"-->
<!--#include file="flag.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns="http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title> 日志管理--编辑</title>
<link href="../css.css" rel="stylesheet" type="text/css" />
</head>

<body>
<%
action=request("action")
id=saferequest("id")

select case action
case "add"
 call add()
case "edit"
 call edit()
case "addsave"
 call addsave()
case "edit"
 call editsave()
case "del"
 call del()
case else
 call add()
 
end select

%>

<%sub add%>
<form id="form1" name="form1" method="post" action="?action=addsave">
<p align="center">值班日志添加</p>
<p align="center">&nbsp;</p>
<table width="650" border="1" bordercolor="#CCCCCC" bordercolordark="#FFFFFF" cellspacing="0" cellpadding="0" align="center">
    <tr>
      <td height="20">值班时间</td>
    <td height="20"><input name="rizhitime" type="text" id="rizhitime" size="30" value="<%=Now()%>" /></td>
  </tr>
    <tr>
      <td height="20">值班人</td>
    <td height="20"><input name="username" type="text" id="username" size="30" /></td>
  </tr>
    <tr>
      <td height="20">操作概述</td>
      <td height="20"><textarea name="intro" cols="75" rows="5" id="intro"></textarea></td>
    </tr>
    <tr>
      <td height="20">操作详情</td>
      <td height="20"><input name="content" type="hidden" id="content" size="30" /><iframe ID="eWebEditor1" src="../editor/ewebeditor.asp?id=content&style=standard" frameborder="0" scrolling="no" width="550" HEIGHT="350"></iframe> </td>
    </tr>
    <tr>
      <td height="20">处理结果</td>
      <td height="20"><input name="result" type="text" id="result" value="" size="30" /></td>
    </tr>
    <tr>
      <td colspan="2" align="center"><input type="submit" name="Submit" value="添加" />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="reset" name="Submit2" value="重置" /></td>
    </tr>
</table>
</form>
<%end sub%>

<%sub edit%>
<%
Set rs=Server.Createobject("Adodb.Recordset")
sql="select * from   where  id="&id
rs.open sql,conn,1,1
if not rs.eof then
%>
<form id="form1" name="form1" method="post" action="?action=addsave">
<p align="center">值班日志修改</p>
<p align="center">&nbsp;</p>
<table width="650" border="1" bordercolor="#CCCCCC" bordercolordark="#FFFFFF" cellspacing="0" cellpadding="0" align="center">
    <tr>
      <td height="20">值班时间</td>
    <td height="20"><input name="rizhitime" type="text" id="rizhitime" size="30" value="<%=rs("rizhitime")%>" /></td>
  </tr>
    <tr>
      <td height="20">值班人</td>
    <td height="20"><input name="username" type="text" id="username" size="30"  value="<%=rs("username")%>" /></td>
  </tr>
    <tr>
      <td height="20">操作概述</td>
      <td height="20"><textarea name="intro" cols="75" rows="5" id="intro"><%=rs("intro")%></textarea></td>
    </tr>
    <tr>
      <td height="20">操作详情</td>
      <td height="20"><input name="content" type="hidden" id="content" size="30"  value="<%=server.HTMLEncode(rs("rizhitime"))%>"  /><iframe ID="eWebEditor1" src="../editor/ewebeditor.asp?id=content&style=standard" frameborder="0" scrolling="no" width="550" HEIGHT="350"></iframe> </td>
    </tr>
    <tr>
      <td height="20">处理结果</td>
      <td height="20"><input name="result" type="text" id="result"  value="<%=rs("result")%>"  size="30" /></td>
    </tr>
    <tr>
      <td colspan="2" align="center"><input name="id" type="hidden" value="<%=rs("id")%>" /><input type="submit" name="Submit" value="修改" />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="reset" name="Submit2" value="重置" /></td>
    </tr>
</table>
</form>
<%
Else
errormsg "此记录已经不存在!"
end if
%>
<%end sub%>

<%sub addsave%>
<%
Set rs=Server.Createobject("Adodb.Recordset")
sql="select * from   "
rs.open sql,conn,1,1
rs.addnew
rs("")=saferequest("")
rs.update
rs.close
%>
<%end sub%>

<%sub editsave%>
<%
Set rs=Server.Createobject("Adodb.Recordset")
sql="select * from   where   id="&ID
rs.open sql,conn,1,1
If Not rs.EOF Then
rs("")=saferequest("")
rs.update
Else
errormsg "此记录已经不存在!"
End IF
rs.close
%>
<%end sub%>

<%sub del%>
<%conn.execute ("delete from Links where ID="&ID)%>
<%end sub%>
</body>
</html>

<%sub delok()%>
<%conn.execute ("delete from Links where ID="&ID)%>
<%end sub%>

  • 0
    点赞
  • 0
    评论
  • 1
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值