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

📄 class.asp

📁 一套很早的多用户电子商务程序
💻 ASP
📖 第 1 页 / 共 3 页
字号:
<!--#include file="../conn2.asp" -->
<%
sp_name=request.cookies("sp_name")
Rem 断开数据库连接
function CloseDatabase
	Conn.close
	Set conn = Nothing
End Function

Rem 过滤SQL非法字符
function checkStr(str)
	if isnull(str) then
		checkStr = ""
		exit function 
	end if
	checkStr=replace(str,"'","''")
end function
%>
<HTML><HEAD><TITLE>后台管理 </TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="admin.css" type=text/css rel=stylesheet>
</HEAD>
<BODY>
<table width="80%" border="0" align="center" cellspacing="2">
  <tr> 
    <td  class="b1" valign="top"> 
<%
call main()
sub main()
%>
      <table width="100%" border="0" cellspacing="1" cellpadding="3"  align=center>
        <tr> 
          <td width="100"> <B>栏目操作选项</B></td>
          <td class="tdbg2"><a href="class.asp">栏目管理首页</a> | <a href="class.asp?action=add">新建栏目版面</a> 
            | <a href="?action=orders">一级分类排序</a> | <a href="?action=boardorders">N级分类排序</a> 
            | <a href="?action=RestoreBoard" onclick="{if(confirm('  请慎重操作,不要轻易使用该功能!\n\n  复位所有版面将把所有版面恢复成为一级大分类,复位后要对所有版面重新进行归属的基本设置,仅在做出了错误的设置而无法复原版面之间的关系和排序的时候使用,请慎重操作,确定复位吗?')){return true;}return false;}">复位所有版面</a> 
          </td>
        </tr>
      </table>
      <%
select case Request("action")
case "add"
	call add()
case "edit"
	call edit()
case "savenew"
	call savenew()
case "savedit"
	call savedit()
case "del"
	call del()
case "orders"
	call orders()
case "updatorders"
	call updateorders()
case "boardorders"
	call boardorders()
case "updatboardorders"
	call updateboardorders()
case "addclass"
	call addclass()
case "saveclass"
	call saveclass()
case "RestoreBoard"
	call RestoreBoard()
case else
	call CatalogInfo()
end select
end sub

sub CatalogInfo()
 %>
      <table width="100%" cellspacing="1" cellpadding="2" align=center>
        <tr class="tdbg1"> 
          <td width="35%"><strong>栏目版面</strong> </td>
          <td width="35%"><strong>操作</strong> </td>
        </tr>
<%
sql="select * from SoftDown_Catalog where sp_name='"&sp_name&"' order by rootid,orders"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
do while not rs.eof
%>
        <tr class="tdbg2"> 
          <td width=35% > 
            <%
 if rs("depth") =1 then  Response.Write "&nbsp;&nbsp;<font color=""#666666"">├</font>"
 if rs("depth") >1 then
 for i=2 to rs("depth")
	Response.Write "&nbsp;&nbsp;<font color=""#666666"">│</font>"
 next
 Response.Write "&nbsp;&nbsp;<font color=""#666666"">├</font> "
 end if
 
  if rs("parentid")=0 then Response.Write("<b>")
  Response.Write rs("CatalogName")
  if rs("child")>0 then Response.Write "("&rs("child")&")"
  %>
          </td>
          <td width=65% align=right><a href="class.asp?action=add&editid=<%=rs("CatalogID")%>">添加子分类</a> 
            | <a href="class.asp?action=edit&editid=<%=rs("CatalogID")%>">分类修改</a> 
            | 
            <%if rs("child")=0 then%>
            <a href="class.asp?action=del&editid=<%=rs("CatalogID")%>" onclick="{if(confirm('删除将使该分类下的所有商品不显示,确定删除吗?')){return true;}return false;}">删除 
            <% else %><a href="#" onclick="{if(confirm('该栏目含有下属栏目,必须先删除其下属栏目方能删除本栏目!')){return true;}return false;}"> 
            删除</a> 
            <%end if%>
          </td>
        </tr>
        <%
rs.movenext
loop
rs.close
set rs=nothing
%>
      </table>
      <% 
end sub 

sub add()
'定义栏目编号=============================================
set rs = server.CreateObject ("Adodb.recordset")
	sql="select Max(CatalogID) from SoftDown_Catalog"
	rs.open sql,conn,1,1
	if rs.eof and rs.bof then
	CatalogNum=1001
	else
	CatalogNum=rs(0)+1
	end if
	if isnull(CatalogNum) then CatalogNum=1001
	rs.close
%>
      <form action ="class.asp?action=savenew" method=post>
        <input type="hidden" name="newCatalogID" value="<%=CatalogNum%>">
        <table width="100%" border="0" cellspacing="1" cellpadding="3"  align=center>
          <tr> 
            <td height=24 colspan=2 class="tdbg1"><strong>添加新栏目</strong></td>
          </tr>
          <tr class="tdbg2"> 
            <td width="52%" height=30><U>栏目名称</U></td>
            <td width="48%"> <input type="text" name="CatalogName" size="35"> 
            </td>
          </tr>
          <tr class="tdbg2"> 
            <td width="52%" height=24><U>栏目说明</U></td>
            <td width="48%"> <textarea name="Readme" cols="40" rows="5"></textarea> 
            </td>
          </tr>
          <tr class="tdbg2"> 
            <td width="52%" height=30><U>所属类别</U></td>
            <td width="48%"> <select name="class">
                <option value="0">做为栏目分类</option>
                <%
