<!--#include file="check.asp"-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>新闻管理</title>
<link href="images/main.css" rel="stylesheet" type="text/css" media="all" />
</head>
<!--#include file="top.asp"-->
<div id="systime"><p id="servertime"></p></div>
<div id="mainBody" >

<div class="space">&nbsp;</div>
<div class="list">
<%
Call hrPower(5.1,0)

Sub newscheckform()
 if request.form("topic")="" then 
    response.write "<script language='JavaScript'>{window.alert('您没有填写标题，请重新填写！');window.location='javascript:history.back();';}</script>"
    response.end
 end if
 if request.form("checkbox4")=1 then 
  '为链接新闻
   if request.form("titlelink")="" then 
    response.write "<script language='JavaScript'>{window.alert('您没有填写链接，请重新填写！');window.location='javascript:history.back();';}</script>"
    response.end
   end if
 else
  '为普通新闻
  if request.form("content")="" then 
    response.write "<script language='JavaScript'>{window.alert('您没有填写新闻内容，请重新填写！');window.location='javascript:history.back();';}</script>"
    response.end
  end if
 end if
end sub

dim action,newid,s,i,Rsboard,myurl
action=request.QueryString("action")
newsid=request.QueryString("newsid")


select case action
case "addnew"
'新增一条新闻，创建一个新的表单
%>
<script language="javascript">
try{
    var nav="H06";
    var subnav="L0602";
	
    document.getElementById(nav).className="current";
    document.getElementById(subnav).className="first current";
    document.getElementById(subnav).parentNode.parentNode.style.display="block";

}catch(e){
	document.getElementById("H06").className="current";
}
</script>

        <table border="0" width="100%">
            <tr class="pagehead">
                <td>
                    &nbsp;&nbsp;<b>您现在所在位置：</b>
                    <span id="lblNav">添加新闻</span>
                </td>
                <td>
                </td>
                <td align="right">
                </td>
            </tr>

<script   language="JavaScript">   
  function   ValidateInput()   
  {   



	var e=document.form1;
	if (e.topic.value==""){
		alert("新闻标题不能为空！");
		e.topic.focus();
		return;
	}


	if (e.content.value==""){
		alert("新闻内容不能为空！");
		e.content.focus();
		return;
	}

      document.form1.submit();   
      document.form1.Submit.disabled=true;   
  }   
  </script>  

            <td colspan="3" style="padding: 6px"><form name="form1" method="post" action="news.asp?action=upaddnew">
                    <table cellspacing="0" cellpadding="0" width="100%" border="0">
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                <span style="color: #cc0033">*</span>
                                新闻标题
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
                                <input name="topic" type="text" maxlength="150" id="topic" class="ShouldBeNote" style="width:200px;" />
  
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                <span style="color: #cc0033">*</span>
                                内容
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
                                <textarea name="content" ROWS="8" COLS="100" style="display='none'"><%=content%></textarea>
             
                            </td>
                        </tr>
<input name="auther" type="hidden" value="<%=request.cookies("Admin_Username")%>" id="auther">
                        <tr>
                            <td align="right" style="width: 180px; height: 34px" valign="middle">
                            </td>
                            <td valign="middle" width="*" style="height: 34px">

<input type="button" name="Submit" onClick="JavaScript:ValidateInput();" value="提交" id="Submit" /></td>
                        </tr>
                    </table>



<%
case "edit"
  set Rs=GrateRs("select * from H_news where newsid="&newsid,3)
  if not Rs.eof then 
  defalutboardid=Rs("boardtype")
%>

<script language="javascript">
try{
    var nav="H06";
    var subnav="L0601";
	
    document.getElementById(nav).className="current";
    document.getElementById(subnav).className="first current";
    document.getElementById(subnav).parentNode.parentNode.style.display="block";

}catch(e){
	document.getElementById("H06").className="current";
}
</script>

        <table border="0" width="100%">
            <tr class="pagehead">
                <td>
                    &nbsp;&nbsp;<b>您现在所在位置：</b>
                    <span id="lblNav">编辑新闻</span>
                </td>
                <td>
                </td>
                <td align="right">
                </td>
            </tr>

