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

Dim SupplyId, AuthorName
Dim IncludePic, UploadFiles, DefaultPicUrl, Status, ManageType

Dim CommandChannelPoint '把供求信息设置为频道推荐每天要扣除的点数
Dim CommandClassPoint '把供求信息设置为栏目推荐每天要扣除的点数
Dim ReleaseClassPoint '设置在栏目下发布信息要扣除的会员点数
Dim ClassID, SpecialID, OnTop, IsElite, IsHot, Created

Dim tClass, ClassName, RootID, ParentID, Depth, ParentPath, Child, arrChildID, ParentDir, ClassDir, ClassPurview

Sub Execute()
    ChannelID = PE_CLng(Trim(Request("ChannelID")))
    Call GetChannel(ChannelID)
    If FoundErr = True Then
        Response.Write ErrMsg
        Exit Sub
    End If

    ManageType = Trim(Request("ManageType"))
    SupplyId = PE_CLng(Trim(Request("SupplyID")))
    ClassID = PE_CLng(Trim(Request("ClassID")))
    Status = Trim(Request("Status"))

    If Status = "" Then
        Status = -1
    Else
        Status = PE_CLng(Status)
    End If
    If XmlDoc.Load(Server.MapPath(InstallDir & "Language/Gb2312_Channel_" & ChannelID & ".xml")) = False Then XmlDoc.Load (Server.MapPath(InstallDir & "Language/Gb2312.xml"))

    If Action = "" Then Action = "Manage"
    FileName = "User_Supply.asp?ChannelID=" & ChannelID & "&Action=" & Action & "&ManageType=" & ManageType
    strFileName = FileName & "&ClassID=" & ClassID & "&Field=" & strField & "&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='User_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
        Call CloseConn
        Exit Sub
    End If
   Response.Write "<table align='center'><tr align='center' valign='top'>"
   Response.Write "<td width='90'><a href='User_Supply.asp?ChannelID=" & ChannelID & "&Action=Add'><img src='images/article_add.gif' border='0' align='absmiddle'><br>添加" & ChannelShortName & "</a></td>"
   Response.Write "<td width='90'><a href='User_Supply.asp?ChannelID=" & ChannelID & "&Status=9'><img src='images/article_all.gif' border='0' align='absmiddle'><br>所有" & ChannelShortName & "</a></td>"
   Response.Write "<td width='120'><a href='User_Supply.asp?ChannelID=" & ChannelID & "&Status=0'><img src='images/article_unpassed.gif' border='0' align='absmiddle'><br>待审核的" & ChannelShortName & "</a></td>"
   Response.Write "<td width='120'><a href='User_Supply.asp?ChannelID=" & ChannelID & "&Status=1'><img src='images/article_passed.gif' border='0' align='absmiddle'><br>已审核的" & ChannelShortName & "</a></td>"
   Response.Write "<td width='120'><a href='User_Supply.asp?ChannelID=" & ChannelID & "&Status=2'><img src='images/article_reject.gif' border='0' align='absmiddle'><br>过期的" & ChannelShortName & "</a></td>"
   Response.Write "</tr></table>" & vbCrLf

    Select Case Action
        Case "Add", "Modify"
            Call Add
        Case "SaveAdd", "SaveModify"
            Call SaveSupply
        Case "Show"
            Call Show
        Case "Del"
            Call Del
        Case "Manage"
            Call main
    End Select
    If FoundErr = True Then
        Call WriteErrMsg(ErrMsg, ComeUrl)
    End If
    
End Sub

