<!--#include file="../include/Conn.asp"-->
<!--#include file="../Include/Char.asp" -->
<!--#include file="Admin_IsLogin.asp" -->
<!--#include file="../LatticeEditor/latticeeditor.asp" -->
<%
'Define Variable 
dim i
dim rs
dim mGrade,m_SQL,mFlag,mBgColor
'initialization 
mFlag=true'add

'Display
if Request("action") = "edit" then 
 m_SQL = "Select * From jy_news Where F_ID = " & Request.QueryString("ModifyID")
 Set rs = conn.Execute(m_SQL)
 if Not rs.Eof then
   ID = Trim(rs("F_ID"))
   m_Title = Trim(rs("F_Title"))
   'm_Title2 = Trim(rs("F_Title2"))
   m_CategoryID = Trim(rs("F_CategoryID"))
   m_Contents = rs("F_Contents")
   'm_Contents2 = rs("F_Contents2")
   m_Image = Trim(rs("F_Image"))
   m_Author = Trim(rs("F_Author"))
   m_IsCommend = Trim(rs("F_IsCommend"))
   m_Addtime = Trim(rs("F_Addtime"))
 End if
 mFlag=false
 rs.Close
end if

if Request.ServerVariables("REQUEST_METHOD")="POST" then
   m_Title = checkStr(Trim(Request.Form("txtTitle")))
   m_Title2 = checkStr(Trim(Request.Form("txtTitle2")))
   m_CategoryID = checkStr(Trim(Request.Form("selCategoryID")))
   m_Contents = checkStr(Trim(Request.Form("hidContents")))
   m_Image = checkStr(Trim(Request.Form("txtImage")))
   m_Author = checkStr(Trim(Request.Form("selAuthor")))
   m_IsCommend = checkStr(Trim(Request.Form("chkIsCommend")))
   IF m_IsCommend = "1" then m_IsCommend = 1 else m_IsCommend = 0
   m_Addtime = checkStr(Trim(Request.Form("txtAddtime")))

 if Request.Querystring("action")="Insert" then
	m_Sql = "Insert Into jy_news(F_Title,F_Title2,F_CategoryID,F_Author,F_Contents,F_Contents2,F_Image,F_IsCommend,F_Addtime)"
	m_Sql = m_Sql + "Values('"&m_Title&"','"&m_Title2&"',"&m_CategoryID&",'"&m_Author&"','"&m_Contents&"','"&m_Contents2&"','"&m_Image&"',"&m_IsCommend&",'"&m_Addtime&"')"
    conn.Execute(m_Sql)
    response.redirect "Admin_News.asp?action=IsInsert&pageno="&Request("pageno")
  end if
  
 if Request.Querystring("action")="Modify" then
      m_SQL = "UPDATE jy_news SET"
      m_SQL = m_SQL+" F_Title='"&m_Title&"',"
      'm_SQL = m_SQL+" F_Title2='"&m_Title2&"',"
      m_SQL = m_SQL+" F_Image='"&m_Image&"',"
      m_SQL = m_SQL+" F_Author='"&m_Author&"',"
      m_SQL = m_SQL+" F_CategoryID="&m_CategoryID&","
      m_SQL = m_SQL+" F_Contents='"&m_Contents&"',"
      'm_SQL = m_SQL+" F_Contents2='"&m_Contents2&"',"
      m_SQL = m_SQL+" F_IsCommend="&m_IsCommend&","
      m_SQL = m_SQL+" F_Addtime='"&m_Addtime&"'"
      m_SQL = m_SQL +" WHERE F_ID=" & Request("ModifyID") 
      conn.Execute(m_SQL)
      Response.redirect "Admin_News.asp?action=IsModify&pageno="&Request("pageno")
   End if
 End if
 
'Delect Records
if request("action")="Delete" then
  m_SQL = "DELETE FROM jy_news WHERE F_ID = " &Request.QueryString("DeleteID")
  conn.execute m_SQL
  Response.write "<script>location.replace('Admin_News.asp?action=IsDelete&pageno="&Request.Querystring("pageno")&"')</script>"
end if
%>

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="Images/Style.css" rel="stylesheet" type="text/css">
<SCRIPT language="JavaScript">
function jDelete(url)
{
  if((confirm(" 警告:请确定是否删除,删除后不能恢复! "))==true) 
	self.location=url+'&action=Delete';
}
</SCRIPT>
<script language="javascript">
<!--


