<!--#include file="Admin_Common.asp"-->
<!--#include file="Admin_CommonCode_Content.asp"-->
<!--#include file="../Include/PowerEasy.ConsumeLog.asp"-->
<!--#include file="../Include/PowerEasy.Common.Supply.asp"-->
<!--#include file="../Include/PowerEasy.FSO.asp"-->
<%
'**************************************************************
' Software name: PowerEasy SiteWeaver
' Web: http://www.powereasy.net
' Copyright (C) 2005－2009 佛山市动易网络科技有限公司 版权所有
'**************************************************************

Const NeedCheckComeUrl = True   '是否需要检查外部访问

Const PurviewLevel = 2      '0--不检查，1--超级管理员，2--普通管理员
Const PurviewLevel_Channel = 3   '0--不检查，1--频道管理员，2--栏目总编，3--栏目管理员
Const PurviewLevel_Others = ""   '其他权限

Dim SupplyId
'Dim CommandChannelPoint '把供求信息设置为频道推荐每天要扣除的点数
Dim HtmlDir
Dim ManageType, Field, ClassID, SpecialID, Status
Dim tClass, ClassName, RootID, ParentID, Depth, ParentPath, Child, arrChildID, ParentDir, ClassDir, ClassPurview

Dim PurviewChecked

HtmlDir = InstallDir & ChannelDir

ManageType = Trim(Request("ManageType")) '
ClassID = PE_CLng(Trim(Request("ClassID")))
SpecialID = PE_CLng(Trim(Request("SpecialID")))
SupplyId = Trim(Request("SupplyId"))
Status = Trim(Request("Status")) '信息状态

If Action = "" Then
    Action = "Manage"
End If
If Status = "" Then
    Status = 9
Else
    Status = PE_CLng(Status)
End If

If IsValidID(SupplyId) = False Then
    SupplyId = ""
End If

Dim arrClass_Viewtemp,arrClass_Inputtemp,arrClass_Checktemp,arrClass_Managetemp
arrClass_Viewtemp = arrClass_View
arrClass_Inputtemp = arrClass_Input
arrClass_Checktemp = arrClass_Check
arrClass_Managetemp = arrClass_Manage

Call GetUser(UserName)

arrClass_View = arrClass_Viewtemp
arrClass_Input = arrClass_Inputtemp
arrClass_Check = arrClass_Checktemp
arrClass_Manage = arrClass_Managetemp

If XmlDoc.Load(Server.MapPath(InstallDir & "Language/Gb2312_Channel_" & ChannelID & ".xml")) = False Then XmlDoc.Load (Server.MapPath(InstallDir & "Language/Gb2312.xml"))
   
FileName = "Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=" & Action & "&ManageType=" & ManageType
strFileName = FileName & "&Field=" & Field & "&ClassID=" & ClassID & "&SpecialID=" & SpecialID & "&keyword=" & Keyword & ""
Response.Write "<html><head><title>" & ChannelShortName & "管理</title>" & vbCrLf
Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbCrLf
Response.Write "<link href='Admin_Style.css' rel='stylesheet' type='text/css'>" & vbCrLf
Response.Write "</head>" & vbCrLf
Response.Write "<body leftmargin='2' topmargin='0' marginwidth='0' marginheight='0'>" & vbCrLf
If Action = "Preview" Then
    Call Preview
    Response.End
End If
Response.Write "<table width='100%' border='0' align='center' cellpadding='2' cellspacing='1' class='border'>"
Dim strTitle
strTitle = ChannelName & "管理----"
Select Case Action
    Case "Add"
        strTitle = strTitle & "添加" & ChannelShortName
    Case "Modify"
        strTitle = strTitle & "修改" & ChannelShortName
    Case "Check"
        strTitle = strTitle & "审核" & ChannelShortName
    Case "SaveAdd", "SaveModify"
        strTitle = strTitle & "保存" & ChannelShortName
    Case "Preview", "Show"
        strTitle = strTitle & "预览" & ChannelShortName
    Case "Manage"
        Select Case ManageType
        Case "Check"
            strTitle = strTitle & ChannelShortName & "审核"
        Case "Special"
            strTitle = strTitle & "专题" & ChannelShortName & "管理"
        Case Else
            strTitle = strTitle & ChannelShortName & "管理首页"
        End Select
End Select
Call ShowPageTitle(strTitle, 10161)
Response.Write "  <tr class='tdbg'>"
Response.Write "    <td width='70' height='30' ><strong>管理导航：</strong></td><td colspan='5'>"
Response.Write "<a href='Admin_Supply.asp?ChannelID=" & ChannelID & "&Status=9'>" & ChannelShortName & "管理首页</a>&nbsp;|&nbsp;"
Response.Write "<a href='Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=Add&ClassID=" & ClassID & "&SpecialID=" & SpecialID & "'>添加" & ChannelShortName & "</a>&nbsp;|&nbsp;"
Response.Write "<a href='Admin_Supply.asp?ChannelID=" & ChannelID & "&ManageType=Check&Status=0'>审核" & ChannelShortName & "</a>"
If AdminPurview = 1 Or AdminPurview_Channel <= 2 Then
    Response.Write "&nbsp;|&nbsp;<a href='Admin_Supply.asp?ChannelID=" & ChannelID & "&ManageType=Special'>专题" & ChannelShortName & "管理</a>"
End If
Response.Write "</td></tr>" & vbCrLf
If Action = "Manage" Then
    Response.Write "<form name='form3' method='Post' action='" & strFileName & "'><tr class='tdbg'>"
    Response.Write "  <td width='70' height='30' ><strong>" & ChannelShortName & "选项：</strong></td><td>"
    Response.Write "  <input name='Status' type='radio' value='9' onclick='submit();'"
    If Status = 9 Then Response.Write " checked"
    Response.Write ">所有" & ChannelShortName & "&nbsp;&nbsp;&nbsp;<input name='Status' type='radio' value='0' onclick='submit();'"
    If Status = 0 Then Response.Write " checked"
    Response.Write ">待审核的" & ChannelShortName & " &nbsp;&nbsp;<input name='Status' type='radio' value='1' onclick='submit();'"
    If Status = 1 Then Response.Write " checked"
    Response.Write ">已审核的" & ChannelShortName & " &nbsp;&nbsp;<Input Name='Status' Type='Radio' Value=2 Onclick='submit();'"
    If Status = 2 Then Response.Write "Checked"
    Response.Write ">过期的" & ChannelShortName & "</td>"
    Response.Write "<td></td></tr></form>" & vbCrLf
End If
Response.Write "</table>" & vbCrLf

strFileName = strFileName & "&Status=" & Status
Select Case Action
Case "Add", "Modify"
    Call Add
Case "SaveAdd", "SaveModify"
    Call SaveSupply
Case "SetPassed", "CanCelPassed", "SetOnTop"
    Call SetProperty
Case "Show"
    Call Show
Case "Del"
    Call Del
Case "ConfirmDel"
    Call ConfirmDel
Case "DelFromSpecial"
    Call DelFromSpecial
Case "MoveToSpecial"
    Call MoveToSpecial
Case "MoveSupply"
    Call MoveSupply
Case "Move"
    Call Move
Case "Restore"
    Call Restore
Case "RestoreAll"
    Call RestoreAll
Case "BatchMove"
    Call BatchMove
Case "DoBatchMove"
    Call DoBatchMove
Case "ClearRecyclebin"
    Call ClearRecyclebin
Case "Manage"
    Call main
End Select

If FoundErr = True Then
    Call WriteErrMsg(ErrMsg, ComeUrl)
End If
Response.Write "</body></html>"
Call CloseConn