Sub main()
    Dim rsSupplyList, sql, tmpChannelID, tClass, Querysql
    If ClassID > 0 Then
        Set tClass = Conn.Execute("select ClassName,RootID,ParentID,Depth,ParentPath,Child,arrChildID from PE_Class where ClassID=" & ClassID)
        If tClass.BOF And tClass.EOF Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>找不到指定的栏目</li>"
            Exit Sub
        Else
            ClassName = tClass(0)
            RootID = tClass(1)
            ParentID = tClass(2)
            Depth = tClass(3)
            ParentPath = tClass(4)
            Child = tClass(5)
            arrChildID = tClass(6)
        End If
    End If
    If Request("page") <> "" Then
        CurrentPage = PE_CLng(Request("page"))
    Else
        CurrentPage = 1
    End If

    Call ShowJS_Main(ChannelShortName)
    Response.Write "<br>"
    If ChannelID > 0 Then
        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'>" & GetRootClass() & "</td>"
        Response.Write "  </tr>" & GetChild_Root() & ""
        Response.Write "</table><br>"
    End If

    Call ShowContentManagePath(ChannelShortName & "管理")

    Response.Write "<table width='100%' border='0' cellpadding='0' cellspacing='0'><tr>"
    Response.Write "    <form name='myform' method='Post' action='User_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>"
    Else
        Response.Write "            <td width='80' align='center' ><strong>常规操作</strong></td>"
    End If
    Response.Write "          </tr>"

    sql = "select Top " & MaxPerPage & " A.SupplyId,A.ChannelID,A.ClassID,A.SupplyType,A.TradeType,A.CommandType,A.SupplyPeriod,A.Hits, "
    sql = sql & "C.ClassName,C.ParentDir,C.ClassDir,C.ClassPurview, A.SupplyTitle, A.UserName,A.UpdateTime, "
    sql = sql & "A.SupplyPicUrl,A.Status from PE_Supply A left join PE_Class C on A.ClassID=C.ClassID "

    Querysql = "Where A.ChannelID=" & ChannelID & " And  A.Deleted=" & PE_False & ""
    Querysql = Querysql & " and A.UserName='" & UserName & "' "
    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 & ",A.UpdateTime, " & PE_Now & ") > A.SupplyPeriod And SupplyPeriod<> -1 "
        Case Else
            Querysql = Querysql & " and A.Status>=0 "
    End Select
    
    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 Keyword <> "" Then
        Select Case strField
            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")
    rsSupplyList.Open sql, Conn, 1, 1
    If rsSupplyList.BOF And rsSupplyList.EOF Then
        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 SupplyNum, SupplyPath
        SupplyNum = 0
        Do While Not rsSupplyList.EOF
            If ChannelID = 0 Then
                If rsSupplyList("ChannelID") <> tmpChannelID Then
                    ChannelID = rsSupplyList("ChannelID")
                    Call GetChannel(ChannelID)
                    tmpChannelID = rsSupplyList("ChannelID")
                End If
            End If
            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='unselectall()' 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='User_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 rsSupplyList("UserName") = UserName And (rsSupplyList("Status") = 0 Or EnableModifyDelete = 1) Then
                Response.Write "    <a href=User_Supply.asp?ChannelID=" & ChannelID & "&Action=Modify&SupplyId=" & rsSupplyList("SupplyId") & ">修改</a>"
                Response.Write "    <a href=User_Supply.asp?ChannelID=" & ChannelID & "&Action=Del&SupplyId=" & rsSupplyList("SupplyId") & " onclick=""return confirm('确定要删除此" & ChannelShortName & "吗？一旦删除将不能恢复！');"">删除</a>"
            End If
            Response.Write "         </td>"
            Response.Write "</tr>"

            SupplyNum = SupplyNum + 1
            If SupplyNum >= MaxPerPage Then Exit Do
            rsSupplyList.MoveNext
        Loop
    End If
    rsSupplyList.Close
    Set rsSupplyList = Nothing
    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>"
   
    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>"
    Response.Write "<form method='Get' name='SearchForm' action='" & FileName & "'>"
    Response.Write "<table width='100%' border='0' cellpadding='0' cellspacing='0' class='border'>"
    Response.Write "  <tr class='tdbg'>"
    Response.Write "   <td width='100' align='right'><strong>" & ChannelShortName & "搜索：</strong></td>"
    Response.Write "   <td>"
    Response.Write "<select name='Field' size='1'>"
    Response.Write "<option value='Title' selected>" & ChannelShortName & "信息标题</option>"
    Response.Write "<option value='Content'>" & ChannelShortName & "信息内容</option>"
    Response.Write "<option value='UserName'>发布人</option>"
    Response.Write "</select>"
    Response.Write "<select name='ClassID'><option value=''>所有栏目</option>" & User_GetClass_Option(4, ClassID) & "</select>"
    Response.Write "<input type='text' name='keyword'  size='20' value='关键字' maxlength='50' onFocus='this.select();'>"
    Response.Write "<input type='submit' name='Submit'  value='搜索'>"
    Response.Write "<input name='ManageType' type='hidden' id='ManageType' value='" & ManageType & "'>"
    Response.Write "<input name='ChannelID' type='hidden' id='ChannelID' value='" & ChannelID & "'>"
    Response.Write "</td></tr></table></form>"
