<!--#include file="../inc/const.asp"-->
<!--#include file="inc/char.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><%=site_info(0)%></title>
<link href="xfok.css" type="text/css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; chaRset=gb2312">
<script src="../js/ubbcode.js"></script>
<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
-->
</script>
</head>
<body text=#000000 leftmargin=0 topmargin=0 marginheight="0" marginwidth="0" bgcolor="#E5E5E5">
<br>

<%
Dim Admin_flag,Action,ID,Title,Content
Admin_flag="01"
If Not CheckAdmin(Admin_Flag) Then
    strMsg="<Li>您没有管理本页面的权限。"
    Call Msg()
Else
   DataConn()
   	SELECT Case Request("Action")
	  	Case "Add"
		    Call Add()
       	Case "Save"
            Call Save()
		Case "Edit"
		    Call Edit()
		Case "EditSave"
		    Call EditSave()
        Case "Del"
            Call Del()
        Case Else
            Call Main()
    End Select
End If
DataClose()

Sub Main()
%>
<table width="95%" border=0 align="center" cellpadding=5 cellspacing=1 class="border-all">
  <tbody>
    <tr> 
      <th height=22 colspan="3" align="center" sytle="line-height:150%">通知公告列表</th>
    </tr>
    <tr> 
      <td width="10%" height=22 class="TopTitle" sytle="line-height:150%">序号</td>
      <td height=22 class="TopTitle" sytle="line-height:150%"><div align="cener">标题</div></td>
      <td width="10%" height=22 align="center" class="TopTitle" sytle="line-height:150%">操作</td>
    </tr>
	<tr class=line-bg-b> 
	  <td height=22 colspan="3" align="center" bgcolor="#eeeeee"><a href="?Action=Add"><FONT  COLOR="#ff0000">【点击这里添加新内容】</FONT></a>预览点击序号、修改点击标题</td>
	 </tr>
 <%
    SQL="SELECT ID,Title FROM news ORDER BY ID DESC"
    Set Rs=Server.CreateObject("Adodb.RecordSet")
     Rs.CursorLocation=3
     Rs.Open SQL,Conn,1
     InfoCount=Rs.RecordCount
     Page=Request.QueryString("Page")
	If isInt(Page)=False Then 
	 Page=1
	Else
	  Page=Cint(Page)
	End If 
	PageSize=CInt(Site_Info(12))
	If InfoCount Mod Cint(PageSize)=0 Then
	 PageCount= InfoCount \ Cint(PageSize)
	Else
	 PageCount= InfoCount \ Cint(PageSize)+1
	End If
If Not (Rs.Bof And Rs.Eof) Then
    Rs.MoveFirst
    If Page > PageCount Then Page = PageCount
    If Page<1 Then Page=1
    Rs.Move (Page-1) * Cint(PageSize)
	I=1
   Do While Not Rs.EOF and I<=PageSize
	  I=I+1      
	  ID=Rs("ID")
	  Title=cutstr(Rs("Title"),60)
%>
    <tr class="line-bg-b"> 
      <td align="center"><% ="<a href=../disp.asp?ID="&ID&">"&PageSize*(Page-1)+(I-1)&"</a>"%></td>
      <td><%="<a href=?Action=Edit&ID="&ID&">"&Title&"</a>"%></td>
      <td width="10%" align="center"><a href="?Action=Del&ID=<%=ID%>" onClick="{if(confirm('确定删除吗?')){return true;}return false;}"><FONT COLOR="red">【删除】</FONT></a> 
      </td>
    </tr>
   
	<%
	Rs.MoveNext
	Loop
	Response.Write ("<tr><td colspan='3' align='center' bgcolor=#eeeeee>"&ShowPage(PageCount,InfoCount,Page,PageSize,"News.asp?")&"</td></tr>")
	else
	Response.Write ("<tr><td colspan='2' align='left'>尚未添加</td></tr>")
	End If 
	%>
  </tbody>
</table>
<br>

<%
End Sub

Sub add()
%>
<form name="myform" method="post" action="?" onsubmit="return CheckFm(this);">
  <table width="95%" border="0" align="center" cellpadding="5" cellspacing="1" class="border-all">
    <tr><th colspan="2" id="succmsg">添加通知或公告</th></tr>
    <tr class="table_row_2"> 
      <td width="12%">标题: </td>
      <td width="88%"> 
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td width="40%"><input type="text" name="title" size="70" class="editbox" id="title" style="color:#000000">
            </td>
          </tr>
        </table></td>
    </tr>
    <tr align="center" id=e2> 
      <td colspan="2"> 
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr> 
            <td bgcolor="#FFFFFF">
              <!--#include file="inc/ubb.asp" -->
            </td>
          </tr>
          <tr> 
            <td bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
                <tr> 
                  <td bgcolor="#FFFFFF"><textarea name="content" rows="25" cols="76" class="Content"></textarea> 
                  </td>
                </tr>
              </table></td>
          </tr>
          <tr> 
            <td bgcolor="#FFFFFF"><img src="images/editor/bian.gif" width="100%" height="13"></td>
          </tr>
        </table>        
      </td>
    </tr><th colspan="2"><input type="submit" name="Submit" value="发布" class=button> 
