<!-- #include file="include/admin_onlogin.asp" -->
<!-- #INCLUDE file="admins_config_music.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 href='admin_music_class.asp'>音乐管理首页</a></td>
<td width=10></td>
<td><a href='admin_music_class.asp?action=addclass'>添加一级分类</a></td>
<td width=10></td>
<td><a href='admin_music_disk.asp'>专辑管理</a></td>
<td width=10></td>
<td><a href='admin_music_song.asp'>歌曲管理</a>
</tr>
</table>
</td></tr>
<tr><td colspan=2 align=center>
  <table border=0 cellspacing=0 cellpadding=2>
  <form action='?action=sea' method=post>
  <tr>
  <td>搜索（歌手列表）关键字：</td>
  <td><input type=text name=keyword value='<%response.write keyword%>' size=15 maxlength=20></td>
  <td><input type=submit value='搜索'></td>
  </tr>
  </form>
  </table>
</td></tr>
<script language=javascript>
<!--
function del_sort(t1,t2,t3)
{
  if (t3=="yes")
  {
    var cf=window.confirm("您确定要删除主音乐分类（"+t2+"）吗？\n其下的各级音乐分类也将一并删除！\n\n删除后将不可恢复！是否确定该操作？");
    if (cf)
    { return true; }
    else
    { return false; }
  }
  else if (t3=="no")
  {
    var cf1=window.confirm("您确定要删除二级音乐分类（"+t2+"）吗？\n其下的各级音乐分类也将一并删除！\n\n删除后将不可恢复！是否确定该操作？");
    if (cf1)
    { return true; }
    else
    { return false; }
  }
  else
  {
    var cf1=window.confirm("您确定要删除此歌手（"+t2+"）吗？\n其下的各级音乐数据也将一并删除！\n\n删除后将不可恢复！是否确定该操作？");
    if (cf1)
    { return true; }
    else
    { return false; }
  }
  return false;
}
-->
</script>
<%
call admin_table(1,0)
select case action
  case "addclass"
    call sort_add_class()
  case "editclass"
    call sort_edit_class()
  case "delclass"
    call sort_del_class()
  case "addsclass"
    call sort_add_sclass()
  case "editsclass"
    call sort_edit_sclass()
  case "delsclass"
    call sort_del_sclass()
  case "addnclass"
    call sort_add_nclass()
  case "editnclass"
    call sort_edit_nclass()
  case "delnclass"
    call sort_del_nclass()
  case "sea"
    response.write singer_list("sea")&"<tr class=tr1><td>现有<font class=red>"&rssum&"</font>位歌手，页次：<font class=red>"&viewpage&"</font>/<font class=red>"&thepages&"</font>分页："&jk_pagecute(nummer,thepages,viewpage,pageurl,5,"#ff0000")&"</td><td colspan=2 align=center>执行<select name=sel_type size=1><option value='审核'>审核</option><option value='待审核'>待审核</option><option value='删除'>删除</option></select><input type=submit value='操作' onclick=""return sel_click(this.form);""></td></tr></form></table></td></tr>"
  case else
    call music_sort()
    %><td height=25 colspan=4><a class=read alt='<table border=0 cellspacing=0 cellpadding=0 width=400><tr><td height=25><font class=read><b>系统更新通知</b></font>：</td></tr><tr><td class=htd>有关您正在使用的这个系统官方站点所发布的更新信息，包括安全补丁，功能升级等；建议在每次登陆管理后台时注意一下。</td></tr></table>'>相关说明</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<script language="javascript" src="http://cja831.yi.org/update/mvhome_cms.js"></script></td>
