<!--#include file="../include/Conn.jsp"-->
<!--#include file="../Include/Char.jsp" -->
<!--#include file="Admin_IsLogin.jsp" -->
<%
'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 News_Contents Where F_ID = " & Request.QueryString("ModifyID")
 Set rs = conn.Execute(m_SQL)
 if Not rs.Eof then
   m_NewsName = Trim(rs("F_NewsName"))
   m_NewsName2 = Trim(rs("F_NewsName2"))
   m_CategoryID = Trim(rs("F_CategoryID"))
   m_Contents = rs("F_Contents")
   m_Contents2 = rs("F_Contents2")
   m_Image = Trim(rs("F_Image"))
   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_NewsName = checkStr(Trim(Request.Form("txtNewsName")))
   m_NewsName2 = checkStr(Trim(Request.Form("txtNewsName2")))
   m_CategoryID = checkStr(Trim(Request.Form("selCategoryID")))
   m_Contents = checkStr(Trim(Request.Form("txtContents")))
   m_Contents2 = checkStr(Trim(Request.Form("txtContents2")))
   m_Image = checkStr(Trim(Request.Form("txtImage")))
   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 = "Select * From News_Contents Where F_NewsName='"&m_NewsName&"'"
	Set rs = conn.Execute(m_SQL)
	if not rs.Eof then
	   rs.Close
	   call msgbox("对不起，该用户名已存在，请更换用户名后再试",1)
	else
	  rs.Close
	  m_Sql = "Insert Into News_Contents(F_NewsName,F_NewsName2,F_CategoryID,F_Contents,F_Contents2,F_Image,F_IsCommend,F_Addtime)"
	  m_Sql = m_Sql + "Values('"&m_NewsName&"','"&m_NewsName2&"',"&m_CategoryID&",'"&m_Contents&"','"&m_Contents2&"','"&m_Image&"',"&m_IsCommend&",'"&m_Addtime&"')"
	  conn.Execute(m_Sql)
      response.redirect "Admin_NewsContents.jsp?action=IsInsert&pageno="&Request("pageno")
     end if '//rs.eof
  end if
  
 if Request.Querystring("action")="Modify" then
      m_SQL = "UPDATE News_Contents SET"
      m_SQL = m_SQL+" F_NewsName='"&m_NewsName&"',"
      m_SQL = m_SQL+" F_NewsName2='"&m_NewsName2&"',"
      m_SQL = m_SQL+" F_Image='"&m_Image&"',"
      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_NewsContents.jsp?action=IsModify&pageno="&Request("pageno")
   End if
 End if
 
'Delect Records
if request("action")="Delete" then
  m_SQL = "DELETE FROM News_Contents WHERE F_ID = " &Request.QueryString("DeleteID")
  conn.execute m_SQL
  Response.write "<script>location.replace('Admin_NewsContents.jsp?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="../include/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 isDate(str)
{var regstr=/^\d{4}-(\d{1}|11|12)-([1-2]?\d{1}|3[0-1])$/;
 return regstr.test(str);
}

function checkForm()
{
  if (document.form1.txtNewsName.value=="")
  {
    alert("对不起，新闻标题不能为空，请输入！");
	document.form1.txtNewsName.focus();
	return false;
   }
  if (document.form1.txtNewsName2.value=="")
  {
    alert("对不起，新闻标题_英文不能为空，请输入！");
	document.form1.txtNewsName2.focus();
	return false;
   }
  if (!isDate(document.form1.txtAddtime.value))
	{alert('请按照规定格式输入日期！');
	 document.form1.txtAddtime.select();
	 return false;
	 }
  

}
//-->
</script>

</head>
<body text="#000000">
<SCRIPT src="../include/Calendar/date.js"></SCRIPT>
<IFRAME id=CalFrame 
style="DISPLAY: none; Z-INDEX: 100; WIDTH: 148px; POSITION: absolute; HEIGHT: 194px" 
marginWidth=0 marginHeight=0 src="../include/Calendar/calendar.htm" frameBorder=0 noResize 
scrolling=no></IFRAME>
<table width="100%" height="1"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td></td>
  </tr>