Sub main()
    Dim rsSupplyList, sql, Querysql
    PurviewChecked = False
    '检查栏目管理员的权限
    
    Call CheckAdminClassPuriew
    If FoundErr = True Then Exit Sub

    Call ShowJS_Manage(ChannelShortName)
    Response.Write "<br><table width='100%' border='0' align='center' cellpadding='2' cellspacing='1' class='border'>"
    If ManageType = "Special" Then
        Response.Write "<tr class='title'>"
        Response.Write "  <td height='22'>" & GetSpecialList() & "</td></tr>" & vbCrLf
    Else
        Response.Write "  <tr class='title'>"
        Response.Write "    <td height='22'>" & GetRootClass() & "</td>"
        Response.Write "  </tr>" & GetChild_Root() & ""
    End If
    Response.Write "</table><br>"

    Select Case ManageType
    Case "Check"
        Call ShowContentManagePath(ChannelShortName & "审核")
    Case "Special"
        Call ShowContentManagePath("专题" & ChannelShortName & "管理")
    Case Else
        Call ShowContentManagePath(ChannelShortName & "管理")
    End Select

    Response.Write "<table width='100%' border='0' cellpadding='0' cellspacing='0'><tr>"
    Response.Write "    <form name='myform' method='Post' action='Admin_Supply.asp' onsubmit='return ConfirmDel();'>"
    Response.Write "     <td><table class='border' border='0' cellspacing='1' width='100%' cellpadding='0'>"
    Response.Write "          <tr class='title' height='22'> "
    Response.Write "            <td height='22'  width='30' align='center'><strong>选中</strong></td>"
    Response.Write "            <td width='25' align='center'><strong>ID</strong></td>"
    If ManageType = "Special" Then
        Response.Write "        <td width='100' align='center'><strong>所属专题</strong></td>"
    End If
    Response.Write "            <td align='center' ><strong>" & ChannelShortName & "标题</strong></td>"
    Response.Write "            <td width='80' align='center' ><strong>交易方式</strong></td>"
    Response.Write "            <td width='60' align='center' ><strong>有效期</strong></td>"
    Response.Write "            <td width='60' align='center' ><strong>发布人</strong></td>"
    Response.Write "            <td width='80' align='center' ><strong>发布时间</strong></td>"
    Response.Write "            <td width='60' align='center' ><strong>点击数</strong></td>"
    Response.Write "            <td width='80' align='center' ><strong>信息状态</strong></td>"
    If ManageType = "Check" Then
        Response.Write "            <td width='120' align='center' ><strong>审核操作</strong></td>"
    ElseIf ManageType = "Recyclebin" Then
        Response.Write "              <td width='100' align='center' ><strong>回收站操作</strong></td>"
    Else
        Response.Write "            <td width='80' align='center' ><strong>常规操作</strong></td>"
    End If
    Response.Write "          </tr>"
    
    If ManageType = "Special" Then
        sql = "select top " & MaxPerPage & " A.SupplyId,A.CommandType,A.Deleted,"
        sql = sql & "A.ClassID,A.ChannelId,A.SpecialId,A.SupplyName,A.SupplyType,A.SupplyTitle,"
        sql = sql & "A.SupplyIntro,A.SupplyPeriod,A.TradeType,A.PriceIntro,A.SupplyPicUrl,"
        sql = sql & "A.TemplateId,A.SkinId,A.Status,A.UserName,A.Hits,A.UpdateTime,"
        sql = sql & " SP.SpecialName from PE_Supply A Left join PE_Special SP on A.SpecialId=SP.SpecialId "
    Else
        sql = "select top " & MaxPerPage & " A.SupplyId,A.CommandType,A.Deleted,"
        sql = sql & "A.ClassID,A.ChannelId,A.SpecialId,A.SupplyName,A.SupplyType,A.SupplyTitle,"
        sql = sql & "A.SupplyIntro,A.SupplyPeriod,A.TradeType,A.PriceIntro,A.SupplyPicUrl,"
        sql = sql & "A.TemplateId,A.SkinId,A.Status,A.UserName,A.Hits,A.UpdateTime,"
        sql = sql & "C.ClassName,C.ParentDir,C.ClassDir,C.ClassPurview "
        sql = sql & "from PE_Supply A left join PE_Class C on A.ClassID=C.ClassID "
    End If
    
    Querysql = " where A.ChannelID=" & ChannelID & ""
    If ManageType = "Recyclebin" Then
        Querysql = Querysql & "And Deleted=" & PE_True & ""
    Else
        Querysql = Querysql & "And Deleted = " & PE_False & ""
    End If
    
    If ClassID > 0 Then
        If Child > 0 Then
            Querysql = Querysql & " and A.ClassID in (" & arrChildID & ")"
        Else
            Querysql = Querysql & " and A.ClassID=" & ClassID
        End If
    End If
    If SpecialID > 0 Then
        Querysql = Querysql & " and A.SpecialID=" & SpecialID
    End If
    If ManageType = "My" Then
        Querysql = Querysql & " and A.UserName='" & UserName & "' "
    End If
    
    Select Case Status
        Case 0 '待审核
            Querysql = Querysql & " and A.Status=0 "
        Case 1  '已审核
            Querysql = Querysql & " and A.Status=1 "
        Case 2  '过期的
            Querysql = Querysql & " and DateDiff(" & PE_DatePart_D & ",UpdateTime," & PE_Now & ")>SupplyPeriod And SupplyPeriod<> -1 "
        Case Else
            Querysql = Querysql & " and A.Status>=0 "
    End Select
    
    If Keyword <> "" Then
        Select Case Field
            Case "Title"
                Querysql = Querysql & " and A.SupplyTitle like '%" & Keyword & "%' "
            Case "Content"
                Querysql = Querysql & " and A.SupplyIntro like '%" & Keyword & "%' "
            Case "UserName"
                Querysql = Querysql & " and A.UserName='" & Keyword & "' "
            Case Else
                Querysql = Querysql & " and A.SupplyTitle like '%" & Keyword & "%' "
        End Select
    End If
    
    TotalPut = PE_CLng(Conn.Execute("select Count(*) from PE_Supply A " & Querysql)(0))
    If CurrentPage > 1 Then
        Querysql = Querysql & " and A.SupplyID < (select min(SupplyId) from (select top " & ((CurrentPage - 1) * MaxPerPage) & " A.SupplyId from PE_Supply A " & Querysql & " order by A.SupplyId desc) as QueryArticle) "
    End If

    sql = sql & Querysql & " order by A.SupplyId desc"
    Set rsSupplyList = Server.CreateObject("ADODB.Recordset")
    'Call OpenConn()
    rsSupplyList.Open sql, Conn, 1, 1
    If rsSupplyList.BOF And rsSupplyList.EOF Then
        TotalPut = 0
        Response.Write "<tr class='tdbg'><td colspan='20' align='center'><br>"
        If ClassID > 0 Then
            Response.Write "此栏目及其子栏目中没有任何"
        Else
            Response.Write "没有任何"
        End If
       
        Select Case Status
            Case -1
                Response.Write "供求信息"
            Case 0
                Response.Write "<font color=blue>待审核</font>的" & ChannelShortName & "！"
            Case 1
                Response.Write "<font color=green>已审核</font>的" & ChannelShortName & "！"
            Case 2
                Response.Write "<font Color=green>过期</font>的信息!"
            Case Else
                Response.Write "供求信息！"
        End Select
      
        Response.Write "<br><br></td></tr>"
    Else
        Dim ArticleNum, ArticlePath
        ArticleNum = 0
        Do While Not rsSupplyList.EOF
            Response.Write "      <tr class='tdbg' onmouseout=""this.style.backgroundColor=''"" onmouseover=""this.style.backgroundColor='#BFDFFF'"">"
            Response.Write "        <td  align='center'><input name='SupplyId' type='checkbox' onclick='CheckItem(this)' id='SupplyId' value='" & rsSupplyList("SupplyId") & "'></td>"
            Response.Write "        <td  align='center'>" & rsSupplyList("SupplyId") & "</td>"
            If ManageType = "Special" Then
                Response.Write "     <td  align='Left'>" & rsSupplyList("SpecialName") & "</td>"
            End If
            Response.Write "        <td  align='Left'><a href='Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=Show&SupplyID=" & rsSupplyList("SupplyId") & "'><font color=red>[" & GetSupplyInfoType(rsSupplyList("SupplyType"), "//SupplyType/Type") & "]</font>&nbsp;" & rsSupplyList("SupplyTitle") & "</a></td>"
            Response.Write "        <td  align='center'>" & GetSupplyInfoType(rsSupplyList("TradeType"), "//TradeType/Type") & "</td>"
            Response.Write "        <td  align='center'>"
            If rsSupplyList("SupplyPeriod") = -1 Then
                Response.Write " 长期有效 "
            Else
                Response.Write rsSupplyList("SupplyPeriod") & "天"
            End If
            Response.Write "        </td>"
            Response.Write "        <td  align='center'>" & rsSupplyList("UserName") & "</td>"
            Response.Write "        <td  align='center'>" & rsSupplyList("UpdateTime") & "</td>"
            Response.Write "        <td  align='center'>" & rsSupplyList("Hits") & "</td>"
            Response.Write "        <td  align='center'>" & GetSupplyPeriod(rsSupplyList("UpdateTime"), rsSupplyList("SupplyPeriod")) & "&nbsp;" & GetSupplyStatus(rsSupplyList("Status")) & "&nbsp"
            Select Case rsSupplyList("CommandType")
                Case 1
                    Response.Write "&nbsp;<font Color=Red>频道推荐</font>"
                Case 2
                    Response.Write "&nbsp;<font Color=Red>栏目推荐</font>"
                
            End Select
            Response.Write "        </td><td  align='center'>"
            
            If ManageType = "Check" Then
                If rsSupplyList("Status") = 0 Then
                    Response.Write "    <a href=Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=SetPassed&SupplyId=" & rsSupplyList("SupplyId") & ">审核通过</a>"
                Else
                    Response.Write "    <a href=Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=CanCelPassed&SupplyId=" & rsSupplyList("SupplyId") & ">取消审核</a>"
                End If
            ElseIf ManageType = "Recyclebin" Then
                Response.Write "<a href='Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=ConfirmDel&SupplyID=" & rsSupplyList("SupplyID") & "' onclick=""return confirm('确定要彻底删除此" & ChannelShortName & "吗？彻底删除后将无法还原！');"">彻底删除</a> "
                Response.Write "<a href='Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=Restore&SupplyID=" & rsSupplyList("SupplyID") & "'>还原</a>"
            Else
                Response.Write "    <a href=Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=Modify&SupplyId=" & rsSupplyList("SupplyId") & ">修改</a>"
                Response.Write "    <a href=Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=Del&SupplyId=" & rsSupplyList("SupplyId") & " onclick=""return confirm('确定要删除此" & ChannelShortName & "吗？删除后你还可以从回收站中还原。');"">删除</a>"
                Response.Write "    <a href=Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=Move&SupplyId=" & rsSupplyList("SupplyId") & ">移动</a>"
            End If
            Response.Write "         </td>"
            Response.Write "    </tr>"
            rsSupplyList.MoveNext
      Loop
      rsSupplyList.Close
      Set rsSupplyList = Nothing
      'Call CloseConn()
  End If
  Response.Write "</Table>"
   Response.Write "<table width='100%' border='0' cellpadding='0' cellspacing='0'>"
    Response.Write "  <tr>"
    Response.Write "    <td width='200' height='30'><input name='chkAll' type='checkbox' id='chkAll' onclick='CheckAll(this.form)' value='checkbox'>选中本页显示的所有" & ChannelShortName & "</td><td>"
    If ManageType = "Check" Then
        Response.Write "<input name='submit1' type='submit' id='submit1' onClick=""document.myform.Action.value='SetPassed'"" value='审核通过选定的" & ChannelShortName & "'"
        If AdminPurview = 2 And AdminPurview_Channel > 2 And PurviewChecked = False Then Response.Write " disabled"
        Response.Write ">&nbsp;&nbsp;"
        Response.Write "<input name='submit2' type='submit' id='submit2' onClick=""document.myform.Action.value='CanCelPassed'"" value='取消审核选定的" & ChannelShortName & "'"
        If AdminPurview = 2 And AdminPurview_Channel > 2 And PurviewChecked = False Then Response.Write " disabled"
        Response.Write ">&nbsp;&nbsp;"
        Response.Write "<input name='submit3' type='submit' value='删除选定的" & ChannelShortName & "' onClick=""document.myform.Action.value='Del'"" "
        If AdminPurview = 2 And AdminPurview_Channel > 2 And PurviewChecked = False Then Response.Write "disabled"
        Response.Write ">"
     ElseIf ManageType = "Recyclebin" Then
        Response.Write "<input name='submit1' type='submit' id='submit1' onClick=""document.myform.Action.value='ConfirmDel'"" value='彻底删除选定的" & ChannelShortName & "'>&nbsp;"
        Response.Write "<input name='Submit2' type='submit' id='Submit2' onClick=""document.myform.Action.value='ClearRecyclebin'"" value='清空回收站'>&nbsp;&nbsp;&nbsp;&nbsp;"
        Response.Write "<input name='Submit3' type='submit' id='Submit3' onClick=""document.myform.Action.value='Restore'"" value='还原选定的" & ChannelShortName & "'>&nbsp;"
        Response.Write "<input name='Submit4' type='submit' id='Submit4' onClick=""document.myform.Action.value='RestoreAll'"" value='还原所有" & ChannelShortName & "'>"
     ElseIf ManageType = "Special" Then
        Response.Write "<input name='submit1' type='submit' id='submit1' onClick=""document.myform.Action.value='DelFromSpecial'"" value='将选定的" & ChannelShortName & "从所属专题中删除'>&nbsp;&nbsp;"
        Response.Write "<input name='Submit2' type='submit' id='Submit2' onClick=""document.myform.Action.value='MoveToSpecial'"" value='将选定的" & ChannelShortName & "移动到 ->'> "
        Response.Write "<select name='SpecialID' id='SpecialID'>" & GetSpecial_Option(0) & "</select>"
    
     Else
        Response.Write "<input name='submit1' type='submit' value='删除选定的" & ChannelShortName & "' onClick=""document.myform.Action.value='Del'"" "
        If PurviewChecked = False And AdminPurview = 2 And AdminPurview_Channel >= 3 Then Response.Write "disabled"
        Response.Write ">"
        If AdminPurview = 1 Or AdminPurview_Channel <= 2 Then
            Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' name='Submit4' value='批量移动' onClick=""document.myform.Action.value='BatchMove'"">"
        End If
    End If
    Response.Write "<input name='Action' type='hidden' id='Action' value=''>"
    Response.Write "<input name='ChannelID' type='hidden' id='ChannelID' value='" & ChannelID & "'>"
    Response.Write "  </td></tr>"
    Response.Write "</table>"
    Response.Write "</td>"
    Response.Write "</form></tr></table>"

    If TotalPut > 0 Then
        Response.Write ShowPage(strFileName, TotalPut, MaxPerPage, CurrentPage, True, True, ChannelItemUnit & ChannelShortName & "", True)
    End If

    Response.Write "<br>"
    If ClassID > 0 And Child > 0 Then
        Response.Write "<table width='100%' border='0' align='center' cellpadding='2' cellspacing='1' class='border'>"
        Response.Write "  <tr height='20' class='tdbg'>"
        Response.Write "    <td width='150' align='right'>【<a href='" & strFileName & "'>" & ClassName & "</a>】子栏目导航：</td>"
        Response.Write " <td>" & GetChildClass() & "</td></tr></table>"
    End If
    Response.Write GetSearchForm(FileName)
   
End Sub

