<!--#include file="../include/Conn.asp"-->
<!--#include file="Admin_IsLogin.asp" -->
<%
'Define Variable 
dim i
dim rs,rst
dim mTypeName,mGrade,mSql,mFlag,mBgColor
Set rs=Server.CreateObject("Adodb.RecordSet")

'initialization 
mFlag=true'add


'edit
if request("action")="edit" then 
  mSql="Select * From jy_newsCategory Where F_ID="&Request.QueryString("ModifyID")
  Set rs=Conn.Execute(mSql)
  If not rs.Eof then
    mValue=rs("F_Value")
    mGrade=rs("F_Grade")
    rs.Close
  End if
  mFlag=false
end if

'Insert Records
if request("action")="Insert" then
  mSql="Select * From jy_newsCategory"
  rs.open mSql,conn,1,3
  rs.AddNew
  rs("F_Value")=Trim(Request.Form("txtValue"))
  rs("F_Grade")=Trim(Request.Form("txtGrade"))
  rs.update
  rs.close
  response.redirect "Admin_NewsCategory.asp?action=IsInsert&pageno="&Request("pageno")
end if

'Modify Records
if request("action")="editsave" then
  mSql="Select * From jy_newsCategory Where F_ID="&Request.QueryString("ModifyID")
  rs.open mSql,conn,1,3
  rs("F_Value")=Trim(Request.Form("txtValue"))
  rs("F_Grade")=Trim(Request.Form("txtGrade"))
  rs.update
  response.redirect "Admin_NewsCategory.asp?action=IsModify&pageno="&Request.Querystring("pageno")
  flag=false
end if

'Delect Records
if request("action")="delete" then
  mSql = "DELETE FROM jy_newsCategory WHERE F_ID=" &Request.QueryString("DeleteID")
  conn.execute mSql
  Response.write "<script>location.replace('Admin_NewsCategory.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 CheckData(){
  if (document.form1.txtValue.value=="")
   {
    alert("类别名称不能为空，请输入！");
	document.form1.txtValue.focus();
	return false;
   }
  if (document.form1.txtGrade.value=="")
   {
    alert("类别排序不能为空，请输入！");
	document.form1.txtGrade.focus();
	return false;
   }

}
</script>
</head>
<body text="#000000" >
<table width="100%" height="1"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td></td>
  </tr>
</table>
<TABLE width=100% height=100% border=1 align="center" cellPadding=0 
cellSpacing=0 borderColor=#7c96b8 borderColorDark=#ffffff>
  <TBODY>
    <TR> 
      <TD width="100%" align=center valign="top">
	   <%
      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
      %>
<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%"><font color="#666666"><b>ID</b></font></td>
            <td width="55%"><font color="#666666"><b>新闻类别</b></font></td>
            <td><font color="#666666"><b>类别排序</b></font></td>
            <td width="21%"><font color="#666666"><b>管理</b></font></td>
          </tr>
        </table>
        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#ebeef6">
          <%  
	Set rs=Server.createobject("Adodb.RecordSet")
    pageno=request.querystring("pageno")
    pmcount=16  
    mSql="select * from jy_newsCategory order by F_Grade"
	rs.open mSql,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%>" style="cursor:hand"  onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#EBEEF6'" > 
            <td  width="8%" align="center"><%=rs("F_ID")%></td>
            <td width="55%" ><%=rs("F_Value")%> </td>
            <td align="center" ><%= rs("F_Grade") %>&nbsp; </td>
            <td width="21%" align="center" ><a title="添加记录" href='Admin_NewsCategory.asp?pageno=<%=mPage%>'><font color="#666666">[添加]</font></a><a title="修改记录" href='Admin_NewsCategory.asp?action=edit&ModifyID=<%=rs("F_ID")%>&BgColor=<%=rs("F_ID")%>&pageno=<%=cstr(pageno)%>'><font color="#666666">[修改]</font></a><a title="请确定是否删除,删除后不能恢复!" href="javascript:jDelete('Admin_NewsCategory.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="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>1 then
   response.write "<a href='Admin_NewsCategory.asp'> <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_NewsCategory.asp?pageno="&pageno-1&"'><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_NewsCategory.asp?pageno="&pno&"'>"&pno&"</a></b>"
 end if
next
response.write "&nbsp"

if int(pageno) < int(rs.pagecount) then
  response.write "<a href='Admin_NewsCategory.asp?pageno="&pageno+1&"'><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_NewsCategory.asp?pageno="&mpage&"'><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%>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="18" 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_NewsCategory.asp?pageno=<%=mpage%>&action=Insert" onSubmit="return CheckData()">
              <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="12%" height="19">类别名称：</td>
                          <td width="88%"><input name="txtValue" type="text"  class='text' value="" size="31" maxlength="80"></td>
                        </tr>
                        <tr> 
                          <td>类别排序： </td>
                          <td><input name="txtGrade" type="text"  class='text' value="" size="31" maxlength="6" onBlur="if (isNaN(this.value)){this.value='0';  alert('类型错误,请输入数值型！');this.focus(); }"></td>
                        </tr>
                        <tr> 
                          <td height="40" colspan="2"><input type="submit" value="提交信息" name="B32" class="button"> 
                            &nbsp; <input type="reset" value="从新来过" name="B32" class="button"></td>
                        </tr>
                      </table>
                      
                    </td>
                  </tr>
                </table></td>
            </form>
          </tr>
        </table>
        <%else%>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td height="18" 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_NewsCategory.asp?pageno=<%=request("pageno")%>&action=editsave&ModifyID=<%=request("ModifyID")%>" onSubmit="return CheckData()">
              <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="12%">类别名称：</td>
                          <td width="88%"><input name="txtValue" type="text"  class='text' value="<%=mValue%>" size="31" maxlength="80"></td>
                        </tr>
                        <tr> 
                          <td>类别排序：</td>
                          <td><input name="txtGrade" type="text"  class='text' value="<%=mGrade%>" size="31" maxlength="6" onBlur="if (isNaN(this.value)){this.value='0';  alert('类型错误,请输入数值型！');this.focus(); }"></td>
                        </tr>
                        <tr> 
                          <td height="40" colspan="2"><input type="submit" value="提交信息" name="B32" class="button"> 
                            &nbsp; <input type="reset" value="从新来过" name="B32" class="button"></td>
                        </tr>
                      </table>
					</td>
                  </tr>
                </table></td>
            </form>
          </tr>
        </table>
        <%end if%>
      </TD>
    </TR>
  </TBODY>
</TABLE>
</body>
</html>
<%
 rs.close
 set rs=nothing
 conn.close
 set conn=nothing
%>