<script   language="JavaScript">   
  function   ValidateInput()   
  {   



	var e=document.form1;
	if (e.topic.value==""){
		alert("新闻标题不能为空！");
		e.topic.focus();
		return;
	}


	if (e.content.value==""){
		alert("新闻内容不能为空！");
		e.content.focus();
		return;
	}

      document.form1.submit();   
      document.form1.Submit.disabled=true;   
  }   
  </script> 

            <td colspan="3" style="padding: 6px"><form name="form1" method="post" action="news.asp?action=upedit&newsid=<%=Rs("newsid")%>">
                    <table cellspacing="0" cellpadding="0" width="100%" border="0">
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                <span style="color: #cc0033">*</span>
                                新闻标题
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
                                <input name="topic" type="text" value="<%=Rs("topic")%>" maxlength="150" id="topic" class="ShouldBeNote" style="width:200px;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                <span style="color: #cc0033">*</span>
                                内容
                                &nbsp;
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
                               <div><textarea name="content" ROWS="8" COLS="100" display='none'><%=Rs("content")%></textarea></div>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" style="width: 180px; height: 34px" valign="middle">
                            </td>
                            <td valign="middle" width="*" style="height: 34px">
<input type="button" name="Submit" onClick="JavaScript:ValidateInput();" value="提交" id="Submit" /></td>
                        </tr>

</form>

<%
   else
    response.write "<script language='JavaScript'>{window.alert('新闻不存在,无法完成操作！');window.location='"&Request.ServerVariables("HTTP_REFERER")&"';}</script>"
  end if	
case "del"
  set Rs=GrateRs("select * from H_news where newsid="&newsid,3)
  if not Rs.eof then 
    Rs.delete
	Rs.update
    response.write "<script language='JavaScript'>{window.alert('新闻已经成功删除！');window.location='"&Request.ServerVariables("HTTP_REFERER")&"';}</script>"
  else
    response.write "<script language='JavaScript'>{window.alert('新闻不存在,无法完成删除！');window.location='"&Request.ServerVariables("HTTP_REFERER")&"';}</script>"
  end if	  
case "upaddnew"
  call newscheckform
  set Rs=GrateRs("select * from H_news",3)
  Rs.addnew
  Rs("topic")=request.form("topic")
  Rs("content")=request.form("content")
  Rs("boardtype")=request.form("boardtype")





  Rs("time")=date()
  Rs("lasttime")=now()


  if request.form("auther")<>"" then 
  	Rs("auther")=request.form("auther")
  else
    Rs("auther")=request.cookies("Admin_Username")
  end if
  Rs.update
  response.write "<script language='JavaScript'>{window.alert('您增加的新闻已经成功保存,请查看！');window.location='news.asp?action=list';}</script>"
case "upedit"
  call newscheckform
  set Rs=GrateRs("select * from H_news where newsid="&newsid,3)
  Rs("topic")=request.form("topic")
  Rs("content")=request.form("content")
  Rs("boardtype")=request.form("boardtype")

  Rs("lasttime")=now()
  Rs("time")=date()
  Rs.update
  response.write "<script language='JavaScript'>{window.alert('您编辑的新闻已经成功保存,请查看！');window.location='news.asp?action=list';}</script>"
case "list"
%>

<script language="javascript">
try{
    var nav="H06";
    var subnav="L0601";
	
    document.getElementById(nav).className="current";
    document.getElementById(subnav).className="first current";
    document.getElementById(subnav).parentNode.parentNode.style.display="block";

}catch(e){
	document.getElementById("H06").className="current";
}
</script>


<table class="listtable">
  <thead>
    <tr>
      <th scope="col">新闻ID</th>
	  <th scope="col">新闻标题</th>
            <th scope="col">加入时间</th>
            <th scope="col">作者</th>
            <th scope="col">操作</th>
    </tr>
  </thead>
  <tbody> 






              	   <%
				   Nowpage=CLng(Request.QueryString("Page"))
				   boardtype=Request.QueryString("boardtype")
				   searchtext=Request.QueryString("searchtext")
				   newsid=request.QueryString("newsid")				   
				   boardstyle=1
				   defalutboardid=boardtype
				   if Isnumeric(newsid) and newsid<>"" then 
				   		set Rs=GrateRs("select * from H_news where newsid="&newsid&" order by newsid desc",1)
				   else
				  	  if boardtype="" then 
						  if searchtext="" then 
							  set Rs=GrateRs("select * from H_news order by newsid desc",1)
							else
							  set Rs=GrateRs("select * from H_news where topic like '%"&searchtext&"%'"&" order by newsid desc",1)
						  end if
				   		else
						   if searchtext="" then 
							  set Rs=GrateRs("select * from H_news where boardtype="&boardtype&" order by newsid desc",1)
							else
							  set Rs=GrateRs("select * from H_news where boardtype="&boardtype&" and topic like '%"&searchtext&"%'"&" order by newsid desc",1)
				   	      end if
				        end if
				   end if
				   Rs.PageSize=20
				   i=1
				   if Rs.eof then 
				     %>