'检查栏目管理员权限
Sub CheckAdminClassPuriew()
    If ClassID = 0 Then
        If strField = "" And AdminPurview = 2 And AdminPurview_Channel = 3 And ManageType <> "My" Then
            If ManageType = "Check" Then
                If arrClass_Check = "" Then
                    FoundErr = True
                    ErrMsg = ErrMsg & "<li>对不起，您没有在此频道审核" & ChannelShortName & "的权限！</li>"
                    Exit Sub
                End If
                Set tClass = Conn.Execute("select top 1 ClassID,ClassName,RootID,ParentID,Depth,ParentPath,Child,arrChildID,ClassPurview from PE_Class where ChannelID=" & ChannelID & " and ClassID In (" & DelRightComma(arrClass_Check) & ")")
            Else
            
                If arrClass_Manage = "" Then
                    FoundErr = True
                    ErrMsg = ErrMsg & "<li>对不起，您没有在此频道管理" & ChannelShortName & "的权限！</li>"
                    Call CloseConn
                    Exit Sub
                End If
                Set tClass = Conn.Execute("select top 1 ClassID,ClassName,RootID,ParentID,Depth,ParentPath,Child,arrChildID,ClassPurview from PE_Class where ChannelID=" & ChannelID & " and ClassID In (" & DelRightComma(arrClass_Manage) & ")")
            End If
            
            If tClass.BOF And tClass.EOF Then
                FoundErr = True
                ErrMsg = ErrMsg & "<li>对不起，您没有在此频道的管理权限！</li>"
            Else
                ClassID = tClass(0)
                ClassName = tClass(1)
                RootID = tClass(2)
                ParentID = tClass(3)
                Depth = tClass(4)
                ParentPath = tClass(5)
                Child = tClass(6)
                arrChildID = tClass(7)
                PurviewChecked = True
                ClassPurview = tClass(8)
            End If
        End If
    ElseIf ClassID = -1 Then
        If AdminPurview = 1 Or (AdminPurview = 2 And AdminPurview_Channel < 3) Then PurviewChecked = True
    End If
    
    If ClassID > 0 And PurviewChecked = False Then
        Set tClass = Conn.Execute("select ClassName,RootID,ParentID,Depth,ParentPath,Child,arrChildID,ClassPurview from PE_Class where ClassID=" & ClassID)
        If tClass.BOF And tClass.EOF Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>找不到指定的栏目</li>"
        Else
            ClassName = tClass(0)
            RootID = tClass(1)
            ParentID = tClass(2)
            Depth = tClass(3)
            ParentPath = tClass(4)
            Child = tClass(5)
            arrChildID = tClass(6)
            ClassPurview = tClass(7)
        End If
        Set tClass = Nothing
        
        If ManageType = "Check" Then
            If ParentID > 0 Then
                PurviewChecked = CheckPurview_Class(arrClass_Check, ParentPath & "," & ClassID)
            Else
                PurviewChecked = CheckPurview_Class(arrClass_Check, ClassID)
            End If
        Else
            If ParentID > 0 Then
                PurviewChecked = CheckPurview_Class(arrClass_Manage, ParentPath & "," & ClassID)
            Else
                PurviewChecked = CheckPurview_Class(arrClass_Manage, ClassID)
            End If
        End If
    End If
End Sub

Function GetSearchForm(Action)
    Dim strForm
    strForm = "<form method='Get' name='SearchForm' action='" & FileName & "'>"
    strForm = strForm & "<table width='100%' border='0' cellpadding='0' cellspacing='0' class='border'>"
    strForm = strForm & "  <tr class='tdbg'>"
    strForm = strForm & "   <td width='100' align='right'><strong>" & ChannelShortName & "搜索：</strong></td>"
    strForm = strForm & "   <td>"
    strForm = strForm & "<select name='Field' size='1'>"
    strForm = strForm & "<option value='Title' selected>" & ChannelShortName & "信息标题</option>"
    strForm = strForm & "<option value='Content'>" & ChannelShortName & "信息内容</option>"
    strForm = strForm & "<option value='UserName'>发布人</option>"
    strForm = strForm & "</select>"
    strForm = strForm & "<select name='ClassID'><option value=''>所有栏目</option>" & GetClass_Option(1, 0) & "</select>"
    strForm = strForm & "<input type='text' name='keyword'  size='20' value='关键字' maxlength='50' onFocus='this.select();'>"
    strForm = strForm & "<input type='submit' name='Submit'  value='搜索'>"
    strForm = strForm & "<input name='ManageType' type='hidden' id='ManageType' value='" & ManageType & "'>"
    strForm = strForm & "<input name='ChannelID' type='hidden' id='ChannelID' value='" & ChannelID & "'>"
    strForm = strForm & "</td></tr></table></form>"
    GetSearchForm = strForm
End Function


Sub ShowJS_Article()
    Response.Write "<script language = 'JavaScript'>" & vbCrLf

    Response.Write "function AddItem(strFileName){" & vbCrLf
    Response.Write "  var arrName=strFileName.split('.');" & vbCrLf
    Response.Write "  var FileExt=arrName[1];" & vbCrLf
    Response.Write "  if (FileExt=='gif'||FileExt=='jpg'||FileExt=='jpeg'||FileExt=='jpe'||FileExt=='bmp'||FileExt=='png'){" & vbCrLf
    Response.Write "  document.myform.DefaultPicUrl.value=strFileName;}" & vbCrLf
    Response.Write "  document.myform.DefaultPicList.options[document.myform.DefaultPicList.length]=new Option(strFileName,strFileName);" & vbCrLf
    Response.Write "  document.myform.DefaultPicList.selectedIndex+=1;" & vbCrLf
    Response.Write "  if(document.myform.UploadFiles.value==''){" & vbCrLf
    Response.Write "    document.myform.UploadFiles.value=strFileName;" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "  else{" & vbCrLf
    Response.Write "    document.myform.UploadFiles.value=document.myform.UploadFiles.value+'|'+strFileName;" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "}" & vbCrLf

    Response.Write "function CheckForm(){" & vbCrLf
    Response.Write "  var CurrentMode=editor.CurrentMode;" & vbCrLf
    Response.Write "  if (CurrentMode==0){" & vbCrLf
    Response.Write "    document.myform.Content.value=editor.HtmlEdit.document.body.innerHTML; " & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "  else if(CurrentMode==1){" & vbCrLf
    Response.Write "   document.myform.Content.value=editor.HtmlEdit.document.body.innerText;" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "  else{" & vbCrLf
    Response.Write "    alert('预览状态不能保存！请先回到编辑状态后再保存');" & vbCrLf
    Response.Write "    return false;" & vbCrLf
    Response.Write "  }" & vbCrLf

    Response.Write "  if (document.myform.ClassID.value==''){" & vbCrLf
    Response.Write "    alert('" & ChannelShortName & "所属栏目不能指定为外部栏目！');" & vbCrLf
    Response.Write "    return false;" & vbCrLf
    Response.Write "  }" & vbCrLf

    Response.Write "  if (document.myform.ClassID.value=='0'){" & vbCrLf
    Response.Write "    alert('指定的栏目不允许添加" & ChannelShortName & "！只允许在其子栏目中添加" & ChannelShortName & "。');" & vbCrLf
    Response.Write "    return false;" & vbCrLf
    Response.Write "  }" & vbCrLf

    Response.Write "  if (document.myform.SupplyTitle.value==''){" & vbCrLf
    Response.Write "     alert('" & ChannelShortName & "标题不能为空！');" & vbCrLf
    Response.Write "     return false;" & vbCrLf
    Response.Write "  }" & vbCrLf

    Response.Write "    if (document.myform.Content.value==''){" & vbCrLf
    Response.Write "      alert('" & ChannelShortName & "内容不能为空！');" & vbCrLf
    Response.Write "      return false;" & vbCrLf
    Response.Write "    }" & vbCrLf

    Response.Write "  return true;  " & vbCrLf
    Response.Write "}" & vbCrLf

    Response.Write "</script>" & vbCrLf
End Sub

