<!--#include file="../include/Conn.jsp"-->
<!--#include file="../include/Char.jsp"-->
<!--#include file="Admin_IsLogin.jsp" -->
<%
dim i
dim rs,rst
dim mTypeName,mGrade,mSql,mFlag,mBgColor
'initialization 
mFlag=true'add

if request("action")="edit" then
 mSql = "Select * From T_BigCategory Where F_ID=" & Request("ModifyID")
 Set rs=conn.Execute(mSql)
 if Not rs.Eof then
   mTypeName = rs("F_Value")
   mFolder = rs("F_Value2")
   mImage = rs("F_Image")
   mColor1 = rs("F_Color")
 End if
 rs.Close
 mFlag=false
end if

'Insert Records
if Request.ServerVariables("REQUEST_METHOD")="POST" then
  mTypeName = checkStr(Trim(Request.Form("txtTypeName")))
  mFolder = checkStr(Trim(Request.Form("txtFolder")))  
  mImage = checkStr(Trim(Request.Form("txtImage")))  
  mColor = checkStr(Trim(Request.Form("txtColor")))  
  if request("action")="Insert" then
    if Trim(Request.QueryString("grade"))="" then mGrade=1 else mGrade=Cint(Request.QueryString("grade"))
    mSql="insert into T_BigCategory(F_Value,F_Value2,F_Image,F_Color,F_Grade)values('"&mTypeName&"','"&mFolder&"','"&mImage&"','"&mColor&"',"&mGrade&")"
    conn.execute(mSql)
    response.redirect "BigCategoryManage.jsp?action=IsInsert&pageno="&Request("pageno")
  else
    mSql="update T_BigCategory set F_Value='" & mTypeName &"',F_Image='" & mImage &"',F_Color='" & mColor &"' where F_ID="&request.querystring("ModifyID")
    conn.execute(mSql)
    response.redirect "BigCategoryManage.jsp?action=IsModify&pageno="&Request.Querystring("pageno")
    flag=false
  end if
end if

'Delect Records
if request("action")="Delete" then
  '删除一级栏目
  mSql = "Delete From T_BigCategory WHERE F_ID=" & Request.QueryString("DeleteID")
  conn.Execute(mSql)
  Response.write "<script>location.replace('BigCategoryManage.jsp?action=IsDelete&pageno="&Request.Querystring("pageno")&"')</script>"
  '删除二级栏目
  mSql = "Delete From T_SmallCategory Where F_BigCategoryID=" & Request.QueryString("DeleteID")
  conn.Execute(mSql)
end if

'Sort Grade Up
If Request.QueryString("action")="up" then
   mSql="update T_BigCategory set F_Grade=F_Grade-1 where F_Grade="&request.querystring("grade")
   conn.execute(mSql)
   mSql="update T_BigCategory set F_Grade=F_Grade+1 where F_Grade="&cint(request.querystring("grade"))-1&" and F_ID<>"&Request.QueryString("SortID")
   conn.execute(mSql)
   mBgColor=Request.QueryString("SortID")
   Response.Redirect "BigCategoryManage.jsp?pageno="&Request("pageno")&"&BgColor="&mBgColor
 End if

'Sort Grade Down
If Request.QueryString("action")="down" then
   mSql="update T_BigCategory set F_Grade=F_Grade+1 where F_Grade="&request.querystring("grade")
   conn.execute(mSql)
   mSql="update T_BigCategory set F_Grade=F_Grade-1 where F_Grade="&cint(request.querystring("grade"))+1&" and F_ID<>"&Request.QueryString("SortID")
   conn.execute(mSql)
   mBgColor=Request.QueryString("SortID")
   Response.Redirect "BigCategoryManage.jsp?pageno="&Request("pageno")&"&BgColor="&mBgColor
 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.txtTypeName.value=="")
   {
    alert("类型不能为空，请输入！");
	document.form1.txtTypeName.focus();
	return false;
   }
  if (document.form1.txtFolder.value=="")
   {
    alert("文件夹不能为空，请输入！");
	document.form1.txtFolder.focus();
	return false;
   }

   
}

