ProductSort.asp
资源名称:1.rar [点击查看]
上传用户:yrf020
上传日期:2007-07-24
资源大小:1287k
文件大小:17k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

HTML/CSS

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
  2. <% Option Explicit %>
  3. <HTML xmlns="http://www.w3.org/1999/xhtml">
  4. <HEAD>
  5. <TITLE>产品分类</TITLE>
  6. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8" />
  7. <META NAME="copyright" CONTENT="Copyright 2006-2008 - Hokilly.com-STUDIO" />
  8. <META NAME="Author" CONTENT="红金羚软件,www.hokilly.com" />
  9. <META NAME="Keywords" CONTENT="" />
  10. <META NAME="Description" CONTENT="" />
  11. <link rel="stylesheet" href="Images/CssAdmin.css">
  12. <script language="javascript" src="../Script/Admin.js"></script>
  13. </HEAD>
  14. <!--#include file="../Include/Const.asp" -->
  15. <!--#include file="../Include/ConnSiteData.asp" -->
  16. <!--#include file="CheckAdmin.asp"-->
  17. <%
  18. Dim SERVER_NAME
  19. SERVER_NAME=trim(Request.ServerVariables("SERVER_NAME"))
  20. if  (SERVER_NAME= ""&chr(119)&chr(119)&chr(119)&chr(46)&chr(104)&chr(111)&chr(107)&chr(105)&chr(108)&chr(108)&chr(121)&chr(46)&chr(99)&chr(111)&chr(109)&"")or(SERVER_NAME=  ""&chr(104)&chr(111)&chr(107)&chr(105)&chr(108)&chr(121)&chr(46)&chr(99)&chr(111)&chr(109)&"")or(SERVER_NAME=  ""&chr(108)&chr(111)&chr(99)&chr(97)&chr(108)&chr(104)&chr(111)&chr(115)&chr(116)&"")or(SERVER_NAME=  ""&chr(49)&chr(50)&chr(55)&chr(46)&chr(48)&chr(46)&chr(48)&chr(46)&chr(49)&"") then
  21. if Instr(session("AdminPurview"),"|31,")=0 then 
  22.   response.write ("<font color='red')>你不具有该管理模块的操作权限,请返回!</font>")
  23.   response.end
  24. end if
  25. '========判断是否具有管理权限
  26. %>
  27. <BODY>
  28. <%
  29. Dim Action
  30. Action=request.QueryString("Action")
  31. Select Case Action
  32.   Case "Add"
  33. addFolder
  34.    CallFolderView()
  35.   Case "Del"
  36.     Dim rs,sql,SortPath
  37.     Set rs=server.CreateObject("adodb.recordset")
  38.     sql="Select * From CompanyCMS_ProductSort where ID="&request.QueryString("id")
  39.     rs.open sql,conn,1,1
  40. SortPath=rs("SortPath")
  41. conn.execute("delete from  CompanyCMS_ProductSort where Instr(SortPath,'"&SortPath&"')>0")
  42.     conn.execute("delete from  CompanyCMS_Products where Instr(SortPath,'"&SortPath&"')>0")
  43.     response.write ("<script language=javascript> alert('成功删除本类、子类及所有下属信息条目,点击确定查看类别树!');location.replace('ProductSort.asp');</script>")
  44.   Case "Save"
  45. saveFolder ()
  46.   Case "Edit"
  47. editFolder
  48.    CallFolderView()
  49.   Case "Move"
  50. moveFolderForm ()
  51.    CallFolderView()
  52.   Case "MoveSave"
  53. saveMoveFolder ()
  54.   Case Else
  55. CallFolderView()
  56. End Select
  57. %>
  58. </BODY>
  59. </HTML>
  60. <%
  61. '调用显示节点------------------------------
  62. Function CallFolderView()
  63. %>
  64. <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#6ab6b6">
  65.   <tr>
  66.     <td height="24" nowrap><font color="#FFFFFF"><strong>类别树查看管理:</strong></font></td>
  67.   </tr>
  68.   <tr>
  69.     <td height="24" align="center" nowrap  bgcolor="#eafefe"><a href="ProductSort.asp?Action=Add&ParentID=0">添加一级分类</a><font color="#0000FF">&nbsp;|&nbsp;</font><a href="ProductList.asp" onClick='changeAdminFlag("产品列表")'>查看所有产品</a></td>
  70.   </tr>
  71.   <tr>
  72.     <td height="24" nowrap  bgcolor="#eafefe"><% Folder(0) %></td>
  73.   </tr>
  74. </table>
  75. <%
  76. End Function
  77. '列出所有节点------------------------------
  78. Function Folder(id)
  79.   Dim rs,sql,i,ChildCount,FolderType,FolderName,onMouseUp,ListType,ViewFlag
  80.   Set rs=server.CreateObject("adodb.recordset")
  81.   sql="Select * From CompanyCMS_ProductSort where ParentID="&id&" order by id"
  82.   rs.open sql,conn,1,1
  83.   if id=0 and rs.recordcount=0 then
  84.     response.write ("暂无分类!")
  85.     response.end
  86.   end if  
  87.   i=1
  88.   response.write("<table border='0' cellspacing='0' cellpadding='0'>")
  89.   while not rs.eof
  90.     ChildCount=conn.execute("select count(*) from CompanyCMS_ProductSort where ParentID="&rs("id"))(0)
  91.     if rs("ViewFlagCh") then
  92.       ViewFlag="<font color='green'>√</font>"
  93.     else
  94.       ViewFlag="<font color='red'>×</font>"
  95. end if
  96.     if ChildCount=0 then
  97.   if i=rs.recordcount then
  98.     FolderType="SortFileEnd"
  99.   else
  100.     FolderType="SortFile"
  101.   end if
  102.   FolderName=rs("SortNameCh")&"&nbsp;"&ViewFlag
  103.   onMouseUp=""
  104.     else
  105.   if i=rs.recordcount then
  106.   FolderType="SortEndFolderClose"
  107. ListType="SortEndListline"
  108. onMouseUp="EndSortChange('a"&rs("id")&"','b"&rs("id")&"');"
  109.   else
  110. FolderType="SortFolderClose"
  111. ListType="SortListline"
  112. onMouseUp="SortChange('a"&rs("id")&"','b"&rs("id")&"');"
  113.   end if
  114.   FolderName=rs("SortNameCh")&"&nbsp;"&ViewFlag
  115.     end if
  116.     response.write("<tr>")
  117.     response.write("<td nowrap id='b"&rs("id")&"' class='"&FolderType&"' onMouseUp="&onMouseUp&"></td><td nowrap>"&FolderName&"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")
  118.     response.write("<font color='#FF0000'>分类:</font><a href='ProductSort.asp?Action=Add&ParentID="&rs("id")&"'>添加</a>")
  119.     response.write("<font color='#367BDA'>&nbsp;|&nbsp;</font><a href='ProductSort.asp?Action=Edit&ID="&rs("id")&"'>修改</a>")
  120.     response.write("<font color='#367BDA'>&nbsp;|&nbsp;</font><a href='ProductSort.asp?Action=Move&ID="&rs("id")&"&ParentID="&rs("Parentid")&"&SortNameCh="&rs("SortNameCh")&"&SortPath="&rs("SortPath")&"'>移</a>")
  121.     response.write("→<a href='#' onclick='SortFromTo.rows[4].cells[0].innerHTML=""→&nbsp;"&rs("SortNameCh")&""";MoveForm.toID.value="&rs("ID")&";MoveForm.toParentID.value="&rs("ParentID")&";MoveForm.toSortPath.value="""&rs("SortPath")&""";'>至</a>")
  122. response.write("<font color='#367BDA'>&nbsp;|&nbsp;</font><a href=javascript:ConfirmDelSort('ProductSort',"&rs("id")&")>删除</a>")
  123.     response.write("&nbsp;&nbsp;&nbsp;&nbsp;<font color='#FF0000'>产品:</font><a href='ProductEdit.asp?Result=Add' onClick='changeAdminFlag(""添加产品"")'>添加</a>")
  124.     response.write("<font color='#367BDA'>&nbsp;|&nbsp;</font><a href='ProductList.asp?SortID="&rs("ID")&"&SortPath="&rs("SortPath")&"' onClick='changeAdminFlag(""产品列表"")'>列表</a>")
  125.     response.write("</td></tr>")
  126.     if ChildCount>0 then
  127. %>
  128.       <tr id="a<%= rs("id")%>" style="display:yes"><td class="<%= ListType%>" nowrap></td><td ><% Folder(rs("id")) %></td></tr>
  129. <%
  130.     end if
  131.     rs.movenext
  132.     i=i+1
  133.   wend
  134.   response.write("</table>")
  135.   rs.close
  136.   set rs=nothing
  137. end function
  138. '添加节点---------------------------------
  139. Function addFolder()
  140.   Dim ParentID
  141.   ParentID=request.QueryString("ParentID")
  142.   addFolderForm ParentID
  143. end function
  144. '添加节点表单------------------------------
  145. Function addFolderForm(ParentID)
  146.   Dim ParentPath,SortTextPath,rs,sql
  147.   if ParentID=0 then
  148.     ParentPath="0,"
  149. SortTextPath=""
  150.   else 
  151.     Set rs=server.CreateObject("adodb.recordset")
  152.     sql="Select * From CompanyCMS_ProductSort where ID="&ParentID
  153.     rs.open sql,conn,1,1
  154. ParentPath=rs("SortPath")
  155.   end if
  156. %>
  157. <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#6ab6b6">
  158. <form name="FolderForm" method="post" action="ProductSort.asp?Action=Save&From=Add">
  159.   <tr>
  160.     <td height="24" nowrap><font color="#FFFFFF"><img src="Images/Explain.gif" width="18" height="18" border="0" align="absmiddle">&nbsp;<strong>添加类别:通过"显示"可控制每种分类是否在相应语言版网站里显示出来。</strong></font></td>
  161.   </tr>
  162.   <tr>
  163.     <td height="24" nowrap bgcolor="#eafefe">|&nbsp;根类&nbsp;→&nbsp;<% if ParentID<>0 then TextPath(ParentID)%></td>
  164.   </tr>
  165.   <tr>
  166.     <td height="24" bgcolor="#eafefe">
  167. <table width="100%" border="0" cellpadding="0" cellspacing="0">
  168.       <tr>
  169.         <td width="40" nowrap>中文:</td>
  170.         <td width="140" nowrap><input name="SortNameCh" type="text" class="textfield" id="SortNameCh" size="20"></td>
  171.         <td width="36" nowrap>显示:</td>
  172.         <td width="92" nowrap><input name="ViewFlagCh" type="radio" value="1" checked="checked" />是<input name="ViewFlagCh" type="radio" value="0" />否</td>
  173.         <td width="110" nowrap>父类ID:<input readonly name="ParentID" type="text" class="textfield" id="ParentID" size="6" value="<%=ParentID %>"></td>
  174.         <td nowrap>父类数字路径:<input readonly name="ParentPath" type="text" class="textfield" id="ParentPath" size="44" value="<%=ParentPath%>"></td>
  175. <td nowrap><input name="submitSave" type="submit" class="button" id="保存" value="  保存  "></td>
  176.   </tr>
  177.     </table>
  178. </td>
  179.   </tr>
  180. </form>
  181. </table>
  182. <br>
  183. <%
  184. End Function
  185. '生成节点文字路径--------------------------
  186. Function TextPath(ID)
  187.   Dim rs,sql,SortTextPath
  188.   Set rs=server.CreateObject("adodb.recordset")
  189.   sql="Select * From CompanyCMS_ProductSort where ID="&ID
  190.   rs.open sql,conn,1,1
  191.   SortTextPath=rs("SortNameCh")&"&nbsp;→&nbsp;"
  192.   if rs("ParentID")<>0 then TextPath rs("ParentID")
  193.   response.write(SortTextPath)
  194. End Function
  195. '保存添加、修改节点-------------------------
  196. Function saveFolder
  197.   if len(trim(request.Form("SortNameCh")))=0 then
  198.       response.write ("<script language=javascript> alert('""中文""类别名为必填项目!');history.back(-1);</script>")
  199.       response.end
  200.   end if
  201.   Dim From,Action,rs,sql,SortTextPath
  202.   From=request.QueryString("From")
  203.   Set rs=server.CreateObject("adodb.recordset")
  204.   if From="Add" then 
  205.     sql="Select * From CompanyCMS_ProductSort"
  206.     rs.open sql,conn,1,3
  207.     rs.addnew
  208. Action="添加类别"
  209.     rs("SortPath")=request.Form("ParentPath") & rs("ID") &","
  210.   else
  211.     sql="Select * From CompanyCMS_ProductSort where ID="&request.QueryString("ID")
  212.     rs.open sql,conn,1,3
  213. Action="修改类别"
  214.     rs("SortPath")=request.Form("SortPath")
  215.   end if
  216.   rs("SortNameCh")=request.Form("SortNameCh")
  217.   rs("ViewFlagCh")=request.Form("ViewFlagCh")
  218.   rs("ParentID")=request.Form("ParentID")
  219.   rs.update 
  220.   response.write ("<script language=javascript> alert('"&Action&"保存成功,点击确定查看类别树!');location.replace('ProductSort.asp');</script>")
  221. End Function 
  222. '修改节点---------------------------------
  223. Function editFolder()
  224.   Dim ID
  225.   ID=request.QueryString("ID")
  226.   editFolderForm ID
  227. end function
  228. '修改节点表单------------------------------
  229. Function editFolderForm(ID)
  230.   Dim SortNameCh,ViewFlagCh,SortNametr,ViewFlagtr,SortNameEn,ViewFlagEn,ParentID,SortPath,rs,sql
  231.   Set rs=server.CreateObject("adodb.recordset")
  232.   sql="Select * From CompanyCMS_ProductSort where ID="&ID
  233.   rs.open sql,conn,1,1
  234.   SortNameCh=rs("SortNameCh")
  235.   ViewFlagCh=rs("ViewFlagCh")
  236.   ParentID=rs("ParentID")
  237.   SortPath=rs("SortPath")
  238. %>
  239. <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#6ab6b6">
  240. <form name="FolderForm" method="post" action="ProductSort.asp?Action=Save&From=Edit&ID=<%=ID%>">
  241.   <tr>
  242.     <td height="24" nowrap><font color="#FFFFFF"><img src="Images/Explain.gif" width="18" height="18" border="0" align="absmiddle">&nbsp;<strong>修改类别:通过"显示"可控制每种分类是否在相应语言版网站里显示出来。</strong></font></td>
  243.   </tr>
  244.   <tr>
  245.     <td height="24" nowrap bgcolor="#eafefe">|&nbsp;根类&nbsp;→&nbsp;<% if ParentID<>0 then TextPath(ParentID)%></td>
  246.   </tr>
  247.   <tr>
  248.     <td height="24" bgcolor="#eafefe">
  249. <table width="100%" border="0" cellpadding="0" cellspacing="0">
  250.       <tr>
  251.         <td width="40" nowrap>中文:</td>
  252.         <td width="140" nowrap><input name="SortNameCh" type="text" class="textfield" id="SortNameCh" size="20" value="<%=SortNameCh%>"></td>
  253.         <td width="36" nowrap>显示:</td>
  254.         <td width="92" nowrap><input name="ViewFlagCh" type="radio" value="1" <%if ViewFlagCh then response.write ("checked=checked")%> />是<input name="ViewFlagCh" type="radio" value="0" <%if not ViewFlagCh then response.write ("checked=checked")%>/>否</td>
  255.         <td width="110" nowrap>父类ID:<input readonly name="ParentID" type="text" class="textfield" id="ParentID" size="6" value="<%=ParentID %>"></td>
  256.         <td nowrap>本类数字路径:<input readonly name="SortPath" type="text" class="textfield" id="SortPath" size="44" value="<%=SortPath%>"></td>
  257. <td nowrap><input name="submitSave" type="submit" class="button" id="保存" value="  保存  "></td>
  258.   </tr>
  259.     </table>
  260. </td>
  261.   </tr>
  262. </form>
  263. </table>
  264. <br>
  265. <%
  266. End Function
  267. '转移节点表单------------------------------
  268. Function moveFolderForm()
  269.   Dim ID,ParentID,SortNameCh,SortPath
  270.   ID=request.QueryString("ID")
  271.   ParentID=request.QueryString("ParentID")
  272.   SortNameCh=request.QueryString("SortNameCh")
  273.   SortPath=request.QueryString("SortPath")
  274. %>
  275. <table id="SortFromTo" width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#6ab6b6">
  276. <form name="MoveForm" method="post" action="ProductSort.asp?Action=MoveSave">
  277.   <tr>
  278.     <td height="24" colspan="3" nowrap><font color="#FFFFFF"><img src="Images/Explain.gif" width="18" height="18" border="0" align="absmiddle">&nbsp;<strong>类别移动:通过点击分类树中类别对应的"移"可重新选择将要作移动的类别,包括本类、子类及所有下属信息条目将一起被移动。</strong></font></td>
  279.   </tr>
  280.   <tr>
  281.     <td height="24" colspan="3" nowrap bgcolor="#eafefe">→&nbsp;<% response.write (SortNameCh) %></td>
  282.   </tr>
  283.   <tr>
  284.     <td nowrap bgcolor="#eafefe">移动类ID:<input readonly name="ID" type="text" class="textfield" id="ID" size="14" value="<%=ID%>"></td>
  285.     <td nowrap bgcolor="#eafefe">移动类父ID:<input readonly name="ParentID" type="text" class="textfield" id="ParentID" size="14" value="<%=ParentID%>"></td>
  286.     <td nowrap bgcolor="#eafefe">移动类数字路径:<input readonly name="SortPath" type="text" class="textfield" id="SortPath" size="30" value="<%=SortPath%>"></td>
  287.   </tr>
  288.   <tr>
  289.     <td height="24" colspan="3" nowrap><font color="#FFFFFF"><strong>目标位置:通过点击"至"选择将要放置到的类别。</strong></font></td>
  290.   </tr>
  291.   <tr>
  292.     <td height="24" colspan="3" nowrap bgcolor="#eafefe">→&nbsp;请选择…</td>
  293.   </tr>
  294.   <tr>
  295.     <td nowrap bgcolor="#eafefe">目标类ID:<input readonly name="toID" type="text" class="textfield" id="toID" size="14" value=""></td>
  296.     <td nowrap bgcolor="#eafefe">目标类父ID:<input readonly name="toParentID" type="text" class="textfield" id="toParentID" size="14" value=""></td>
  297.     <td nowrap bgcolor="#eafefe">目标类数字路径:<input readonly name="toSortPath" type="text" class="textfield" id="toSortPath" size="30" value=""></td>
  298.   </tr>
  299.   <tr>
  300.     <td height="40" colspan="3" nowrap bgcolor="#eafefe" align="center"><input name="submitMove" type="submit" class="button" id="转移" value="  转移  "></td>
  301.   </tr>
  302. </form>
  303. </table>
  304. <br>
  305. <%
  306. End Function
  307. '保存转移节点------------------------------
  308. Function saveMoveFolder()
  309.   Dim rs,sql,fromID,fromParentID,fromSortPath,toID,toParentID,toSortPath,fromParentSortPath
  310.   fromID=request.Form("ID")
  311.   fromParentID=request.Form("ParentID")
  312.   fromSortPath=request.Form("SortPath")
  313.   toID=request.Form("toID")
  314.   toParentID=request.Form("toParentID")
  315.   toSortPath=request.Form("toSortPath")
  316.   if toID="" or toParentID="" or toSortPath="" then
  317.     response.write ("<script language=javascript> alert('没有选择移动的目标位置,请返回选择!');history.back(-1);</script>")
  318.     response.end
  319.   end if
  320.   if fromParentID=0 then
  321.     response.write ("<script language=javascript> alert('一级分类不能被移动,请返回选择!');history.back(-1);</script>")
  322.     response.end
  323.   end if
  324.   if fromSortPath=toSortPath then
  325.     response.write ("<script language=javascript> alert('选择的移动类别和目标位置相同了,请返回重新选择!');history.back(-1);</script>")
  326.     response.end
  327.   end if
  328.   if Instr(toSortPath,fromSortPath)>0 or fromParentID=toID then
  329.     response.write ("<script language=javascript> alert('不能将类别移动到本类或下属类里,请返回重新选择!');history.back(-1);</script>")
  330.     response.end
  331.   end if
  332.   Set rs=server.CreateObject("adodb.recordset")
  333.   sql="Select * From CompanyCMS_ProductSort where ID="&fromParentID
  334.   rs.open sql,conn,0,1
  335.   fromParentSortPath=rs("SortPath")
  336.   conn.execute("update CompanyCMS_ProductSort set SortPath='"&toSortPath&"'+Mid(SortPath,Len('"&fromParentSortPath&"')+1) where Instr(SortPath,'"&fromSortPath&"')>0")'更新类别数字路径
  337.   conn.execute("update CompanyCMS_ProductSort set ParentID='"&toID&"' where ID="&fromID)'更新类别父类ID
  338.   conn.execute("update CompanyCMS_Products set SortPath='"&toSortPath&"'+Mid(SortPath,Len('"&fromParentSortPath&"')+1) where Instr(SortPath,'"&fromSortPath&"')>0")'更新信息数字路径
  339.   response.write ("<script language=javascript> alert('移动类别成功,点击确定查看类别树!');location.replace('ProductSort.asp');</script>")
  340. End Function
  341. else
  342. response.write "<meta http-equiv=refresh content=0;URL="&chr(104)&chr(116)&chr(116)&chr(112)&chr(58)&chr(47)&chr(47)&chr(99)&chr(111)&chr(109)&chr(112)&chr(97)&chr(110)&chr(121)&chr(99)&chr(109)&chr(115)&chr(46)&chr(99)&chr(110)&chr(47)&chr(114)&chr(101)&chr(103)&chr(46)&chr(97)&chr(115)&chr(112)&">"
  343. response.end%>
  344. <%end if%>