<%@language=vbscript codepage=936%>
<%
Response.Buffer = True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
dim dns
dns="../"
%>
<!--#Include file="../Common/Inc_DatConn.asp"-->
<!--#Include file="Common/Inc_Config.asp"-->
<!--#Include file="Common/Inc_Function.asp"-->
<!--#Include file="fy_admin_check.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="images/Admin_Style.Css" rel="stylesheet" type="text/css">
<script src="../common/Admin.js" type="text/javascript"></script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<%
if fla18<>1 and Session("intUserLevel")<2 then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>错误：操作权限出错，您没有权限操作些功能！</li>"
Call Admin_ShowErr(ErrMsg)
end if
bbaction=changechr(request("bbaction"))
Select case bbaction
  	Case "addbigclass"
		call addbigclass
	Case "saveaddbig"
		call saveaddbig
 	Case "saveeditpoint"
		call saveeditpoint
 	Case "deldl"
		call deldl
	Case "delxl"
		call delxl
	Case "aa"
		call aa
	Case "aaa"
		call aaa
	Case "addsmallclass"
		call addsmallclass
	Case "saveaddsmall"
		call saveaddsmall
	Case "editsmallclass"
		call editsmallclass
	Case "editbigclass"
		call editbigclass
	Case "saveeditbig"
		call saveeditbig
	Case "saveeditsmall"
		call saveeditsmall
	Case else
%>

<table width="100%" border="0"565 cellpadding="2" cellspacing="1" class="border" align="center" >
  <tr class="title"> 
    <td height="22" colspan="2"565><strong>供求分类设置</strong></td>
  </tr>
  <tr class="tdbg"> 
    <td width="70" height="30"><strong>管理导航：</strong></td>
    <td height="30">
			<img border="0" src="../images/dot_02.gif" width="14" height="14"><a href="?bbaction=addbigclass">添加一级分类</a>&nbsp;&nbsp;
			<img border="0" src="../images/dot_02.gif" width="14" height="14"><a href="?bbaction=addnews">分类菜单设置</a>
			<br>
			<br>
				<a name="top"><font color="#ff0000"><b>注</b>：在分类目录的管理上尽可有的保持“宁改勿删”的原则，因为删除目录，则同时会将该目录下的子目录及所有此目录下的信息全部被删除。</font></a></td>
  </tr>
</table>
<br>
  <div>
  <table width="100%" border="0" cellpadding="0" cellspacing="1" Class="border" align="center" >
    <tr class="title"> 
      <td width="30%"565>名称</td>
      <td width="40%"565>操作选项</td>
      <td width="30%"565>管理员</td>
    </tr>
<%
dim sql,rsBigClass,rsSmallClass,ErrMsg
set rsBigClass=server.CreateObject("adodb.recordset")
sqlInfod = "Select * From BigClass order by sj desc"
rsBigClass.Open sqlInfod,Conn,1,1
do while not rsBigClass.eof
%>
    <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'"> 
      <td width="30%"565><img src="../Images/tree_folder4.gif" width="15" height="15"><%=rsBigClass("BigClassName")%></td>
      <td width="40%"565><a href="?bbaction=addsmallclass&BigClassName=<%=rsBigClass("BigClassName")%>&dl=<%=rsBigClass("id")%>">添加子栏目</a> 
            | <a href="?bbaction=editbigclass&BigClassID=<%=rsBigClass("ID")%>">修改</a> 
            | <a href="?BigClassName=<%=rsBigClass("BigClassName")%>&dl=<%=rsBigClass("id")%>&bbaction=deldl" onclick="{if(confirm('确定删除吗?')){return true;}return false;}">删除</a> 
				| <a href="?id=<%=rsBigClass("id")%>&bbaction=aa">排序</a></td>
      <td width="30%"565><%=rsBigClass("admin")%></td>
    </tr>
<%
	  set rsSmallClass=server.CreateObject("adodb.recordset")
	  	sqlInfosm = "Select * From SmallClass Where dl='" & rsBigClass("id") & "' order by sj desc"