Function ReplaceJSImage(ByVal Content)
    If Content = "" Then
        ReplaceJSImage = Content
        Exit Function
    End If
    Dim strTemp
    
    '图片替换JS
    regEx.Pattern = "(\<Script)(.[^\<]*)(\<\/Script\>)"
    Set Matches = regEx.Execute(Content)

    For Each Match In Matches
        strTemp = Replace(Match.value, "<", "[!")
        strTemp = Replace(strTemp, ">", "!]")
        strTemp = Replace(strTemp, "'", """")
        strTemp = "<IMG alt='#" & strTemp & "#' src=""" & InstallDir & "editor/images/jscript.gif"" border=0 $>"
        Content = Replace(Content, Match.value, strTemp)
    Next
    ReplaceJSImage = Content
End Function



Sub Add()
    Call ShowJS_Article
    Dim SupplyType, SupplyPeriod, TradeType, Status, ClassID, SpecialID, CommandType, DefaultPicUrl
    Dim SupplyName, SupplyTitle, SupplyIntro, PriceIntro, SupplyPicUrl, TemplateID, SkinID, Hits, arrSupplyPicUrl
    If Action = "Add" Then
        If ContacterID = 0 Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>你的用户信息填写不完整,请去修改你的个人信息!</li>"
        End If
    End If
    If FoundErr = True Then Exit Sub
    If Action = "Modify" Then
        Dim strSql, rs
        strSql = "Select * From PE_Supply Where SupplyId= " & SupplyId
        Set rs = Server.CreateObject("ADODB.Recordset")
        
        rs.Open strSql, Conn, 1, 1
        If rs.EOF And rs.BOF Then
            Response.Write "<li>不存在此数据!</li>"
            'Call CloseConn()
            Exit Sub
        Else
            ClassID = rs("ClassId")
            SpecialID = rs("SpecialId")
            SupplyType = rs("SupplyType")
            SupplyName = rs("SupplyName")
            SupplyTitle = rs("SupplyTitle")
            SupplyIntro = rs("SupplyIntro")
            SupplyPeriod = rs("SupplyPeriod")
            SkinID = rs("SkinId")
            PriceIntro = rs("PriceIntro")
            Status = rs("Status")
            SupplyPicUrl = rs("SupplyPicUrl")
            TemplateID = rs("TemplateId")
            TradeType = rs("TradeType")
            Hits = rs("Hits")
            CommandType = rs("CommandType")
            UserName = rs("UserName")
            If InStr(SupplyPicUrl, "|") > 0 Then
                arrSupplyPicUrl = Split(SupplyPicUrl, "|")
                DefaultPicUrl = arrSupplyPicUrl(0)
            End If
        End If
        rs.Close
        Set rs = Nothing
        'Call CloseConn()
    End If
    Response.Write "<br><table width='100%'><tr><td align='left'>您现在的位置：<a href='Admin_Supply.asp?ChannelID=" & ChannelID & "'>" & ChannelName & "管理</a>&nbsp;&gt;&gt;&nbsp;添加" & ChannelShortName & "</td></tr></table>"
    Response.Write "<form method='POST' name='myform' onSubmit='return CheckForm();' action='Admin_Supply.asp' target='_self'>"

    Response.Write "<table width='100%' border='0' align='center' cellpadding='5' cellspacing='0' class='border'>"
    Response.Write "  <tr align='center'>"
    Response.Write "    <td class='tdbg' height='200' valign='top'>"
    Response.Write "      <table width='98%' border='0' cellpadding='2' cellspacing='1' bgcolor='#FFFFFF'>"
    Response.Write "        <tbody id='Tabs' style='display:'>" & vbCrLf
    Response.Write "          <tr class='tdbg'>"
    Response.Write "            <td width='120' align='right' class='tdbg5'>" & ChannelShortName & "类别：</td>"
    Response.Write "            <td>"
    Response.Write "              <select name='ClassID' "
    If Action = "Add" Or CommandType = 0 Then
        Response.Write "onChange=""setBackValue('getClassCommandValue.asp?ClassID='+this.value)"""
    End If
    Response.Write ">" & GetClass_Option(3, ClassID) & "</select>"
    Response.Write "              &nbsp;&nbsp;&nbsp;&nbsp;<font color='#FF0000'><strong>注意：</strong></font>"
    Response.Write "              <font color='#0000FF'>不能指定为外部栏目</font>"
    If AdminPurview = 2 And AdminPurview_Channel = 3 Then
        Response.Write "<font color='#0000FF'>，并且你只能在<font color='#FF0000'>红色栏目</font>及其子栏目中发表" & ChannelShortName & "</font>"
    End If
    Response.Write "            </td>"
    Response.Write "          </tr>"
    Response.Write "          <tr class='tdbg'>"
    Response.Write "            <td width='120' align='right' class='tdbg5'>所属专题：</td>"
    Response.Write "            <td><select name='SpecialID' id='SpecialID'><option value='0'>不指定专题</option>" & GetSpecial_Option(SpecialID) & "</select></td>"
    Response.Write "          </tr>"
    If Action = "Add" Or CommandType = 0 Then
        Response.Write "          <tr class='tdbg'>"
        Response.Write "            <td width='120' align='right' class='tdbg5'>是否推荐：</td>"
        Response.Write "            <td>" & getCommandType(CommandType, CommandChannelPoint, PointName, PointUnit) & "</td>"
        Response.Write "          </tr>"
    End If
    Response.Write "          <tr class='tdbg'>"
    Response.Write "            <td width='120' align='right' class='tdbg5'>信息类型：</td>"
    Response.Write "            <td>" & GetSupplyInfo_Radio(SupplyType, "SupplyType", "//SupplyType/Type", 0) & "</td>"
    Response.Write "          </tr>"
    Response.Write "          <tr class='tdbg'>"
    Response.Write "            <td width='120' align='right' class='tdbg5'>交易方式：</td>"
    Response.Write "            <td>" & GetSupplyInfo_Radio(TradeType, "TradeType", "//TradeType/Type", 0) & "</td>"
    Response.Write "          </tr>"

    Response.Write "          <tr class='tdbg'>"
    Response.Write "            <td width='120' align='right' class='tdbg5'>信息标题：</td>"
    Response.Write "            <td>"
    Response.Write "            <input type='Text' Name='SupplyTitle' size='70' Maxlength='250' Value=" & SupplyTitle & ">&nbsp;<font color=red> * </font></td>"
    Response.Write "          </tr>"
    Response.Write "          <tr class='tdbg'>"
    Response.Write "            <td width='120' align='right' class='tdbg5'>信息有效期：</td>"
    Response.Write "            <td>" & GetSupplyPeriod_Select(SupplyPeriod) & "</td>"
    Response.Write "          </tr>"
    Response.Write "          <tr class='tdbg'>"
    Response.Write "            <td width='120' align='right' class='tdbg5'>产品名称：</td>"
    Response.Write "            <td><INPUT TYPE='text' NAME='SupplyName' size='30' Maxlength='200' Value =" & SupplyName & ">&nbsp;</td>"
    Response.Write "          </tr>"
    Response.Write "          <tr class='tdbg'>"
    Response.Write "            <td width='120' align='right' class='tdbg5'>价格说明：</td>"
    Response.Write "            <td>"
    Response.Write "            <input type='Text' Name='PriceIntro' size='30' Maxlength='250' Value=" & PriceIntro & ">&nbsp;</td>"
    Response.Write "          </tr>"
    
    Response.Write "          <tr class='tdbg'>"
    Response.Write "            <td width='120' align='right' valign='middle' class='tdbg5'><strong>" & ChannelShortName & "简介：</strong></td>"
    Response.Write "            <td>"
    Response.Write "              <textarea name='Content' cols='60' rows='5' id='Content' style='display:none'>" & FilterJS(SupplyIntro) & "</textarea>"
    Response.Write "               <iframe ID='editor' src='../editor.asp?ChannelID=" & ChannelID & "&ShowType=5&tContentid=Content' frameborder='1' scrolling='no' width='680' height='300' ></iframe>"
    Response.Write "            </td>"
    Response.Write "          </tr>"
    Response.Write "        </tbody>" & vbCrLf
    
    Response.Write "        <tbody id='Tabs'>" & vbCrLf
   
    Response.Write "          <tr class='tdbg'>"
    Response.Write "            <td width='120' align='right' class='tdbg5'><font color='#FF0000'>首页图片：</font></td>"
    Response.Write "            <td>"
    Response.Write "              <input name='DefaultPicUrl' type='text' id='DefaultPicUrl' size='56' maxlength='200' value='" & DefaultPicUrl & "' readonly>"
    Response.Write "              用于在首页的图片" & ChannelShortName & "处显示 <br>直接从上传图片中选择："
    Response.Write "              <select name='DefaultPicList' id='DefaultPicList' onChange=""DefaultPicUrl.value=this.value;"">"
    If InStr(SupplyPicUrl, "|") > 0 Then
        Dim intTemp
        arrSupplyPicUrl = Split(SupplyPicUrl, "|")
        For intTemp = 0 To UBound(arrSupplyPicUrl)
            Response.Write "<option Value='" & arrSupplyPicUrl(intTemp) & "'>" & arrSupplyPicUrl(intTemp) & "</Option>"
        Next
    Else
        If SupplyPicUrl <> "" Then
            Response.Write "<option Value='" & SupplyPicUrl & "'>" & SupplyPicUrl & "</Option>"
        End If
    End If
    Response.Write "                <option selected>不指定首页图片</option>"
    Response.Write "              </select>"
    Response.Write "              <input name='UploadFiles' type='hidden' id='UploadFiles' Value='" & SupplyPicUrl & "'>"
    Response.Write "            </td>"
    Response.Write "          </tr>"

    If Action = "Add" Then
        Response.Write "          <tr class='tdbg'>"
        Response.Write "            <td width='120' align='right' class='tdbg5'>录入时间：</td>"
        Response.Write "            <td>"
        Response.Write "              <input name='UpdateTime' type='text' id='UpdateTime' value='" & Now() & "' maxlength='50'> 时间格式为“年-月-日 时:分:秒”，如：<font color='#0000FF'>2003-5-12 12:32:47</font>"
        Response.Write "            </td>"
        Response.Write "          </tr>"
    End If
    Response.Write "          <tr class='tdbg'>"
    Response.Write "            <td width='120' align='right' class='tdbg5'>配色风格：</td>"
    Response.Write "            <td><select Name='SkinID'>" & GetSkin_Option(Session("SkinID")) & "</select>&nbsp;相关模板中包含CSS、颜色、图片等信息</td>"
    Response.Write "          </tr>"
    Response.Write "          <tr class='tdbg'>"
    Response.Write "            <td width='120' align='right' class='tdbg5'>版面设计模板：</td>"
    Response.Write "            <td><select Name='TemplateID'>" & GetTemplate_Option(ChannelID, 3, Session("TemplateID")) & "</select>&nbsp;相关模板中包含了版面设计的版式等信息</td>"
    Response.Write "          </tr>"

    Response.Write "          <tr class='tdbg'>"
    Response.Write "            <td width='120' align='right' class='tdbg5'>点击数：</td>"
    Response.Write "            <td><INPUT TYPE='Input' NAME='Hits' size=7 MaxLeng=20 Value=" & Hits & "></td>"
    Response.Write "          </tr>"

    Response.Write "          <tr class='tdbg'>"
    Response.Write "            <td width='120' align='right' class='tdbg5'>信息状态：</td>"
    Response.Write "            <td><INPUT TYPE='radio' NAME='Status' Value=0 "
    If Status = 0 Then Response.Write "Checked"
    Response.Write ">待审核&nbsp;&nbsp;<INPUT TYPE='radio' NAME='Status' Value=1 "
    If Status = 1 Or Action = "Add" Then Response.Write "Checked"
    Response.Write ">立即发布</td>"
    Response.Write "          </tr>"

    Response.Write "        </tbody>" & vbCrLf
    
    Response.Write "        </table>"
    Response.Write "      </td>"
    Response.Write "    </tr>"
    Response.Write "  </table>"
    
    Response.Write "  <p align='center'>"
    
    Response.Write "   <input name='Action' type='hidden' id='Action' value=''>"
    
 
    Response.Write "   <input name='ChannelID' type='hidden' id='ChannelID' value='" & ChannelID & "'>"
    Response.Write "   <input name='UserName' type='hidden'  id='UserName' value='" & UserName & "'>"
    If Action = "Modify" Then
        Response.Write "   <input name='Modify' type='submit'  id='Modify' value=' 保存修改结果 ' onClick=""document.myform.Action.value='SaveModify';document.myform.target='_self';"" style='cursor:hand;'>&nbsp;"
        Response.Write "   <input name='add' type='submit'  id='Add' value=' 保存为添加 ' onClick=""document.myform.Action.value='SaveAdd';document.myform.target='_self';"" style='cursor:hand;'>&nbsp; "
        Response.Write "   <input name='SupplyId' type='hidden' id='SupplyId' value='" & SupplyId & "'>"
    Else
        Response.Write "   <input name='add' type='submit'  id='Add' value=' 添 加 ' onClick=""document.myform.Action.value='SaveAdd';document.myform.target='_self';"" style='cursor:hand;'>&nbsp; "
    End If
    'Response.Write "   <input name='Preview' type='submit'  id='Preview' value=' 预 览 ' onClick=""document.myform.Action.value='Preview';document.myform.target='_blank';"" style='cursor:hand;'>"
    Response.Write "   <input name='Cancel' type='button' id='Cancel' value=' 取 消 ' onClick=""window.location.href='Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=Manage';"" style='cursor:hand;'>"
    Response.Write "  </p><br>"
    Response.Write "</form>"
    If Action = "Add" Or CommandType = 0 Then
        Call SetAjax
    End If
End Sub



'2006-5-15 修正扣除点数错误和审核统计错误 -- 刘永涛
'2007-01-16 修正过期的信息修改后重新计算有效期为修改时间。
Sub SaveSupply()
    Dim rsSupply, strSql
    Dim SupplyId, SupplyType, SupplyName, TradeType, PriceIntro, SupplyTitle, SupplyPeriod, Content, Status
    Dim UpdateTime, CreateImmediate, SkinID, TemplateID, ChannelID, SupplyPicUrl, UserName, Hits, CommandType
    Dim Point, CommandChannelDays, CommandClassDays, ReleasePoint, DefaultPicUrl
    'Dim TempChannelDays,TempClassDays
    ChannelID = PE_CLng(Trim(Request.Form("ChannelId")))
    ClassID = PE_CLng(Trim(Request.Form("ClassID")))
    SpecialID = PE_CLng(Trim(Request.Form("SpecialID")))
    SkinID = PE_CLng(Trim(Request.Form("SkinID")))
    TemplateID = PE_CLng(Trim(Request.Form("TemplateID")))
    SupplyId = PE_CLng(Trim(Request.Form("SupplyId")))
    SupplyType = PE_CLng(Trim(Request.Form("SupplyType")))
    SupplyName = Trim(Request.Form("SupplyName")) '产品名称
    TradeType = PE_CLng(Trim(Request.Form("TradeType"))) '交易方式
    PriceIntro = Trim(Request.Form("PriceIntro")) '价格说明
    SupplyTitle = Trim(Request.Form("SupplyTitle")) '信息标题
    SupplyPeriod = PE_CLng(Trim(Request.Form("SupplyPeriod"))) '信息有效期
    Content = Trim(Request.Form("Content"))   '产品简介
    Hits = PE_CLng(Trim(Request.Form("Hits"))) '点击数
    UpdateTime = PE_CDate(Trim(Request.Form("UpdateTime")))
    SupplyPicUrl = PE_HTMLEncode(Trim(Request.Form("UploadFiles"))) '图片地址
    
    UserName = ReplaceText(Trim(Request.Form("UserName")), 2) '添加人的姓名
    Status = PE_CLng(Trim(Request.Form("Status"))) '信息状态
    DefaultPicUrl = Trim(Request.Form("DefaultPicUrl"))
    
    CommandType = PE_CLng(Trim(Request.Form("CommandType"))) '推荐类型
    CommandChannelDays = PE_CLng(Trim(Request.Form("CommandChannelDays"))) '频道推荐的天数
    CommandClassDays = PE_CLng(Trim(Request.Form("CommandClassDays"))) '栏目推荐的天数

    Dim strSiteUrl
    strSiteUrl = InstallDir & ChannelDir & "/"
    Content = Replace(Content, "'" & strSiteUrl, "'" & "[InstallDir_ChannelDir]")
    Content = Replace(Content, """" & strSiteUrl, """" & "[InstallDir_ChannelDir]")
    Content = Replace(Content, "=" & strSiteUrl, "=" & "[InstallDir_ChannelDir]")
	
    If Not (CheckClassPurview(Action, ClassID)) Then '
        Exit Sub
    End If
    
    If SupplyTitle = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>" & ChannelShortName & "标题不能为空</li>"
    Else
        SupplyTitle = ReplaceText(SupplyTitle, 2)
    End If
    
    '开始添加数据
    '首先检测用户的点数是否够用，如果够了，才可以添加信息
    Select Case CommandType
       ' Case 0
           ' Point =
        Case 1
            Point = PE_CLng(CommandChannelPoint * CommandChannelDays) '+ PE_CLng(GetTypePoint(SupplyType, "//SupplyType/Type", "Point")))
        Case 2
            Point = PE_CLng(getCommandClassPoint(ClassID) * CommandClassDays) '+ PE_CLng(GetTypePoint(SupplyType, "//SupplyType/Type", "Point")))
        Case Else
            Point = 0
    End Select
    ReleasePoint = PE_CLng(getReleaseClassPoint(ClassID, SupplyType)) + Point
    'If Action = "SaveAdd" Then
    Call CheckUserPoint(ReleasePoint, UserName) '检查的点数是否够用
    'End If

    If FoundErr = True Then
        Exit Sub
    End If

    SupplyTitle = PE_HTMLEncode(SupplyTitle)
    SupplyName = PE_HTMLEncode(SupplyName)
    SupplyName = ReplaceText(SupplyName, 2)
    PriceIntro = ReplaceText(PriceIntro, 2)
    Content = ReplaceText(Content, 2)

    If UpdateTime <> "" And IsDate(UpdateTime) = True Then
        UpdateTime = CDate(UpdateTime)
    Else
        UpdateTime = Now()
    End If
    SupplyPicUrl = getOrderPicUrl(SupplyPicUrl, DefaultPicUrl)
    If Action = "SaveAdd" Then
        Dim mrs
        'Call OpenConn()
        Set mrs = Conn.Execute("select max(SupplyId) from PE_Supply")
        If IsNull(mrs(0)) Then
            SupplyId = 1
        Else
            SupplyId = mrs(0) + 1
        End If
        Set mrs = Nothing
        strSql = "Select Top 1 * From PE_Supply"
        
        Set rsSupply = Server.CreateObject("Adodb.Recordset")
        rsSupply.Open strSql, Conn, 1, 3
        rsSupply.AddNew
        rsSupply("ChannelId") = ChannelID
        rsSupply("SupplyId") = SupplyId
        rsSupply("ClassId") = ClassID
        rsSupply("SpecialId") = SpecialID
        rsSupply("SupplyName") = SupplyName
        rsSupply("SupplyType") = SupplyType
        rsSupply("SupplyTitle") = SupplyTitle
        rsSupply("SupplyIntro") = Content
        rsSupply("SupplyPeriod") = SupplyPeriod
        rsSupply("TradeType") = TradeType
        rsSupply("PriceIntro") = PriceIntro
        rsSupply("SupplyPicUrl") = SupplyPicUrl
        rsSupply("UpdateTime") = UpdateTime
        rsSupply("Hits") = Hits
        rsSupply("Status") = Status
        rsSupply("UserName") = UserName
        rsSupply("TemplateId") = TemplateID
        rsSupply("SkinId") = SkinID
        
        rsSupply("CommandType") = CommandType
        rsSupply("CommandChannelDays") = CommandChannelDays
        rsSupply("CommandClassDays") = CommandClassDays

        rsSupply("Deleted") = False
        rsSupply.Update
        rsSupply.Close
        Set rsSupply = Nothing
        If Status = 1 Then
            Conn.Execute ("update PE_Channel set ItemCount=ItemCount+1,ItemChecked=ItemChecked+1 where ChannelID=" & ChannelID & "")
            Conn.Execute ("update PE_Class set ItemCount=ItemCount+1 where ClassID=" & ClassID & "")
            '如果是栏目不指定任何栏目的话，按频道标准来减去点数，如果是在栏目下的话，按栏目减去，然后记录到消费记录表内
            Conn.Execute ("update PE_User set PostItems=PostItems+1,PassedItems=PassedItems+1,UserPoint=UserPoint-" & ReleasePoint & " where UserName='" & UserName & "'")
            
            If CommandType = 1 And Point > 0 Then
                Call AddConsumeLog("System", ModuleType, UserName, SupplyId, ReleasePoint, 2, "发布供求+设定频道推荐")
            ElseIf CommandType = 2 And Point > 0 Then
                Call AddConsumeLog("System", ModuleType, UserName, SupplyId, ReleasePoint, 2, "发布供求+设定栏目推荐")
            Else
                Call AddConsumeLog("System", ModuleType, UserName, SupplyId, ReleasePoint, 2, "发布供求信息")
            End If
        Else
            Conn.Execute ("update PE_Channel set ItemCount=ItemCount+1 where ChannelID=" & ChannelID & "")
            Conn.Execute ("update PE_User set PostItems=PostItems+1 where UserName='" & UserName & "'")
            If CommandType = 2 And Point > 0 Then
                Conn.Execute ("update PE_User set UserPoint=UserPoint-" & Point & " where UserName='" & UserName & "'")
                Call AddConsumeLog("System", ModuleType, UserName, SupplyId, Point, 2, "设定栏目推荐")
            End If
            If CommandType = 1 And Point > 0 Then
                Conn.Execute ("update PE_User set UserPoint=UserPoint-" & Point & " where UserName='" & UserName & "'")
                Call AddConsumeLog("System", ModuleType, UserName, SupplyId, Point, 2, "设定频道推荐")
            End If
        End If
    Else
        If SupplyId <> "" Then
            strSql = "Select Top 1 * From PE_Supply Where SupplyId=" & SupplyId
            Set rsSupply = Server.CreateObject("Adodb.Recordset")
           
            rsSupply.Open strSql, Conn, 1, 3
            If rsSupply.EOF Or rsSupply.BOF Then
                FoundErr = True
                ErrMsg = ErrMsg & "<li>找不到此" & ChannelShortName & "，可能已经被其他人删除。</li>"
            Else
                If Status = 1 And rsSupply("Status") = 0 Then
                    Conn.Execute ("UPDATE PE_Channel SET ItemChecked=ItemChecked+1 WHERE ChannelID=" & ChannelID & "")
                    Conn.Execute ("update PE_Class set ItemCount=ItemCount+1 where ClassID=" & ClassID & "")
                    Conn.Execute ("UPDATE PE_User SET PassedItems=PassedItems+1,UserPoint=UserPoint-" & ReleasePoint & " WHERE UserName='" & UserName & "'")
                    If CommandType = 1 And Point > 0 Then
                        rsSupply("CommandType") = CommandType
                        rsSupply("CommandChannelDays") = CommandChannelDays
                        rsSupply("CommandClassDays") = CommandClassDays
                        Call AddConsumeLog("System", ModuleType, UserName, SupplyId, ReleasePoint, 2, "发布供求+设定频道推荐")
                    ElseIf CommandType = 2 And Point > 0 Then
                        rsSupply("CommandType") = CommandType
                        rsSupply("CommandChannelDays") = CommandChannelDays
                        rsSupply("CommandClassDays") = CommandClassDays
                        Call AddConsumeLog("System", ModuleType, UserName, SupplyId, ReleasePoint, 2, "发布供求+设定栏目推荐")
                    Else
                        Call AddConsumeLog("System", ModuleType, UserName, SupplyId, ReleasePoint, 2, "发布供求信息")
                    End If
               ' End If
                ElseIf Status = 0 And rsSupply("Status") = 1 Then
                    Conn.Execute ("UPDATE PE_Channel SET ItemChecked=ItemChecked-1 WHERE ChannelID=" & ChannelID & "")
                    Conn.Execute ("update PE_Class set ItemCount=ItemCount-1 where ClassID=" & ClassID & "")
                    If CommandType = 1 And Point > 0 Then
                        rsSupply("CommandType") = CommandType
                        rsSupply("CommandChannelDays") = CommandChannelDays
                        rsSupply("CommandClassDays") = CommandClassDays
                        Conn.Execute ("UPDATE PE_User SET PassedItems=PassedItems-1,UserPoint = UserPoint-" & Point & " WHERE UserName='" & UserName & "'")
                        Call AddConsumeLog("System", ModuleType, UserName, SupplyId, Point, 2, "设定频道推荐")
                    ElseIf CommandType = 2 And Point > 0 Then
                        rsSupply("CommandType") = CommandType
                        rsSupply("CommandChannelDays") = CommandChannelDays
                        rsSupply("CommandClassDays") = CommandClassDays
                        Conn.Execute ("UPDATE PE_User SET PassedItems=PassedItems-1,UserPoint = UserPoint-" & Point & " WHERE UserName='" & UserName & "'")
                        Call AddConsumeLog("System", ModuleType, UserName, SupplyId, Point, 2, "设定栏目推荐")
                    End If
                Else
                    If CommandType = 1 And Point >= 0 Then
                        rsSupply("CommandType") = CommandType
                        rsSupply("CommandChannelDays") = CommandChannelDays
                        rsSupply("CommandClassDays") = CommandClassDays
                        Conn.Execute ("UPDATE PE_User SET PassedItems=PassedItems-1,UserPoint = UserPoint-" & Point & " WHERE UserName='" & UserName & "'")
                        Call AddConsumeLog("System", ModuleType, UserName, SupplyId, Point, 2, "设定频道推荐")
                    ElseIf CommandType = 2 And Point >= 0 Then
                        rsSupply("CommandType") = CommandType
                        rsSupply("CommandChannelDays") = CommandChannelDays
                        rsSupply("CommandClassDays") = CommandClassDays
                        Conn.Execute ("UPDATE PE_User SET PassedItems=PassedItems-1,UserPoint = UserPoint-" & Point & " WHERE UserName='" & UserName & "'")
                        Call AddConsumeLog("System", ModuleType, UserName, SupplyId, Point, 2, "设定栏目推荐")
                    End If
                End If
                rsSupply("ClassId") = ClassID
                rsSupply("SpecialId") = SpecialID
                rsSupply("SupplyName") = SupplyName
                rsSupply("SupplyType") = SupplyType
                rsSupply("SupplyTitle") = SupplyTitle
                rsSupply("SupplyIntro") = Content
                rsSupply("SupplyPeriod") = SupplyPeriod
                rsSupply("TradeType") = TradeType
                rsSupply("PriceIntro") = PriceIntro
                rsSupply("SupplyPicUrl") = SupplyPicUrl
                rsSupply("Hits") = Hits
                rsSupply("Status") = Status
                
                rsSupply("UpdateTime") = UpdateTime
                'rsSupply("UserName") = UserName
                rsSupply("TemplateId") = TemplateID
                rsSupply("SkinId") = SkinID
                rsSupply.Update
                rsSupply.Close
                Set rsSupply = Nothing
            End If

        End If
    End If
    Response.Write "<br><br>"
    Response.Write "<table class='border' align=center width='500' border='0' cellpadding='2' cellspacing='1'>"
    Response.Write "  <tr align=center> "
    Response.Write "    <td  height='22' align='center' class='title' colspan='2'> "
    If Action = "SaveAdd" Then
        Response.Write "<b>添加" & ChannelShortName & "成功</b>"
    Else
        Response.Write "<b>修改" & ChannelShortName & "成功</b>"
    End If
    Response.Write "    </td>"
    Response.Write "  </tr>"
    Response.Write "  <tr class='tdbg'>"
    Response.Write "    <td width='100' align='right' class='tdbg5'><strong>所属栏目：</td>"
    Response.Write "    <td width='400'>" & ShowClassPath() & "</td>"
    Response.Write "  </tr>"
    Response.Write "  <tr class='tdbg'>"
    Response.Write "    <td width='100' align='right' class='tdbg5'><strong>" & ChannelShortName & "标题：</td>"
    Response.Write "    <td width='400'>" & SupplyTitle & "</td>"
    Response.Write "  </tr>"
    Response.Write "  <tr class='tdbg'>"
    Response.Write "    <td width='100' align='right' class='tdbg5'><strong>" & ChannelShortName & "作者：</td>"
    Response.Write "    <td width='400'>" & UserName & "</td>"
    Response.Write "  </tr>"
    Response.Write "  <tr class='tdbg'>"
    Response.Write "    <td width='100' align='right' class='tdbg5'><strong>" & ChannelShortName & "状态：</strong></td>"
    Response.Write "    <td width='400'>"
    If Status = 0 Then
        Response.Write "待审核"
    Else
        Response.Write "直接发布"
    End If
    Response.Write "</td>"
    Response.Write "  </tr>"
    Response.Write "  <tr class='tdbg'>"
    Response.Write "    <td height='40' colspan='2' align='center'>"
    Response.Write "【<a href='Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=Modify&SupplyID=" & SupplyId & "'>修改此" & ChannelShortName & "</a>】&nbsp;"
    Response.Write "【<a href='Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=Add&ClassID=" & ClassID & "&SpecialID=" & SpecialID & "'>继续添加" & ChannelShortName & "</a>】&nbsp;"
    Response.Write "【<a href='Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=Manage&ClassID=" & ClassID & "'>" & ChannelShortName & "管理</a>】&nbsp;"
    Response.Write "【<a href='Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=Show&SupplyID=" & SupplyId & "'>预览" & ChannelShortName & "内容</a>】"
    Response.Write "    </td>"
    Response.Write "  </tr>"
    Response.Write "</table>" & vbCrLf
    'Response.Redirect ComeUrl
    Call ClearSiteCache(0)
    'Call CreateAllJS
End Sub

Function getOrderPicUrl(SupplyPicUrl, DefaultPicUrl)
    getOrderPicUrl = SupplyPicUrl
    If InStr(SupplyPicUrl, "|") > 0 Or DefaultPicUrl <> "" Then
        If InStr(SupplyPicUrl & "|", DefaultPicUrl & "|") > 0 Then
            SupplyPicUrl = SupplyPicUrl & "|"
            SupplyPicUrl = Replace(SupplyPicUrl, DefaultPicUrl & "|", "")
            If Right(SupplyPicUrl, 1) = "|" Then
                SupplyPicUrl = Left(SupplyPicUrl, Len(SupplyPicUrl) - 1)
            End If
            getOrderPicUrl = DefaultPicUrl & "|" & SupplyPicUrl
        End If
    End If
End Function
'*******************************
'检查用户的可用点数
'刘永涛
'2005-12-9
'********************************
Function CheckUserPoint(ByVal PresentExp, ByVal UserName)
    Dim UserPoint
    If UserName = AdminName Then
        UserPoint = getUserPoint(AdminName)
    Else
        UserPoint = getUserPoint(UserName)
    End If
    If PresentExp > UserPoint Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>你的点数不够，不可以发布信息！</li>"
    End If
End Function

Function getUserPoint(ByVal UserName)
    Dim strSql
    strSql = "SELECT UserPoint FROM PE_User WHERE UserName = '" & UserName & "'"
    getUserPoint = PE_CLng(Conn.Execute(strSql)(0))
End Function
'获得栏目的推荐点数
Function getCommandClassPoint(ByVal ClassID)
    Dim strSql
    strSql = "Select CommandClassPoint From PE_Class Where ClassId=" & ClassID & ""
    'Call OpenConn()
    getCommandClassPoint = PE_CLng(Conn.Execute(strSql)(0))
    'Call CloseConn()
End Function
'获得栏目发布需要的点数
Function getReleaseClassPoint(ByVal ClassID, ByVal SupplyType)
    Dim strSql
    strSql = "Select ReleaseClassPoint From PE_Class Where ClassId = " & ClassID & ""
    'Call OpenConn()
    getReleaseClassPoint = PE_CLng(Conn.Execute(strSql)(0)) + PE_CLng(GetTypePoint(SupplyType, "//SupplyType/Type", "Point"))
    'Call CloseConn()
End Function

'******************************************************************************************
'以下为显示和预览内容时使用的函数。
'******************************************************************************************

Sub Show()
    If SupplyId = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定" & ChannelShortName & "ID！</li>"
        Exit Sub
    Else
        SupplyId = PE_CLng(SupplyId)
    End If
    
    Dim rsSupply, sqlSupply, PurviewChecked, PurviewChecked2
    PurviewChecked = False
    PurviewChecked2 = False
    sqlSupply = "select SupplyId,ChannelId,ClassId,SpecialId,SupplyName,SupplyType,SupplyTitle,SupplyIntro,SupplyPeriod,TradeType,PriceIntro,UserName,UpdateTime,Deleted,Status from PE_Supply where SupplyID=" & SupplyId & ""
    'Call OpenConn()
    Set rsSupply = Conn.Execute(sqlSupply)
    If rsSupply.BOF And rsSupply.EOF Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>找不到" & ChannelShortName & "！</li>"
    Else
        ClassID = rsSupply("ClassID")
        Call CheckClassPurview(Action, ClassID)
    End If
    If FoundErr = True Then
        rsSupply.Close
        Set rsSupply = Nothing
        Call CloseConn
        Exit Sub
    End If
    
    If AdminPurview = 1 Or AdminPurview_Channel <= 2 Then
        PurviewChecked = True
        PurviewChecked2 = True
    Else
        If ParentID > 0 Then
            PurviewChecked = CheckPurview_Class(arrClass_Manage, ParentPath & "," & ClassID)
            PurviewChecked2 = CheckPurview_Class(arrClass_Check, ParentPath & "," & ClassID)
        Else
            PurviewChecked = CheckPurview_Class(arrClass_Manage, ClassID)
            PurviewChecked2 = CheckPurview_Class(arrClass_Check, ClassID)
        End If
    End If

    Response.Write "<SCRIPT language='javascript'>" & vbCrLf
    Response.Write "function resizepic(thispic){" & vbCrLf
    Response.Write "  if(thispic.width>600) thispic.width=600;" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "function bbimg(o){" & vbCrLf
    Response.Write "  var zoom=parseInt(o.style.zoom, 10)||100;" & vbCrLf
    Response.Write "  zoom+=event.wheelDelta/12;" & vbCrLf
    Response.Write "  if (zoom>0) o.style.zoom=zoom+'%';" & vbCrLf
    Response.Write "  if (zoom>0) o.style.zoom=zoom+'%';" & vbCrLf
    Response.Write "  return false;" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "</SCRIPT>" & vbCrLf


    Response.Write "<br>您现在的位置：&nbsp;<a href='Admin_Supply.asp?ChannelID=" & ChannelID & "'>" & ChannelShortName & "管理</a>&nbsp;&gt;&gt;&nbsp;"
    If ParentID > 0 Then
        Dim sqlPath, rsPath
        sqlPath = "select ClassID,ClassName from PE_Class where ClassID in (" & ParentPath & ") order by Depth"
        Set rsPath = Conn.Execute(sqlPath)
        Do While Not rsPath.EOF
            Response.Write "<a href='Admin_Supply.asp?ChannelID=" & ChannelID & "&ClassID=" & rsPath(0) & "'>" & rsPath(1) & "</a>&nbsp;&gt;&gt;&nbsp;"
            rsPath.MoveNext
        Loop
        rsPath.Close
        Set rsPath = Nothing
    End If
    Response.Write "<a href='Admin_Supply.asp?ChannelID=" & ChannelID & "&ClassID=" & ClassID & "'>" & ClassName & "</a>&nbsp;&gt;&gt;&nbsp;查看" & ChannelShortName & "内容："
      
    Response.Write rsSupply("SupplyTitle") & "<br><br>"

    Response.Write "<table width='100%' border='0' align='center' cellpadding='5' cellspacing='0' class='border'>"
    Response.Write "  <tr align='center'>"
    Response.Write "    <td class='tdbg' height='200' valign='top'>"
    Response.Write "      <table width='98%' border='0' cellpadding='2' cellspacing='1' bgcolor='#FFFFFF'>"
    Response.Write "        <tbody id='Tabs' style='display:'>" & vbCrLf
     
    Response.Write "  <tr align='Left' class='tdbg'>"
    Response.Write "    <td width='10%'><b>信息类型：</b></b></td>"
    Response.Write "    <td>" & GetSupplyInfoType(rsSupply("SupplyType"), "//SupplyType/Type") & "</td>"
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr align='Left' class='tdbg'>"
    Response.Write "    <td><b>信息标题：</b></td>"
    Response.Write "    <td>" & rsSupply("SupplyTitle") & "</td>"
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr align='Left' class='tdbg'>"
    Response.Write "    <td><b>交易方式：</b></td>"
    Response.Write "    <td>" & GetSupplyInfoType(rsSupply("TradeType"), "//TradeType/Type") & "</td>"
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr align='Left' class='tdbg'>"
    Response.Write "    <td><b>产品名称：</b></td>"
    Response.Write "    <td>" & rsSupply("SupplyName") & "</td>"
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr align='Left' class='tdbg'>"
    Response.Write "    <td><b>价格说明：</b></td>"
    Response.Write "    <td>" & rsSupply("PriceIntro") & "</td>"
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr align='Left' class='tdbg'>"
    Response.Write "    <td><b>发布时间：</b></td>"
    Response.Write "    <td>" & rsSupply("UpdateTime") & "</td>"
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr align='Left' class='tdbg'>"
    Response.Write "    <td><b>有效期至：</b></td>"
    If rsSupply("SupplyPeriod") <> -1 Then
        Response.Write "    <td>" & DateAdd("d", rsSupply("SupplyPeriod"), rsSupply("UpdateTime")) & "</td>"
    Else
        Response.Write "    <td>长期有效</td>"
    End If
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr class='tdbg'>"
    Response.Write "    <td align='Left'><b>详细内容:</b></td>"
    Response.Write "    <td >"
     Response.Write "<p>" & Replace(Replace(FilterJS(rsSupply("SupplyIntro")), "[InstallDir_ChannelDir]", InstallDir & ChannelDir & "/"), "{$UploadDir}", UploadDir) & "</p>"
    Response.Write "</td>"
    Response.Write "  </tr>" & vbCrLf
        
    Response.Write "        </tbody>" & vbCrLf
    Response.Write "      </table>"
    Response.Write "    </td>"
    Response.Write "  </tr>"
    Response.Write "</table>" & vbCrLf
    Response.Write "<p align='center'>" & vbCrLf
    If rsSupply("Deleted") = False Then
        If (rsSupply("UserName") = UserName And rsSupply("Status") = 0) Or PurviewChecked = True Then
            Response.Write "<input type='button' name='buttons' value='修改/审核' onclick=""window.location.href='Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=Modify&SupplyID=" & rsSupply("SupplyID") & "'"">&nbsp;&nbsp;"
            Response.Write "<input type='button' name='buttons' value=' 删 除 ' onclick=""window.location.href='Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=Del&SupplyID=" & rsSupply("SupplyID") & "'"">&nbsp;&nbsp;"
        End If
        If AdminPurview = 1 Or AdminPurview_Channel <= 2 Then
            Response.Write "<input type='button' name='buttons' value=' 移 动 ' onclick=""window.location.href='Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=Move&SupplyID=" & rsSupply("SupplyID") & "'"">&nbsp;&nbsp;"
        End If
    End If
    
    Response.Write "<input type='button' name='buttons' value='彻底删除' onclick=""if(confirm('确定要彻底删除此" & ChannelShortName & "吗？彻底删除后将无法还原！')==true){window.location.href='Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=Del&SupplyId=" & rsSupply("SupplyId") & "';}"">&nbsp;&nbsp;"
    Response.Write "</p>"

    rsSupply.Close
    Set rsSupply = Nothing
    'Call CloseConn()
    Call ShowComment(SupplyId)
End Sub


'预览信息
Sub Preview()
    Response.Write "<br><table width='760' border='0' align='center' cellpadding='5' cellspacing='0' class='border'>"
    Response.Write "  <tr class='title'>"
    Response.Write "    <td width='400' height='22'>"

    If ClassID = 0 Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定所属栏目</li>"
        Exit Sub
    ElseIf ClassID > 0 Then
        'Call OpenConn()
        Set tClass = Conn.Execute("select ClassName,ParentID,ParentPath from PE_Class where ClassID=" & ClassID)
        If tClass.BOF And tClass.EOF Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>找不到指定的栏目</li>"
            Set tClass = Nothing
            Exit Sub
        Else
            ClassName = tClass(0)
            ParentID = tClass(1)
            ParentPath = tClass(2)
        End If
        Set tClass = Nothing
        If ParentID > 0 Then
            Dim sqlPath, rsPath
            sqlPath = "select ClassID,ClassName from PE_Class where ClassID in (" & ParentPath & ") order by Depth"
            Set rsPath = Conn.Execute(sqlPath)
            Do While Not rsPath.EOF
                Response.Write rsPath(1) & "&nbsp;&gt;&gt;&nbsp;"
                rsPath.MoveNext
            Loop
            rsPath.Close
            Set rsPath = Nothing
        End If
        'Call CloseConn()
        Response.Write ClassName & "&nbsp;&gt;&gt;&nbsp;"
    End If
    Response.Write PE_HTMLEncode(Request("Title"))
    Response.Write " </td>"
    Response.Write "    <td width='50' height='22' align='right'>"
    '显示信息
    Response.Write "&nbsp;&nbsp;"
    Response.Write "</td>"
    Response.Write "  </tr>"
    Response.Write "  <tr class='tdbg'><td colspan='3' align='center'><font size='4'>"
    Response.Write "</font></td></tr>"
    Response.Write "</table>"
    Response.Write "<p align='center'>【<a href='javascript:window.close();'>关闭窗口</a>】</p>"
End Sub


'******************************************************************************************
'以下为设置固顶、推荐等属性使用的函数，各模块实现过程类似，修改时注意同时修改各模块内容。
'******************************************************************************************

Sub SetProperty()
    Dim ReleasePoint, Point
    If SupplyId = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请先选定" & ChannelShortName & "！</li>"
        Exit Sub
    End If

    If Action = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>参数不足！</li>"
        Exit Sub
    End If
    
    Dim sqlProperty, rsProperty
    If InStr(SupplyId, ",") > 0 Then
        sqlProperty = "select ChannelId,ClassId,SupplyTitle,Status,UserName,CommandType,SupplyID,SupplyType from PE_Supply where SupplyId in (" & SupplyId & ")"
    Else
        sqlProperty = "select ChannelId,ClassId,SupplyTitle,Status,UserName,CommandType,SupplyID,SupplyType from PE_Supply where SupplyId=" & SupplyId
    End If
    
    Set rsProperty = Server.CreateObject("ADODB.Recordset")
    'Call OpenConn
    rsProperty.Open sqlProperty, Conn, 1, 3
    Do While Not rsProperty.EOF
        If CheckClassPurview(Action, rsProperty("ClassID")) = False Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>对 " & rsProperty("SupplyTitle") & " 没有操作权限！</li>"
        Else
            Select Case Action
                Case "SetPassed" '推荐分频道推荐和栏目推荐，他们分别扣除的点数不一样
                    If rsProperty("Status") = 0 Then
                        'Point = PE_CLng(GetTypePoint(, "//SupplyType/Type", "Point"))
                        ReleasePoint = getReleaseClassPoint(rsProperty("ClassId"), rsProperty("SupplyType"))
                        'Call OpenConn()
                        Conn.Execute ("update PE_Channel set ItemChecked=ItemChecked+1 where ChannelID=" & ChannelID & "")
                        Conn.Execute ("update PE_Class set ItemCount=ItemCount+1 where ClassID=" & rsProperty("ClassID") & "")
                        Conn.Execute ("update PE_User set PassedItems=PassedItems+1,UserPoint=UserPoint-" & ReleasePoint & " where UserName='" & rsProperty("UserName") & "'")
                        Call AddConsumeLog("System", ModuleType, rsProperty("UserName"), rsProperty("SupplyId"), ReleasePoint, 2, "发布供求信息")
                        'Call CloseConn()
                    End If
                    rsProperty("Status") = 1
                Case "CanCelPassed"
                    If rsProperty("Status") = 1 Then
                        'Call OpenConn()
                        Conn.Execute ("update PE_Channel set ItemChecked=ItemChecked-1 where ChannelID=" & ChannelID & "")
                        Conn.Execute ("update PE_Class set ItemCount=ItemCount-1 where ClassID=" & ClassID & "")
                        Conn.Execute ("update PE_User set PassedItems=PassedItems-1 where UserName='" & rsProperty("UserName") & "'")
                        'Call CloseConn()
                    End If
                    rsProperty("Status") = 0
            End Select
            rsProperty.Update
        End If
        rsProperty.MoveNext
    Loop
    rsProperty.Close
    Set rsProperty = Nothing
    Call ClearSiteCache(0)
    'Call CloseConn
    If FoundErr = False Then
        Response.Redirect ComeUrl
    End If
End Sub


'******************************************************************************************
'以下为移动至栏目、专题等操作使用的函数，各模块实现过程类似，修改时注意同时修改各模块内容。
'******************************************************************************************

Sub Move()
    If AdminPurview = 2 And AdminPurview_Channel > 2 Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>对不起，你的权限不够！</li>"
        Exit Sub
    End If
    If SupplyId = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请选择要移动的" & ChannelShortName & "！</li>"
        Exit Sub
    End If

    Dim sqlStr, rsSupply
    sqlStr = "select A.ClassID,A.SpecialID,A.SupplyTitle,C.ClassName,C.ParentPath,C.Depth from PE_Supply A"
    sqlStr = sqlStr & " left join PE_Class C on A.ClassID=C.ClassID where A.SupplyId=" & SupplyId
    Set rsSupply = Conn.Execute(sqlStr)
    If rsSupply.BOF And rsSupply.EOF Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>找不到要移到的" & ChannelShortName & "</li>"
    Else
        Response.Write "<form name='myform' method='post' action='Admin_Supply.asp'>"
        Response.Write "  <table width='100%' border='0' align='center' cellpadding='0' cellspacing='0' class='border'>"
        Response.Write "    <tr class='title'>"
        Response.Write "      <td height='22' align='center'><strong>" & ChannelShortName & "移动</strong></td>"
        Response.Write "    </tr>"
        Response.Write "    <tr>"
        Response.Write "      <td>"
        Response.Write "        <table width='100%' border='0' cellspacing='1' cellpadding='2'>"
        Response.Write "          <tr class='tdbg'>"
        Response.Write "            <td width='200'><strong>所属栏目：</strong></td>"
        Response.Write "            <td>" & ShowClassPath() & "</td>"
        Response.Write "          </tr>"
        Response.Write "          <tr class='tdbg'>"
        Response.Write "            <td width='200'><strong>所属专题：</strong></td>"
        Response.Write "            <td><select name='SepcialID'><option value='0'>不指定专题</option>" & GetSpecial_Option(rsSupply("SpecialID")) & "</select></td>"
        Response.Write "          </tr>"
        Response.Write "          <tr class='tdbg'>"
        Response.Write "            <td width='200'><strong>" & ChannelShortName & "标题：</strong></td>"
        Response.Write "            <td>" & rsSupply("SupplyTitle") & "<input name='SupplyId' type='hidden' id='SupplyId' value='" & SupplyId & "'></td>"
        Response.Write "          </tr>"
        Response.Write "          <tr class='tdbg'>"
        Response.Write "            <td width='200'><strong>移动到：</strong><br>不能指定为外部栏目</td>"
        Response.Write "            <td><select name='TargetClassID' size='2'  style='height:300px;width:400px;'>" & GetClass_Option(3, rsSupply("ClassID")) & "</select></td>"
        Response.Write "          </tr>"
        Response.Write "        </table>"
        Response.Write "      </td>"
        Response.Write "    </tr>"
        Response.Write "    <tr class='tdbg'>"
        Response.Write "      <td align='center'>"
        Response.Write "        <input name='strComeUrl' type='hidden' id='strComeUrl' value='" & ComeUrl & "'>"
        Response.Write "        <input name='Action' type='hidden' id='Action' value='MoveSupply'>"
        Response.Write "        <input name='ChannelID' type='hidden' id='ChannelID' value='" & ChannelID & "'>"
        Response.Write "        <input type='submit' name='Submit' value=' 确 定 '>&nbsp;"
        Response.Write "        <input name='Cancel' type='button' id='Cancel' value=' 取 消 ' onClick=""window.location.href='Admin_Supply.asp?ChannelID=" & ChannelID & "'"" style='cursor:hand;'>"
        Response.Write "      </td>"
        Response.Write "    </tr>"
        Response.Write "  </table>"
        Response.Write "</form>"
    End If
    rsSupply.Close
    Set rsSupply = Nothing
    'Call CloseConn()
End Sub

Sub MoveSupply()
    If AdminPurview = 2 And AdminPurview_Channel > 2 Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>对不起，你的权限不够！</li>"
        Exit Sub
    End If
    If SupplyId = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请选择要移动的" & ChannelShortName & "！</li>"
        Exit Sub
    End If
    
    Dim strComeUrl, TargetClassID
    strComeUrl = Trim(Request("strComeUrl"))
    TargetClassID = Trim(Request("TargetClassID"))
    Call CheckClassPurview("saveadd", TargetClassID)
    If FoundErr = True Then Exit Sub
    
    Dim sqlMove, rsMove
    sqlMove = "select SupplyId,ClassID,SpecialID,Status from PE_Supply where SupplyId in (" & SupplyId & ")"
    Set rsMove = Server.CreateObject("ADODB.Recordset")
    'Call OpenConn()
    rsMove.Open sqlMove, Conn, 1, 3
    Do While Not rsMove.EOF
        If rsMove("Status") = 1 Then
            Conn.Execute ("update PE_Class set ItemCount=ItemCount-1 where ClassID=" & rsMove("ClassID") & "")
            Conn.Execute ("update PE_Class set ItemCount=ItemCount+1 where ClassID=" & TargetClassID & "")
        End If
        rsMove("ClassID") = TargetClassID
        rsMove("SpecialID") = SpecialID
        rsMove.Update
        rsMove.MoveNext
    Loop
    rsMove.Close
    Set rsMove = Nothing
    
    'Conn.Execute ("update PE_Comment set ClassID=" & TargetClassID & " where ChannelID=" & ChannelID & " and InfoID in (" & SupplyId & ")")
    'Call CreateAllJS
    Call ClearSiteCache(0)
    Call CloseConn
    Response.Redirect strComeUrl
End Sub

Sub MoveToSpecial()
    If AdminPurview = 2 And AdminPurview_Channel > 2 Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>对不起，你的权限不够！</li>"
        Exit Sub
    End If
    If SupplyId = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请选择要移动的" & ChannelShortName & "！</li>"
        Exit Sub
    End If
    If SpecialID = 0 Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定目标专题！</li>"
        Exit Sub
    End If
    
    Conn.Execute ("update PE_Supply set SpecialID=" & SpecialID & " where SupplyId in (" & SupplyId & ")")
    Call ClearSiteCache(0)
    Call CloseConn
    Response.Redirect ComeUrl
End Sub

Sub BatchMove()
    If AdminPurview = 2 And AdminPurview_Channel > 2 Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>对不起，你的权限不够！</li>"
        Exit Sub
    End If
    
    Dim tChannelID, BatchSupplyId
    tChannelID = Trim(Request("tChannelID"))
    If tChannelID = "" Then
        tChannelID = ChannelID
    Else
        tChannelID = PE_CLng(tChannelID)
    End If
    BatchSupplyId = ReplaceBadChar(Request("BatchSupplyId"))
    If BatchSupplyId = "" Then
        BatchSupplyId = ReplaceBadChar(Request("SupplyId"))
    End If
    
    Response.Write "<form method='POST' name='myform' action='Admin_Supply.asp' target='_self'>"
    Response.Write "  <table width='100%' border='0' align='center' cellpadding='2' cellspacing='1' class='border'>"
    Response.Write "    <tr class='title'>"
    Response.Write "      <td height='22' colspan='4' align='center'><b>批量移动" & ChannelShortName & "</td>"
    Response.Write "    </tr>"
    Response.Write "    <tr align='left' class='tdbg'>"
    Response.Write "      <td vlign='top' width='300'>"
    Response.Write "      <input type='radio' name='ArticleType' value='1' checked>指定" & ChannelShortName & "ID：<input type='text' name='BatchSupplyId' value='" & BatchSupplyId & "' size='30'><br>"
    Response.Write "      <input type='radio' name='ArticleType' value='2'>指定栏目的" & ChannelShortName & "：<br><select name='BatchClassID' size='2' multiple style='height:360px;width:300px;'>" & GetClass_Option(0, 0) & "</select><br>"
    Response.Write "      <input type='button' name='Submit' value='  选定所有栏目  ' onclick='SelectAll()'>"
    Response.Write "      <input type='button' name='Submit' value='取消选定所有栏目' onclick='UnSelectAll()'>"
    Response.Write "      </td>"
    Response.Write "      <td align='center' >移动到&gt;&gt;</td>"
    Response.Write "      <td valign='top'>"
    Response.Write "目标栏目：<font color=red>（不能指定为外部栏目）</font><br><select name='tClassID' size='2' style='height:360px;width:300px;'>" & GetClass_Channel(tChannelID) & "</select>"
    Response.Write "      </td>"
    Response.Write "    </tr>"
    Response.Write "  </table>"
    Response.Write "  <p align='center'>"
    Response.Write "   <input name='ChannelID' type='hidden' id='ChannelID' value='" & ChannelID & "'>"
    Response.Write "   <input name='Action' type='hidden' id='Action' value='BatchMove'>"
    Response.Write "   <input name='add' type='submit'  id='Add' value=' 执行批处理 ' style='cursor:hand;' onClick=""document.myform.Action.value='DoBatchMove';"">&nbsp; "
    Response.Write "   <input name='Cancel' type='button' id='Cancel' value=' 取 消 ' onClick=""window.location.href='Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=Manage';"" style='cursor:hand;'>"
    Response.Write "  </p><br>"
    Response.Write "</form>"
    Response.Write "<script language='javascript'>" & vbCrLf
    Response.Write "function SelectAll(){" & vbCrLf
    Response.Write "  for(var i=0;i<document.myform.BatchClassID.length;i++){" & vbCrLf
    Response.Write "    document.myform.BatchClassID.options[i].selected=true;}" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "function UnSelectAll(){" & vbCrLf
    Response.Write "  for(var i=0;i<document.myform.BatchClassID.length;i++){" & vbCrLf
    Response.Write "    document.myform.BatchClassID.options[i].selected=false;}" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "</script>" & vbCrLf
End Sub

Sub DoBatchMove()
    If AdminPurview = 2 And AdminPurview_Channel > 2 Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>对不起，你的权限不够！</li>"
        Exit Sub
    End If
    
    Dim ArticleType, BatchSupplyId, BatchClassID
    Dim tClassID
    Dim rsBatchMove, sqlBatchMove
    
    ArticleType = PE_CLng(Trim(Request("ArticleType")))
    BatchSupplyId = Trim(Request.Form("BatchSupplyId"))
    BatchClassID = Trim(Request.Form("BatchClassID"))
    tClassID = Trim(Request("tClassID"))
    
    If ArticleType = 1 Then
        If IsValidID(BatchSupplyId) = False Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>请指定要批量移动的" & ChannelShortName & "的ID</li>"
        End If
    Else
        If IsValidID(BatchClassID) = False Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>请指定要批量移动的" & ChannelShortName & "的栏目</li>"
        End If
    End If

    If tClassID = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定目标栏目！不能指定为外部栏目。</li>"
    Else
        tClassID = PE_CLng(tClassID)
        If tClassID = 0 Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>目标栏目不允许添加" & ChannelShortName
        End If
    End If
    If FoundErr = True Then Exit Sub
    
    sqlBatchMove = "select ChannelID,SupplyId,ClassID,SpecialID,Status,SupplyPicUrl,TemplateID from PE_Supply"
    If ArticleType = 1 Then
        sqlBatchMove = sqlBatchMove & " where ChannelID=" & ChannelID & " and SupplyId in (" & BatchSupplyId & ")"
    Else
        sqlBatchMove = sqlBatchMove & " where ChannelID=" & ChannelID & " and ClassID in (" & BatchClassID & ")"
    End If
    Set rsBatchMove = Server.CreateObject("ADODB.Recordset")
    rsBatchMove.Open sqlBatchMove, Conn, 1, 3
    Do While Not rsBatchMove.EOF
        If rsBatchMove("Status") = 1 Then
            Conn.Execute ("update PE_Class set ItemCount=ItemCount-1 where ClassID=" & rsBatchMove("ClassID") & "")
            Conn.Execute ("update PE_Class set ItemCount=ItemCount+1 where ClassID=" & tClassID & "")
        End If
        rsBatchMove("ClassID") = tClassID
        rsBatchMove.Update
        rsBatchMove.MoveNext
    Loop
    rsBatchMove.Close
    Set rsBatchMove = Nothing
        
    ComeUrl = "Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=BatchMove"
    Call WriteSuccessMsg("成功将选定的" & ChannelShortName & "移动到目标频道的目标栏目中！", ComeUrl)
    Call ClearSiteCache(0)
End Sub


'******************************************************************************************
'以下为删除、清空、还原等操作使用的函数，各模块实现过程类似，修改时注意同时修改各模块内容。
'******************************************************************************************

Sub Del()
    If SupplyId = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请先选定" & ChannelShortName & "！</li>"
        Exit Sub
    End If
    
    Dim sqlDel, rsDel, ArticlePath
    sqlDel = "select A.SupplyId,A.SupplyTitle,A.UpdateTime,A.UserName,A.Status,A.ClassID,A.Deleted,C.ParentDir,C.ClassDir,C.ClassPurview from PE_Supply A left join PE_Class C on A.ClassID=C.ClassID"
    If InStr(SupplyId, ",") > 0 Then
        sqlDel = sqlDel & " where A.SupplyId in (" & SupplyId & ") And Deleted=" & PE_False & " order by A.SupplyId"
    Else
        sqlDel = sqlDel & " where A.SupplyId=" & SupplyId & " And Deleted=" & PE_False & ""
    End If
    Set rsDel = Server.CreateObject("ADODB.Recordset")
    'Call OpenConn()
    rsDel.Open sqlDel, Conn, 1, 3
    '删除静态页
    Do While Not rsDel.EOF
        PurviewChecked = False
        ClassID = rsDel("ClassID")
        If AdminPurview = 1 Or AdminPurview_Channel <= 2 Or (rsDel("UserName") = UserName And rsDel("Status") = 0) Then
            PurviewChecked = True
        Else
            PurviewChecked = CheckClassPurview(Action, ClassID)
        End If
        
        If PurviewChecked = False Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>删除 <font color=red>" & rsDel("SupplyTitle") & "</font> 失败！原因：没有操作权限！</li>"
        Else
      '权限检查过后，首先减少通过审查，或过期的频道总的信息数，再减少栏目中的信息数，最后减少用户总共发布的信息数。
            If rsDel("Status") = 1 Or rsDel("Status") = 2 Then
                Conn.Execute ("update PE_Channel set ItemCount=ItemCount-1,ItemChecked=ItemChecked-1 where ChannelID=" & ChannelID & "")
                Conn.Execute ("update PE_Class set ItemCount=ItemCount-1 where ClassID=" & rsDel("ClassID") & "")
                Conn.Execute ("update PE_User set PostItems=PostItems-1,PassedItems=PassedItems-1 where UserName='" & rsDel("UserName") & "'")
            Else
                '对于删除没有通过审核的，只减少频道中的信息数，
                Conn.Execute ("update PE_Channel set ItemCount=ItemCount-1 where ChannelID=" & ChannelID & "")
                Conn.Execute ("update PE_User set PostItems=PostItems-1 where UserName='" & rsDel("UserName") & "'")
            End If
            rsDel("Deleted") = True
            rsDel.Update
        End If
        rsDel.MoveNext
    Loop
    rsDel.Close
    Set rsDel = Nothing
    Call ClearSiteCache(0)
    'Call CloseConn
    If FoundErr = False Then
        Response.Redirect ComeUrl
    End If
End Sub


Sub ConfirmDel()
    If AdminPurview = 2 And AdminPurview_Channel > 2 Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>对不起，你的权限不够！</li>"
        Exit Sub
    End If
    If SupplyId = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请先选定" & ChannelShortName & "！</li>"
        Exit Sub
    End If
    
    Dim sqlDel, rsDel
    sqlDel = "select SupplyPicUrl from PE_Supply where SupplyId in (" & SupplyId & ")"
    Set rsDel = Conn.Execute(sqlDel)
    Do While Not rsDel.EOF
        Call DelFiles(rsDel("SupplyPicUrl"))
        rsDel.MoveNext
    Loop
    rsDel.Close
    Set rsDel = Nothing
    Conn.Execute ("delete from PE_Supply where SupplyId in (" & SupplyId & ")")
    Conn.Execute ("delete from PE_Comment where ModuleType=" & ModuleType & " and InfoID in (" & SupplyId & ")")
    'Call CloseConn
    Response.Redirect ComeUrl
End Sub

Sub ClearRecyclebin()
    If AdminPurview = 2 And AdminPurview_Channel > 2 Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>对不起，你的权限不够！</li>"
        Exit Sub
    End If
    
    Dim sqlDel, rsDel
    SupplyId = ""
    sqlDel = "select SupplyId,SupplyPicUrl from PE_Supply where Deleted=" & PE_True & " and ChannelID=" & ChannelID
    Set rsDel = Conn.Execute(sqlDel)
    Do While Not rsDel.EOF
        If SupplyId = "" Then
            SupplyId = rsDel(0)
        Else
            SupplyId = SupplyId & "," & rsDel(0)
        End If
        Call DelFiles(rsDel("SupplyPicUrl"))
        rsDel.MoveNext
    Loop
    rsDel.Close
    Set rsDel = Nothing
    If SupplyId <> "" Then
        Conn.Execute ("delete from PE_Supply where Deleted=" & PE_True & " and ChannelID=" & ChannelID & "")
        Conn.Execute ("delete from PE_Comment where ModuleType=" & ModuleType & " and InfoID in (" & SupplyId & ")")
    End If
    Call CloseConn
    Response.Redirect "Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=Manage&ManageType=Recyclebin"
End Sub

Sub Restore()
    If AdminPurview = 2 And AdminPurview_Channel > 2 Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>对不起，你的权限不够！</li>"
        Exit Sub
    End If
    If SupplyId = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请先选定" & ChannelShortName & "！</li>"
        Exit Sub
    End If
    
    Dim sqlDel, rsDel
    If InStr(SupplyId, ",") > 0 Then
        sqlDel = "select * from PE_Supply where SupplyId in (" & SupplyId & ")"
    Else
        sqlDel = "select * from PE_Supply where SupplyId=" & SupplyId
    End If
    Set rsDel = Server.CreateObject("ADODB.Recordset")
    'Call OpenConn
    rsDel.Open sqlDel, Conn, 1, 3
    Do While Not rsDel.EOF
        If rsDel("Status") = 3 Then
            Conn.Execute ("update PE_Channel set ItemCount=ItemCount+1,ItemChecked=ItemChecked+1 where ChannelID=" & ChannelID & "")
            Conn.Execute ("update PE_Class set ItemCount=ItemCount+1 where ClassID=" & rsDel("ClassID") & "")
            Conn.Execute ("update PE_User set PostItems=PostItems+1,PassedItems=PassedItems+1 where UserName='" & rsDel("UserName") & "'")
        Else
            Conn.Execute ("update PE_Channel set ItemCount=ItemCount+1 where ChannelID=" & ChannelID & "")
            Conn.Execute ("update PE_User set PostItems=PostItems+1 where UserName='" & rsDel("UserName") & "'")
        End If
        rsDel("Deleted") = False
        rsDel.Update
        rsDel.MoveNext
    Loop
    rsDel.Close
    Set rsDel = Nothing
    'Call CreateAllJS
    Call ClearSiteCache(0)
    'Call CloseConn
    Response.Redirect "Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=Manage&ManageType=Recyclebin"
End Sub

Sub RestoreAll()
    If AdminPurview = 2 And AdminPurview_Channel > 2 Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>对不起，你的权限不够！</li>"
        Exit Sub
    End If
    
    Dim sqlDel, rsDel
    sqlDel = "select * from PE_Supply where Deleted=" & PE_True & " and ChannelID=" & ChannelID
    Set rsDel = Server.CreateObject("ADODB.Recordset")
    rsDel.Open sqlDel, Conn, 1, 3
    Do While Not rsDel.EOF
        If rsDel("Status") = 1 Then
            Conn.Execute ("update PE_Channel set ItemCount=ItemCount+1,ItemChecked=ItemChecked+1 where ChannelID=" & ChannelID & "")
            Conn.Execute ("update PE_Class set ItemCount=ItemCount+1 where ClassID=" & rsDel("ClassID") & "")
            Conn.Execute ("update PE_User set PostItems=PostItems+1,PassedItems=PassedItems+1 where UserName='" & rsDel("UserName") & "'")
        Else
            Conn.Execute ("update PE_Channel set ItemCount=ItemCount+1 where ChannelID=" & ChannelID & "")
            Conn.Execute ("update PE_User set PostItems=PostItems+1 where UserName='" & rsDel("UserName") & "'")
        End If
        rsDel("Deleted") = False
        rsDel.Update
        rsDel.MoveNext
    Loop
    rsDel.Close
    Set rsDel = Nothing
    'Call CreateAllJS
    Call ClearSiteCache(0)
    Call CloseConn
    Response.Redirect "Admin_Supply.asp?ChannelID=" & ChannelID & "&Action=Manage&ManageType=Recyclebin"
End Sub

Sub DelFromSpecial()
    If AdminPurview = 2 And AdminPurview_Channel > 2 Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>对不起，你的权限不够！</li>"
        Exit Sub
    End If
    If SupplyId = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请选择要移动的" & ChannelShortName & "！</li>"
        Exit Sub
    End If
    
    Conn.Execute ("update PE_Supply set SpecialID=0 where SupplyId in (" & SupplyId & ")")
    Call ClearSiteCache(0)
    Call CloseConn
    Response.Redirect "Admin_Supply.asp?ChannelID=" & ChannelID
End Sub

%>