function checkForm()
{  

  if (document.LatticeEditorForm.txtTitle.value=="")
  {
    alert("对不起，新闻标题不能为空，请输入！");
	document.LatticeEditorForm.txtTitle.focus();
	return false;
   }
  document.LatticeEditorForm.hidContents.value = frames.LatticeEditDocument.document.body.innerHTML;
}
//-->
</script>

</head>
<SCRIPT LANGUAGE="JScript.Encode" src="../latticeeditor/LatticeEditor1.asp"></SCRIPT>
<SCRIPT LANGUAGE="JScript.Encode" src="../latticeeditor/LatticeEditor2.asp"></SCRIPT>
<SCRIPT LANGUAGE="JScript.Encode" src="../latticeeditor/LatticeEditor3.asp"></SCRIPT>
<body text="#000000" onLoad = "initEditor();" ondragstart = "return false;" oncontextmenu = "return contextmenu();">
<SCRIPT src="../include/Calendar/date.js"></SCRIPT>

        <%
      admin_flag="11"
      if instr(session("flag1"),admin_flag)=0 or isnull(session("flag1"))=true then
         Response.write "<br><br><br><br><b><font color=red>对不起，您没有管理本页面的权限!</font></B>"
		 Response.end
	  end if
      %>
<br>
<table class=tableBorder width="95%" border="0" align="center" cellpadding="2" cellspacing="1">
  <tr>
    <th height="22" > 数据查询</th>
	</tr>
	<tr>
  <form name="frmSearch" method="post" action="Admin_News.asp">
              <td class=forumRowHighlight height="22" align="center">请输入关键字： 
                <input type="text" name="Keywords" class="text">
                <select name="CategoryID" class="text">
                  <%
			   Response.write "<option value='-1'>--------所有类别--------</option>"
			   m_SQL = "SELECT F_ID,F_Value FROM jy_newsCategory ORDER BY F_ID "
			   Set rst = conn.Execute(m_SQL)
			   Do While Not rst.Eof
			     if cint(Request("CategoryID")) = cint(rst(0)) then
				    Response.write "<option value='"&rst(0)&"' selected>"&rst(1)&"</option>"
                 else
				    Response.write "<option value='"&rst(0)&"'>"&rst(1)&"</option>"
				 end if
				 rst.MoveNext
			   Loop
			   rst.Close
			   %>
                </select> 
                <input name="btnSearch" type="submit"  value="搜索"> </td>
            </form>
          </tr>
        </table> 

        
<br>
<table class=tableBorder width="95%" border="0" align="center" cellpadding="2" cellspacing="1">
		<tr style="cursor:hand"   bgcolor="#dde1ec" align="center"> 
            <td width="8%" class=forumHeaderBackgroundAlternate><b>ID</b></td>
            <td class=forumHeaderBackgroundAlternate><b>新闻标题</b></td>
            <td width="22%" class=forumHeaderBackgroundAlternate><b>所属分类</b></td>
            <td width="6%" class=forumHeaderBackgroundAlternate><b>点击</b></td>
            <td width="6%" class=forumHeaderBackgroundAlternate><b>推荐</b></td>
            <td width="15%" class=forumHeaderBackgroundAlternate><b>管理<a title="添加记录" href='Admin_News.asp?pageno=<%=mPage%>#anInsert'>[添加]</a></b></td>
          </tr>
          <%  
	Keywords = Trim(Request("keywords"))
	CategoryID = Trim(Request("CategoryID"))
	Set rs=Server.createobject("Adodb.RecordSet")
    pageno=request.querystring("pageno")
    pmcount=16  
    m_SQL = "SELECT * FROM jy_news WHERE (1=1)"
	if CategoryID <> "" and CategoryID <> "-1" then
      m_SQL = m_SQL + " AND F_CategoryID="&CategoryID
	end if

    m_SQL = m_SQL +" and (F_Title like  '%" & Keywords & "%'"
	m_SQL = m_SQL +" or F_Contents like  '%" & Keywords & "%'"
	m_SQL = m_SQL +" or F_ID like  '%" & Keywords & "%')"

	m_SQl = m_SQL + " order by F_ID desc"
	rs.open m_SQL,conn,1,1

	if rs.eof then
	   'response.write "<br><p  align='center'><font color=red><B> 对不起，数据已清空！</B></font></p>"
    else
    rs.pagesize=pmcount
    mpage=rs.pagecount
    if pageno="" then pageno=1
    if  cint(pageno)<1 or cint(pageno)>mpage then  pageno=1
    rs.absolutepage=pageno

 Dim rc,re
 rc=rs.pagesize
 re=1
 do while not rs.eof and rc>0
 mBgColor=Request.Querystring("BgColor")
 if Trim(rs("F_ID"))=Trim(mBgColor) then mColor= "D6DFFF" else mColor= "ffffff"