</tr><%
end select
call admin_ender(1)
'-----------------------------------歌手列表
function singer_list(ltype)
  dim temp1
  sql_add=""
  PageUrl="?classid="&classid&"&sclassid="&sclassid&"&"
  temp1="<tr><td class=td align=center width='60%'>歌手名称</td><td class=td align=center>添加歌曲/专辑</td><td class=td align=center>相关操作</td></tr>"
  if ltype="sea" then
    sql_add=" where nclass Like '%"& keyword &"%'"
  else
    sql_add=" where classid="&classid&" and sclassid="&sclassid
  end if
  sql="select count(nclassid) from mv_nclass"&sql_add
  set rs=joekoe_cms.exec(sql,1)
  rssum=rs(0)
  rs.close
  call format_pagecute()
  sql="select top "&nummer*viewpage&" * from mv_nclass"&sql_add&" order by nclassid desc"
  call joekoe_cms.exec(sql,-1)
  rs.open sql,conn,1,1
  if int(viewpage)>1 then rs.move (viewpage-1)*nummer
  if int(viewpage*nummer)>int(rssum) then nums=nummer-(viewpage*nummer-rssum)
    for i=1 to nums
    temp1=temp1&"<tr height=24 class=tr3><td><table width='100%'><tr height=24 class=tr3><td width='*'>&nbsp;&nbsp;"&rs("nclass")&"&nbsp;</td><td align=right width=120><a href='admin_music_song.asp?classid="&rs("classid")&"&sclassid="&rs("sclassid")&"&nclassid="&rs("nclassid")&"'><font class=gray>歌曲列表</font></a><font class=gray>┋</font><a href='admin_music_disk.asp?classid="&rs("classid")&"&sclassid="&rs("sclassid")&"&nclassid="&rs("nclassid")&"'><font class=gray>专辑列表</font></a></td></tr></table></td><td align=center><a href='admin_music_disk.asp?action=add&classid="&rs("classid")&"&sclassid="&rs("sclassid")&"&nclassid="&rs("nclassid")&"'>添加专辑</a></td><td align=center><a href='?action=editnclass&classid="&rs("classid")&"&sclassid="&rs("sclassid")&"&nclassid="&rs("nclassid")&"'>编辑</a>&nbsp;&nbsp;<a href='?action=delnclass&classid="&rs("classid")&"&sclassid="&rs("sclassid")&"&nclassid="&rs("nclassid")&"' onclick=""return del_sort("&rs("nclassid")&",'"&rs("nclass")&"','nno');"">删除</a></td></tr>"
      rs.movenext
    next
    rs.close
    set rs=nothing
    temp1=temp1&""
    singer_list=temp1
end function
'-----------------------------------分类列表
sub music_sort()
  dim temp1,imgtpic,rs2,sql2
  temp1="<tr height=24><td class=td colspan=2>分类名称</td><td class=td align=center>添加分类</td><td class=td align=center>相关操作</td></tr>"
  sql3="select * from mv_class order by classid"
  set rs3=joekoe_cms.exec(sql3,1)
  if rs3.eof then
    temp1=temp1&"<tr><td>尚无任何分类</td></tr>"
  else
    do while not rs3.eof
      temp1=temp1&"<tr height=24 class=tr3><td width='1%' bgcolor='#ff3300'></td><td width='40%'>&nbsp;"&img_admin("s_left_sort","")&"&nbsp;<a href='?classid="&rs3("classid")&"'><b><font class=red title='点击展开二级分类'>"&rs3("class")&"</font></b></a></td><td align=center width='20%'><a href='?action=addsclass&classid="&rs3("classid")&"' >添加二级分类</a></td><td align=center width='20%'><a href='?action=editclass&classid="&rs3("classid")&"'>编辑</a>&nbsp;&nbsp;<a href='?action=delclass&classid="&rs3("classid")&"' title='删除此一级栏目' onclick=""return del_sort("&rs3("classid")&",'"&rs3("class")&"','yes');"">删除</a></td></tr>"
      if int(classid)=rs3("classid") then
        sql2="select * from mv_sclass where classid="&rs3("classid")&" order by sclassid"
        set rs2=joekoe_cms.exec(sql2,1)
        do while not rs2.eof
          temp1=temp1&"<tr height=20 class=tr><td width='1%' bgcolor='#0066cc'><td width='40%' >&nbsp;"&img_admin("s_left","")&"&nbsp;<a href='?classid="&rs2("classid")&"&sclassid="&rs2("sclassid")&"'><font class=blue title='点击展开歌手分类'>"&rs2("sclass")&"</font></a></td><td align=center width='20%'><a href='?action=addnclass&classid="&rs2("classid")&"&sclassid="&rs2("sclassid")&"'>添加歌手</a></td><td align=center width='20%'><a href='?action=editsclass&classid="&rs2("classid")&"&sclassid="&rs2("sclassid")&"'>编辑</a>&nbsp;&nbsp;<a href='?action=delsclass&classid="&rs2("classid")&"&sclassid="&rs2("sclassid")&"' onclick=""return del_sort("&rs2("sclassid")&",'"&rs2("sclass")&"','no');"">删除</a></td></tr>"
      if int(sclassid)=rs2("sclassid") then temp1=temp1&"<tr class=tr2><td width='1%' bgcolor='#0066cc'><td colspan=3><table  cellspacing=1 cellpadding=4 class=table align=right>"&singer_list("")&"<tr class=tr1 height=30><td colspan=3>现有<font class=red>"&rssum&"</font>位歌手，页次：<font class=red>"&viewpage&"</font>/<font class=red>"&thepages&"</font>分页："&jk_pagecute(nummer,thepages,viewpage,pageurl,10,"#ff0000")&"</td></table></td></tr>"
        rs2.movenext
        loop
	rs2.close
      end if
    rs3.movenext
    loop
  end if
  temp1=temp1&"</form>"
  rs3.close
  response.write temp1
