<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp" -->
<!--#include file="admin.asp" -->

<%
if session("s1985nnhfasname")="" then
response.Write "<script language=javascript>alert('您还未登陆或已超时,请重新登陆！');this.location.href='login.asp';</script>"
end if
dim worktypr
worktype=request.QueryString("worktype")
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body,td,th {
	font-size: 12px;
}
body {
	background-color: #d6dff7;
}
-->
</style>
<SCRIPT language="javascript">
<!--
function del_space(s)
{
	for(i=0;i<s.length;++i)
	{
	 if(s.charAt(i)!=" ")
		break;
	}

	for(j=s.length-1;j>=0;--j)
	{
	 if(s.charAt(j)!=" ")
		break;
	}

	return s.substring(i,++j);
}

function VerifySubmit()
{
	title = del_space(document.all("title").value);
     if (title.length == 0)
     {
        alert("标题不能为空!");
	return false;
     }
	 
	
	text_worker = del_space(document.all("text_worker").value);
     if (text_worker.length == 0)
     {
        alert("作者不能为空!");
	return false;
     }

	return true;
}
//-->
</SCRIPT>
</head>

<body>
<br>
<%
 if worktype="add" then
%>
<table width="580" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#000000">
  <tr>
    <td height="35" background="images/titlebg.gif" bgcolor="#FFFFFF" align="center" colspan="2">添加新闻</td>
  </tr>
  <form action="add_news.asp?worktype1=addnews" method="post" name="dataform" onSubmit="return VerifySubmit()">
    <tr>
      <td width="49" align="center" bgcolor="#FFFFFF">新闻标题</td>
	  <td width="520" bgcolor="#FFFFFF"><input name="title" type="text" id="title" /></td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF" align="center">新闻作者</td>
	  <td bgcolor="#FFFFFF"><input name="come" type="text" id="come" /></td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF" align="center">新闻内容</td>
	  <td bgcolor="#FFFFFF"><input name="content1" type="hidden" id="content1" value="" />
              <IFRAME ID="eWebEditor1" SRC="editor/ewebeditor.asp?id=content1&style=standard" FRAMEBORDER="0" SCROLLING="no" WIDTH="520" HEIGHT="350"></iframe></td>
    </tr>
    <tr>
      <td colspan="2" bgcolor="#FFFFFF" align="center"><input type="submit" name="Submit" value="提交" />
        &nbsp; <input type="reset" name="Submit2" value="重置" /></td>
    </tr>
  </form>
</table>
<%elseif worktype="mody" then%>
<table width="580" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#000000">
  <tr>
    <td height="35" colspan="4" align="center" background="images/titlebg.gif" bgcolor="#FFFFFF">管理新闻</td>
  </tr>
    <tr align="center">
      <td width="85" bgcolor="#FFFFFF" height="30">编号</td>
      <td width="288" bgcolor="#FFFFFF">标题</td>
      <td width="111" bgcolor="#FFFFFF">时间</td>
      <td width="75" bgcolor="#FFFFFF">操作</td>
    </tr> 
<%
sql="select * from news order by id desc"
rs.open sql,conn,1,1
  rs.PageSize =5 '每页记录条数
			iCount=rs.RecordCount '记录总数
			iPageSize=rs.PageSize
    		maxpage=rs.PageCount 
    		page=request("page")
    if Not IsNumeric(page) or page="" then
        page=1
    else
        page=cint(page)
    end if
    if page<1 then
        page=1
    elseif  page>maxpage then
        page=maxpage
    end if
    rs.AbsolutePage=Page
	if page=maxpage then
		x=iCount-(maxpage-1)*iPageSize
	else
		x=iPageSize
	end if

  ii=0
  For i=1 To x
  %>
<tr bgColor='#E6EFF8' onMouseOver="javascript:this.bgColor='#BFDFFF'" onMouseOut="javascript:this.bgColor='#E6EFF8'">
      <td align="center"><%=rs("id")%></td>
    <td><%=rs("title")%></td>
    <td align="center"><%=rs("time")%></td>
      <td align="center"><a href="news_message.asp?worktype=edit&id=<%=rs("id")%>">编辑</a> <a href="add_news.asp?worktype1=del&id=<%=rs("id")%>">删除</a></td>
  </tr>
 <%rs.movenext
		     ii=ii+1
			 next%>
	<tr>
   <td colspan="4" bgcolor="#FFFFFF" align=center height=30><%call PageControl(iCount,maxpage,page,"border=0 align=center","<p align=center>")
		
		rs.close
		set rs=nothing
