<!--#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,mFolder
'initialization 
mFlag=true'add

if request("action")="edit" then 
  mSql = "Select * From T_SmallCategory Where F_ID=" & Request.QueryString("ModifyID")
  Set rs = conn.Execute(mSql)
  mTypeName = rs("F_Value")
  mFolder = rs("F_Value2")
  mTemplate = rs("F_TemplateID")
  mColor1 = rs("F_Color")
  mImage = rs("F_Image")
  mFlag=false
end if

'Insert Records
if Request.QueryString("action")="Insert" then
  mTypeName = checkStr(Trim(Request.Form("txtTypeName")))
  mFolder = checkStr(Trim(Request.Form("txtFolder")))
  mTemplate = checkStr(Trim(Request.Form("selTemplate")))
  mColor = checkStr(Trim(Request.Form("txtColor")))
  mImage = checkStr(Trim(Request.Form("txtImage")))
  mBigCategoryID = Trim(Request.QueryString("BigCategoryID"))
  if Trim(Request.QueryString("grade"))="" then mGrade=1 else mGrade=Cint(Request.QueryString("grade"))
  mSql="Insert into T_SmallCategory(F_Value,F_Value2,F_TemplateID,F_Grade,F_BigCategoryID,F_Image,F_Color)values('"&mTypeName&"','"&mFolder&"','"&mTemplate&"',"&mGrade&","&mBigCategoryID&",'"&mImage&"','"&mColor&"')"
  conn.execute(mSql)
  response.redirect "SmallCategoryManage.jsp?action=IsInsert&pageno=" & Request("pageno") & "&BigCategoryID="&Request("BigCategoryID")
end if

'Modify Records
if request("action")="editsave" then
  mTypeName = checkStr(Trim(Request.Form("txtTypeName2")))
  mFolder = checkStr(Trim(Request.Form("txtFolder2")))
  mTemplate = checkStr(Trim(Request.Form("selTemplate2")))
  mColor = checkStr(Trim(Request.Form("txtColor2")))
  mImage = checkStr(Trim(Request.Form("txtImage2")))
  mBigCategoryID = Trim(Request.QueryString("BigCategoryID"))
  mSql="update T_SmallCategory set F_Value='" & mTypeName &"',F_TemplateID='" & mTemplate &"',F_BigCategoryID=" & mBigCategoryID &",F_Color='" & mColor &"',F_Image='" & mImage &"' where F_ID=" & Request.Querystring("ModifyID")
  conn.execute(mSql)
  response.redirect "SmallCategoryManage.jsp?action=IsModify&pageno="&Request.Querystring("pageno")&"&BigCategoryID="&Request.Querystring("BigCategoryID")
  flag=false
end if

'Delect Records
if request("action")="delete" then
  mSql = "DELETE FROM T_SmallCategory WHERE F_ID=" &Request.QueryString("DeleteID")
  conn.execute mSql
  Response.write "<script>location.replace('SmallCategoryManage.jsp?action=IsDelete&pageno="&Request("pageno")&"&BigCategoryID="&Request("BigCategoryID")&"')</script>"
end if

'Sort Grade Up
If Request.QueryString("action")="up" then
   mSql="update T_SmallCategory set F_Grade=F_Grade-1 where F_Grade="&request.querystring("grade")
   conn.execute(mSql)
   mSql="update T_SmallCategory 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 "SmallCategoryManage.jsp?pageno="&Request("pageno")&"&BigCategoryID="&Request("BigCategoryID")&"&BgColor="&mBgColor
 End if