end sub
'---------------------------------------修改一级分类
sub sort_edit_class()
  dim temp1
  if chk() then
    if classname=""  then
      call admin_error("一级分类名称不能为空！")
      response.write "</table>"
      exit sub
    else
      sql = "SELECT * FROM mv_class where classid="&classid
       call joekoe_cms.exec(sql,-1)
      rs.open sql,conn,1,3
      rs("class") = classname
      rs.Update
      rs.Close
    end if
    call admin_msg("已成功编辑了一条"&tit_fir&"！","?",0)
  else
    call form_first()
    sql="select * from mv_Class where classid="&classid&" order by classid"
    set rs=joekoe_cms.exec(sql,1)
    temp1=temp1&"<form method='POST' action='?action=editclass&classid="&classid&"' name=edit_frm><input type=hidden name=chk value='yes'><tr><td>&nbsp;&nbsp;分类名称：</td><td><input size=30 type='text' name='class' value='"&rs("class")&"'></td></tr>"
    rs.close
    Response.write temp1
    call submit_edit()
  end if
end sub
'---------------------------------------删除一级分类
sub sort_del_class()
  call joekoe_cms.exec("delete from mv_class where classid="&classid,0)
  call joekoe_cms.exec("delete from mv_sclass where classid="&classid,0)
  call joekoe_cms.exec("delete from mv_nclass where classid="&classid,0)
  call joekoe_cms.exec("delete from mv_Musiclist where classid="&classid,0)
  call joekoe_cms.exec("delete from mv_Special where classid="&classid,0)
  call admin_msg("已成功删除了一条"&tit_fir&"！","?",0)
end sub
'---------------------------------------添加一级分类
sub sort_add_class()
  if chk() then
    if classname="" then
      call admin_error("一级分类名称不能为空！")
      response.write "</table>"
      exit sub
    else
      sql = "SELECT * FROM mv_class where (classid IS NULL)"
      call joekoe_cms.exec(sql,-1)
      rs.open sql,conn,1,3
      rs.AddNew
      rs("class") = classname
      rs.Update
      rs.Close
      call admin_msg("已成功编辑了一条"&tit_fir&"！","?",0)
    end if
  else
  call form_first()
%>
<form method='POST' name=add_frm action='?action=addclass'><input type=hidden name=chk value='yes'><tr><td colspan=2 height=24 class=td>添加一级分类</td></tr><tr><td height=24>分类名称：</td><td><input type='text' name='class' size=20></td></tr>
<%
  call submit_add()
  end if