Sub PageControl(iCount,pagecount,page,table_style,font_style)
'生成上一页下一页链接
    Dim query, a, x, temp
    action = "http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME")
    query = Split(Request.ServerVariables("QUERY_STRING"), "&")
    For Each x In query
        a = Split(x, "=")
        If StrComp(a(0), "page", vbTextCompare) <> 0 Then
            temp = temp & a(0) & "=" & a(1) & "&"
        End If
    Next
    Response.Write("<table width=100% border=0 cellpadding=0 cellspacing=0 >" & vbCrLf )        
    Response.Write("<form method=get onsubmit=""document.location = '" & action & "?" & temp & "Page='+ this.page.value;return false;""><TR >" & vbCrLf )
    Response.Write("<TD align=center height=40>" & vbCrLf )
    Response.Write(font_style & vbCrLf )    
    if page<=1 then
        Response.Write ("首 页 " & vbCrLf)        
        Response.Write ("上一页 " & vbCrLf)
    else        
        Response.Write("<A HREF=" & action & "?" & temp & "Page=1>首 页</A> " & vbCrLf)
        Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page-1) & ">上一页</A> " & vbCrLf)
    end if
    if page>=pagecount then
        Response.Write ("下一页 " & vbCrLf)
        Response.Write ("尾 页 " & vbCrLf)            
    else
        Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page+1) & ">下一页</A> " & vbCrLf)
        Response.Write("<A HREF=" & action & "?" & temp & "Page=" & pagecount & ">尾 页</A> " & vbCrLf)            
    end if
    Response.Write(" 页次：" & page & "/" & pageCount & "页" &  vbCrLf)
    Response.Write(" 共有" & iCount & "个会员" &  vbCrLf)
    Response.Write(" 转到" & "<INPUT CLASS=wenbenkuang TYEP=TEXT NAME=page SIZE=2 Maxlength=5 VALUE=" & page & ">" & "页"  & vbCrLf & "<INPUT CLASS=go-wenbenkuang type=submit value=GO>")
    Response.Write("</TD>" & vbCrLf )                
    Response.Write("</TR></form>" & vbCrLf )        
    Response.Write("</table>" & vbCrLf )        
End Sub
%></td>
 </tr>
</table>

<%elseif  worktype="edit" then%>
<style type="text/css">
<!--
body,td,th {
	font-size: 12px;
}
body {
	background-color: #d6dff7;
}
-->
</style>
<%
dim id
id=request.QueryString("id")
sql="select * from news where id="&id
rs.open sql,conn,1,1
%>
<table width="580" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#000000">
  <tr>
    <td height="35" colspan="2" background="images/titlebg.gif" bgcolor="#FFFFFF" align="center">编辑新闻</td>
  </tr>
    <form action="add_news.asp?worktype1=modynews&id=<%=rs("id")%>" method="post" name="dataform" id="inserttext">
  <tr>
    <td width="49" align="center" bgcolor="#FFFFFF">新闻标题</td>
    <td bgcolor="#FFFFFF"><input name="title" type="text" id="title" value="<%=rs("title")%>" /></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF" align="center">新闻作者</td>
    <td bgcolor="#FFFFFF"><input name="come" type="text" id="come" value="<%=rs("come")%>" /></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF" align="center">新闻内容</td>
    <td bgcolor="#FFFFFF"><input type="hidden" name="content1" value="<%=Server.HTMLEncode(rs("content"))%>" />
        <iframe id="eWebEditor1" src="editor/ewebeditor.asp?id=content1&amp;style=standard" frameborder="0" scrolling="No" width="520" height="350"></iframe></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF" align="center"><input type="submit" name="Submit" value="提交"> <input type="reset" name="Submit2" value="重置"></td>
  </tr>
  </form>
</table>
<%
end if
%>
</body>
</html>
