<!-- #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)

dim askclassid,asksclassid,asknclassid,wma,musicname,classid,sclassid,nclassid,specialid,founerr,founderr
dim classic,conclassic,num,nclass,nrs,url1,nsql,act,singer,play,url,urlid

select case action
case "music_addone"
  call music_addone()
case "music_good"
  call music_good()
case "music_good1"
  call music_good1()
case "music_edit"
  call music_edit()
case "music_del"
  call music_del()
case "word_add"
  call word_add()
case else
  call music_add()
end select

sub music_addone()
page=trim(request.querystring("page"))
askclassid=trim(request.querystring("askclassid"))
asksclassid=trim(request.querystring("asksclassid"))
asknclassid=trim(request.querystring("asknclassid"))
url=trim(request.form("url"))
urlid=trim(request.form("urlid"))
wma=trim(request.form("wma"))
musicname=trim(request.form("musicname"))
classid=trim(request.form("classid"))
sclassid=trim(request.form("sclassid"))
nclassid=trim(request.form("nclassid"))
specialid=trim(request.form("specialid"))
play=request.form("play")

founerr=false
act=request("act")
	if musicname="" then
		response.write vbcrlf&"<scRIPT language=Javascript>alert('歌曲名称不能为空');</scRIPT>"
		founderr=true
	end if
		if trim(Request.Form("wma"))="" then
			wma=""
		else
			wma=request.form("wma")
		end if

if founderr=true then
	call error()
else
	set rs=server.createobject("adodb.recordset")
	if act<>"" then
		sql="select nclass from mv_nclass where nclassid="&nclassid
		rs.open sql,conn_mv,1,1
		singer=rs("nclass")
		rs.close
	end if
	if act="edit" and request("id")<>"" then
		sql="select * from mv_musiclist where id="&request("id")
		rs.open sql,conn_mv,1,3
                rs("url")=url
                rs("urlid")=urlid
		rs("wma")=trim(wma)
		rs("musicname")=musicname
		rs("classid")=classid
		rs("sclassid")=sclassid
		rs("nclassid")=nclassid
		rs("specialid")=specialid
		rs("singer")=trim(singer)
		rs("play")=play
		rs.update
		rs.close

		call Success
		Response.End 
	elseif act="add" then
		sql="select * from mv_musiclist where (id is null)" 
		rs.open sql,conn_mv,1,3
		rs.addnew
                rs("url")=url
                rs("urlid")=urlid
		rs("wma")=wma
		rs("musicname")=musicname
		rs("classid")=classid
		rs("sclassid")=sclassid
		rs("nclassid")=nclassid
		if specialid<>"" then rs("specialid")=specialid
		rs("singer")=singer
		rs("play")=play
		rs.update
		rs.close
		call Success
		Response.End 
		call error()
		Response.End
	end if
	set rs=nothing
	conn_mv.close
	set conn_mv=nothing
	Response.Redirect "admin_music_list.asp?classid="+askclassid+"&sclassid="+asksclassid+"&nclassid="+asknclassid+"&Page="+Page
end if
end sub

sub music_add()
set rs=server.createobject("adodb.recordset")
sql="select * from mv_musiclist"
rs.open sql,conn_mv,1,3
num=100
for i=1 to num
	classic=request.form("classic"&i)
	conclassic=split(classic,",")
	musicname=trim(request.form("musicname"&i))
	wma=trim(request.form("wma"&i))
        url=request.form("url")
        urlid=request.form("urlid")
	url1=request.form("url1")
	play=request.form("play")

	if musicname="" or isnull(musicname) or wma="" or isnull(wma) then
		num=i-1
		exit for
	end if
	
	set nrs=server.createobject("adodb.recordset")
	Nsql="select nclass from mv_nclass where nclassid="&conclassic(2)
	nrs.open Nsql,conn_mv,1,1
	if not nrs.eof then
		nclass=nrs("nclass")
	end if
	nrs.close

	rs.addnew
	rs("musicname")=musicname
	rs("Singer")=nclass
	rs("classid")=conclassic(0)
	rs("sclassid")=conclassic(1)
	rs("nclassid")=conclassic(2)
	rs("specialid")=conclassic(3)
        rs("url")=url
        rs("urlid")=urlid
	rs("wma")=url1&wma
	rs("play")=play
	rs.update