<tr onmouseover="this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='infobackground'" onmouseout="this.style.backgroundColor=this.oldcolor" style="color:#284775;background-color:White;">
                      <td height="26" colspan="6" align="center" bgcolor="#DEE3EF">对不起,该分类还没有添加新闻!</td>
                    </tr>
					 <%
				   else
				   
				   If Nowpage=0 then Nowpage=1
				   Rs.AbsolutePage=Nowpage 
				   do while not Rs.eof and i<=Rs.pagesize
			   %>
<%if i mod 2 =0 then%>
         <tr class="listtr1" >
<%else%>
         <tr class="listtr2" >
<%end IF%>
                  <td><%=Rs("newsid")%></td>
                  <td><%=Rs("topic")%></td>
                  <td><%=Rs("lasttime")%></td>
                  <td><%=Rs("auther")%></td>
                  <td><a href="news.asp?action=edit&newsid=<%=Rs("newsid")%>">编辑</a> /<a href='javascript:if(confirm("确实要删除吗?"))location="news.asp?action=del&newsid=<%=Rs("newsid")%>"'>删除</a></td>
			    </tr>
				<%
				Rs.movenext
				i=i+1
				loop
				end if
				%>
<tr>
<td height="26" colspan="6">
&nbsp;<strong>翻页: :</strong>
<%
  myurl="news.asp?Action=list&boardtype="&boardtype&"&searchtext="&searchtext&"&"
  response.write("共:"&Rs.PageCount&"页,"&Rs.PageSize&"条/页,第"&NowPage&"页&nbsp;")
  response.write("<a href='"&myurl&"page=1'>"&"首页</a>&nbsp;")
  if NowPage>1 then response.write("<a href='"&myurl&"page="&Nowpage-1&"'>上一页</a>&nbsp;")
  if NowPage<Rs.PageCount then response.write("<a href='"&myurl&"page="&Nowpage+1&"'>下一页</a>&nbsp;")
  response.write("<a href='"&myurl&"page="&Rs.PageCount&"'>尾页</a>&nbsp;")
  %></td>
                </tr>
<tr>
                  <td height="52" colspan="6" align="center"><form name="form2" method="get" action="news.asp">
                    <input name="action" type="hidden" id="action" value="list">
&nbsp;新闻ID:
<input name="newsID" type="text" class="inputbox" id="newsID" size="6">
&nbsp;新闻标题:
<input name="searchtext" type="text" class="inputbox" id="searchtext">
<input name="Submit" type="submit" class="inputbutton" value=" 立即搜索 ">

                  </form></td>
                </tr>
            </table>
          </td>
        </tr>

    </table></td>
  </tr>
</table>
<%
case else
%><table width="98%"  border="0" align="center" cellpadding="0" cellspacing="1" class="tablegg">
  <tr>
    <td><table width="100%"  border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#F1F1F1">
      <tr bgcolor="#E3E2C3">
        <td height="23" bgcolor="#869BC6"><div align="center" class="style4">新闻管理 </div></td>
      </tr>
      <tr>
        <td height="84" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
          <tr bgcolor="#EDEDE1">
            <td height="26" colspan="2" bgcolor="#DEE3EF"><span class="forumRow">&nbsp;&nbsp;&nbsp;<strong>&nbsp;&nbsp;: : 系统错误 : :</strong></span></td>
          </tr>
          <tr bgcolor="#F1F1F1">
            <td width="10%" height="26" align="center" bgcolor="#DEE3EF">□</td>
            <td width="90%" height="26" bgcolor="#DEE3EF">您没有管理的权限或者您的登录已经超时，请重新<a href="index.asp" target="_parent">登录</a>！</td>
          </tr>
          <tr bgcolor="#F1F1F1">
            <td height="26" align="center" bgcolor="#DEE3EF">□</td>
            <td height="26" bgcolor="#DEE3EF">调用参数非法导致错误，请不要越权使用！</td>
          </tr>
        </table></td>
      </tr>

    </table></td>
  </tr>
</table>
<%
end select
call DBConnEnd
%>
</body>
</html>
