<!-- #include file="include/admin_onlogin.asp" -->
<!-- #InclUDE file="include/jk_pagecute.asp" -->
<!--#include file="include/con_music_conn.asp"-->
<%

tit="音乐分类"
index_url="music"
call admin_master(0,0)
call admin_header(0,0)

%>
<tr><td align=center colspan=2 height=30>
  <table border=0>
  <tr>
  <td><a class=h_menu onmouseover=ShowMenu(strMenu_music,100) href='admin_music.asp'>音乐列表</a></td>
  <td width=10></td>
  <td><a href='admin_music_list.asp'>歌曲管理</a></td>
  <td width=10></td>
  <td><a class=h_menu onmouseover=ShowMenu(strMenu_singer,100) href='admin_music_singer.asp'>歌手管理</a></td>
  <td width=10></td>
  <td><a href='admin_music.asp?action=disk_list'>专辑管理</a></td> 
  <td width=10></td>
  <td><a href='admin_music_sort.asp'>音乐分类</a></td>
  <td width=10></td>
  <td><a href='admin_song.asp'>点歌管理</a></td>
  <td width=10></td>
  <td><a href='admin_fav.asp'>歌曲收藏</a></td>
  <td width=10></td>
  <td><a href='admin_disk.asp'>专辑收藏</a></td>
  </tr>
  </table>
</td></tr>
<tr><td colspan=2 align=center>
  <table border=0 cellspacing=0 cellpadding=2>
  <form action='admin_music_search.asp' name="search" method="post">
  <input type=hidden name=sea_term value='only'>
  <input type=hidden name=sea_type value='name'>
  <tr>
  <td>音 乐 搜 索</td>
  <td>&nbsp;<select name='stype' size=1>
<option value='Special'>专辑</option>
<option value='Music'>音乐</option>
<option value='Singer'>歌手</option>
</select></td>
  <td>&nbsp;<input type='text' name='keyword' value='' size=12 maxlength=20 alt='多个关键字请用 空格 格开'></td>
  <td>&nbsp;<select name=s_area size=1>
<option value='' class=mbg_tds>所有地区</option>
<option value='1'>大陆地区</option>
<option value='2'>港台地区</option>
<option value='3'>海外地区</option></select></td>
  <td>&nbsp;<select name=s_sex size=1>
<option value='' class=mbg_tds>所有歌手</option>
<option value='1'>男歌手</option>
<option value='2'>女歌手</option>
<option value='3'>乐队组合</option></select></td>
  <td>&nbsp;<select name=s_lang size=1>
<option value='' class=mbg_tds>语言</option>
<option value='中文'>中文</option>
<option value='粤语'>粤语</option>
<option value='英文'>英文</option>
<option value='日文'>日文</option>
<option value='韩文'>韩文</option>
<option value='其它'>其它</option>
</select></td>
  <td valign=top>&nbsp;<input type=submit value='搜 索'></td>
  </tr>
  </form>
</table>
<%


dim act,classID,founderr,sclassid,sclass
dim maxList

select case action
case "sort_add"
  call sort_add()
case "sort_list"
  call sort_list()
case "sort_edit"
  call sort_edit()
case else
  call sort_main()
end select

sub sort_main()
i=0 
maxList=80
set rs=server.createobject("adodb.recordset")

sql="select * from mv_class order by classid"
rs.open sql,conn_mv,1,1
i=request("id")
if i="" then i=rs("classid")
%>
<table class=table cellSpacing=1 cellPadding=1>	
<tr height=20 align=center>
<td width="20%"><a title="点击进入修改总类名称" href="?action=sort_edit">总类名称</a></td>
<td width="80%">添加分类</td>
</tr>
</table> 

<table class=table cellSpacing=1 cellPadding=1>	   
<%
do while not rs.eof
i=i+1
%>
<form method="POST" action="?action=sort_add&act=add&classid=<%=rs("classid")%>" align="center">
<tr height=25 align=center>
<td width="20%"><a title="点击进入管理 <%=rs("class")%> 的二级分类" href=?action=sort_list&id=<%=rs("classid")%>><%=rs("class")%></a></td>
<td width="80%" align=left>&nbsp;&nbsp;<input class=input type="text" name="sclass" size="55">&nbsp;&nbsp;<input class=input type="submit" value="添 加" name="B1"></td>
</tr>
</form>
<%
if (i mod (maxList/2)=0) and i>=(maxList/2) then
end if
if i>=maxList then exit do
rs.movenext
loop
rs.close
%>
</table>
<%
end sub

sub sort_add()
act=request("act")
classID=request.form("classid")
founderr=false

if act="rename" then
	FunRename
elseif act="del" then
	FunDel
elseif act="add" then
	FunAdd
else
	call error()
end if

Response.Redirect "?action=sort_list"
end sub

function FunRename
	sclassid=request.QueryString("sclassid")
	sclass=trim(request.form("sclass"))
	if sclass="" then
		response.write vbcrlf&"<scRIPT language=Javascript>alert('栏目名称不能为空！');</scRIPT>"
		call error()
		Response.End 
	end if
	set rs=server.createobject("adodb.recordset")
	sql = "SELECT * FROM mv_sclass where sclassid=" & sclassid
	rs.Open sql,conn_mv, 1, 3
	if err.Number<>0 then
		err.clear
		call error()
		founderr=true
	else
		rs("sclass") = sclass
		rs.Update
	end if
	rs.close

	set rs=nothing
	conn_mv.close
	set conn_mv=nothing