next
rs.close
call Success
end sub

sub Success
response.write vbcrlf&"<scRIPT language=Javascript>alert('操作成功！');javascript:history.go(-2);</scRIPT>"
end sub

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

sub music_good()
page=trim(request.querystring("page"))
askclassid=trim(request.querystring("askclassid"))
asksclassid=trim(request.querystring("asksclassid"))
asknclassid=trim(request.querystring("asknclassid"))
url=trim(request.form("url"))
urlid=trim(request.form("urlid"))
wma=trim(request.form("wma"))
musicname=trim(request.form("musicname"))
classid=trim(request.form("classid"))
sclassid=trim(request.form("sclassid"))
nclassid=trim(request.form("nclassid"))
specialid=trim(request.form("specialid"))
set rs=server.createobject("adodb.recordset")
founerr=false
if act<>"SetisGood" then
act=request("act")
end if

if act="SetisGood" then
		sql="select IsGood from mv_musiclist where id="&request("id") 
		rs.open sql,conn_mv,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
	else
		conn_mv.close
		set conn_mv=nothing
		call error()
		Response.End
	end if
	set rs=nothing
	conn_mv.close
	set conn_mv=nothing
response.write vbcrlf&"<scRIPT language=Javascript>alert('成功推荐一首歌曲！');javascript:history.go(-1);</scRIPT>"
end sub

sub music_good1()
page=trim(request.querystring("page"))
askclassid=trim(request.querystring("askclassid"))
asksclassid=trim(request.querystring("asksclassid"))
asknclassid=trim(request.querystring("asknclassid"))
url=trim(request.form("url"))
urlid=trim(request.form("urlid"))
wma=trim(request.form("wma"))
musicname=trim(request.form("musicname"))
classid=trim(request.form("classid"))
sclassid=trim(request.form("sclassid"))
nclassid=trim(request.form("nclassid"))
specialid=trim(request.form("specialid"))
set rs=server.createobject("adodb.recordset")
founerr=false
if act<>"Sethidden" then
act=request("act")
end if

if act="Sethidden" then
		sql="select hidden from mv_musiclist where id="&request("id") 
		rs.open sql,conn_mv,1,3
		if not rs.EOF then
			if rs("hidden")=true then
				rs("hidden")=false
			else
				rs("hidden")=true
			end if
			rs.update
		end if
		rs.close
	else
		conn_mv.close
		set conn_mv=nothing
		call error()
		Response.End
	end if
	set rs=nothing
	conn_mv.close
	set conn_mv=nothing
response.write vbcrlf&"<scRIPT language=Javascript>alert('成功显示一首歌词！');javascript:history.go(-1);</scRIPT>"
end sub


sub music_edit()
id=request.QueryString("id")
askclassid=request.QueryString("askclassid")
asksclassid=request.QueryString("asksclassid")
asknclassid=request.QueryString("asknclassid")
page=request.QueryString("page")
set rs=server.createobject("adodb.recordset")
sql="select * from mv_musiclist where id="&id
rs.open sql,conn_mv,1,1
if rs.eof then
	call error()
	Response.End 
else 
        url=rs("url")
        urlid=rs("urlid")
	wma=rs("wma")
	musicname=rs("musicname")
	classid=rs("classid")
	sclassid=rs("sclassid")
	nclassid=rs("nclassid")
	specialid=rs("specialid")
	singer=rs("singer")
	play=rs("play")
