<!-- #include file="include/admin_onlogin.asp" -->
<!-- #InclUDE file="include/jk_pagecute.asp" -->
<!--#include file="include/con_music_conn.asp"-->
<%
'****************************************************
' 阳光情缘 2006V3.0      Power by sdsun.com.cn
' Email: 27072320@qq.com  , sdsun163@163.com
' Web: http://www.sdsun.com.cn
' Copyright (C) 2006 sdsun.com.cn All Rights Reserved.
'****************************************************
tit="总类管理"     
index_url="music"
call admin_master(0,0)
call admin_header(0,0)

dim founderr,act,classid

founderr=false
act=request("act")
classid=request.QueryString("classid")
if act="rename" then
	FunRename
elseif act="del" then
	FunDel
elseif act="add" then
	FunAdd
else
	call error()
	founderr=true
end if
if founderr=true then
	call error()
else
end if

function FunRename
if trim(request.form("class"))="" then
	response.write vbcrlf&"<scRIPT language=Javascript>alert('分类名不能为空！');</scRIPT>"
	founderr=true
else
	set rs=server.createobject("adodb.recordset")
	sql = "SELECT * FROM mv_class where classid=" & classid
	rs.Open sql,conn_mv,1,3
	if err.Number<>0 then
		err.clear
		call error()
		founderr=true
	else
		rs("class") = request.form("class")
		rs.Update

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

function FunDel
	sql="delete from mv_class where classid=" & classid
	conn_mv.execute sql
'----------------------------------删除相关栏目对应分类----------------------------------
	sql="delete from mv_sclass where classid=" & classid
	conn_mv.execute sql
'----------------------------------删除相关栏目对应歌手----------------------------------
	sql="delete from mv_nclass where classid=" & classid
	conn_mv.execute sql
'----------------------------------删除相关栏目对应专辑----------------------------------
	sql="delete from mv_Special where classid=" & classid
	conn_mv.execute sql
	if err.Number<>0 then
		err.clear
		call error()
		founderr=true
	end if
end function

function FunAdd
if trim(request("class"))="" then
	response.write vbcrlf&"<scRIPT language=Javascript>alert('分类名不能为空！');</scRIPT>"
	founderr=true
else
	set rs=server.createobject("adodb.recordset")
	sql = "SELECT * FROM mv_class where (classid IS NULL)"
	rs.Open sql,conn_mv,1,3
	if err.Number<>0 then
		err.clear
		call error()
		founderr=true
	else
		rs.AddNew
		rs("class") = request.form("class")
		rs.Update
	end if
	rs.close
	set rs=nothing
	conn_mv.close
	set conn_mv=nothing
end if
end function
Response.Redirect "admin_music_sort.asp?action=sort_edit"

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

'****************************************************
' 阳光情缘 2006V3.0      Power by sdsun.com.cn
' Email: 27072320@qq.com  , sdsun163@163.com
' Web: http://www.sdsun.com.cn
' Copyright (C) 2006 sdsun.com.cn All Rights Reserved.
'****************************************************
%>