end sub
'---------------------------------------修改二极分类
sub sort_edit_sclass()
  dim temp1
  if chk() then
    if sclassname=""  then
      call admin_error("二级分类名称不能为空！")
      response.write "</table>"
      exit sub
    else
      sql = "SELECT * FROM mv_sclass where sclassid="&sclassid
      call joekoe_cms.exec(sql,-1)
      rs.open sql,conn,1,3
      rs("sclass") = sclassname
      rs.Update
      rs.Close
    end if
    call admin_msg("已成功编辑了一条"&tit_fir&"！","?classid="&classid,0)
  else
    call form_first()
    sql="select * from mv_sclass where sclassid="&sclassid
    set rs=joekoe_cms.exec(sql,1)
    temp1="<tr><td class=td colspan=2>编辑"&rs("sclass")&"</td></tr><form method='POST' action='?action=editsclass&classid="&classid&"&sclassid="&sclassid&"' name=edit_frm><input type=hidden name=chk value='yes'><tr><td align=right>二级分类名称：</td><td><input size=10 type='text' name='sclass' value='"&rs("sclass")&"'></td></tr>"
    rs.close
    Response.write temp1
    call submit_edit()
  end if
end sub
'---------------------------------------添加二级分类
sub sort_add_sclass()
  dim tmp1,temp1
  if chk() then
    if SClassname="" then
      call admin_error("二级分类名称不能为空！")
      response.write "</table>"
      exit sub 
    end if
    sql = "SELECT * FROM mv_Sclass where (sclassid IS NULL)"
    call joekoe_cms.exec(sql,-1)
    rs.open sql,conn,1,3
    rs.AddNew
    rs("sclass") = SClassname
    rs("classid") = classid
    rs.Update
    rs.Close
     call admin_msg("已成功添加了一条"&tit_fir&"！","?classid="&classid,0)
  else
    call form_first()
    sql="select * from mv_Class where classid="&classid&" order by classid"
    set rs=joekoe_cms.exec(sql,1)
    tmp1=rs("class")
    rs.close
    temp1="<form method='POST' action='?action=addsclass&classid="&classid&"' name=add_frm><input type=hidden name=chk value='yes'><tr><td colspan=4 height=24 class=td>添加二级分类</td></tr><tr height=22><td  align=right>一级分类名称：</td><td>"&tmp1&"</td></tr><tr height=22><td align=right>二级分类名称：</td><td><input type='text' name='SClass' size='20'></td></tr>"
  Response.write temp1
  call submit_add()
end if
end sub
'---------------------------------------删除二级分类
sub sort_del_sclass()
  call joekoe_cms.exec("delete from mv_sclass where sclassid=" & sclassid,0)
  call joekoe_cms.exec("delete from mv_nclass where sclassid=" & sclassid,0)
  call joekoe_cms.exec("delete from mv_musiclist where sclassid=" & sclassid,0)
  call joekoe_cms.exec("delete from mv_Special where sclassid=" & sclassid,0)
  Response.Redirect "?classid="&classid
end sub
'---------------------------------------修改三级分类
sub sort_edit_nclass()
  if chk() then
  Classic=request.form("Classic")
  if Classic<>"" and not isnull(Classic) then
    ConClassic=split(Classic,",")
    classid=ConClassic(0)
    sclassid=ConClassic(1)
  end if
  if nclassname="" then
    call admin_error("歌手名称不能为空！")
    response.write "</table>"
    exit sub
  end if
  sql = "SELECT * FROM mv_nclass where nclassid="&nclassid
  call joekoe_cms.exec(sql,-1)
  rs.Open sql,conn, 1, 3
'修改栏目中的资料
  rs("nclass") = nclassname
  rs("classid") = classid
  rs("sclassid") = sclassid
  rs("abcd") = request("character")
  rs("ea") = trim(request("ea"))
  if trim(request("ew"))<>"" then
    rs("ew")=trim(request("ew"))
    call consview()
  else
    rs("ew")="1981/05/21"
  end if
  rs("pic") = trim(request("Pic"))
  rs("ef") = trim(request("ef"))
  rs("da") = request("da")
  rs.Update
  rs.Close
'修改歌曲列表中的资料
  sql= "SELECT * FROM mv_Musiclist where nclassid="&nclassid
  call joekoe_cms.exec(sql,-1)
  rs.Open sql,conn, 1, 3
  if not rs.eof then
    do while not rs.eof
      rs("Singer")=nclassname
      rs("classid")=classid
      rs("sclassid")=sclassid
      rs.update
    rs.movenext
    loop
  end if
  rs.close
