asp同一个文件操作数据表,添加、删除、修改、列表、查询

[全站通告] 想快速节省您的时间并可接受付费的朋友,可扫右边二维码加博主微信-非诚勿扰!

asp同一个文件操作数据表,添加、删除、修改、列表、查询

 

<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/Inc_Functions.asp"-->
<!--#include file="../inc/Inc_SystemFun.asp"-->
<!--#include file="../inc/Inc_Common.asp"-->
<!--#include file="Admin_Check.asp"-->
<%
'检测是否有管理标签选项的权限
        If Not ChkFlag("selectcata") Then
                Call WriteSystemLog("标签选项类别管理","权限不够。")
                Call ShowJsMsg("权限不够","history.back();") : Response.End()
        End If
'权限管理没有写完
%>
<!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=utf-8" />
<title>标签选项类别管理</title>
<link href="Images/Manage/Manage.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="Admin_Js.js"></script>
</head>
<body>
<div id="BodyContent"><div id="BodyNav"><div id="PageLoc">当前位置 &gt;&gt; <a href="Admin_SelectValue.asp">标签选项管理</a> &gt;&gt; 标签选项分类管理</div><div id="PageNavBar"><ul>
                                <li><a href="Admin_SelectCata.asp?action=edit">添加分类</a></li>
                                <li><a href="Admin_SelectCata.asp">分类管理</a></li>
                        </ul></div></div>
<div id="BodyWork">
<%
Select Case GetRequest("action","GET",1,0)
        Case "del"
                Call Del()
        Case "edit"
                Call Edit()
        Case "save"
                Call Save()
        Case Else
                Call Main()
End Select
%></div></div>
<%
Sub Del()
        Dim Sql,Rs,ID
        ID = GetRequest("ID","GET",0,0)
        Sql = "select top 1 * from "&Table_Name&"_SelectCata where ID=" & ID
        If IsNull(ID) or Not IsNumeric(ID) Then Sql = ""
        If Sql <> "" Then
                Set Rs = ExecuteSql(Sql)
                If Not Rs.Eof Then
                        If ExecuteSql("select count(*) from "&Table_Name&"_SelectValue where SelectCata="&ID)(0)>0 Then
                                ShowAlertMsg "系统提示","删除失败,存在日志正在使用该分类。","",450
                        Else
                                ExecuteSql "delete from "&Table_Name&"_SelectCata where ID=" & ID
                                ShowAlertMsg "系统提示","删除成功。","",450
                                Call WriteSystemLog("标签选项类别管理","删除成功,ID:"&ID&"。")
                        End IF
                Else
                        ShowAlertMsg "系统提示","删除失败找不到指定的记录。","",450
                End IF
                Rs.Close
                Set Rs = Nothing
        Else
                ShowAlertMsg "系统提示","删除失败找不到指定的记录。","",450
        End If
End Sub

Sub Main()
        Call WriteSystemLog("标签选项类别管理","标签选项类别管理。")
        'display the list
        Dim RsArr,Sql,sPage,sKey,sPageSize,sSearch,sCount,sPageCount,i
        sPageSize = 25
        sPage = CLng(Request.QueryString("page"))
        sKey = Trim(Request("sKey"))
        sSearch = ""
        If sKey <> "" Then
                sSearch = " and Title like '%"&SafeSql(sKey)&"%'"
        End If
        sCount = ExecuteSql("select count(*) from "&Table_Name&"_SelectCata where 1=1 "&sSearch&"")(0)
        sPageCount = Fix(sCount / sPageSize)
        If sCount Mod sPageSize <> 0 Then sPageCount = sPageCount + 1
        If sPage>sPageCount Then sPage = sPageCount
        Sql = "select top "&sPageSize&" ID,Title,SelectType from "&Table_Name&"_SelectCata where 1=1 "&sSearch&" order by id desc"
        If sPage > 1 Then
                Sql = "select top "&sPageSize&" ID,Title,SelectType from "&Table_Name&"_SelectCata where 1=1 "&sSearch&" and id not in(select top "&(sPage-1)*sPageSize&" id from "&Table_Name&"_SelectCata where 1=1 "&sSearch&" order by id desc) order by id desc"
        End If
        RsArr = RsResult(Sql)
            %><div id="CataArea">
<div id="Search"><form action="Admin_SelectCata.asp" name="sch" method="post">标题关键字<input name="skey" id="skey" style="width:80px;" /> <input type="submit" class="Btn_Ok" name="Submit" value="搜索" /></form></div>
<ul><%=GetSelectCataList(CataID)%></ul><div class="clear"></div></div>
<table width="100%" cellpadding="3" cellspacing="1"><tr class="MainTableBg"><td>编号</td><td>名称</td><td>选项类别</td><td>管 理</td></tr><%
        If IsArray(RsArr) Then
            For i = 0 To UBOUND(RsArr,2)
                %><tr class="MainTd"><td><%=RsArr(0,i)%></td><td><%=RsArr(1,i)%></td><td><%if RsArr(2,i)=1 then%>单选<%else%>多选<%end if%></td><td><a href="Admin_SelectCata.asp?ID=<%=RsArr(0,i)%>&action=edit">编辑</a> <a href="Admin_SelectCata.asp?ID=<%=RsArr(0,i)%>&action=del" onClick="return Confirm('是否删除');">删除</a></td></tr>
                <%
            Next
            Erase RsArr
        End If
            %></table><%
        Response.Write "<div id=""Pager""><ul>"
        Response.Write GetPageBar(sPage,sPageCount,"Admin_SelectCata.asp?page={i}&sKey=" & sKey)
        Response.Write "</ul></div>"