%>
          <tr bgcolor="<%=mColor%>"   onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#EBEEF6'" > 
            <td  class=forumRow width="8%" align="center"><%=rs("F_ID")%></td>
            <td class=forumRow>
			<A target="_blank" href="../News/ShowNews.asp?ID=<%=rs("F_ID")%>">
			<%=rs("F_Title")%>
			</A>
			</td>
            <td class=forumRow width="22%" align="center" > <%
			m_SQL = "SELECT F_Value FROM jy_newsCategory Where F_ID =" & rs("F_CategoryID")
			Set rst = conn.Execute(m_SQL)
			Response.Write rst(0)
			rst.Close
			%> </td>
            <td class=forumRow  width="6%" align="center" ><%=rs("F_Hits")%></td>
            <td class=forumRow width="6%" align="center" > <%
			'推荐处理
			if Request("action") = "IsCommend" then
			  mIsCommend = Request("IsCommend")
			  if mIsCommend=1 then mIsCommend = 0 else mIsCommend = 1
			  mSql = "update jy_news Set F_IsCommend= "&mIsCommend&" Where F_ID="&Request("ID")
              conn.execute(mSql)
			  Response.redirect "Admin_News.asp?pageno="&Request("pageno")
			end if
			Response.Write "<a href='Admin_News.asp?action=IsCommend&IsCommend="&rs("F_IsCommend")&"&pageno="&Request("pageno")&"&ID="&rs("F_ID")&"'>"
			if rs("F_IsCommend")=1 then Response.Write "<font color=red>是</font>" Else Response.write "否"
			Response.Write "</a>"
			%> </td>
            <td class=forumRow width="15%" align="center" > <a title="修改记录" href='Admin_News.asp?action=edit&ModifyID=<%=rs("F_ID")%>&BgColor=<%=rs("F_ID")%>&pageno=<%=cstr(pageno)%>#anModify'><font color="#666666">[修改]</font></a><a title="请确定是否删除,删除后不能恢复!" href="javascript:jDelete('Admin_News.asp?DeleteID=<%=rs("F_ID")%>&pageno=<%=cstr(pageno)%>')"><font color="#666666">[删除]</font></a></td>
          </tr>
          <%
 rs.movenext
 re=re+1
 rc=rc-1
 loop
 end if
%>
        </table> 
		
        <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="FFFFFF">
          <tr> 
            <td width="35%" height="22">
			  &nbsp;共
			  <font color=red><strong><% = rs.recordcount%></strong></font>
			  条记录 当前第
			  <font color=red><strong><% = Trim(pageno)%></strong></font>页/共
			  <font color=red><strong><% = Trim(mpage)%></strong></font>页
			  </td>
            <td width="65%" align="right"> 
<%
if pageno="" then pageno=1
if pageno>1 then
   response.write "<a href='Admin_News.asp?keywords="&Keywords&"&TradeType="&TradeType&"'> <img alt='首页' src='Images/boqb02.gif' border=0 width='15' height='14'></a>"
else
   response.write "<img alt='首页' src='Images/boqb02.gif' border=0 width='15' height='14'>"
end if

if pageno>1 then
   response.write "<a href='Admin_News.asp?pageno="&pageno-1&"&keywords="&Keywords&"&TradeType="&TradeType&"'><img alt='上一页' src='Images/bob02.gif' border=0 width='15' height='14'></a>"
else
   response.write "<img alt='上一页' src='Images/bob02.gif' border=0 width='15' height='14'>"
end if

add=5'数字分页个数+1
if pageno-int(add/2)<=1 then m=1 else m=pageno-int(add/2)
if m+add>mpage then 
   n=mpage
   if mpage-add<=1 then m=1 else m=mpage-add