'Sort Grade Down
If Request.QueryString("action")="down" then
   mSql="update T_SmallCategory set F_Grade=F_Grade+1 where F_Grade="&request.querystring("grade")
   conn.execute(mSql)
   mSql="update T_SmallCategory 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 "SmallCategoryManage.jsp?pageno="&Request("pageno")&"&BigCategoryID="&Request("BigCategoryID")&"&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.txtTypeName2.value=="")
   {
    alert("类型不能为空，请输入！");
	document.form2.txtTypeName2.focus();
	return false;
   }
  if (document.form2.txtFolder2.value=="")
   {
    alert("文件夹不能为空，请输入！");
	document.form2.txtFolder2.focus();
	return false;
   }
}
</script>
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</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">
<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="7%" height="11"><b><font color="#333333">ID</font></b></td>
            <td width="9%" height="11"><b><font color="#333333">新序</font></b></td>
            <td width="12%"><b><font color="#333333"><a href="BigCategoryManage.jsp">二级类别</a></font></b></td>
            <td width="14%"><b><font color="#333333"><a href="BigCategoryManage.jsp">文件夹</a></font></b></td>
            <td width="18%"><b><font color="#333333"><a href="BigCategoryManage.jsp">模板名称</a></font></b></td>
            <td width="10%"><b><font color="#333333">排序</font></b></td>
            <td width="12%"><b><font color="#333333">批量生成</font></b></td>
            <td width="18%" 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_SmallCategory Where F_BigCategoryID="&Request("BigCategoryID")&" 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="7%" height="2" align="center" ><%=rs("F_ID")%></td>
            <td width="9%" height="2" align="center" ><%=i+(Pageno-1)*pmcount%> </td>
            <td width="12%" > 
			<a href="BigCategoryManage.jsp">
			<%if rs("F_Color") <>"" then Response.write "<font color="&rs("F_Color")&">■</font>" else Response.write "■"
			response.write rs("F_Value")%> 
			</a></td>
            <td width="14%" align="center" ><a href="BigCategoryManage.jsp"> <%=rs("F_Value2")%> 
            </td>
            <td width="18%" align="center" >
              <%
			mSql = "Select F_TemplateName From T_Template Where F_ID="&rs("F_TemplateID")
			Set rst = conn.Execute(mSql)
			if Not rst.Eof then Response.write rst(0)
			rst.Close
			%>
            </td>
            <td width="10%" align="center" > <%
	 if i+(Pageno-1)*pmcount=1 then 
	    Response.write "拉上"
	  else
		Response.write "<a href='SmallCategoryManage.jsp?pageno="&Request("pageno")&"&action=up&SortID="&rs("F_ID")&"&BigCategoryID="&Request("BigCategoryID")&"&grade="&i+(Pageno-1)*pmcount&"'>拉上</a>"
      end if
	  Response.write "&nbsp;|&nbsp;"

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

if int(pageno) < int(rs.pagecount) then
  response.write "<a href='SmallCategoryManage.jsp?pageno="&pageno+1&"&BigCategoryID="&Request("BigCategoryID")&"'><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='SmallCategoryManage.jsp?pageno="&mpage&"&BigCategoryID="&Request("BigCategoryID")&"'><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="SmallCategoryManage.jsp?pageno=<%=mpage%>&action=Insert&BigCategoryID=<%=Request("BigCategoryID")%>&grade=<%=rs.recordcount+1%>" onSubmit="return CheckData()">
              <td valign="top"> <table width="100%" height="67" border="0" cellpadding="1" cellspacing="0">
                  <tr background="Images/mmTo.gif"> 
                    <td height="6" colspan="2" 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 width="14%" align="center" bgcolor="fcfcfc">类别名称： 
                    </td>
                    <td width="86%" valign="top" bgcolor="fcfcfc"><input class="text" name="txtTypeName" type="text"  value="" size="30" maxlength="20"></td>
                  </tr>
                  <tr> 
                    <td width="14%" align="center" bgcolor="fcfcfc">文 
                      件 夹： </td>
                    <td width="86%" valign="top" bgcolor="fcfcfc"><input class="text" name="txtFolder" type="text" size="30" maxlength="20"></td>
                  </tr>
                  <tr> 
                    <td height="2" align="center" bgcolor="fcfcfc">模　　板： 
                    </td>
                    <td valign="top" bgcolor="fcfcfc"><font color="#FF0000"> 
                      <select name="selTemplate"  style="width:140">
                        <%
               mSql="Select * from T_Template order by F_ID"
               Set rst=conn.Execute(mSql)
			   Do While Not rst.Eof
			     Response.write "<option value="& rst("F_ID") &">"& rst("F_TemplateName") &"</option>"
			     rst.MoveNext
			   Loop
			   rst.Close
  		      %>
                      </select>
                      </font></td>
                  </tr>
                  <tr> 
                    <td height="2" align="center" bgcolor="fcfcfc">图片地址：</td>
                    <td valign="top" bgcolor="fcfcfc">