End Sub

Sub ShowJS_Supply()
    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


Sub Add()
    Dim SupplyType, SupplyPeriod, TradeType, ClassID, SpecialID, CommandType, DefaultPicUrl
    Dim SupplyName, SupplyTitle, SupplyIntro, PriceIntro, SupplyPicUrl, TemplateId, SkinId, Hits, arrSupplyPicUrl

    '检查用户的填写信息是否完整
    
    If Not (CheckUserInfo()) Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>你的用户信息填写不完整,请去修改你的个人信息!</li><li><a href=User_Info.asp?Action=Modify>点击这里修改我的<b>联系信息</b></a></li>"
        Call CloseConn
        Exit Sub
    End If

    '检查用户是否有在这个栏目发表信息的权限
    If FoundInArr(arrClass_Input, ChannelDir & "none", ",") = True Then
        FoundErr = True
        ErrMsg = ErrMsg & "<br><li>对不起！您没有在" & ChannelName & "添加" & ChannelShortName & "的权限！</li><br><br>"
        Call CloseConn
        Exit Sub
    End If
    Dim trs

    '判断用户发表的信息数是否达到了最大值
    If MaxPerDay > 0 Then
        Set trs = Conn.Execute("select count(SupplyId) from PE_Supply where UserName='" & UserName & "' and DateDiff(" & PE_DatePart_D & "," & PE_Now & ",UpdateTime)=0")
        If trs(0) >= MaxPerDay Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>您今天发表的的信息已经达到了上限！</li>"
        End If
        Set trs = Nothing
        If FoundErr Then
            Call CloseConn
            Exit Sub
        End If
    End If
   
    Call ShowJS_Supply

    If Action = "Modify" Then
        Dim strSql, rs
        strSql = "Select ClassId,SpecialId,SupplyType,SupplyName,SupplyTitle,SupplyIntro,SupplyPeriod,PriceIntro,SupplyPicUrl,CommandType,UserName From PE_Supply Where SupplyId= " & SupplyId & " and UserName='" & UserName & "'"
        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")
            PriceIntro = rs("PriceIntro")
            SupplyPicUrl = rs("SupplyPicUrl")
            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
    End If

    Response.Write "<form method='POST' name='myform' onSubmit='return CheckForm();' action='User_Supply.asp' target='_self'>"
    Response.Write "  <table width='100%' border='0' align='center' cellpadding='0' cellspacing='0' class='border'>"
    Response.Write "  <tr align='center'>"
    Response.Write "    <td class='tdbg' height='200' valign='top'>"
    Response.Write "      <table width='100%' 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 ">" & User_GetClass_Option(4, ClassID) & "</select>"
    Response.Write "              &nbsp;&nbsp;&nbsp;&nbsp;<font color='#FF0000'><strong>注意：</strong></font>"
    Response.Write "              <font color='#0000FF'>不能指定为外部栏目</font>"
   ' Response.Write "<font color='#0000FF'>，并且你只能在<font color='#FF0000'>绿色栏目</font>及其子栏目中发表" & ChannelShortName & "</font>"
    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>"
    Else
        Response.Write "          <tr class='tdbg'>"
        Response.Write "            <td width='120' align='right' class='tdbg5'>推荐类型：</td>"
        Response.Write "            <td>"
        Select Case CommandType
            Case 1
                Response.Write "&nbsp;<font Color=Red>频道推荐</font>"
            Case 2
                Response.Write "&nbsp;<font Color=Red>栏目推荐</font>"
        End Select
        Response.Write "          </td></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' style='display:none'>" & Server.HTMLEncode(SupplyIntro) & "</textarea>"
    Response.Write "               <iframe ID='editor' src='../editor.asp?ChannelID=" & ChannelID & "&ShowType=5&tContentid=Content' frameborder=1 scrolling=no width='600' 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>"

    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='Cancel' type='button' id='Cancel' value=' 取 消 ' onClick=""window.location.href='User_Supply.asp?ChannelID=" & ChannelID & "&Action=Manage';"" style='cursor:hand;'>"
    Response.Write "  </p><br>"
    Response.Write "</form>"
    If (Action = "Add" Or CommandType = 0) And FoundErr = False Then
        Call SetAjax
    End If
