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

来源:互联网 发布:壳域名仅限局域网使用 编辑:程序博客网 时间:2024/06/05 17:27

<!--#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%>" onclick="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="删除" onclick="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%>

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 泰拉瑞亚地图找不到备份怎么办 服务器没远程管理卡怎么办 tplink上不了网怎么办 键盘端口坏了怎么办 小米路由dns错误怎么办 电脑内存性能低怎么办 nas硬盘坏了怎么办 360安装环境异常怎么办 连接不上服务器怎么办 路由器被绑定mac怎么办 mac地址绑定失败怎么办 触摸屏忘了密码怎么办? 小区高层水压低怎么办 高层楼房水压不够怎么办 热水器温度太高怎么办 热水器出热水小怎么办 天然气热水器水压不够怎么办 热水器水变小了怎么办 液压齿轮泵没力怎么办 gps总是浮点解怎么办 电源要做到稳压怎么办 变压器输出电压低怎么办 变压器输出电压高怎么办 家里空调带不动怎么办 小天才定位不准怎么办 伐木锯链条不出油怎么办 角磨机切割片卸不下来怎么办 油泵电机声音大怎么办 汽车油泵声音大怎么办 水泵电机噪音大怎么办 注塑机油泵超载怎么办 模具老是粘模怎么办 打印机提示卡纸2怎么办 扬子空调显示e9怎么办 供应商不配合售后怎么办? 数控车床显示屏不亮怎么办? 西威变频器过载怎么办 vgm申报错了怎么办 老公常年不回家怎么办 狗对主人龇牙怎么办 酒喝多了会尿床怎么办