<% Option Explicit %>
<!--#include file="inc/Cls_DB.asp" -->
<!--#include file="../../Inc/Const.asp" -->
<%
'==============================================================================
'软件名称：风讯新闻采集系统V1.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友情连接
'==============================================================================
Dim DBC,Conn,CollectConn
Set DBC = New DataBaseClass
Set CollectConn = DBC.OpenConnection()
DBC.ConnStr = "DBQ=" + Server.MapPath(DataBaseConnectStr) + ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
Set Conn = DBC.OpenConnection()
Set DBC = Nothing
'判断权限
%>
<!--#include file="../../Inc/Session.asp" -->
<!--#include file="../../Inc/CheckPopedom.asp" -->
<%
if Not JudgePopedomTF(Session("Name"),"P1408") then Call ReturnError1()
'判断权限结束

Dim NewsIDStr,Result,RsNewsObj,Sql
Dim Title,Links,Content,AddDate,ClassID,SiteID,SysTemplet
Result = Request("Result")
NewsIDStr = Request("NewsIDStr")
if Result = "Submit" then
	Title = Request.Form("Title")
	Links = Request.Form("Links")
	Content = Request.Form("Content")
	AddDate = Request.Form("AddDate")
	ClassID = Request.Form("ClassID")
	SiteID = Request.Form("SiteID")
	SysTemplet = Request.Form("SysTemplet")
	if NewsIDStr <> "" then
		Sql = "Select * from News where ID=" & NewsIDStr
		'On Error Resume Next
		Set RsNewsObj = Server.CreateObject("ADODB.RecordSet")
		RsNewsObj.Open Sql,CollectConn,3,3
		RsNewsObj("Title") = Title 
		RsNewsObj("Links") = Links
		RsNewsObj("Content") = Content
		RsNewsObj("AddDate") = AddDate
		RsNewsObj("ClassID") = ClassID
		RsNewsObj("SysTemplet") = SysTemplet
		RsNewsObj("SiteID") = SiteID
		RsNewsObj.UpDate
		RsNewsObj.Close
		Set RsNewsObj = Nothing
		if Err.Number <> 0 then
%>
	<script language="JavaScript">
	alert('修改失败');
	dialogArguments.location.reload();
	window.close();
	</script>
<%
		else
%>
	<script language="JavaScript">
	alert('修改成功');
	dialogArguments.location.reload();
	window.close();
	</script>
<%
		end if
	else
%>
	<script language="JavaScript">
	alert('修改的新闻不存在');
	</script>
<%
	end if
else
	if NewsIDStr <> "" then
		Sql = "Select * from News where ID=" & NewsIDStr
		Set RsNewsObj = CollectConn.Execute(Sql)
		if Not RsNewsObj.Eof then
			Title = RsNewsObj("Title")
			Links = RsNewsObj("Links")
			Content = RsNewsObj("Content")
			AddDate = RsNewsObj("AddDate")
			ClassID = RsNewsObj("ClassID")
			SiteID = RsNewsObj("SiteID")
			SysTemplet = RsNewsObj("SysTemplet")
		else
%>
	<script language="JavaScript">
	alert('新闻不存在');
	</script>
<%
		end if
	else
%>
	<script language="JavaScript">
	alert('参数错误');
	</script>
<%
	end if
end if

Dim ClassList,RsClassObj
Set RsClassObj = Server.CreateObject("Adodb.RecordSet")
RsClassObj.Source = "Select ClassID,ClassCName from NewsClass order by id desc"
RsClassObj.open RsClassObj.Source,Conn,1,3
do while Not RsClassObj.Eof
	if RsClassObj("ClassID") = ClassID then
		ClassList = ClassList & "<option selected value=" & RsClassObj("ClassID") & "" & ">" & RsClassObj("ClassCName") & "</option><br>"
	else
		ClassList = ClassList & "<option value=" & RsClassObj("ClassID") & "" & ">" & RsClassObj("ClassCName") & "</option><br>"
	end if
	RsClassObj.MoveNext	
loop
RsClassObj.Close
Set RsClassObj = Nothing

Dim SiteList,RsSiteObj
Set RsSiteObj = Server.CreateObject("Adodb.RecordSet")
RsSiteObj.Source = "Select ID,SiteName from Site order by id desc"
RsSiteObj.open RsSiteObj.Source,CollectConn,1,3
do while Not RsSiteObj.Eof
	if RsSiteObj("ID") = CInt(SiteID) then
		SiteList = SiteList & "<option selected value=" & RsSiteObj("ID") & "" & ">" & RsSiteObj("SiteName") & "</option><br>"
	else
		SiteList = SiteList & "<option value=" & RsSiteObj("ID") & "" & ">" & RsSiteObj("SiteName") & "</option><br>"
	end if
	RsSiteObj.MoveNext	