End Sub

'***********************************************
'检查用户的联系信息是否完整
'如果不完整 返回 false，否则 返回 true
'刘永涛
'2006-1-14
'************************************************
Function CheckUserInfo()
    Dim strSql
    strSql = "Select Count(*) From PE_User inner join PE_Contacter on PE_User.ContacterId = PE_Contacter.ContacterId Where PE_User.UserName='" & UserName & "'"
    If PE_CLng(Conn.Execute(strSql)(0)) < 1 Then
        CheckUserInfo = False
    Else
        CheckUserInfo = True
    End If
End Function

'2006-5-15 修正扣除点数错误和审核统计错误 -- 刘永涛
Sub SaveSupply()
    If FoundInArr(arrClass_Input, ChannelDir & "none", ",") = True Then
        FoundErr = True
        ErrMsg = ErrMsg & "<br><li>对不起！您没有在" & ChannelName & "添加" & ChannelShortName & "的权限！</li><br><br>"
        Exit Sub
    End If

    Dim rsSupply, strSql
    Dim SupplyId, SpecialID, SupplyType, SupplyName, TradeType, PriceIntro, SupplyTitle, SupplyPeriod, Content
    Dim UpdateTime, CreateImmediate, SkinId, TemplateId, ChannelID, SupplyPicUrl, UserName, Hits, CommandType
    Dim Point, CommandChannelDays, CommandClassDays, ReleasePoint, Status, DefaultPicUrl

    ChannelID = PE_CLng(Trim(Request.Form("ChannelId")))
    ClassID = PE_CLng(Trim(Request.Form("ClassID")))
    SpecialID = PE_CLng(Trim(Request.Form("SpecialID")))
    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 = PE_HTMLEncode(Trim(Request.Form("PriceIntro"))) '价格说明
    SupplyTitle = Trim(Request.Form("SupplyTitle")) '信息标题
    SupplyPeriod = PE_CLng(Trim(Request.Form("SupplyPeriod"))) '信息有效期
    Content = ReplaceBadUrl(Trim(Request.Form("Content")))   '产品简介
    DefaultPicUrl = Trim(Request.Form("DefaultPicUrl"))
    SupplyPicUrl = PE_HTMLEncode(Trim(Request.Form("UploadFiles"))) '图片地址
    UserName = ReplaceText(Trim(Request.Form("UserName")), 2) '添加人的姓名

    CommandType = PE_CLng(Trim(Request.Form("CommandType"))) '推荐类型
    CommandChannelDays = PE_CLng(Trim(Request("CommandChannelDays"))) '频道推荐的天数
    CommandClassDays = PE_CLng(Trim(Request("CommandClassDays"))) '栏目推荐的天数

    Call CheckClassPurview(ClassID) '检查在栏目的操作权限

    If FoundErr = True Then Exit Sub
  
    If SupplyTitle = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>" & ChannelShortName & "标题不能为空</li>"
    Else
        SupplyTitle = ReplaceText(SupplyTitle, 2)
    End If

    '开始添加数据
    '首先检测用户的点数是否够用，如果够了，才可以添加信息
    Select Case CommandType
        'Case 0
           ' Point = PE_CLng(GetTypePoint(SupplyType, "//SupplyType/Type", "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) '检查的点数是否够用
    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)
    UpdateTime = Now()
    Select Case CheckLevel
        Case 0
            Status = 1
        Case 1
            Status = 0
        Case Else
            Status = 1
    End Select

    SupplyPicUrl = getOrderPicUrl(SupplyPicUrl, DefaultPicUrl)
    '开始添加数据
    If Action = "SaveAdd" Then
        If Session("Content") = Content And DateDiff("S", Session("AddTime"), Now()) < 100 Then
            FoundErr = True
            ErrMsg = "<li>请不要重复添加同一" & ChannelItemUnit & ChannelShortName & "</li>"
            Exit Sub
        Else
            Session("Content") = Content
            Session("AddTime") = Now()
            Dim mrs
            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") = 0
            rsSupply("Status") = Status
            rsSupply("UserName") = UserName
            rsSupply("TemplateId") = 0
            rsSupply("SkinId") = 0
            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, Point, 2, "发布供求+设定频道推荐")
                ElseIf CommandType = 2 And Point > 0 Then
                    Call AddConsumeLog("System", ModuleType, UserName, SupplyId, Point, 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
        End If
    Else
        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 CommandType = 2 And Point > 0 Then
                rsSupply("CommandType") = CommandType
                rsSupply("CommandChannelDays") = CommandChannelDays
                rsSupply("CommandClassDays") = CommandClassDays
                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
                rsSupply("CommandType") = CommandType
                rsSupply("CommandChannelDays") = CommandChannelDays
                rsSupply("CommandClassDays") = CommandClassDays
                Conn.Execute ("update PE_User set UserPoint=UserPoint-" & Point & " where UserName='" & UserName & "'")
                Call AddConsumeLog("System", ModuleType, UserName, SupplyId, Point, 2, "设定频道推荐")
            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("UserName") = UserName
            rsSupply.Update
            rsSupply.Close
            Set rsSupply = Nothing
        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='User_Supply.asp?ChannelID=" & ChannelID & "&Action=Modify&SupplyID=" & SupplyId & "'>修改此" & ChannelShortName & "</a>】&nbsp;"
    Response.Write "【<a href='User_Supply.asp?ChannelID=" & ChannelID & "&Action=Add&ClassID=" & ClassID & "&SpecialID=" & SpecialID & "'>继续添加" & ChannelShortName & "</a>】&nbsp;"
    Response.Write "【<a href='User_Supply.asp?ChannelID=" & ChannelID & "&Action=Manage&ClassID=" & ClassID & "'>" & ChannelShortName & "管理</a>】&nbsp;"
    Response.Write "【<a href='User_Supply.asp?ChannelID=" & ChannelID & "&Action=Show&SupplyID=" & SupplyId & "'>预览" & ChannelShortName & "内容</a>】"
    Response.Write "    </td>"
    Response.Write "  </tr>"
    Response.Write "</table>" & vbCrLf

    Call ClearSiteCache(0)
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)
    If PresentExp > UserPoint Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>你的点数不够，不可以发布信息！</li>"
    End If
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