end if
rs.close
%>
<table class=table cellspacing=1 cellPadding=1>
<form method="POST" action="?action=music_addone&act=edit&id=<%=id%>&askclassid=<%=askclassid%>&asksclassid=<%=asksclassid%>&asknclassid=<%=asknclassid%>&page=<%=page%>">
<tr><td width="100%" height="20" colspan=2 align=center><b>修 改 歌 曲</b></td></tr>
<tr><td colspan=2>&nbsp;&nbsp;分类：
<select class=input  class="smallSel" name="classid" size="1" onchange="window.open('?action=music_edit&id=<%=request("id")%>&askclassid=<%=askclassid%>&asksclassid=<%=asksclassid%>&asknclassid=<%=asknclassid%>&page=<%=page%>&classid='+this.options[this.selectedIndex].value,'_self')">
<%
set rs=server.createobject("adodb.recordset")
sql="select * from mv_class"
rs.open sql,conn_mv,1,1
do while not rs.eof
%>
<option<%if (cstr(request("classid"))=cstr(rs("classid")) and request("classid")<>"") or (cstr(classid)=cstr(rs("classid")) and request("classid")="") then%> selected<%end if%> value="<%=CStr(rs("classid"))%>" name=classid><%=rs("class")%></option>
<%
rs.movenext
loop
rs.close
%>
</select>&nbsp;&nbsp;
<%
if request("classid")<>"" or request("sclassid")<>"" then
if request("classid")<>"" then
%>
<select class=input  name="sclassid" size="1" onchange="window.open('?action=music_edit&id=<%=request("id")%>&askclassid=<%=askclassid%>&asksclassid=<%=asksclassid%>&asknclassid=<%=asknclassid%>&page=<%=page%>&classid=<%=request("classid")%>&sclassid='+this.options[this.selectedIndex].value,'_self')">
<%else%>
<select class=input  name="sclassid" size="1" onchange="window.open('?action=music_edit&id=<%=request("id")%>&askclassid=<%=askclassid%>&asksclassid=<%=asksclassid%>&asknclassid=<%=asknclassid%>&page=<%=page%>&classid=<%=classid%>&sclassid='+this.options[this.selectedIndex].value,'_self')">
<%end if%>
<option value="" <%if request("nclassid")="" then%> selected<%end if%>>选择栏目</option>
<%
if request("classid")<>"" then
sql="select * from mv_sclass where classid="&request("classid")
else
sql="select * from mv_sclass where classid="&classid
end if
rs.open sql,conn_mv,1,1
Do while not rs.eof
%>
<option<%if (cstr(request("sclassid"))=cstr(rs("sclassid")) and request("sclassid")<>"") then%> selected<%end if%> value="<%=CStr(rs("sclassid"))%>" name=sclassid><%=rs("sclass")%></option>
<%
rs.MoveNext
Loop
rs.close
else
%>
<select class=input  name="sclassid" size="1" onchange="window.open('?action=music_edit&id=<%=request("id")%>&askclassid=<%=askclassid%>&asksclassid=<%=asksclassid%>&asknclassid=<%=asknclassid%>&page=<%=page%>&classid=<%=request("classid")%>&sclassid='+this.options[this.selectedIndex].value,'_self')">
<option value="">选择栏目</option>
<%
sql="select * from mv_sclass where classid="&classid
rs.open sql,conn_mv,1,1
Do while not rs.eof
%>
<option<%if cstr(sclassid)=cstr(rs("sclassid")) then%> selected<%end if%> value="<%=CStr(rs("sclassid"))%>" name=sclassid><%=rs("sclass")%></option>
<%
rs.MoveNext
Loop
rs.close
end if
%>
</select>&nbsp;&nbsp;  
<%
if request("sclassid")<>"" or request("nclassid")<>"" then
if request("sclassid")<>"" then
%>
<select class=input  name="nclassid" size="1" onchange="window.open('?action=music_edit&id=<%=request("id")%>&askclassid=<%=askclassid%>&asksclassid=<%=asksclassid%>&asknclassid=<%=asknclassid%>&page=<%=page%>&classid=<%=request("classid")%>&sclassid=<%=request("sclassid")%>&nclassid='+this.options[this.selectedIndex].value,'_self')">
<%else%>
<select class=input  name="nclassid" size="1" onchange="window.open('?action=music_edit&id=<%=request("id")%>&askclassid=<%=askclassid%>&asksclassid=<%=asksclassid%>&asknclassid=<%=asknclassid%>&page=<%=page%>&classid=<%=classid%>&sclassid=<%=sclassid%>&nclassid='+this.options[this.selectedIndex].value,'_self')">
<%end if%>
<option value="" <%if request("nclassid")="" then%> selected<%end if%>>选择子栏目</option>
<%
if request("sclassid")<>"" then
sql="select * from mv_nclass where sclassid="&request("sclassid")
else
sql="select * from mv_nclass where sclassid="&sclassid
end if
rs.open sql,conn_mv,1,1
Do while not rs.eof
%>
<option<%if (cstr(request("nclassid"))=cstr(rs("nclassid")) and request("nclassid")<>"") then%> selected<%end if%> value="<%=CStr(rs("nclassid"))%>" name=nclassid><%=rs("nclass")%></option>
<%
rs.MoveNext
Loop
rs.close
else
%>
<select class=input  name="nclassid" size="1" onchange="window.open('?action=music_edit&id=<%=request("id")%>&askclassid=<%=askclassid%>&asksclassid=<%=asksclassid%>&asknclassid=<%=asknclassid%>&page=<%=page%>&classid=<%=request("classid")%>&sclassid=<%=request("sclassid")%>&nclassid='+this.options[this.selectedIndex].value,'_self')">
<option value="">选择子栏目</option>
<%
sql="select * from mv_nclass where sclassid="&sclassid
rs.open sql,conn_mv,1,1
Do while not rs.eof
%>
<option<%if cstr(nclassid)=cstr(rs("nclassid")) then%> selected<%end if%> value="<%=CStr(rs("nclassid"))%>" name=nclassid><%=rs("nclass")%></option>
<%
rs.MoveNext
Loop
rs.close
end if
%>
</select>
</td></tr>
<tr><td align=right>专辑：</td><td>
<%
if request("classid")<>"" or request("nclassid")<>"" or request("specialid")<>"" then
if request("classid")<>"" then
%>
<select class=input  name="specialid" size="1" onchange="window.open('?action=music_edit&id=<%=request("id")%>&askclassid=<%=askclassid%>&asksclassid=<%=asksclassid%>&asknclassid=<%=asknclassid%>&page=<%=page%>&classid=<%=request("classid")%>&sclassid=<%=request("sclassid")%>&nclassid=<%=request("nclassid")%>&specialid='+this.options[this.selectedIndex].value,'_self')">
<%elseif request("nclassid")<>"" then%>
<select class=input  name="specialid" size="1" onchange="window.open('?action=music_edit&id=<%=request("id")%>&askclassid=<%=askclassid%>&asksclassid=<%=asksclassid%>&asknclassid=<%=asknclassid%>&page=<%=page%>&classid=<%=classid%>&sclassid=<%=request("sclassid")%>&nclassid=<%=request("nclassid")%>&specialid='+this.options[this.selectedIndex].value,'_self')">
<%else%>
<select class=input  name="specialid" size="1" onchange="window.open('?action=music_edit&id=<%=request("id")%>&askclassid=<%=askclassid%>&asksclassid=<%=asksclassid%>&asknclassid=<%=asknclassid%>&page=<%=page%>&classid=<%=classid%>&sclassid=<%=request("sclassid")%>&nclassid=<%=nclassid%>&specialid='+this.options[this.selectedIndex].value,'_self')">
<%end if%>
<option value="" <%if request("specialid")="" then%> selected<%end if%>>选择专辑</option>
<%
if request("nclassid")<>"" then
sql="select * from mv_special where nclassid="&request("nclassid")
else
sql="select * from mv_special where nclassid="&nclassid
end if
rs.open sql,conn_mv,1,1
Do while not rs.eof
%>
<option<%if cstr(request("specialid"))=CStr(rs("specialid")) then%> selected<%end if%> value="<%=CStr(rs("specialid"))%>" name=specialid><%=rs("name")%></option>
<%
rs.MoveNext
Loop
rs.close
else
%>
<select class=input  name="specialid" size="1" onchange="window.open('?action=music_edit&id=<%=request("id")%>&askclassid=<%=askclassid%>&asksclassid=<%=asksclassid%>&asknclassid=<%=asknclassid%>&page=<%=page%>&classid=<%=request("classid")%>&sclassid=<%=request("sclassid")%>&nclassid=<%=request("nclassid")%>&specialid='+this.options[this.selectedIndex].value,'_self')">
<option value="">选择专辑</option>
<%
sql="select * from mv_special where nclassid="&nclassid
rs.open sql,conn_mv,1,1
Do while not rs.eof
%>
<option<%if cstr(specialid)=cstr(rs("specialid")) then%> selected<%end if%> value="<%=CStr(rs("specialid"))%>" name=specialid><%=rs("name")%></option>
<%
rs.MoveNext
Loop
rs.close
end if
%>
</select>
</td></tr>
<tr><td align="right">歌曲名：</td><td><input class=input type="text" name="musicname" size="15" class="smallinput" maxlength="100" value="<%=musicname%>"></td></tr>
<tr>
<td align="right">歌曲格式：</td>
<td><input class=input type="text" name="play" size="15" class="smallinput" maxlength="10" value="<%=play%>"><font color=gray>* 数字0代表wma格式 数字1代表rm格式 数字2代表mp3格式</font></td></tr>
<tr><td width="15%" align="right">歌曲URL：</td><td width="85%"><input class=input  type="text" name="url" value="<%=url%>" size="25"></td></tr>
<tr><td width="15%" align="right">歌曲端口：</td><td width="85%"><input class=input  type="text" name="urlid" value="<%=urlid%>" size="25"></td></tr>
<tr><td width="15%" align="right">歌曲地址：</td><td width="85%"><input class=input  type="text" name="wma" value="<%=wma%>" size="50"></td></tr>
<tr><td colspan=2 align=center height="30"><input  class=input type="hidden" value="edit" name="act">
<%
if request("classid")<>"" then
if request("sclassid")="" then
%>
<input class=input  type="button" value=" 确 定 " name="cmdok" onclick="window.alert('请先选择二级栏目！')">&nbsp; 
<%elseif request("nclassid")="" then%>
<input class=input  type="button" value=" 确 定 " name="cmdok" onclick="window.alert('请先选择三级栏目！')">&nbsp; 
<%elseif request("specialid")="" then%>
<input class=input  type="button" value=" 确 定 " name="cmdok" onclick="window.alert('请先选择专辑！')">&nbsp; 
<%else%>
<input class=input  type="submit" value=" 确 定 " name="cmdok">&nbsp; 
<%
end if
else
%>
<input class=input  type="submit" value=" 确 定 " name="cmdok">&nbsp; 
<%end if%>
<input class=input  type="reset" value=" 清 除 "  name="cmdcancel">
</td></tr></form></table>
<%
end sub

sub music_del()
set rs=server.createobject("adodb.recordset")
conn_mv.execute("delete from mv_musiclist where id="&request.QueryString("id"))
conn_mv.close
set conn_mv=nothing
response.write vbcrlf&"<scRIPT language=Javascript>alert('成功删除一首歌曲！');javascript:history.go(-1);</scRIPT>"
end sub


%>