rsSmallClass.Open sqlInfosm,Conn,1,1
	  if not(rsSmallClass.bof and rsSmallClass.eof) then
		do while not rsSmallClass.eof
	%>
     <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'"> 
      <td width="30%"565>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <img src="../Images/tree_folder3.gif" width="15" height="15"><%=rsSmallClass("SmallClassName")%></td>
      <td width="40%"565>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            <a href="?bbaction=editsmallclass&SmallClassID=<%=rsSmallClass("ID")%>&odl=<%=rsSmallClass("dl")%>">修改</a> 
            | <a href="?SmallClassID=<%=rsSmallClass("ID")%>&SmallClassName=<%=rsSmallClass("SmallClassName")%>&bbaction=delxl" onclick="{if(confirm('确定删除吗?')){return true;}return false;}">删除</a> 
				| <a href="?xlid=<%=rsSmallClass("id")%>&bbaction=aaa">排序</a></td>
      <td width="30%"565>　</td>
    </tr>
<%
			rsSmallClass.movenext
		loop
	  end if
	  rsSmallClass.close
	  set rsSmallClass=nothing	
	  rsBigClass.movenext
	loop
%><%
rsBigClass.close
set rsBigClass=nothing
conn.close
set conn=nothing
%>
  </table>
	</div>
<%
End Select
sub addbigclass
%>
<script language="JavaScript" type="text/JavaScript">
function checkBig()
{
  if (document.form1.BigClassName.value=="")
  {
    alert("大类名称不能为空！");
    document.form1.BigClassName.focus();
    return false;
  }
}
</script>
<br>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="border" height="73">
  <tr class="title"> 
    <td height="22" colspan="2" align="center"><strong>添加一级分类</strong></td>
  </tr><form name="form1" method="post" action="?bbaction=saveaddbig" onsubmit="return checkBig()">
  <tr class="tdbg">
    <td width="12%" height="23" align="right">分类名称：</td>
    <td height="23" width="87%"><input name="BigClassName" type="text" size="23" maxlength="30"></td>
  </tr>
  <tr class="tdbg">
    <td width="12%" height="23" align="right">分类图片：</td>
    <td height="23" width="87%"><input name="pic" type="text" size="23"></td>
  </tr>
  <tr class="tdbg">
    <td width="12%" height="23" align="right">管理员：</td>
    <td height="23" width="87%"><input name="admin" type="text" size="23" readonly></td>
  </tr>  <tr class="tdbg">
    <td width="12%" height="23" align="right"></td>
    <td height="23" width="87%"><SCRIPT language=javascript>
function ToValue(type,objname,strvalue)
{ 
	var obj=document.getElementById(objname)
	if (type=="add"){
		var stemp=obj.value.replace(strvalue,'')
		obj.value=stemp+strvalue;
		}
	else if (type=="+"){obj.value=parseInt(obj.value)+parseInt(strvalue);}
	else{obj.value=strvalue;}
	obj.focus(); 
 return; 
}
</SCRIPT>
<%set rsadm=conn.execute("select * from Sys_Account where UserLevel=1")
if not rsadm.eof then
do while not rsadm.EOF
%><a href="javascript:ToValue('add','admin','|<%=rsadm("Account")%>|')"><%=rsadm("Account")%></a>
<%
rsadm.MoveNext%>|<%
	loop
else
	Response.Write "<a href=# onclick=Javascript:CreateUser()><font color=""#FF0000"">没有普通用户，点击添加...</font></a>"
end if
rsadm.Close
set rsadm= nothing%>
</td>
  </tr>  
        <tr class="tdbg">
          <td height="12" align="right" colspan="2">
			<p align="center"><input type="submit" value="提 交" name="Submit"> <input onclick="parent.location.href='Javascript:history.back()'" type="button" value="返 回" name=button1></td>
        </tr></form>
