<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<% if session("admid")="" or Session("class")<>"1" then response.redirect"login.asp"%>
<!--#include file="conn.asp"-->

<%dim action
action=request.QueryString("action")
function mousereplace(keyword)
keyword=trim(request.form(keyword)) 
mousereplace=keyword
end function%>
<script language=javascript>
function mcheck(){
if(document.form1.N_title.value=="")
{alert("新闻标题不能为空！");
document.form1.N_title.focus();
return false;}
if(document.form1.N_content.value.length<10)
{
alert("新闻内容不得少于10个字符！");
document.form1.N_content.focus();
return false;}
return true;}
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style type="text/css">
<!--
body,td,th {
	font-size: 12px;
}
.style1 {color: #FFFFFF}
-->
</style>
</head>

<body>
<%
if action="" then
sql="select * from news order by n_date desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1%>
      <%
dim page,tolpage,maxlist,pageno
maxlist=15		'//* 每页默认显示信息数 *//
if not isempty(request("page")) then 
pageno=cint(request("page"))
else
pageno=1
end if
%>
<form name="form1" method="post" action="?action=add" onsubmit="return mcheck()">
  <table width="650"  border="1"  bordercolorlight="#006d63" bordercolordark="ffffff" align="center" cellpadding="5" cellspacing="0">
    <tr bgcolor="#006d63">
      <td height="25" colspan="2" align="center"><span class="style1">-=动态新闻发布=-</span></td>
    </tr>
    <tr>
      <td height="20" align="right">新闻类别：</td>
      <td width="393"><select name="N_class" id="N_class">
        <option value="NEWS">NEWS</option>
        <option value="CICLife">CICLife</option>
        </select>
      </td>
    </tr>
    <tr>
      <td height="20" align="right">新闻标题：</td>
      <td height="20"><input name="N_title" type="text" id="N_title">
      </td>
    </tr>
    <tr>
      <td height="20" align="right">新闻内容：</td>
      <td height="20">(*内容至少为10个字符)</td>
    </tr>
    <tr>
      <td height="20">&nbsp;</td>
      <td height="20"><input name="n_content" type="hidden" value="">
          <iframe ID="eWebEditor1" src="editpage/ewebeditor.asp?id=n_content&style=xueren" frameborder="0" scrolling="no" width="500" HEIGHT="300"></iframe></textarea>
      </td>
    </tr>
    <tr align="center">
      <td height="20" align="right">是否推荐：</td>
      <td height="20" align="left"><input name="new1" type="radio" value="true" checked>
        是
          <input type="radio" name="new1" value="false">
      否</td>
    </tr>
    <tr align="center">
      <td height="20" align="right">发布时间：</td>
      <td height="20" align="left"><input type="text" name="ndate">
      如： 2005-10-7</td>
    </tr>
    <tr align="center">
      <td height="20" colspan="2">
          <input type="submit" name="Submit" value="确认发布">
      </td>
    </tr>
  </table></form>
<table width="550"   border="1"  bordercolorlight="#006d63" bordercolordark="ffffff" align="center" cellpadding="2" cellspacing="0">
  <tr bgcolor="#006d63">
    <td height="25" colspan="6" align="center" class="style1">-=动态新闻列表=-</td>
  </tr>
  <tr bgcolor="#88CEDF">
    <td width="47"><div align="center">序号</div></td>
    <td width="80" height="20"><div align="center">类别</div></td>
    <td width="192"><div align="center">标题</div></td>
    <td width="97"><div align="center">时间</div></td>
    <td colspan="2"><div align="center">管理</div></td>
  </tr>
  <%if rs.eof and rs.bof then
	tolpage=0
	page=0
	pageno=0
else
	tolpage=rs.recordcount
	if tolpage mod maxlist=0 then
		page=tolpage\maxlist
	else
		page=tolpage\maxlist+1
	end if
	dim i
	rs.move (pageno-1)*maxlist
  i=1
  do while not rs.eof
  %><tr align="center">
    <td><%=i%></td>
    <td align="left"><%=rs("n_c")%>
      <%if rs("new")=true then%>
      <font color="#FF0000">[推]</font>
      <%end if %></td>
    <td><%=left(rs("n_title"),20)%></td>
    <td><%=rs("n_date")%></td>
    <td width="42">      <input type="button" style="position:relative; color:#ffffff; font_family: 宋体;font-size: 9pt; height: 19;background-color:#006d63;" name="Submit" value="修改" onclick="window.location.href='?action=view&id=<%=rs("n_id")%>'">    </td>
    <td width="42">      <input type="button" style="position:relative; color:#ffffff; font_family: 宋体;font-size: 9pt; height: 19;background-color:#006d63;" name="Submit" value="删除" onclick="javascript:if(confirm('确认删除？')){window.location.href='?action=del&id=<%=rs("n_id")%>';}else{return false;}">    </td>
  </tr><%i=i+1
  if i>=maxlist+1 then exit do
   rs.movenext
    loop
rs.close
  end if %>
  <tr>
    <td colspan="6"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" valign="top">
            <tr>
              <td align="center" >第<%=pageno%>/<%=page%>页</td>
              <td align="center">共<%=tolpage%>条信息</td>
              <td align="center" ><%if pageno>1 then%>
                  <a href="?page=<%=pageno-1%>" title="上一页">上一页</a>
                  <%else%>
      上一页
      <%end if%></td>
              <td align="center"><%if pageno<page then%>
                  <a href="?page=<%=pageno+1%>" title="下一页">下一页</a>
                  <%else%>
      下一页
      <%end if%></td>
              <%if page>1 then%>
              <td align="center" ><a href="?page=1" title="首页">首页</a></td>
              <td align="center" ><a href="?page=<%=page%>" title="尾页">尾页</a></td>
              <%else%>
              <td align="center" >首页</td>
              <td align="center">尾页</td>
              <%end if%>
              <td align="right" >跳转到:&nbsp;第</td>
              <td  align="center"><select name="select" onchange="javascript:window.location.href=this.options[this.selectedIndex].value" size="1">
                  <option value="?page=<%=pageno%>" selected><%=pageno%></option>
                  <%for i=1 to page%>
                  <option value="?page=<%=i%>"><%=i%></option>
                  <%Next%>
              </select></td>
              <td align="left">页</td>
            </tr>
    </table></td>
  </tr>
  
</table><%end if %><%


if action="add" then
ndate=mousereplace("ndate")
n_class=mousereplace("n_class")
n_title=mousereplace("n_title")
n_new=request("new1")
n_content=request.form("n_content")
set rs=server.CreateObject("adodb.recordset")
sql="select * from news"
rs.open sql,conn,1,3
rs.addnew
rs("n_date")=ndate
rs("N_c")=n_class
rs("N_title")=n_title
rs("new")=N_new
rs("n_content")=N_content
rs.update
rs.close
response.redirect"?"
end if 
if action="del" then
set rs=conn.execute("delete from news where n_id="&request("id")&"")
response.redirect"?"
end if 
if action="edit" then
n_class=mousereplace("n_class")
n_title=mousereplace("n_title")
id=mousereplace("id")
n_new=request("new")
n_date=request.form("ndate")
n_content=request.form("n_content")
set rs=server.CreateObject("adodb.recordset")
sql="select * from news where n_id="&id&""
rs.open sql,conn,1,3
rs("n_date")=request("ndate")
rs("N_c")=n_class
rs("N_title")=n_title
rs("new")=request("new")
rs("n_content")=N_content
rs.update
rs.close
response.write"<script language=javascript>alert('修改成功!');this.location.href='?'</script>"
end if 
if action="view" then
id=request("id")
set rs=conn.execute("select * from news where n_id="&id)%>

<form name="form1" method="post" action="?action=edit" onsubmit="return mcheck()">
  <table width="650"  border="1"  bordercolorlight="#006d63" bordercolordark="ffffff" align="center" cellpadding="5" cellspacing="0">
    <tr bgcolor="#006d63">
      <td height="25" colspan="2" align="center">-=动态新闻更新=-</td>
    </tr>
    <tr>
      <td height="20" align="right">新闻类别：</td>
      <td width="393"><select name="N_class" id="N_class">
        <option value="<%=rs("N_c")%>"><%=rs("N_c")%></option>
        <option value="NEWS">NEWS</option>
        <option value="CICLife">CICLife</option>
        </select>
      </td>
    </tr>
    <tr><input name=id type=hidden value="<%=rs("n_id")%>">
      <td height="20" align="right">新闻标题：</td>
      <td height="20"><input name="N_title" type="text" value="<%=rs("N_title")%>" id="N_title">
      </td>
    </tr>
    <tr>
      <td height="20" align="right">新闻内容：</td>
      <td height="20">(*内容至少为10个字符)</td>
    </tr>
    <tr>
      <td height="20">&nbsp;</td>
      <td height="20"><input name="n_content" type="hidden" value="<%=server.HTMLEncode(rs("N_content"))%>">
          <iframe ID="eWebEditor1" src="editpage/ewebeditor.asp?id=n_content&style=xueren" frameborder="0" scrolling="no" width="500" HEIGHT="300"></iframe>
      </td>
    </tr><tr align="center">
      <td height="20" align="right">是否推荐：</td>
      <td height="20" align="left"><input name="new" type="radio" value="true" <%if rs("new")=true then response.write"checked" end if %>>
        是
          <input type="radio" name="new" value="false" <%if rs("new")=false then response.write"checked" end if %>>
          否</td>
    </tr>
    <tr align="center">
      <td height="20" align="right">发布时间：</td>
      <td height="20" align="left"><input name="ndate" type="text" id="ndate" value="<%=rs("n_date")%>">
      如：


 2005-10-7</td>
    </tr>
    <tr align="center">
      <td height="20" colspan="2"><input type="submit" name="Submit" value="确认发布">
      </td>
    </tr>
  </table></form>
<%end if %>
</body>
</html>