End Sub

Sub Save()
        Dim ID,Title,SelectType
        ID = GetRequest("ID","GET",0,0)
        Title = SafeSql(GetRequest("Title","",1,20))
        SelectType = GetRequest("SelectType","GET",0,0)
        If Not IsNumeric(ID) Then ID = 0
        If Title = "" Then ShowAlertMsg "系统错误","分类名称不能为空!","",450:Exit Sub
        Dim Sql,iCount
        Sql = "select count(*) from "&Table_Name&"_SelectCata where Title='"&Title&"' and id<>" & ID
        If ID = 0 Then Sql = "select count(*) from "&Table_Name&"_SelectCata where Title='"&Title&"'"
        iCount = ExecuteSql(Sql)(0)
        If iCount = 0 Then        '可编辑,添加和修改
                Sql = "update "&Table_Name&"_SelectCata set Title='"&Title&"',SelectType="&SelectType&" where ID=" & ID
                If ID = 0 Then Sql = "insert into "&Table_Name&"_SelectCata(Title,SelectType) values('"&Title&"',"&SelectType&")"
                ExecuteSql Sql
                Call WriteSystemLog("标签选项类别管理","添加、编辑标签选项类别,'"&Title&"'。")
        Else
                ShowAlertMsg "系统错误","已经存在该分类!","",450:Exit Sub
        End If
        Response.Redirect "Admin_SelectCata.asp"
End Sub

Sub Edit()
        Dim Sql,Rs,ID
        ID = GetRequest("ID","GET",0,0)
        Call WriteSystemLog("标签选项类别管理","添加、编辑标签选项类别,ID:"&ID&"。")
        Sql = "select top 1 * from "&Table_Name&"_SelectCata where ID=" & ID
        If IsNull(ID) or Not IsNumeric(ID) or ID = 0 Then Sql = ""
        Dim Title,SelectType
        Title = "" : SelectType = 1
        If Not Sql = "" Then
                Set Rs = ExecuteSql(Sql)
                If Not Rs.Eof Then
                        Title = Rs("Title")
                        SelectType = Rs("SelectType")
                Else
                        ID = 0
                End If
                Rs.Close
                Set Rs = Nothing
        Else
                ID = 0
        End If
        %>
<table width="100%" cellpadding="3" cellspacing="1"><form name="AForm" method="post" action="Admin_SelectCata.asp?ID=<%=ID%>&action=save"><tr class="MainTableBg"><td colspan="2">标签选项分类管理</td></tr>
<tr><td class="MainTd2" width="240">分类名称</td><td class="MainTd"><input type="hidden" name="ComeUrl" value="<%=FilterHtml(GetComeURL())%>" /><input type="text" name="Title" value="<%=FilterHtml(Title)%>" /></td></tr>
<tr><td class="MainTd2" width="240">选项类型</td><td class="MainTd"><input type="radio" class="inputCheckBox" name="SelectType" value="1"<%If SelectType=1 Then%> checked="checked"<%End If%> id="IsLock1" /><label for="IsLock1">单选</label> <input type="radio" class="inputCheckBox" name="SelectType" value="0"<%If SelectType=2 Then%> checked="checked"<%End If%> id="IsLock2" /><label for="IsLock2">多选</label></td></tr>
<tr><td class="MainTd2" colspan="2"><input type="submit" class="Btn_Ok" value="提交" name="bt_ok" /> <input type="reset" class="Btn_Cancel" value="取消" name="bt_cancel" /></td></tr></form></table>
        <%
End Sub
%>
</body>
</html>
<%
Call PageBottom()
%>

问题未解决?付费解决问题加Q或微信 2589053300 (即Q号又微信号)右上方扫一扫可加博主微信

所写所说,是心之所感,思之所悟,行之所得;文当无敷衍,落笔求简洁。 以所舍,求所获;有所依,方所成!

支付宝赞助
微信赞助

免责声明,若由于商用引起版权纠纷,一切责任均由使用者承担。

您必须遵守我们的协议,如您下载该资源,行为将被视为对《免责声明》全部内容的认可->联系老梁投诉资源
LaoLiang.Net部分资源来自互联网收集,仅供用于学习和交流,请勿用于商业用途。如有侵权、不妥之处,请联系站长并出示版权证明以便删除。 敬请谅解! 侵权删帖/违法举报/投稿等事物联系邮箱:service@laoliang.net
意在交流学习,欢迎赞赏评论,如有谬误,请联系指正;转载请注明出处: » asp同一个文件操作数据表,添加、删除、修改、列表、查询

发表回复

本站承接,网站推广(SEM,SEO);软件安装与调试;服务器或网络推荐及配置;APP开发与维护;网站开发修改及维护; 各财务软件安装调试及注册服务(金蝶,用友,管家婆,速达,星宇等);同时也有客户管理系统,人力资源,超市POS,医药管理等;

立即查看 了解详情