<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->
<!--#include file="include.asp"-->
<%
	Dim MM_TableName           '表名
	Dim MM_SqlKey              '条件数据库项
	Dim MM_SqlValue            '条件值
	Dim MM_SqlQuery            '最终执行语句
	Dim MM_ReturnPath          '执行成功后返回的路径
	Dim MM_FileName            '自身文件名
	
	MM_TableName = "news"      '?????????????????????????
	MM_SqlKey = "sqlindex"
	MM_SqlValue = Request.Form("MM_recordId")
	MM_ReturnPath = GetReturnPath()
	MM_FileName = GetFileName()
	
	Dim MM_AddDataPage      '添加数据的页面
	Dim MM_ModDataPage      '修改数据的页面
	Dim MM_FindSql          '查询执行语句
	Dim MM_Count            '一页最大显示条数
	Dim MM_re_count         '记录总个数
	Dim MM_re_number1       '记录开始号
	Dim MM_re_number2       '记录结束号
	Dim MM_NowPage          '当前页码
	Dim MM_NowPagePath      '当前页面路径
	
	MM_NowPagePath = CStr(Request.ServerVariables("SCRIPT_NAME"))
	MM_NowPage = Request.QueryString("page")
	MM_AddDataPage = "newsadd.asp"
	MM_ModDataPage = "newsmod.asp"
	MM_FindSql = "select * from " & MM_TableName & " order by sqldate desc"
	MM_Count = 15
	
	'-----------------------------------以上为设置信息-------------------------------------------                               
	
	set re = conn.Execute(MM_FindSql)
	MM_re_count = re.RecordCount
	If (MM_re_count = -1) Then
  		MM_re_count=0
  		While (Not re.EOF)
    		MM_re_count = MM_re_count + 1
 		   	re.MoveNext
  		Wend
		if MM_re_count <> 0 then
			re.MoveFirst
		end if
	end if
	
	if MM_NowPage = "" then
		MM_NowPage = 1
	end if
	Temp = MM_re_Count/MM_count
	MaxPage = Cint(Temp)
	if Temp > MaxPage then
		MaxPage = MaxPage + 1
	end if
	
	
	'以下是删除记录的代码
	
	if (Request.Form("MM_delete") <> "") and (Request.QueryString("style") = "") then
		Dim MM_Delete_Sql
		MM_Delete_Sql = "delete from " & MM_TableName & " where sqlindex=" & Request.Form("MM_recordId")
		conn.Execute(MM_Delete_Sql)
		Response.Redirect(MM_ReturnPath)
	end if

	'以下是更新记录的代码
	if Request.QueryString("style") <> "" then
		Dim MM_Update_Sql
		MM_Update_Sql = "update " & MM_TableName & " set sqlshow=" & Request.QueryString("style") & " where sqlindex=" & Request.QueryString("id")
		
		conn.Execute(MM_Update_Sql)
		Response.Redirect(MM_FileName & "?page=" & MM_NowPage)
	end if
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新闻发布系统</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body topmargin="0" bgcolor="#799AE1">
<table width="100%" height="100%" border="0" align="center" cellspacing="0">
  <tr height="60" valign="bottom" bgcolor="#668ED4"> 
    <td height="63" align="center" valign="middle" bgcolor="#668ED4" class="unnamed1"><img src="images/toplogo.gif" width="500" height="60"></td>
  </tr>
  <tr bgcolor="#9ebef5"> 
    <td height="300" valign="top" bgcolor="#668ED4" class="unnamed1"> <table width="100%" border="0">
        <tr> 
          <td width="100%">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td width="91%" height="23" valign="bottom" background="images/menu_bk.gif"><font color="#FFFFFF">共有<%=MM_re_count%>条记录，现在显示的是第<%=((MM_NowPage*MM_Count)-MM_Count+1)%>条至第 
                  <%
		  	if (((MM_NowPage*MM_Count))) <= MM_re_count then
		  		response.write(MM_NowPage*MM_Count)
			else
				response.write((MM_Count-((MM_NowPage*MM_Count)-MM_re_count)) + ((MM_NowPage*MM_Count)-MM_Count))
			end if
		  %>
                  条！</font></td>
                <td width="9%" valign="bottom" background="images/menu_bk.gif"><a href="<%=MM_AddDataPage%>"><font size="2" color="#FFFFFF"><b>添加记录</b></font></a></td>
              </tr>
            </table>
            <table width="100%" height="100%" align="center" cellpadding="1" cellspacing="1" bordercolor="#ADADC9" bgcolor="#666699">
              <tr bgcolor="#799AE1"> 
                <td width="30"> <div align="center"><font color="#FFFFFF">ID</font></div></td>
                <td> <div align="center"><font color="#FFFFFF"><span class="style4">标题</span></font></div></td>
                <td width="200"> <div align="center"><font color="#FFFFFF"><span class="style4">来源</span></font></div></td>
                <td width="100"> <div align="center"><font color="#FFFFFF">日期</font></div></td>
                <td width="230"> <div align="center"><font color="#FFFFFF"><span class="style4">操作</span></font></div></td>
              </tr>
              <%
			  		dim TheIndex
					TheIndex = 0
					While (NOT re.EOF) 
						TheIndex = TheIndex + 1
						if (TheIndex > (MM_NowPage*MM_Count)-MM_Count) and (TheIndex <= (MM_NowPage*MM_Count)) then
			  %>
              <tr bgcolor="#DFEFFF"> 
                <td width="30"> <div align="center"><%=(re.Fields.Item("sqlindex").Value)%></div></td>
                <td width="45%"><a href="<%=MM_ModDataPage%>?id=<%=re.Fields.item("sqlindex")%>"><%=(re.Fields.Item("sqltitle").Value)%></a></td>
                <td width="200"><%=(re.Fields.Item("sqlyuang").Value)%></td>
                <td width="100"> <div align="center"><%=(re.Fields.Item("sqldate").Value)%></div></td>
                <form ACTION="<%=MM_ReturnPath%>" METHOD="POST" name="form1">
                  <td width="230"> <%if re.Fields.Item("sqlshow") then%> <input type="button" name="Submit22" value="隐 藏" onClick="vbscript:window.location.href='<%=MM_FileName%>?page=<%=MM_NowPage%>&id=<%=re.Fields.item("sqlindex")%>&style=0'"> 
                    <%else%> <input type="button" name="Submit22" value="显 示" onClick="vbscript:window.location.href='<%=MM_ReturnPath%>&id=<%=re.Fields.item("sqlindex")%>&style=1'"> 
                    <%end if%> <input type="button" name="Submit2" value="修 改" onClick="vbscript:window.location.href='<%=MM_ModDataPage%>?id=<%=re.Fields.item("sqlindex")%>'"> 
                    <input type="submit" name="Submit3" value="删 除" onClick="javascript:if(!confirm('确定要删除这条新闻吗？')) return false; "> <input type="hidden" name="MM_delete" value="form1"> 
                    <input type="hidden" name="MM_recordId" value="<%= re.Fields.Item("sqlindex").Value %>"> 
                  </td>
                </form>
              </tr>
              <%
			  		end if
  				  re.MoveNext()
				  Wend
			  %>
            </table></td>
        </tr>
      </table>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td><div align="center"> 
              <%
		  	response.write("<a href=" & NowPagePath & "?page=1><</a>&nbsp;")
		  	if (MM_NowPage-5) < 1 then
				ThePage = 1
			else
				ThePage = MM_NowPage-5
			end if
		  	for i=ThePage to (MM_NowPage-1)
				response.write("<a href=" & MM_NowPagePath & "?page=" & i & ">" & i & "</a>&nbsp;")
			next
			
			response.write(MM_NowPage & "&nbsp;")
			
			if (MM_NowPage+5) > MaxPage then
				ThePage = MaxPage
			else
				ThePage = MM_NowPage+5
			end if
		  	for i=(MM_NowPage+1) to ThePage
				response.write("<a href=" & MM_NowPagePath & "?page=" & i & ">" & i & "</a>&nbsp;")
			next
			response.write("<a href=" & MM_NowPagePath & "?page=" & MaxPage & ">></a>")
		  %>
            </div></td>
        </tr>
      </table>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td> <div align="left">注意：请认真操作，删除后不可恢复！</div></td>
        </tr>
      </table></td>
  </tr>
</table>
</body>
</html>
<%
	re.Close()
	Set re = Nothing
%>