Function CheckClassPurview(ClassID)
    Dim PurviewType, tClass, PurviewChecked, ParentID, Child, CheckParentPath
    If ClassID <= 0 Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>未指定所属栏目，或者指定的栏目不允许此操作！</li>"
    Else
        Set tClass = Conn.Execute("select ClassName,ClassType,Depth,ParentID,ParentPath,Child,EnableAdd from PE_Class where ClassID=" & ClassID)
        If tClass.BOF And tClass.EOF Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>找不到指定的栏目！</li>"
        Else
            ClassName = tClass("ClassName")
            Depth = tClass("Depth")
            ParentPath = tClass("ParentPath")
            ParentID = tClass("ParentID")
            Child = tClass("Child")
        
            If Child > 0 And tClass("EnableAdd") = False Then
                FoundErr = True
                ErrMsg = ErrMsg & "<li>指定的栏目不允许添加" & ChannelShortName & "</li>"
            End If
            If tClass("ClassType") = 2 Then
                FoundErr = True
                ErrMsg = ErrMsg & "<li>不能指定为外部栏目</li>"
            End If
            If ParentID > 0 Then
                CheckParentPath = ChannelDir & "all," & ParentPath & "," & ClassID
            Else
                CheckParentPath = ChannelDir & "all," & ClassID
            End If
            If CheckPurview_Class(arrClass_Input, CheckParentPath) = False Then
                FoundErr = True
                ErrMsg = ErrMsg & "<li>对不起，你没有此栏目的相应操作权限！</li>"
            End If
        End If
        Set tClass = Nothing
    End If
    If FoundErr = True Then
        CheckClassPurview = False
    Else
        CheckClassPurview = True
    End If