else
   n=m+add
end if

for pno=m to n
 if pno=cint(pageno) then
   response.write "&nbsp;<font color=red>"&pno&"</font>"
 else
   response.write "<b>&nbsp;<a href='Admin_News.asp?pageno="&pno&"&keywords="&Keywords&"&TradeType="&TradeType&"'>"&pno&"</a></b>"
 end if
next
response.write "&nbsp"

if int(pageno) < int(rs.pagecount) then
  response.write "<a href='Admin_News.asp?pageno="&pageno+1&"&keywords="&Keywords&"&TradeType="&TradeType&"'><img alt='下一页' src='Images/fbob02.gif' border=0 width='15' height='14'></a>"
else 
  response.write "<img alt='下一页' src='Images/fbob02.gif' border=0 width='15' height='14'>"
end if

if int(pageno) < int(rs.pagecount) then
   response.write "<a href='Admin_News.asp?pageno="&mpage&"&keywords="&Keywords&"&TradeType="&TradeType&"'><img alt='末页' src='Images/fboqb02.gif' border=0 width='15' height='14'></a>"
else
   response.write "<img alt='末页' src='Images/fboqb02.gif' border=0 width='15' height='14'>"
end if
Response.write "&nbsp;&nbsp;"
%>
            </td>
          </tr>
        </table>

<%if mFlag=true then'add%>
<a name="anInsert"></a>
<form name="LatticeEditorForm" method="post" action="Admin_News.asp?action=Insert"  onSubmit="return checkForm();" >
<table class=tableBorder width="95%" border="0" align="center" cellpadding="2" cellspacing="1">
    <tr > 
      <th height="22" colspan="6"> 添加记录</th>
   </tr>

  <tr> 
    <td height="9" class=forumRowHighlight>新闻标题：</td>
    <td width="84%" class=forumRowHighlight><input name="txtTitle" type="text"  class="text" size="70" maxlength="80"></td>
  </tr>
  <tr> 
    <td width="16%" height="19" class=forumRowHighlight>新闻类别：</td>
    <td width="84%" class=forumRowHighlight><select name="selCategoryID" class="text">
        <%
			   m_SQL = "SELECT F_ID,F_Value FROM jy_newsCategory ORDER BY F_Grade"
			   Set rst = conn.Execute(m_SQL)
			   Do While Not rst.Eof
			     if cint(Request("CategoryID")) = cint(rst(0)) then
				    Response.write "<option value='"&rst(0)&"' selected>"&rst(1)&"</option>"
                 else
				    Response.write "<option value='"&rst(0)&"'>"&rst(1)&"</option>"
				 end if
				 rst.MoveNext
			   Loop
			   rst.Close
			   %>
      </select></td>
  </tr>
  <tr> 
  <td height="20" class=forumRowHighlight>文件上传:</td>
  <td height="20" colspan="5" class=forumRowHighlight><iframe src="save_upload.asp" name="upfile" width="100%" height="22" align="default" frameborder="0" scrolling="no">此页使用了内帧，需更高版本的浏览器支持。</iframe></td>
  </tr>
  <tr> 
    <td width="16%"  class=forumRowHighlight>新闻推荐：</td>
    <td width="84%" class=forumRowHighlight> <input type="checkbox" name="chkIsCommend"  value="1" class="text"></td>
  </tr>
  <tr> 
    <td width="16%" class=forumRowHighlight>新闻内容：</td>
      <td width="84%" class=forumRowHighlight><%LatticeEditor("../Latticeeditor/blank.htm")%> <input type="hidden" name="hidContents">
	  </td>
  </tr>
  <tr> 
      <td width="16%" height="19" class=forumRowHighlight>发 布 者：</td>
    <td width="84%" class=forumRowHighlight>
	
	     <select name="selAuthor" class="text">
              <%
			   m_SQL = "SELECT F_UserName FROM jy_admin WHERE F_UserName ='"&session("master")&"'"
			   Set rst = conn.Execute(m_SQL)
			   Do While Not rst.Eof
			     Response.write "<option value='"&rst(0)&"'>"&rst(0)&"</option>"
				 rst.MoveNext
			   Loop
			   rst.Close
			   %>
      </select></td>
  </tr>
  <tr> 
    <td width="16%" class=forumRowHighlight>发布时间：</td>
    <td width="84%" class=forumRowHighlight> <INPUT name=txtAddtime class=text  value="<%=Date()%>" size="13"> 
     
    </td>
  </tr>
  <tr> 
      <td height="37" colspan="2" class=forumRowHighlight> &nbsp; <input type="submit" name="Submit32" value="提交" class="button"> 
        <input type="reSet" name="Submit222" value="重置" class="button"></td>
  </tr>