</table>
<TABLE width=100% height=95% border=1 align="center" cellPadding=0 
cellSpacing=0 borderColor=#7c96b8 borderColorDark=#ffffff>
  <TBODY>
    <TR> 
      <TD width="100%" align=center valign="top">
        <%
      admin_flag="6"
      if instr(session("flag"),admin_flag)=0 or isnull(session("flag"))=true then
         Response.write "<br><br><br><br><b><font color=red>对不起，您没有管理本页面的权限!</font></B>"
		 Response.end
	  end if
      %>
        <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#dde1ec">
          <tr><form name="frmSearch" method="post" action="Admin_NewsContents.jsp">
              <td align="center" bgcolor="#FFFFFF">请输入关键字： 
                <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 News_Category 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> 
        <table width="100%" border="0" cellspacing="1" cellpadding="0" align="center">
          <tr style="cursor:hand" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#EBEEF6'"  bgcolor="#dde1ec" align="center"> 
            <td width="8%" height="11"><font color="#666666"><b>ID</b></font></td>
            <td><font color="#666666"><b>新闻标题</b></font></td>
            <td width="22%"><font color="#666666"><b>所属分类</b></font></td>
            <td width="6%"><font color="#666666"><b>点击</b></font></td>
            <td width="6%"><strong><font color="#666666"><b>推荐</b></font></strong></td>
            <td width="15%"><font color="#666666"><b>管理<a title="添加记录" href='Admin_NewsContents.jsp?pageno=<%=mPage%>#anInsert'><font color="#FF0000">[添加]</font></a></b></font></td>
          </tr>
        </table>
        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#ebeef6">
          <%  
	Keywords = Trim(Request("keywords"))
	CategoryID = Trim(Request("CategoryID"))
	Set rs=Server.createobject("Adodb.RecordSet")
    pageno=request.querystring("pageno")
    pmcount=16  
    m_SQL = "SELECT * FROM News_Contents 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_NewsName 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  width="8%" align="center"><%=rs("F_ID")%></td>
            <td >
			<A target="_blank" href="../News/ShowNews.jsp?ID=<%=rs("F_ID")%>">
			<%=rs("F_NewsName")%>
			</A>
			</td>
            <td width="22%" align="center" > <%
			m_SQL = "SELECT F_Value FROM News_Category Where F_ID =" & rs("F_CategoryID")
			Set rst = conn.Execute(m_SQL)
			if not rst.Eof then Response.Write rst(0)
			rst.Close
			%> </td>
            <td width="6%" align="center" ><%=rs("F_Hits")%></td>
            <td width="6%" align="center" > <%
			'推荐处理
			if Request("action") = "IsCommend" then
			  mIsCommend = Request("IsCommend")
			  if mIsCommend=1 then mIsCommend = 0 else mIsCommend = 1
			  mSql = "update News_Contents Set F_IsCommend= "&mIsCommend&" Where F_ID="&Request("ID")
              conn.execute(mSql)
			  Response.redirect "Admin_NewsContents.jsp?pageno="&Request("pageno")
			end if
			Response.Write "<a href='Admin_NewsContents.jsp?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 width="15%" align="center" > <a title="修改记录" href='Admin_NewsContents.jsp?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_NewsContents.jsp?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="100%" 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_NewsContents.jsp?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_NewsContents.jsp?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_NewsContents.jsp?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_NewsContents.jsp?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_NewsContents.jsp?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%>
        <strong><font color=red><a name="anInsert"></a></font></strong> 
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="32" align="center" bgcolor="FFFFFF"><strong><font color=red> 
              <%
		  if Request.QueryString("action")="IsInsert" then response.write "提示：记录添加成功！" 
		  if Request.QueryString("action")="IsDelete" then response.write "提示：记录删除成功！" 
		  if Request.QueryString("action")="IsModify" then response.write "提示：记录修改成功！" 
  		  if Trim(Request.QueryString("action"))="" then response.write "提示：当前为添加状态！" 
		%>
              </font></strong></td>
          </tr>
        </table> 
        <strong><font color=red> </font></strong> 
        <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
          <tr> 
            <form name="form1" method="post" action="Admin_NewsContents.jsp?action=Insert" onSubmit="return checkForm()">
              <td> <table width="100%" border="0" cellpadding="2" cellspacing="0">
                  <tr background="Images/mmTo.gif"> 
                    <td height="6" background="Images/mmTo.gif"> <span style="CURSOR: hand; FILTER: dropshadow(color=#FFFFFF, offx=1, offy=1, positive=1);  WIDTH: 100%">功能：添加记录</span></td>
                  </tr>
                  <tr> 
                    <td valign="top" bgcolor="fcfcfc"> 
                      <table width="100%" border="0" cellspacing="2" cellpadding="0">
                        <tr> 
                          <td width="16%" height="19">新闻标题：</td>
                          <td width="84%"><input name="txtNewsName" type="text"  class="text" size="40" maxlength="80"></td>
                        </tr>
                        <tr> 
                          <td width="16%" height="19"><font color="#999999">新闻标题_英文：</font></td>
                          <td width="84%"> <input name="txtNewsName2" type="text"  class="text" size="40" maxlength="80"> 
                          </td>
                        </tr>
                        <tr> 
                          <td width="16%" height="19">新闻类别：</td>
                          <td width="84%"><select name="selCategoryID" class="text">
                              <%
			   m_SQL = "SELECT F_ID,F_Value FROM News_Category ORDER BY F_Grade"
			   Set rst = conn.Execute(m_SQL)
			   Do While Not rst.Eof
			     Response.write "<option value='"&rst(0)&"'>"&rst(1)&"</option>"
				 rst.MoveNext
			   Loop
			   rst.Close
			   %>
                            </select></td>
                        </tr>
                        <tr> 
                          <td width="16%" height="19">图片上传：</td>
                          <td width="84%"><input name="txtImage" type="text"  class="text" size="22" maxlength="80"> 
                            <input class="UploadButton" type="button" value="上传图片" name="UpImage1" onClick="javascript:window.open('UploadWindows.jsp?Uploadpath=../News/UploadImages&ReturnForm=form1&ReturnText=txtImage','upload','top=20,left=30,height=134,width=420,scrollbars=no,resizable=no')"> 
                          </td>
                        </tr>
                        <tr> 
                          <td width="16%" height="19">新闻推荐：</td>
                          <td width="84%"> <input type="checkbox" name="chkIsCommend"  value="1" class="text"></td>
                        </tr>
                        <tr> 
                          <td width="16%" height="19">新闻内容：</td>
                          <td width="84%"> <textarea name="txtContents" cols="70" rows="15" class="text"></textarea></td>
                        </tr>
                        <tr> 
                          <td width="16%" height="2"><font color="#999999">新闻内容_英文：</font></td>
                          <td width="84%"><textarea name="txtContents2" cols="70" rows="8" class="text"></textarea> 
                          </td>
                        </tr>
                        <tr> 
                          <td width="16%" height="19">发布时间：</td>
                          <td width="84%"> <INPUT name=txtAddtime class=text  value="<%=Date()%>" size="13"> 
                            <A onclick=event.cancelBubble=true;href="javascript:ShowCalendar(document.form1.dimg5,document.form1.txtAddtime,null,0,330)" target=_self><IMG id=dimg5 style="POSITION: relative" height=16 src="../include/Calendar/0_cal.gif" width=16 align=absMiddle vspace=6 border=0></A> 
                          </td>
                        </tr>
                        <tr> 
                          <td height="37" colspan="2"><input  type="submit" value="提交信息" name="B32" style="width:80;border:1 solid #9a9999; font-size:9pt; background-color:f2f2f2"> 
                            &nbsp; <input type="reset" value="从新来过" name="B32" style="width:80;border:1 solid #9a9999; font-size:9pt; background-color:#f2f2f2"></td>
                        </tr>
                      </table>
                      
                    </td>
                  </tr>
                </table></td>
            </form>
          </tr>
        </table>
        <%else%>
        <strong><font color=red><a name="anModify"></a></font></strong> 
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td height="32" align="center" bgcolor="ffffff"><strong><font color=red> 
       <%
		  if Request.QueryString("action")="IsInsert" then response.write "提示：记录添加成功！" 
		  if Request.QueryString("action")="IsDelete" then response.write "提示：记录删除成功！" 
		  if Request.QueryString("action")="IsModify" then response.write "提示：记录修改成功！" 
		  if Trim(Request.QueryString("action"))="edit" then response.write "提示：当前为修改状态！" 
	   %>
              </font></strong></td>
          </tr>
        </table>
        <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" height="54">
          <tr> 
            <form name="form1" method="post" action="Admin_NewsContents.jsp?action=Modify&pageno=<%=request("pageno")%>&ModifyID=<%=request("ModifyID")%>" onSubmit="return checkForm()">
              <td> <table width="100%" border="0" cellpadding="2" cellspacing="0">
                  <tr background="Images/mmTo.gif"> 
                    <td height="6" background="Images/mmTo.gif"> <span style="CURSOR: hand; FILTER: dropshadow(color=#FFFFFF, offx=1, offy=1, positive=1);  WIDTH: 100%">功能：修改记录</span></td>
                  </tr>
                  <tr> 
                    <td valign="top" bgcolor="fcfcfc">
					<table width="100%" border="0" cellspacing="2" cellpadding="0">
                        <tr> 
                          <td width="16%" height="19">新闻标题：</td>
                          <td width="84%"><input name="txtNewsName" type="text"  class="text"  value="<% =m_NewsName %>" size="40" maxlength="80"></td>
                        </tr>
                        <tr> 
                          <td width="16%" height="19"><font color="#999999">新闻标题_英文：</font></td>
                          <td width="84%"> <input name="txtNewsName2" type="text"  class="text"  value="<% =m_NewsName2 %>" size="40" maxlength="80"> 
                          </td>
                        </tr>
                        <tr> 
                          <td width="16%" height="19">新闻类别：</td>
                          <td width="84%"> <select name="selCategoryID" class="text">
                              <%
			   m_SQL = "SELECT F_ID,F_Value FROM News_Category 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 width="16%" height="19">图片上传：</td>
                          <td width="84%"><input name="txtImage" type="text"  class="text"  value="<% =m_Image %>" size="22" maxlength="80"> 
                            <input class="UploadButton" type="button" value="上传图片" name="UpImage1" onClick="javascript:window.open('UploadWindows.jsp?Uploadpath=../News/UploadImages&ReturnForm=form1&ReturnText=txtImage','upload','top=20,left=30,height=134,width=420,scrollbars=no,resizable=no')"> 
                          </td>
                        </tr>
                        <tr> 
                          <td width="16%" height="19">新闻推荐：</td>
                          <td width="84%"> <input name="chkIsCommend" type="checkbox" class="text"  value="1" <%if m_IsCommend="1" then Response.write "checked"%>></td>
                        </tr>
                        <tr> 
                          <td width="16%" height="19">新闻内容：</td>
                          <td width="84%"> <textarea name="txtContents" cols="70" rows="15" class="text"><% =m_Contents %></textarea></td>
                        </tr>
                        <tr> 
                          <td width="16%" height="2"><font color="#999999">新闻内容_英文：</font></td>
                          <td width="84%"><textarea name="txtContents2" cols="70" rows="8" class="text"><% =m_Contents2 %></textarea> 
                          </td>
                        </tr>
                        <tr> 
                          <td width="16%" height="19">发布时间：</td>
                          <td width="84%"> <INPUT name=txtAddtime class=text  value="<% =m_Addtime %>" size="13"> 
                            <A onclick=event.cancelBubble=true;href="javascript:ShowCalendar(document.form1.dimg5,document.form1.txtAddtime,null,0,330)" target=_self><IMG id=dimg5 style="POSITION: relative" height=16 src="../include/Calendar/0_cal.gif" width=16 align=absMiddle vspace=6 border=0></A> 
                          </td>
                        </tr>
                        <tr> 
                          <td height="37" colspan="2"><input  type="submit" value="提交信息" name="B32" style="width:80;border:1 solid #9a9999; font-size:9pt; background-color:f2f2f2"> 
                            &nbsp; <input type="reset" value="从新来过" name="B32" style="width:80;border:1 solid #9a9999; font-size:9pt; background-color:#f2f2f2"></td>
                        </tr>
                      </table>
					</td>
                  </tr>
                </table></td>
            </form>
          </tr>
        </table>
        <%end if%>
      </TD>
    </TR>
  </TBODY>
</TABLE>
</body>
</html>
<%
 set rs=nothing
 CloseDatabase
%>