sql = "select * from SoftDown_Catalog where sp_name='"&sp_name&"' order by rootid,orders"
rs.open sql,conn,1,1
 do while not rs.eof 
 Response.Write "<option value="""&rs("CatalogID")&""" "
 if request("editid")<>"" and clng(request("editid"))=rs("CatalogID") then Response.Write "selected"
 Response.Write ">"
 if rs("depth") =1 then  Response.Write "&nbsp;&nbsp;├ "
 if rs("depth") >1 then
 for i=2 to rs("depth")
	Response.Write "&nbsp;&nbsp;│"
 next
 Response.Write "&nbsp;&nbsp;├ "
 end if
 Response.Write rs("CatalogName")&"</option>" & vbcrlf
 rs.MoveNext
 loop
 rs.Close 
%>
              </select> </td>
          <tr class="tdbg2"> 
            <td width="52%" height=24>&nbsp;</td>
            <td width="48%"> <input type="submit" name="Submit" value="添加栏目"> 
            </td>
          </tr>
        </table>
      </form>
      <%
set rs=nothing
end sub

sub edit()
set rs = server.CreateObject ("Adodb.recordset")
dim rs_e
sql = "select * from SoftDown_Catalog where sp_name='"&sp_name&"' and CatalogID="&request("editid")
set rs_e=conn.execute(sql)
%>
      <form action ="class.asp?action=savedit" method=post>
        <input type="hidden" name=editid value="<%=Request("editid")%>">
        <table width="95%" border="0" cellspacing="1" cellpadding="3"  align=center>
          <tr> 
            <td height=24 colspan=2 class="tdbg1"><B>编辑栏目:<%= rs_e("CatalogName") %></b></td>
          </tr>
          <tr class="tdbg2"> 
            <td width="52%" height=30><U>栏目名称</U></td>
            <td width="48%"> <input type="text" name="CatalogName" size="35" value="<%= rs_e("CatalogName") %>"> 
            </td>
          </tr>
          <tr class="tdbg2"> 
            <td width="52%" height=24><U>栏目说明</U><BR>
            </td>
            <td width="48%"> <textarea name="Readme" cols="40" rows="5"><%=rs_e("readme")%></textarea> 
            </td>
          </tr>
          <tr class="tdbg2"> 
            <td width="52%" height=30><U>所属类别</U></td>
            <td width="48%"> <select name="class">
                <option value="0">做为栏目分类</option>
                <%
sql = "select * from SoftDown_Catalog where sp_name='"&sp_name&"' order by rootid,orders"
rs.open sql,conn,1,1
 do while not rs.eof 
 Response.Write "<option value="""&rs("CatalogID")&""" "
 if rs_e("parentid")=rs("CatalogID") then Response.Write "selected"
 Response.Write ">"
 if rs("depth") =1 then  Response.Write "&nbsp;&nbsp;├ "
 if rs("depth") >1 then
 for i=2 to rs("depth")
	Response.Write "&nbsp;&nbsp;│"
 next
 Response.Write "&nbsp;&nbsp;├ "
 end if
 Response.Write rs("CatalogName")&"</option>" & vbcrlf
 rs.MoveNext
 loop
 rs.Close 
%>
              </select> </td>
          </tr>
          <tr class="tdbg2"> 
            <td width="52%" height=24>&nbsp;</td>
            <td width="48%"> <input type="submit" name="Submit" value="保存修改"> 
            </td>
          </tr>
        </table>
      </form>
      <%
set rs=nothing
set rs_e=nothing
end sub

'保存添加栏目信息
sub savenew()
' 验证表单输入的正确性开始==========================================
dim Founderr,msginfo,msgtitle
Founderr=false
if request("CatalogName")="" then
	msginfo=msginfo+"<br>"+"<li>请输入栏目名称。"
	Founderr=true
end if
if request("class")="" then
	msginfo=msginfo+"<br>"+"<li>请选择栏目分类。"
	Founderr=true
end if
if request("readme")="" then
	msginfo=msginfo+"<br>"+"<li>请输入栏目说明。"
	Founderr=true
end if
if founderr=true then
    msgtitle="添加新栏目"
	call Sysmsg(msgtitle,msginfo)
	exit sub
end if
' 验证表单输入的正确性结束==========================================

dim CatalogID,rootid,parentid,depth,orders,maxrootid,parentstr,neworders
set rs = server.CreateObject ("adodb.recordset")

if request("class")<>"0" then
sql="select rootid,CatalogID,depth,orders,ParentStr from SoftDown_Catalog where sp_name='"&sp_name&"' and CatalogID="&request("class")
rs.open sql,conn,1,1
rootid=rs(0)
parentid=rs(1)
depth=rs(2)
orders=rs(3)
    if depth+1>20 then
		msgtitle="添加新栏目"
		msginfo="<li>本系统限制最多只能有20级子栏目</li>"
	    call Sysmsg(msgtitle,msginfo)
	exit sub
    end if
parentstr=rs(4)
rs.close
'Response.Write orders&"<br>"
neworders=orders
'算出正确的orders值
sql="select max(orders) from SoftDown_Catalog where sp_name='"&sp_name&"' and ParentID="&request("class")
rs.open sql,conn,1,1
  if not (rs.eof and rs.bof) then
    neworders=rs(0)
  end if
  if isnull(neworders) then neworders=orders
rs.close
'Response.Write(sql)
conn.execute("update SoftDown_Catalog set orders=orders+1 where sp_name='"&sp_name&"' and orders>"&cint(neworders)&"")

else
sql="select max(rootid) from SoftDown_Catalog where sp_name='"&sp_name&"'"

⌨️ 快捷键说明

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