</table>
</form>
<%else%>
<a name="anModify"></a>
            <form name="LatticeEditorForm" method="post" action="Admin_News.asp?action=Modify&pageno=<%=request("pageno")%>&ModifyID=<%=request("ModifyID")%>" onSubmit="return checkForm()">
					<table class=tableBorder width="95%" border="0" align="center" cellpadding="2" cellspacing="1">
              <tr > 
      <th height="22" colspan="6">修改记录</th>
   </tr>
					    <tr> 
                          <td width="16%" class=forumRowHighlight>新闻标题：</td>
                          <td width="84%" class=forumRowHighlight><input name="txtTitle" type="text"  class="text"  value="<% =m_Title%>" size="70" maxlength="80"></td>
                        </tr>
                        <tr> 
                          <td width="16%" class=forumRowHighlight>新闻类别：</td>
                          <td width="84%" class=forumRowHighlight> <select name="selCategoryID" class="text">
                              <%
			   m_SQL = "SELECT F_ID,F_Value FROM jy_newsCategory ORDER BY F_Grade"
			   Set rst = conn.Execute(m_SQL)
			   Do While Not rst.Eof
			     if cint(m_CategoryID) = cint(rst(0)) then
				    Response.write "<option value='"&rst(0)&"' selected>"&rst(1)&"</option>"
                 else
				    Response.write "<option value='"&rst(0)&"'>"&rst(1)&"</option>"
				 end if
				 rst.MoveNext
			   Loop
			   rst.Close
			   %>
                            </select></td>
                        </tr>
                        <tr> 
  <td height="20" class=forumRowHighlight>文件上传:</td>
  <td height="20" colspan="5" class=forumRowHighlight><iframe src="save_upload.asp" name="upfile" width="100%" height="22" align="default" frameborder="0" scrolling="no">此页使用了内帧，需更高版本的浏览器支持。</iframe></td>
  </tr>
                        <tr> 
                          <td width="16%" class=forumRowHighlight>新闻推荐：</td>
                          <td width="84%" class=forumRowHighlight> <input name="chkIsCommend" type="checkbox" class="text"  value="1" <%if m_IsCommend="1" then Response.write "checked"%>></td>
                        </tr>
                        <tr> 
                          <td width="16%" class=forumRowHighlight>新闻内容：</td>
                          
      <td width="84%" class=forumRowHighlight><%LatticeEditor("ViewNewsContent.asp?ID="&ID)%> <input type="hidden" name="hidContents"> &nbsp; </td>
                        </tr>
						<tr> 
      <td width="16%" height="19" class=forumRowHighlight>发 布 者：</td>
    <td width="84%" class=forumRowHighlight>
	     <select name="selAuthor" class="text">
              <%
			   m_SQL = "SELECT F_UserName FROM jy_admin WHERE F_UserName ='"&session("master")&"'"
			   Set rst = conn.Execute(m_SQL)
			   Do While Not rst.Eof
			     Response.write "<option value='"&rst(0)&"'>"&rst(0)&"</option>"
				 rst.MoveNext
			   Loop
			   rst.Close
			   %>
      </select></td>
  </tr>
                        <tr> 
                          <td width="16%" class=forumRowHighlight>发布时间：</td>
                          <td width="84%" class=forumRowHighlight> <INPUT name=txtAddtime class=text  value="<% =m_Addtime %>" size="13"> 
                           
                          </td>
                        </tr>
                        <tr> 
                          <td height="37" colspan="2" class=forumRowHighlight><input type="submit" name="Submit322" value="提交" class="button"> 
                    <input type="reSet" name="Submit2222" value="重置" class="button"></td>
                        </tr>
                      </table>
	
            </form>

        <%end if%>
</body>
</html>
<object id="dlgColHelperTbl" classid="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></object>

<%
 set rs=nothing
 CloseDatabase
%>