<input name="txtImage" type="text"  class="text" size="19"><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')">
                    </td>
                  </tr>
                  <tr> 
                    <td height="3" align="center" bgcolor="fcfcfc">文字颜色：</td>
                    <td valign="top" bgcolor="fcfcfc">
<input name="txtColor" type="text"  class="text" value="" size="30" maxlength="7"> 
                    </td>
                  </tr>
                  <tr> 
                    <td width="14%" valign="top" bgcolor="fcfcfc">&nbsp;</td>
                    <td height="33" colspan="2" bgcolor="fcfcfc"> <input type="submit" value="提交信息" name="B3" class="button"> 
                      <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="SmallCategoryManage.jsp?pageno=<%=request("pageno")%>&BigCategoryID=<%=Request("BigCategoryID")%>&action=editsave&ModifyID=<%=request("ModifyID")%>" onSubmit="return CheckData2()">
              <td> <table width="100%" height="67" border="0" cellpadding="1" cellspacing="0">
                  <tr background="Images/mmTo.gif"> 
                    <td height="6" colspan="2" 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 width="14%" align="center" valign="top" bgcolor="fcfcfc">类别名称： 
                    </td>
                    <td width="86%" valign="top" bgcolor="fcfcfc"><input class="text" name="txtTypeName2" type="text"  value="<% = mTypeName %>" size="30" maxlength="20"></td>
                  </tr>
				  <tr> 
                    <td width="14%" align="center" valign="top" bgcolor="fcfcfc">文 
                      件 夹： </td>
                    <td width="86%" valign="top" bgcolor="fcfcfc"><input class="text" name="txtFolder2" type="text"  disabled value="<% = mFolder %>" size="30" maxlength="20"></td>
                  </tr>
                  <tr> 
                    <td height="7" align="center" valign="top" bgcolor="fcfcfc">模　　板： 
                    </td>
                    <td valign="top" bgcolor="fcfcfc"><font color="#FF0000"> 
                      <select name="selTemplate2"  style="width:140">
                        <%
               mSql="Select * from T_Template  order by F_ID"
			   set rs=conn.Execute(mSql)
			   Do While Not rs.Eof 
			     if Trim(mTemplate) = Trim(rs("F_ID")) then
     				response.write "<option value=" + cstr(rs("F_ID"))
           			response.write " selected"
       				response.write ">" + rs("F_TemplateName")
                  else
                     response.write "<option value='" & rs("F_ID") &"'>"& rs("F_TemplateName") &"</option>"
                  end if
		        rs.movenext
              loop
			  rs.close
			  %>
                      </select>
                      </font></td>
                  </tr>
			<tr> 
                    <td height="2" align="center" bgcolor="fcfcfc">图片地址：</td>
                    <td valign="top" bgcolor="fcfcfc">
<input name="txtImage2" type="text"  class="text" value="<%=mImage%>" size="19"><input class="UploadButton" type="button" value="上传图片" name="UpImage1" onClick="javascript:window.open('UploadWindows.jsp?Uploadpath=../Article/UploadImages&ReturnForm=form2&ReturnText=txtImage2','upload','top=20,left=30,height=134,width=420,scrollbars=no,resizable=no')">
                    </td>
                  </tr>
                  <tr> 
                    <td height="3" align="center" bgcolor="fcfcfc">文字颜色：</td>
                    <td valign="top" bgcolor="fcfcfc">
<input name="txtColor2" type="text"  class="text" value="<%=mColor1%>" size="30" maxlength="7"> 
                    </td>
                  </tr>	  
                  <tr> 
                    <td width="14%" valign="top" bgcolor="fcfcfc">&nbsp;</td>
                    <td height="33" colspan="2" bgcolor="fcfcfc"> <input type="submit" value="提交信息" name="B32" class="button"> 
                      <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
' set rs=nothing
' conn.close
' set conn=nothing
%>