End Function

Sub Del()
    SupplyId = Trim(Request("SupplyID"))
    If IsValidID(SupplyId) = False Then
        SupplyId = ""
    End If
    If SupplyId = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请先选定" & ChannelShortName & "！</li>"
        Exit Sub
    End If
    
    Dim sqlDel, rsDel, NeedUpdateCache
    NeedUpdateCache = False
    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 & ") order by A.SupplyId"
    Else
        sqlDel = sqlDel & " where A.SupplyId=" & SupplyId
    End If
    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") & "'")
                NeedUpdateCache = True
            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
        rsDel.MoveNext
    Loop
    rsDel.Close
    Set rsDel = Nothing
    If NeedUpdateCache = True Then
        Call ClearSiteCache(0)
    End If

    Call CloseConn
    If FoundErr = False Then
        Response.Redirect ComeUrl
        Call Class_Terminate
    End If
End Sub

Sub Show()
    Dim rsSupply, sql, i
    If SupplyId = "" Then
        SupplyId = 0
    Else
        SupplyId = CLng(SupplyId)
    End If
    sql = "select SupplyId,ChannelId,ClassId,SpecialId,SupplyName,SupplyType,SupplyTitle,Status,SupplyIntro,SupplyPeriod,TradeType,PriceIntro,UserName,UpdateTime from PE_Supply where SupplyID=" & SupplyId & " And UserName='" & UserName & "'"
    Set rsSupply = Server.CreateObject("ADODB.Recordset")
    rsSupply.Open sql, Conn, 1, 1
    If rsSupply.BOF And rsSupply.EOF Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>找不到" & ChannelShortName & "</li>"
        rsSupply.Close
        Set rsSupply = Nothing
        Call Class_Terminate
        Exit Sub
    End If
    ClassID = rsSupply("ClassID")
    Dim tClass
    Set tClass = Conn.Execute("select ClassName,RootID,ParentID,Depth,ParentPath 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)
    End If
    Set tClass = Nothing
    If FoundErr = True Then
        rsSupply.Close
        Set rsSupply = Nothing
        Call Class_Terminate
        Exit Sub
    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 "  return false;" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "</SCRIPT>" & vbCrLf


    Response.Write "<br><table width='100%' border='0' align='center' cellpadding='2' cellspacing='0' class='border'>"
    Response.Write "  <tr class='title'>"
    Response.Write "    <td height='22' width='82%'>"
    Response.Write "您现在的位置：&nbsp;<a href='User_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 = Server.CreateObject("adodb.recordset")
        rsPath.Open sqlPath, Conn, 1, 1
        Do While Not rsPath.EOF
            Response.Write "<a href='User_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='User_Supply.asp?ChannelID=" & ChannelID & "&ClassID=" & ClassID & "'>" & ClassName & "</a>&nbsp;&gt;&gt;&nbsp;查看文章内容："
      
    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>" & rsSupply("SupplyIntro") & "</td>"
    Response.Write "  </tr>" & vbCrLf
    
    Response.Write "        </tbody>" & vbCrLf
    Response.Write "      </table>"
    Response.Write "    </td>"
    Response.Write "  </tr>"
    Response.Write "</table>" & vbCrLf
    Response.Write "<form name='formA' method='get' action='User_Supply.asp'><p align='center'> "
    Response.Write "<input type='hidden' name='ChannelID' value='" & ChannelID & "'>"
    Response.Write "<input type='hidden' name='SupplyID' value='" & SupplyId & "'>"
    Response.Write "<input type='hidden' name='Action' value=''>" & vbCrLf
    Response.Write "<p align='center'>" & vbCrLf

    If rsSupply("UserName") = UserName And rsSupply("Status") = 0 Then
        Response.Write "<input type='Submit' name='buttons1' value='修改' onclick=""document.formA.Action.value='Modify'"">&nbsp;&nbsp;"
    End If
    
    Response.Write "<input type='Submit' name='buttons2' value='彻底删除' onclick=""if(confirm('确定要彻底删除此" & ChannelShortName & "吗？彻底删除后将无法还原！')==true){document.formA.Action.value='Del';}"">&nbsp;&nbsp;"
    Response.Write "</Form></p>"

    rsSupply.Close
    Set rsSupply = Nothing


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>"
        Call Class_Terminate
        Exit Sub
    End If
    Dim tClass
    Set tClass = Conn.Execute("select ClassName,RootID,ParentID,Depth,ParentPath,Child from PE_Class where ClassID=" & ClassID)
    If tClass.BOF And tClass.EOF Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>找不到指定的栏目</li>"
        Set tClass = Nothing
        Call Class_Terminate
        Exit Sub
    Else
        ClassName = tClass(0)
        RootID = tClass(1)
        ParentID = tClass(2)
        Depth = tClass(3)
        ParentPath = tClass(4)
        Child = tClass(5)
    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 = Server.CreateObject("adodb.recordset")
        rsPath.Open sqlPath, Conn, 1, 1
        Do While Not rsPath.EOF
            Response.Write "" & rsPath(1) & "&nbsp;&gt;&gt;&nbsp;"
            rsPath.MoveNext
        Loop
        rsPath.Close
        Set rsPath = Nothing
    End If
    Response.Write "" & ClassName & "&nbsp;&gt;&gt;&nbsp;"

    Response.Write "" & PE_HTMLEncode(Request("Title"))
    Response.Write " </td>"
    Response.Write "    <td width='50' height='22' align='right'>"
    If LCase(Request("OnTop")) = "yes" Then
        Response.Write "顶&nbsp;"
    Else
        Response.Write "&nbsp;&nbsp;&nbsp;"
    End If
    If LCase(Request("Hot")) = "yes" Then
        Response.Write "热&nbsp;"
    Else
        Response.Write "&nbsp;&nbsp;&nbsp;"
    End If
    If LCase(Request("Elite")) = "yes" Then
        Response.Write "荐"
    Else
        Response.Write "&nbsp;&nbsp;"
    End If
    Response.Write "</td>"
    Response.Write "  </tr>"
    Response.Write "  <tr class='tdbg'><td colspan='3' align='center'><font size='4'>"
    If Trim(Request("TitleIntact")) <> "" Then
        Response.Write "<font size='4'><b>" & PE_HTMLEncode(Request("TitleIntact")) & "</b></font>"
    Else
        Response.Write "<font size='4'><b>" & PE_HTMLEncode(Request("Title")) & "</b></font>"
    End If
    If Trim(Request("Subheading")) <> "" Then
        Response.Write "<br>" & PE_HTMLEncode(Request("Subheading"))
    End If

    Response.Write "</font></td></tr>"
    Response.Write "  <tr class='tdbg'><td colspan='3' align='center'>作者：" & PE_HTMLEncode(Request("Author")) & "&nbsp;&nbsp;&nbsp;&nbsp;转贴自：" & PE_HTMLEncode(Request("CopyFrom")) & "&nbsp;&nbsp;&nbsp;&nbsp;点击数：0&nbsp;&nbsp;&nbsp;&nbsp;" & ChannelShortName & "录入：" & UserName & "</td></tr>"
    Response.Write "  <tr class='tdbg'><td colspan='3'><p>" & Request("Content") & "</p></td></tr>"
    Response.Write "</table>"
    Response.Write "<p align='center'>【<a href='javascript:window.close();'>关闭窗口</a>】</p>"
End Sub

%>