'修改专辑列表中的资料
  sql = "SELECT * FROM mv_special where nclassid="&nclassid
  call joekoe_cms.exec(sql,-1)
  rs.Open sql,conn, 1, 3
  if not rs.eof then
    do while not rs.eof
      rs("nclass")=nclassname
      rs("classid")=classid
      rs("sclassid")=sclassid
      sql2 = "SELECT * FROM mv_Musiclist where sclassid="&sclassid
      set rs2=joekoe_cms.exec(sql2,1)
      rs("nclass")=rs2("singer")
      rs2.close
      rs.update
    rs.movenext
    loop
  end if
  rs.close
  call admin_msg("已成功修改了一条"&tit_fir&"！","?classid="&classid&"&sclassid="&sclassid,0)
else
  call form_first()
  dim ispic,i
  sql="select * from mv_Nclass where nclassid="&nclassid
  set rs=joekoe_cms.exec(sql,1)
  Tc_id=rs("classid")
  Ts_id=rs("sclassid")
  NClassname=rs("nclass")
  Sex=rs("ea")
  birthday=rs("ew")
  Photo=rs("pic")
  da=rs("da")
  comp=rs("ef")
  character=rs("abcd")
  rs.close
  sql="select * from mv_class"
  set rs=joekoe_cms.exec(sql,1)
  i=0
  do while not rs.eof
    classname=rs("class")
    classid=rs("classid")
    SClassSql="select * from mv_sclass where classid="&classid
    set SClassrs=joekoe_cms.exec(SClasssql,1)
    Do while not SClassRs.eof
      sclassname=SClassRs("sclass")
      sclassid=SClassRs("sclassid")
      if Tc_id&","&Ts_id=classid&","&sclassid then
        k=" selected"
      else
        k=""
      end if
      remember=remember&"<option name='option"&classid&i&"'"&k&" value="&classid&","&sclassid&">"&ClassName&"-"&SClassname&"</option>"
    SClassRs.movenext
    loop
    SClassRs.close
  rs.movenext
  loop
  rs.close
  call admin_td("修改&nbsp;"&NClassname&"&nbsp;的资料")
%>
<form method=POST action='?action=editnclass&classid=<%=classid%>&sclassid=<%=sclassid%>&nclassid=<%=nclassid%>' name=edit_frm><input type=hidden name=chk value='yes'><tr><td width='100%' height='20' colspan=2 align=center>修改歌手资料</td></tr><tr><td width='15%' align=right>栏目：</td><td width='85%'><select name=Classic size=1><%=remember%></select></td></tr><tr><td align=right>字母索引：</td><td><select size=1 name=character>
<%
for i=65 to 90 Step 1
%>
<option value='<%=chr(i)%>'<%if character=chr(i) then%> selected<%end if%>><%=chr(i)%></option>
<%Next%>
</select></td></tr>
<tr><td align=right>歌手名：</td>
<td><input type=text name=NClass value='<%=NClassname%>' size=20></td></tr>
<tr><td align=right>性别：</td>
<td><select size=1 name=Sex><option value='男'<%if Sex="男" then%> selected<%end if%>>男</option><option value='女'<%if Sex="女" then%> selected<%end if%>>女</option><option value='组合'<%if Sex="组合" then%> selected<%end if%>>组合</option></select></td></tr>
<tr><td align=right>生日：</td><td><input type=text name=birthday value='<%=birthday%>' size=10>（格式：2000/01/01）</td></tr>
<tr><td align=right>唱片公司：</td><td width=442><input type=text name=comp value='<%=comp%>' size="20"></td></tr>
<tr><td align=right>相片地址：</td>
<td><input type=text name=pic value='<%=Photo%>' size=50></td></tr><tr><td align=right>上传相片：</td><td width=442><iframe frameborder=0 name=upload_frame width='100%' height=30 scrolling=no src='upload.asp?uppath=<%response.write index_url%>&upname=<%response.write ispic%>&uptext=pic'></iframe></td></tr>
<tr>
<td><%call frm_ubb_type("class=bg_td")%></td>
<td><%call frm_ubb("edit_frm","da","")%></td>
</tr>
<tr><td align=right valign=top>简介：</td>
<td><textarea name=da rows=5 cols=59><%response.write da%></textarea></td>
<% 
call submit_edit()
end if
end sub
'---------------------------------------添加三级分类
sub sort_add_nclass()
  dim errmsg
  if chk() then
    if nclassname="" then
      call admin_error("歌手名称不能为空！")
      response.write "</table>"
      exit sub
    end if
    sql = "SELECT * FROM mv_Nclass where (nclassid IS NULL)"
    call joekoe_cms.exec(sql,-1)
    rs.open sql,conn,1,3
    rs.AddNew
    rs("nclass") = nclassname
    rs("classid") = classid
    rs("sclassid") = sclassid
    rs("abcd") = request("character")
    rs("ea") = trim(request("Sex"))
    if trim(request("birthday"))<>"" then
    rs("ew") = trim(request("birthday"))
      else
    rs("ew")="1981/05/21"
    end if
    if trim(Request.Form("pic"))="" then
			rs("pic")="nophoto.gif"
		else
			rs("pic")=request.form("pic")		
		end if
    rs("da") = request.form("da")
    if trim(request("comp"))<>"" then
    rs("ef") = request.form("comp")
    else
    rs("ef")="秋月家园"
    end if
    rs.Update
    rs.Close
    call admin_msg("已成功添加了一条"&tit_fir&"！","?classid="&classid&"&sclassid="&sclassid,0)
  else
    call form_first()
    dim founderr,ispic
    sql="select * from mv_sclass where sclassid="&sclassid&" order by sclassid"
    set rs=joekoe_cms.exec(sql,1)
    sclassname=rs("sclass")
    rs.Close
    sql="select class from mv_class where classid="&classid&" order by classid"
    set rs=joekoe_cms.exec(sql,1)
    ClassName=rs("class")
    rs.close
    call admin_td("在&nbsp;"&ClassName&"-"&sClassName&"&nbsp;中添加歌手")