&nbsp;<input type="reset" name="Submit2" value="清空" class=button></th>
<input name="action" type="hidden" id="action" value="Save">
<input name="GoUrl" type="hidden" id="GoUrl" value="<%=Url%>">
</tr></table></form>
<%
End Sub

Sub Save()
    Title=CheckStr(Request.Form("Title"))
	Content=Request.Form("Content")
	If Title="" Then	strMsg="<li>标题不能为空!"
	If Content="" Then	strMsg=strMsg&"<li>内容不能为空!"
	If strMsg<>"" Then 
	   Call Msg()
    else
	  SQL="SELECT MAX(ID) FROM news"
	  Set Rs=Conn.Execute(SQL)
	  ID=Rs(0)+1
	  If IsNull(ID) Then ID=1
	  SQL="INSERT INTO news(ID,Title,Content) VALUES("
      SQL=SQL&ID&",'"&Title&"','"&Content&"')"
	  Conn.Execute(SQL)
	  Set Rs=Nothing
     Response.Redirect Request.Form("GoUrl")
	  end if
End Sub

Sub Edit()
    ID=CheckStr(Request.QueryString("ID"))
	SQL="SELECT ID,Title,Content FROM news WHERE ID="&ID
	Set Rs=Conn.Execute(SQL)
	ID=Rs("ID")
	Title=Rs("Title")
	Content=Rs("Content")
	Set Rs=Nothing
%>
<form name="myform" method="post" action="?" onsubmit="return CheckFm(this);">
  <table width="95%" border="0" align="center" cellpadding="5" cellspacing="1" class="border-all">
    <tr><th colspan="2" id="succmsg">添加通知或公告</th></tr>
    <tr class="table_row_2"> 
      <td width="12%">标题: </td>
      <td width="88%"> 
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td width="40%"><input type="text" name="title" size="70" class="editbox" id="title" style="color:#000000" value="<%=Title%>">
            </td>
          </tr>
        </table></td>
    </tr>
    <tr align="center" id=e2> 
      <td colspan="2"> 
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr> 
            <td bgcolor="#FFFFFF">
              <!--#include file="inc/ubb.asp" -->
            </td>
          </tr>
          <tr> 
            <td bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
                <tr> 
                  <td bgcolor="#FFFFFF"><textarea name="content" rows="25" cols="75" class="Content"><%=Content%></textarea> 
                  </td>
                </tr>
              </table></td>
          </tr>
          <tr> 
            <td bgcolor="#FFFFFF"><img src="images/editor/bian.gif" width="100%" height="13"></td>
          </tr>
        </table>        
      </td>
    </tr><th colspan="2"><input type="submit" name="Submit" value="确定" class=button> 
&nbsp;<input type="reset" name="Submit2" value="重置" class=button></th>
<input name="action" type="hidden" id="action" value="EditSave">
<input name="GoUrl" type="hidden" id="GoUrl" value="<%=Url%>">
<input name="ID" type="hidden" id="ID" value="<%=ID%>">
</tr></table></form>
<%
End Sub
Sub EditSave()
    Title=CheckStr(Request.Form("Title"))
	Content=Request.Form("Content")
	ID=Request.Form("ID")
	If Title="" Then	strMsg="<li>标题不能为空!"
	If Content="" Then	strMsg=strMsg&"<li>内容不能为空!"
	If strMsg<>"" Then 
	   Call Msg()
    else
	SQL="UPDATE news SET Title='"&Title&"',Content='"&Content&"' WHERE ID="&Request.Form("ID")
	Conn.Execute(SQL)
	 Set Rs=Nothing
     Response.Redirect Request.Form("GoUrl")
	  end if
End Sub
Sub Del()
	ID=CheckStr(Request.QueryString("ID"))
	SQL="DELETE FROM news WHERE ID="&ID
	Conn.Execute(SQL)
	Response.Redirect Url
End Sub
%>
 <script language="JavaScript">
function CheckFm(form){
	if (form.title.value==""){
       alert("标题不能为空");
	   form.title.focus();
	   return false;
    }
	if (form.content.value==""){
       alert("内容不能为空！");
	   form.content.focus();
	   return false;
    }
}
</script>

</body>
</html>