<!--#include file="inc.asp"-->
<!--#include file="check.asp"-->
<%
act=request("act")
ClassID=request.form("Classid")
founderr=false
if act="del" then
FunDel
elseif act="edit" then
FunEdit
elseif act="add" then
FunAdd
elseif act="SetIsGood" then
FunSetIsGood
else
errmsg=errmsg+"<br>"+"<li>操作错误！请联系管理员"
founderr=true
end if
if founderr=true then
call error()
else
Response.write "<script>javascript:history.back(1);</script>"
end if

function FunDel
Rem 删除子栏目
sql="delete from Nclass where Nclassid=" & request.QueryString("NClassid")
conn.execute sql
Rem 删除歌曲栏目相关内容
sql="delete from special where Nclassid=" & request.QueryString("NClassid")
conn.execute sql
Rem 删除收藏栏目相关内容
sql="delete from Albumbox where Nclassid=" & request.QueryString("NClassid")
conn.execute sql
if err.Number<>0 then
err.clear
errmsg=errmsg+"<br>"+"<li>操作错误！请联系管理员"
founderr=true
end if
end function


function FunAdd
NClass=trim(request.form("NClass"))
if NClass="" then errmsg=errmsg+"<br>"+"<li>歌手名不能为空！"
if request.form("abcd")="" then
errmsg=errmsg+"<br>"+"<li>名字索引不能为空！"
call error()
Response.End
end if
set rs=server.createobject("adodb.recordset")
sql = "SELECT * FROM Nclass where (Nclassid IS NULL)"
rs.Open sql,conn, 1, 3
if err.Number<>0 then
err.clear
errmsg=errmsg+"<br>"+"<li>操作错误！请联系管理员"
founderr=true
else
rs.AddNew
rs("Nclass") = NClass
rs("Classid") = request("Classid")
rs("SClassid") = request("SClassid")
rs("abcd") = Ucase(request.form("abcd"))
if trim(request("Pic"))<>"" then rs("Pic") = request.form("Pic")
if trim(request("intro"))<>"" then rs("txt") = htmlencode2(request.form("intro"))
rs("isgood") = request.form("isgood")
if request("hits")<>"" then rs("hits") = request("hits")
rs.Update
end if
rs.Close
set rs=nothing
conn.close
set conn=nothing
Response.redirect "0hao_Geshou.asp?Classid="&request("Classid")&"&SClassid="&request("SClassid")
end function

function FunEdit
if trim(request("NClass"))="" then errmsg=errmsg+"<br>"+"<li>歌手名不能为空！"
if request.form("abcd")="" then
errmsg=errmsg+"<br>"+"<li>名字索引不能为空！"
call error()
Response.End
end if
set rs=server.createobject("adodb.recordset")
sql = "SELECT * FROM Nclass where NClassid="&request("NClassid")
rs.Open sql,conn, 1, 3
if err.Number<>0 then
err.clear
errmsg=errmsg+"<br>"+"<li>操作错误！请联系管理员"
founderr=true
else
rs("Nclass") = request("NClass")
rs("Classid") = request("Classid")
rs("SClassid") = request("SClassid")
rs("abcd") = Ucase(request("abcd"))
rs("hits") = request("hits")
rs("isgood") = request("isgood")
if trim(request("Pic"))="" then
rs("Pic")=null
else
rs("Pic") = request.form("Pic")
end if
if trim(request("intro"))="" then
rs("txt")=null
else
rs("txt") = htmlencode2(request("intro"))
end if
rs.Update
end if
rs.Close

'修改歌曲中的资料
set rsmin=server.createobject("adodb.recordset")
sqlmin = "SELECT SClass FROM SClass where SClassid="&request("SClassid")
rsmin.Open sqlmin,conn, 1, 1
SClassn=rsmin("SClass")
rsmin.close
set rsmin=nothing

set rs=server.createobject("adodb.recordset")
sql = "SELECT * FROM special where NClassid="&request.QueryString("NClassid")
rs.Open sql,conn, 1, 3
if not rs.eof then
do while not rs.eof
rs("NClass")=trim(Request.Form ("NClass"))
rs("SClass")=SClassn
rs("SClassid")=Request.Form ("SClassid")
rs.movenext
loop
end if
rs.close


'修改收藏中的资料
set rs=server.createobject("adodb.recordset")
sql = "SELECT * FROM Albumbox where NClassid="&request.QueryString("NClassid")
rs.Open sql,conn, 1, 3
if not rs.eof then
do while not rs.eof
rs("Singer")=trim(Request.Form ("NClass"))
'rs("Classid")=Request.Form("Classid")
'rs("SClassid")=Request.Form ("SClassid")
rs.movenext
loop
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
Response.redirect "0hao_Geshou.asp?Classid="&request("Classid")&"&SClassid="&request("SClassid")
end function

'推荐
function FunSetIsGood
set rs=server.createobject("adodb.recordset")
sql="select IsGood from NClass where NClassid="&request("NClassid")
rs.open sql,conn,1,3
if not rs.EOF then
if rs("IsGood")=true then
rs("IsGood")=false
else
rs("IsGood")=true
end if
rs.update
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
end function
%>