%>
<form method=POST action='?action=addnclass&classid=<%=classid%>&sclassid=<%=sclassid%>' name=add_frm><input type=hidden name=chk value='yes'>
<tr><td align=right width='15%'>字母索引：</td><td width='85%'><select size=1 name=character>
<%
for i=65 to 90 Step 1
%>
<option value='<%=chr(i)%>'<%if character=chr(i) then%> selected<%end if%>><%=chr(i)%></option>
<%Next%>       
</select></td></tr>
<tr>
<td align=right>歌手名：</td>
<td width=442><input type=text name=NClass size=20></td>
</tr>
<tr>
<td align=right>性别：</td>
<td width=442><select size=1 name=Sex><option value='男'>男</option><option value='女'>女</option><option value='组合'>组合</option></select></td>
</tr>
<tr>
<td align=right>生日：</td>
<td width=442><input type=text name=birthday size="10">（格式：2000/01/01）</td></tr>
<tr><td align=right>唱片公司：</td>
<td width=442><input type=text name=comp size="20"></td>
</tr>
<tr><td align=right>相片地址：</td>
<td width=442><input type=text name=pic size=30></td>
</tr>
<tr><td align=right>上传相片：</td>
<td width=442><iframe frameborder=0 name=upload_frame width='100%' height=30 scrolling=no src='upload.asp?uppath=<%response.write index_url%>&upname=<%response.write ispic%>&uptext=pic'></iframe></td>
</tr>
<tr>
<td><%call frm_ubb_type("class=bg_td")%></td>
<td><%call frm_ubb("add_frm","da","")%></td>
</tr>
<tr><td align=right>简介：</td>
<td width=442><TEXTAREA name=da rows=5 cols=59></TEXTAREA></td></tr>
<%
  call submit_add()
  end if
end sub

'---------------------------------------删除三级分类
sub sort_del_nclass()
  call joekoe_cms.exec("delete from mv_nclass where nclassid=" & nclassid,0)
  call joekoe_cms.exec("delete from mv_musiclist where nclassid=" & nclassid,0)
  call joekoe_cms.exec("delete from mv_Special where nclassid=" & nclassid,0)
  call admin_msg("已成功删除了一条"&tit_fir&"！","?classid="&classid&"&sclassid="&sclassid,0)
  end sub
%>