</table>
<%
end sub
sub addsmallclass
dl=trim(request("dl"))
%>
<script language="JavaScript" type="text/JavaScript">
function checkSmall()
{
  if (document.form2.BigClassName.value=="")
  {
    alert("请先添加大类名称！");
	document.form1.BigClassName.focus();
	return false;
  }

  if (document.form2.SmallClassName.value=="")
  {
    alert("小类名称不能为空！");
	document.form2.SmallClassName.focus();
	return false;
  }
}
</script>
<br>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="border" height="73">
  <tr class="title"> 
    <td height="22" colspan="2" align="center"><strong>添加二级分类</strong></td>
  </tr><form name="form2" method="post" action="?bbaction=saveaddsmall" onsubmit="return checkSmall()">
  <tr class="tdbg">
    <td width="12%" height="23" align="right">所属大类：</td>
    <td height="23" width="87%"><select name="dl">
                <%
	dim rsBigClass
	set rsBigClass=server.CreateObject("adodb.recordset")
sqlInfod = "Select * From BigClass order by sj desc"
rsBigClass.Open sqlInfod,Conn,1,1
	if rsBigClass.bof and rsBigClass.bof then
		response.write "<option>请先添加大类</option>"
	else
		do while not rsBigClass.eof
			if rsBigClass("id")=cint(dl) then
				response.write "<option value='"& rsBigClass("id") & "' selected>" & rsBigClass("BigClassName") & "</option>"
			else
				response.write "<option value='"& rsBigClass("id") & "'>" & rsBigClass("BigClassName") & "</option>"
			end if
			rsBigClass.movenext
		loop
	end if
	rsBigClass.close
	set rsBigClass=nothing
	%>
              </select></td>
  </tr>
  <tr class="tdbg">
    <td width="12%" height="23" align="right">小类名称：</td>
    <td height="23" width="87%"><input name="SmallClassName" type="text" size="20" maxlength="30"></td>
  </tr>
<tr class="tdbg">
          <td height="12" align="right" colspan="2">
			<p align="center"><input type="submit" value="提 交" name="Submit"> <input onclick="parent.location.href='Javascript:history.back()'" type="button" value="返 回" name=button1></td>
        </tr></form>
</table>
<%
end sub
sub editsmallclass
dim SmallClassID,Action,BigClassName, SmallClassName, OldSmallClassName,rs,FoundErr,ErrMsg
SmallClassID=trim(Request("SmallClassID"))
dl=trim(Request.form("dl"))
odl=trim(Request("odl"))
SmallClassName=trim(Request.form("SmallClassName"))
OldSmallClassName=trim(request.form("OldSmallClassName"))
if SmallClassID="" then
	response.Redirect("infoclass.asp")
end if
Set rs=Server.CreateObject("Adodb.RecordSet")
rs.Open "Select * from SmallClass where ID="&SmallClassID&"",conn,1,3
if rs.Bof or rs.EOF then
	FoundErr=True
	ErrMsg=ErrMsg & "此小类不存在！"
	Call Admin_ShowErr(ErrMsg)
else
%>
<br>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="border" height="73">
  <tr class="title"> 
    <td height="22" colspan="2" align="center"><strong>修改二级分类</strong></td>
  </tr><form name="form2" method="post" action="?bbaction=saveeditsmall">
  <tr class="tdbg">
    <td width="12%" height="23" align="right">所属大类：</td>
    <td height="23" width="87%">
<select name="dl">
                <%
dl=rs("dl")
	dim rsBigClass
	set rsBigClass=server.CreateObject("adodb.recordset")
sqlInfod = "Select * From BigClass order by sj desc"
rsBigClass.Open sqlInfod,Conn,1,1
		do while not rsBigClass.eof
			if cstr(rsBigClass("id"))=odl then
				response.write "<option value='"& rsBigClass("id") & "' selected>" & rsBigClass("BigClassName") & "</option>"
			else
				response.write "<option value='"& rsBigClass("id") & "'>" & rsBigClass("BigClassName") & "</option>"
			end if
			rsBigClass.movenext
		loop
	rsBigClass.close
	set rsBigClass=nothing
	%>
              </select></td>
  </tr>
  <tr class="tdbg">
    <td width="12%" height="23" align="right">小类名称：</td>
    <td height="23" width="87%"><input name="odl" type="hidden" value="<%=request("odl")%>"> 
            <input name="SmallClassID" type="hidden" value="<%=request("SmallClassID")%>"> 
            <input name="Action" type="hidden" id="Action" value="Modify">
              <input name="SmallClassName" type="text" id="SmallClassName" value="<%=rs("SmallClassName")%>" size="20" maxlength="30"></td>
  </tr>