end function

function FunDel
	sclassid=request("sclassid")
	sql="delete from mv_sclass where sclassid=" & sclassid
	conn_mv.execute sql
	Rem 删除三级栏目
	sql="delete from mv_nclass where sclassid=" & sclassid
	conn_mv.execute sql
	Rem 删除相关商品
	sql="delete from mv_special where sclassid=" & sclassid
	conn_mv.execute sql
	if err.Number<>0 then
		err.clear
		call error()
		founderr=true
	end if
end function
	
function FunAdd
	sclass=trim(request.form("sclass"))
	classid=request.QueryString("classid")
	if sclass="" then
		response.write vbcrlf&"<scRIPT language=Javascript>alert('栏目名称不能为空！');</scRIPT>"
		call error()
		Response.End 
	end if
	set rs=server.createobject("adodb.recordset")
	sql = "SELECT * FROM mv_sclass where (sclassid IS NULL)"
	rs.Open sql,conn_mv, 1, 3
	if err.Number<>0 then
		err.clear
		call error()
		founderr=true
	else
		rs.AddNew
		rs("sclass") = sclass
		rs("classid") = classid
		rs.Update
	end if
	rs.close
	set rs=nothing
	conn_mv.close
	set conn_mv=nothing
end function

sub sort_list
dim rs2,sql2,j
set rs=server.createobject("adodb.recordset")
set rs2=server.createobject("adodb.recordset")

sql="select * from mv_class order by classid"
rs.open sql,conn_mv,1,1
i=request("id")
if i="" then i=rs("classid")
do while not rs.eof
rs.movenext
loop
rs.close
sql="select * from mv_class where classid="&i
rs.open sql,conn_mv,1,1
if rs.eof then
else
%>
<table class=table cellSpacing=1 cellPadding=1>
<%
sql2="select * from mv_sclass where classid="&rs("classid")&" order by sclassid"
rs2.open sql2,conn_mv,1,1
if rs2.eof then
%>
<tr><td align="center">尚无任何二级分类</td></tr>
<%
else
j=0
do while not rs2.eof
j=j+1
%>

<tr>
<td width="100%" height="22" align=left>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<form method="POST" action="?action=sort_add&act=rename&sclassid=<%=rs2("sclassid")%>" id=form<%=j%> name=form<%=j%>>
<tr>
<td width="20%"  height=22 align=left>&nbsp;&nbsp;<%=rs2("sclassid")%>.<%=rs2("sclass")%></td>
<td width="73%" height=22><input size=50 type="text" name="sclass" class=input value="<%=rs2("sclass")%>">&nbsp;&nbsp;<input class=input type="submit" value="改 名" name="Submit"></td>
<td width="7%" height=22 align="right"><a title="不到万一请不要用此功能" href='?action=sort_add&act=del&sclassid=<%=rs2("sclassID")%>'><font color=red>删除</font></a>&nbsp;&nbsp;&nbsp;&nbsp;</td>
</tr>
</form>
</table>
</td>
</tr>
<%
rs2.movenext
loop
end if
rs2.close

end if
rs.close
%>
</table>
<%
end sub

sub error()
response.write vbcrlf&"<scRIPT language=Javascript>alert('操作错误！\n\n请到 咪咪娱乐社区(http://www.mimi88.cn/) 查阅相关贴子！\n\n点击返回... ');javascript:history.go(-1);</scRIPT>"
end sub

sub sort_edit
i=0 
maxList=80
set rs=server.createobject("adodb.recordset")
sql="select * from mv_class order by classid"
rs.open sql,conn_mv,1,1
i=request("id")
if i="" then i=rs("classid")
%>
<table class=table cellSpacing=1 cellPadding=1>
<tr><td width="100%" height="25">
<table class=table0 cellSpacing=1 cellPadding=1>
<%
do while not rs.eof
i=i+1
%>  
<form method="POST" action="admin_music_sort_edit.asp?act=rename&classid=<%=rs("classid")%>" id=form1 name=form1>
<tr>
<td width="30%" height=20 align=left>&nbsp;&nbsp;<%=rs("classid")%>.<%=rs("class")%></td>
<td width="60%" height=20 align=center><input size=40 type="text" class=input name="class" value="<%=rs("class")%>">&nbsp;&nbsp;<input class=input type="submit" value="改 名" name="Submit"></td>
<td width="10%" height=20 align=center><a title="不到万一请不要用此功能" href='admin_music_sort_edit.asp?act=del&classid=<%=rs("classID")%>'><font color=red>删除</font></a></td>
</tr>
</form>
<%
if (i mod (maxList/2)=0) and i>=(maxList/2) then
end if
if i>=maxList then exit do
rs.movenext
loop
rs.close
%>
<tr>
<td width="30%" height=20 align=center>添加总类  </td>     
<form method="POST" action="admin_music_sort_edit.asp?act=add">
<td width="60%" height=20 align=center><input type="text" class=input name="class" size="40">  &nbsp;<input type="submit" value="添 加" name="B3" class=input></td>
<td width="10%" height=20 align=center>&nbsp;</td>
</tr>
</form>
</table>
</td></tr></table>
<%
end sub

%>