function CheckData2(){
  if (document.form2.txtTypeName.value=="")
   {
    alert("类型不能为空，请输入！");
	document.form2.txtTypeName.focus();
	return false;
   }
  if (document.form2.txtFolder.value=="")
   {
    alert("文件夹不能为空，请输入！");
	document.form2.txtFolder.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=22 border=1 align="center" cellPadding=0 
cellSpacing=0 borderColor=#7c96b8 borderColorDark=#ffffff>
  <TBODY>
    <TR align="center" > 
      <TD height="22" colspan="8" align="center" sytle="line-height:150%">一级栏目管理</TD>
    </TR>
  </TBODY>
</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=",1|1|0,"
	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" cellspacing="1" cellpadding="1" align="center">
          <tr style="cursor:hand" onMouseOut="this.style.backgroundColor=''" onMouseOver="this.style.backgroundColor='#EBEEF6'"  bgcolor="#dde1ec" align="center"> 
            <td width="6%" height="11"><b><font color="#333333">ID</font></b></td>
            <td width="6%" height="11"><b><font color="#333333">新序</font></b></td>
            <td width="9%"><b><font color="#333333">一级类别名称</font></b></td>
            <td width="9%"><b><font color="#333333">文件夹</font></b></td>
            <td width="8%"><b><font color="#333333">排序</font></b></td>
            <td width="11%" height="11"><b><font color="#333333">管理</font></b></td>
          </tr>
        </table>
        <table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#ebeef6">
          <%  
	Set rs=Server.createobject("Adodb.RecordSet")
    pageno=request.querystring("pageno")
    pmcount=16  
    mSql="select * from T_BigCategory 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
 i=0
 do while not rs.eof and rc>0
 i=i+1
 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="6%" height="2" align="center" ><%=rs("F_ID")%></td>
            <td width="6%" height="2" align="center" ><%=i+(Pageno-1)*pmcount%> </td>
            <td width="9%" > <a href="SmallCategoryManage.jsp?BigCategoryID=<%=rs("F_ID")%>"> 
            <%
			if rs("F_Color") <>"" then Response.write "<font color="&rs("F_Color")&">■</font>" else Response.write "■"
			Response.write rs("F_Value")
			mSql="Select Count(*) From T_SmallCategory Where F_BigCategoryID="&rs("F_ID")
			Set rs1=conn.Execute(mSql)
			Response.write "<font color=red>("&rs1(0)&")</font>"
			%>
              </a> </td>
            <td width="9%" align="center" ><a href="SmallCategoryManage.jsp?BigCategoryID=<%=rs("F_ID")%>">
              <%=rs("F_Value2")%>
              </a></td>
            <td width="8%" align="center" > <%
	 if i+(Pageno-1)*pmcount=1 then 
	    Response.write "拉上"
	  else
		Response.write "<a href='BigCategoryManage.jsp?pageno="&Request("pageno")&"&action=up&SortID="&rs("F_ID")&"&grade="&i+(Pageno-1)*pmcount&"'>拉上</a>"
      end if
	  Response.write " | "

	  if i+(Pageno-1)*pmcount=rs.recordcount then 
	    response.write "拉下"
	  else
		response.write "<a href='BigCategoryManage.jsp?pageno="&Request("pageno")&"&action=down&SortID="&rs("F_ID")&"&grade="&i+(Pageno-1)*pmcount&"'>拉下</a>"
      end if
	%> </td>
            <td width="11%" height="2" align="center" > <a href='BigCategoryManage.jsp?pageno=<%=mPage%>'><font color="#666666">添加</font></a> 
              | <a href='BigCategoryManage.jsp?action=edit&ModifyID=<%=rs("F_ID")%>&BgColor=<%=rs("F_ID")%>&pageno=<%=cstr(pageno)%>'><font color="#666666">修改</font></a> 
              | <a href="javascript:jDelete('BigCategoryManage.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="f2f2f2">
          <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='BigCategoryManage.jsp'> <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='BigCategoryManage.jsp?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='BigCategoryManage.jsp?pageno="&pno&"'>"&pno&"</a></b>"
 end if
next
response.write "&nbsp"

if int(pageno) < int(rs.pagecount) then
  response.write "<a href='BigCategoryManage.jsp?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='BigCategoryManage.jsp?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="f2f2f2"><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" height="54">
          <tr> 
            <form name="form1" method="post" action="BigCategoryManage.jsp?pageno=<%=mpage%>&action=Insert&grade=<%=rs.recordcount+1%>" onSubmit="return CheckData()">
              <td> <table width="100%" height="32" 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 height="7" bgcolor="fcfcfc">类别名称： 
                      <input name="txtTypeName" type="text" id="txtTypeName" class="text" value="" size="32" maxlength="20">
                      <br>
                      文 件 夹： 
                      <input name="txtFolder" type="text"  class="text" value="" size="32" maxlength="20">
                      <br>
                      图片地址： 
                      <input name="txtImage" type="text"  class="text" size="21"><input class="UploadButton" type="button" value="上传图片" name="UpImage1" onClick="javascript:window.open('UploadWindows.jsp?Uploadpath=../Article/UploadImages&ReturnForm=form1&ReturnText=txtImage','upload','top=20,left=30,height=134,width=420,scrollbars=no,resizable=no')">
                      <br>
                      文字颜色： 
                      <input name="txtColor" type="text"  class="text" value="" size="32" maxlength="6"> 
                      <br> </td>
                  </tr>
                  <tr> 
                    <td height="33" bgcolor="fcfcfc"> 
					<input type="submit" value="提交信息" name="B3" class="button"> 
                      &nbsp; <input type="reset" value="从新来过" name="B3" class="button"> 
                    </td>
                  </tr>
                </table></td>
            </form>
          </tr>
        </table>
        <%else%>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td height="18" align="center" bgcolor="f2f2f2"><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="form2" method="post" action="BigCategoryManage.jsp?pageno=<%=request("pageno")%>&action=editsave&ModifyID=<%=request("ModifyID")%>" onSubmit="return CheckData2()">
              <td> <table width="100%" border="0" cellspacing="0" cellpadding="2" height="32">
                  <tr bgcolor="#CCCCCC"> 
				  <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 bgcolor="f2f2f2"> 
                    <td height="7" bgcolor="fcfcfc">类别名称： 
                      <input name="txtTypeName" type="text" id="txtTypeName" class="text" value="<%=mTypeName%>" size="32" maxlength="20">
                      <br>
                      文 件 夹： 
                      <input name="txtFolder" disabled type="text"  class="text" value="<%=mFolder%>" size="32" maxlength="20">
                      <br>
                      图片地址： 
                      <input name="txtImage" type="text"  class="text" value="<%=mImage%>" size="21"><input class="UploadButton" type="button" value="上传图片" name="UpImage1" onClick="javascript:window.open('UploadWindows.jsp?Uploadpath=../Article/UploadImages&ReturnForm=form1&ReturnText=txtImage','upload','top=20,left=30,height=134,width=420,scrollbars=no,resizable=no')">
                      <br>
                      文字颜色： 
                      <input name="txtColor" type="text"  class="text" value="<% = mColor1 %>" size="32" maxlength="6"> 
                      <br> </td>
                  </tr>
                  <tr bgcolor="f2f2f2"> 
                    <td height="35" bgcolor="fcfcfc"><input type="submit" value="提交信息" name="B32" class="button"> 
                      &nbsp; <input type="reset" value="从新来过" name="B32" class="button"> 
                    </td>
                  </tr>
                </table></td>
            </form>
          </tr>
        </table>
        <%end if%>
      </TD>
    </TR>
  </TBODY>
</TABLE>
</body>
</html>
<%
 rs.close
 call CloseDatabase()
%>