<tr class="tdbg">
          <td height="12" align="right" colspan="2">
			<p align="center"><input type="submit" value="提 交" name="Submit"> <input onclick="parent.location.href='Javascript:history.back()'" type="button" value="返 回" name=button1></td>
        </tr></form>
</table>
<%
end if
end sub
sub editbigclass
dim BigClassID,Action,rs,NewBigClassName,OldBigClassName,FoundErr,ErrMsg
BigClassID=trim(Request("BigClassID"))
admin=trim(Request("admin"))

if BigClassID="" then
  response.Redirect("infoclass.asp")
end if
Set rs=Server.CreateObject("Adodb.RecordSet")
rs.Open "Select * from BigClass where ID=" & CLng(BigClassID),conn,1,3
if rs.Bof and rs.EOF then
	FoundErr=True
	ErrMsg=ErrMsg & "此大类不存在！"
	Call Admin_ShowErr(ErrMsg)
else
%>
<br>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="border" height="73">
  <tr class="title"> 
    <td height="22" colspan="2" align="center"><strong>修改一级分类</strong></td>
  </tr><form name="form2" method="post" action="?bbaction=saveeditbig">
  <tr class="tdbg">
    <td width="12%" height="23" align="right">大类ID：</td>
    <td height="23" width="87%">
<%=rs("ID")%></td>
  </tr>
  <tr class="tdbg">
    <td width="12%" height="23" align="right">大类名称：</td>
    <td height="23" width="87%"><input name="BigClassID" type="hidden" id="BigClassID" value="<%=rs("ID")%>"> 
              <input name="OldBigClassName" type="hidden" id="OldBigClassName" value="<%=rs("BigClassName")%>"> 
              <input name="NewBigClassName" type="text" id="NewBigClassName" value="<%=rs("BigClassName")%>" size="20" maxlength="30"></td>
  </tr>
    <tr class="tdbg">
    <td width="12%" height="23" align="right">分类图片：</td>
    <td height="23" width="87%">
<input name="pic" type="text" value="<%=rs("pic")%>" size="20"></td>
  </tr>
    <tr class="tdbg">
    <td width="12%" height="23" align="right">管理员：</td>
    <td height="23" width="87%">
<input name="admin" type="text" size="23" readonly value="<%=rs("admin")%>"></td>
  </tr>
    <tr class="tdbg">
    <td width="12%" height="23" align="right"></td>
    <td height="23" width="87%">
<SCRIPT language=javascript>
function ToValue(type,objname,strvalue)
{ 
	var obj=document.getElementById(objname)
	if (type=="add"){
		var stemp=obj.value.replace(strvalue,'')
		obj.value=stemp+strvalue;
		}
	else if (type=="+"){obj.value=parseInt(obj.value)+parseInt(strvalue);}
	else{obj.value=strvalue;}
	obj.focus(); 
 return; 
}
</SCRIPT><script language="javascript">
function CreateUser() {
  popupWin = window.open('Oper.asp?Oper=AddUser','','width=300,height=150,scrollbars=no')
}
</script>
<%set rsadm=conn.execute("select * from Sys_Account where UserLevel=1")
if not rsadm.eof then
do while not rsadm.EOF
%><a href="javascript:ToValue('add','admin','|<%=rsadm("Account")%>|')"><%=rsadm("Account")%></a>
<%
rsadm.MoveNext%>|<%
	loop
else
	Response.Write "<a href=# onclick=Javascript:CreateUser()><font color=""#FF0000"">没有普通用户，点击添加...</font></a>"
end if
rsadm.Close
set rsadm= nothing%></td>
  </tr>
<tr class="tdbg">
          <td height="12" align="right" colspan="2">
			<p align="center"><input type="submit" value="提 交" name="Submit"> <input onclick="parent.location.href='Javascript:history.back()'" type="button" value="返 回" name=button1></td>
        </tr></form>
</table>
<%
end if
end sub

%>