loop
RsSiteObj.Close
Set RsSiteObj = Nothing
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>修改新闻</title>
<style type="text/css">
<!--
.LableDown {
	border-top-width: thin;
	border-right-width: thin;
	border-bottom-width: thin;
	border-left-width: thin;
	border-top-style: solid;
	border-right-style: solid;
	border-bottom-style: none;
	border-left-style: solid;
	border-top-color: #000000;
	border-right-color: #CCCCCC;
	border-left-color: #FFFFFF;
}
.LableUp {
	border-top-width: thin;
	border-right-width: thin;
	border-bottom-width: thin;
	border-left-width: thin;
	border-top-style: solid;
	border-right-style: solid;
	border-bottom-style: solid;
	border-left-style: solid;
	border-top-color: #000000;
	border-right-color: #000000;
	border-bottom-color: #999999;
	border-left-color: #999999;
}
-->
</style>
</head>

<link href="inc/ModeWindow.css" rel="stylesheet">
<body topmargin="0" leftmargin="0">
<div align="center">
  <table width="96%" border="0" cellspacing="0" cellpadding="0">
    <form action="" method="post" name="NewsForm">
      <tr> 
        <td height="30"><div align="center">新闻标题</div></td>
        <td height="30" colspan="3"><input name="Title" type="text" id="Title2" style="width:100%;" value="<% = Title %>"></td>
      </tr>
      <tr> 
        <td width="15%" height="30"> <div align="center">新闻联接</div></td>
        <td height="30" colspan="3"> <div align="right"></div>
          <input name="Links" type="text" id="Links" style="width:100%;" value="<% = Links %>"></td>
      </tr>
      <tr> 
        <td height="30"> <div align="center">目标栏目</div></td>
        <td width="35%" height="30"><select style="width:100%;" name="ClassID">
            <% = ClassList %>
          </select></td>
        <td width="15%" height="30"><div align="center">新闻摸板</div></td>
        <td height="30"><input name="SysTemplet" type="text" id="SysTemplet" style="width:100%;" value="<% = SysTemplet %>"> 
        </td>
      </tr>
      <tr> 
        <td height="30"> <div align="center">采集站点</div></td>
        <td height="30"> <select style="width:100%;" name="SiteID">
            <% = SiteList %>
          </select> </td>
        <td height="30"><div align="center">采集日期</div></td>
        <td height="30"><input name="AddDate" type="text" id="AddDate" style="width:100%;" value="<% = AddDate %>"></td>
      </tr>
      <tr style="display:none;"> 
        <td height="30" colspan="4"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
            <tr> 
              <td width="100" class="LableDown" onClick="CodeContent();"> 
                <div align="center">
                  <p>代 码</p>
                </div></td>
              <td width="100" class="LableUp" onClick="Preview();"> 
                <div align="center">预 览</div></td>
              <td>&nbsp;</td>
            </tr>
          </table></td>
      </tr>
      <tr> 
        <td height="30" colspan="4"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
            <tr> 
              <td><div align="center">
                  <input type="button" name="Submit3" value=" 代 码 " onClick="CodeContent();">
                </div></td>
              <td><div align="center">
                  <input type="button" name="Submit4" value=" 预 览 " onClick="Preview();">
                </div></td>
            </tr>
          </table></td>
      </tr>
      <tr id="EditCodeArea"> 
        <td width="15%" height="300"> <div align="center">新闻内容</div></td>
        <td height="30" colspan="3"><textarea name="Content" rows="20" id="Content" style="width:615;height:100%;"><% = Content %></textarea></td>
      </tr>
      <tr id="PreviewArea" style="display:none;"> 
        <td width="15%" height="300"> <div align="center">新闻内容</div></td>
        <td height="30" colspan="3"><iframe name="PreviewContent" class="Composition" ID="PreviewContent" MARGINHEIGHT="1" MARGINWIDTH="1" width="615" height="100%" scrolling="yes" src="about:blank"></iframe></td>
      </tr>
      <tr> 
        <td height="50" colspan="4"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr> 
              <td><div align="center"> 
                  <input type="submit" name="Submit" value=" 确 定 ">
                  <input name="Result" type="hidden" id="Result" value="Submit">
                  <input value="<% = NewsIDStr %>" name="NewsIDStr" type="hidden" id="NewsIDStr">
                </div></td>
              <td><div align="center"> 
                  <input onClick="window.close();" type="button" name="Submit2" value=" 取 消 ">
                </div></td>
            </tr>
          </table></td>
      </tr>
    </form>
  </table>
</div>
</body>
</html>
<%
Set CollectConn = Nothing
Set Conn = Nothing
Set RsNewsObj = Nothing
%>
<script language="JavaScript">
function Preview()
{
	var TempStr='';
	document.all.EditCodeArea.style.display='none';
	document.all.PreviewArea.style.display='';
	//PreviewContent.document.write('');
	PreviewContent.document.write('<head><link href=\"../../css/css.css\" type=\"text/css\" rel=\"stylesheet\"></head><body MONOSPACE>');
	//PreviewContent.document.write('');
	PreviewContent.document.body.innerHTML=document.all.Content.value;
}
function CodeContent()
{
	document.all.EditCodeArea.style.display='';
	document.all.PreviewArea.style.display='none';
}
</script>