<% Option Explicit %>
<!--#include file="../../Inc/Const.asp" -->
<!--#include file="../../Inc/Cls_DB.asp" -->
<%
Dim DBC,Conn
Set DBC = New DataBaseClass
Set Conn = DBC.OpenConnection()
Set DBC = Nothing
'==============================================================================
'软件名称：风讯网站信息管理系统
'当前版本：Foosun Content Manager System 2.0 
'最新更新：2004.12
'==============================================================================
'商业注册联系：028-85098980-601,602 技术支持：028-85098980-606、607,客户支持：608
'产品咨询QQ：159410,655071,66252421
'技术支持:所有程序使用问题，请提问到bbs.foosun.net我们将及时回答您
'程序开发：风讯开发组 & 风讯插件开发组
'论坛支持：风讯在线论坛(http://bbs.foosun.net)
'官方网站：www.Foosun.net  演示站点：test.cooin.com    
'网站建设专区：www.cooin.com
'==============================================================================
'免费版本请在新闻首页保留版权信息，并做上本站LOGO友情连接
'==============================================================================
%>
<!--#include file="../../Inc/Session.asp" -->
<!--#include file="../../Inc/CheckPopedom.asp" -->
<%
if Not JudgePopedomTF(Session("Name"),"P0111") then Call ReturnError()
    Dim NewsIDStr,RsNewsObj
	If Request("NewsID")<>"" then
	   NewsIDStr = Cstr(Request("NewsID"))
	else
		Response.Write("<script>alert(""参数传递错误"");dialogArguments.location.reload();window.close();</script>")
		Response.End
	end if
%>
<html>
<head>
<link href="../Inc/ModeWindow.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>添加新闻到专题</title>
</head>

<body>
<form action="" name="ToWordJsForm" method="post">
  <table width="100%" border="0" cellspacing="5" cellpadding="0">
    <tr> 
      <td width="7%" height="5">&nbsp;</td>
      <td width="16%" height="5">&nbsp;</td>
      <td width="77%" height="5">&nbsp;</td>
    </tr>
    <tr> 
      <td>&nbsp;</td>
      <td>专题名称</td>
      <td><select name="SpecialID" id="JSName" style="width:90%">
          <option value=""> </option>
          <%
	    Dim SpecialObj
		Set SpecialObj = Conn.Execute("Select SpecialID,CName from Special order by ID desc")
	    While Not SpecialObj.eof 
	  %>
          <option value="<%=SpecialObj("SpecialID")%>"><%=SpecialObj("CName")%></option>
          <%
		SpecialObj.MoveNext
		Wend
	    SpecialObj.Close
		Set SpecialObj = Nothing
	  %>
        </select>
      </td>
    </tr>
    <tr> 
      <td height="5">&nbsp;</td>
      <td height="5">&nbsp;</td>
      <td height="5">&nbsp;</td>
    </tr>
    <tr> 
      <td colspan="3"><div align="center"> 
          <input type="submit" name="Submit22" value=" 确 定 ">
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
          <input name="action" type="hidden" id="action2" value="trues">
          <input type="button" name="Submit32" value=" 取 消 " onClick="window.close();">
        </div></td>
    </tr>
  </table>
</form>
</body>
</html>
<%
  If Request.Form("action") = "trues" then
     Dim ToSpecialID,SpecialIDStr,NewsIDArray,R_i,ErrorStr
		 ToSpecialID = Request.Form("SpecialID")
	 If ToSpecialID = "" or isnull(ToSpecialID) then
	    Response.Write("<script>alert(""请选择专题"");</script>")
		Response.End
	 End If
	 NewsIDArray = Array("")
	 NewsIDArray = Split(NewsIDStr,",")
	 For R_i = 0 to UBound(NewsIDArray)
		 Set RsNewsObj = Server.CreateObject("ADODB.RecordSet")
		 RsNewsObj.Open "Select SpecialID,NewsID,Title from News where HeadNewsTF=0 and NewsID='"&NewsIDArray(R_i)&"'",Conn,1,1
		 If Not RsNewsObj.eof then
			if IsNull(RsNewsObj("SpecialID")) then
				Conn.Execute("Update News set SpecialID='"&ToSpecialID&"' where NewsID='"&NewsIDArray(R_i)&"'")
			else
				if RsNewsObj("SpecialID") = "" then
					Conn.Execute("Update News set SpecialID='"&ToSpecialID&"' where NewsID='"&NewsIDArray(R_i)&"'")
				elseIf Instr(1,RsNewsObj("SpecialID"),ToSpecialID) = 0 then
					SpecialIDStr = RsNewsObj("SpecialID")&","&ToSpecialID
					Conn.Execute("Update News set SpecialID='"&SpecialIDStr&"' where NewsID='"&NewsIDArray(R_i)&"'")
				else
					if ErrorStr = "" then
						ErrorStr = RsNewsObj("Title")
					else
						ErrorStr = ErrorStr & "|" & RsNewsObj("Title")
					end if
				End If
			End If
		end if
		RsNewsObj.Close
		Set RsNewsObj = Nothing
	 Next
	 if ErrorStr = "" then
		Response.Write("<script>alert(""所选新闻已经成功加入专题"");dialogArguments.location.reload();window.close();</script>")
	else
		Response.Write("<script>alert('专题中已经存在:" & ErrorStr & "');dialogArguments.location.reload();window.close();</script>")
	end if
	Response.End
  End If
%>