asp同一個文件操作數(shù)據(jù)表,添加、刪除、修改、列表、查詢
[重要通告]如您遇疑難雜癥,本站支持知識付費業(yè)務(wù),掃右邊二維碼加博主微信,可節(jié)省您寶貴時間哦!
asp同一個文件操作數(shù)據(jù)表,添加、刪除、修改、列表、查詢
<!--#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"-->
<%
'檢測是否有管理標簽選項的權(quán)限
If Not ChkFlag("selectcata") Then
Call WriteSystemLog("標簽選項類別管理","權(quán)限不夠。")
Call ShowJsMsg("權(quán)限不夠","history.back();") : Response.End()
End If
'權(quán)限管理沒有寫完
%>
<!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">當前位置 >> <a href="Admin_SelectValue.asp">標簽選項管理</a> >> 標簽選項分類管理</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 "系統(tǒng)提示","刪除失敗,存在日志正在使用該分類。","",450
Else
ExecuteSql "delete from "&Table_Name&"_SelectCata where ID=" & ID
ShowAlertMsg "系統(tǒng)提示","刪除成功。","",450
Call WriteSystemLog("標簽選項類別管理","刪除成功,ID:"&ID&"。")
End IF
Else
ShowAlertMsg "系統(tǒng)提示","刪除失敗找不到指定的記錄。","",450
End IF
Rs.Close
Set Rs = Nothing
Else
ShowAlertMsg "系統(tǒng)提示","刪除失敗找不到指定的記錄。","",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">標題關(guān)鍵字<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 "系統(tǒng)錯誤","分類名稱不能為空!","",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 "系統(tǒng)錯誤","已經(jīng)存在該分類!","",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號又微信號)右上方掃一掃可加博主微信
所寫所說,是心之所感,思之所悟,行之所得;文當無敷衍,落筆求簡潔。 以所舍,求所獲;有所依,方所成!