<!-- #include file="include/admin_onlogin.asp" -->
<!-- #InclUDE file="include/jk_pagecute.asp" -->
<%
keyword=trim(request("keyword")) 
keyword=replace(keyword,"'","''") 
stype=request("stype")
if keyword="" then
response.write("<script language=javascript>" & _
  vbcrlf & "alert(""请输入查询关键字！"")" & _
  vbcrlf & "history.back(1)" & _
  vbcrlf & "</script>")
Response.End
end if

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?action=addnclass'>歌手分类首页</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='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='Music'>音乐</option>
<option value='Special'>专辑</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 stype,currentPage,totalPut,MaxPerPage,classid,sclassid,nclassid,AlertFColor
dim Trs,Tsql,TotalMNum,TotalSNum,tu

Set rs= Server.CreateObject("ADODB.Recordset")
if stype="Singer" then
sql="select * from mv_nclass where nclass Like '%"& keyword &"%' order by Nclassid desc"
elseif stype="Music" then 
sql="select * from mv_musiclist"
elseif stype="Special" then
sql="select * from mv_special where Name Like '%"& keyword &"%' order by Specialid desc"        
else
end if
rs.open sql,conn,1,1

if stype="Music" then        
 rs.filter = "MusicName like '%"&keyword&"%'"        
end if   

if not isempty(request.QueryString("page")) then
currentPage=cint(request.QueryString("page"))
else
currentPage=1
end if
if rs.eof and rs.bof then

if stype="Singer" then
response.write "<table border=0 class=mtb cellspacing=0 cellpadding=0 align=center>"
response.write "<tr><td height=2></td></tr><tr><td colspan=4 height=160 align=center><font size=3>您查找的关键字是：<font class=red>"&keyword&"</font><br><br>没有找到您要的<font class=blue><b>歌手</b></font>，真不好意思！</font></td></tr>"
response.write "</table>"

elseif stype="Music" then
response.write "<table cellspacing=1 cellpadding=1 class=mtable>"
response.write "<form name=singer_listtype_frm action='music_view_pass.asp' method=get target='music_play_win'>"
response.write "<tr align=center height=20>"
response.write "<td width='7%' class=mtd>序号</td>"
response.write "<td width='47%' class=mtd>歌曲名称</td>"
response.write "<td width='18%' class=mtd>歌手</td>"
response.write "<td width='7%' class=mtd>试听</td>"
response.write "<td width='7%' class=mtd>下载</td>"
response.write "<td width='7%' class=mtd>收藏</td>"
response.write "<td width='7%' class=mtd>选择</td>"
response.write "</tr>"
response.write "<tr><td colspan=7 class=mbg_td height=160 align=center><font size=3>您查找的关键字是：<font class=red>"&keyword&"</font><br><br>没有找到您要的<font class=blue><b>音乐</b></font>，真不好意思！</font></td></tr>"
response.write "</tr>"
response.write "<tr><td colspan=7 class=mbg_tds height=30 align=center>"
response.write "<input type=button name=b1 value='全部选择' onClick='javascript:music_check_all(this.form);'>"
response.write "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
response.write "<input type=button name=b2 value='反向选择' onClick='javascript:music_check_other(this.form);'>"
response.write "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
response.write "<input type=button name=b3 value='播放所选' onClick='javascript:music_check_play(this.form,'yes');'>"
response.write "</td></tr>"
response.write "</form>"
response.write "</table>"

elseif stype="Special" then
response.write "<table border=0 class=mtb cellspacing=0 cellpadding=0 align=center>"
response.write "<tr><td height=2></td></tr><tr><td colspan=4 height=160 align=center><font size=3>您查找的关键字是：<font class=red>"&keyword&"</font><br><br>没有找到您要的<font class=blue><b>专辑</b></font>，真不好意思！</font></td></tr>"
response.write "</table>"

end if
else
totalPut=rs.recordcount
MaxPerPage=15
PageUrl="admin_music_search.asp"
if currentpage<1 then currentpage=1
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showContent
showpage totalput,MaxPerPage,PageUrl
search
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,PageUrl
search
else
currentPage=1
showContent
showpage totalput,MaxPerPage,PageUrl
search
end if
end if
rs.close
end if

sub showContent 
i=0 
'-----------------------搜索歌手-----------------------------
if stype="Singer" then
%>
<table class=table cellspacing=1 cellpadding=1>
<tr align=center height=20>
<td width='10%' class=mtd>序号</td>
<td width='50%' class=mtd>歌手</td>
<td width='10%' class=mtd>添加专辑</td>
<td width='10%' class=mtd>收录歌曲</td>
<td width='20%' class=mtd>收录专辑</td>
</tr>
<%
Set Trs= Server.CreateObject("ADODB.Recordset")
do while not rs.eof
i=i+1
Tsql="SELECT * FROM mv_MusicList where Nclassid="+cstr(rs("Nclassid"))
Trs.open Tsql,conn,1,1
TotalMNum=Trs.recordcount
Trs.close
Tsql="SELECT * FROM mv_Special where Nclassid="+cstr(rs("Nclassid"))
Trs.open Tsql,conn,1,1
TotalSNum=Trs.recordcount
Trs.close
Tsql="SELECT * FROM mv_Nclass where Nclassid="+cstr(rs("Nclassid"))
Trs.open Tsql,conn,1,1
Trs.close
%>
<tr align=center height=22 class=mbg_td>
<td class=tims><%=i%></td>
<td align=left><a href='admin_music_disk.asp?classid=<%=rs("classid")%>&sclassid=<%=rs("sclassid")%>&nclassid=<%=rs("nclassid")%>' alt='查看歌手 <%=rs("Nclass")%> 的所有专辑'><%response.write joekoe_cms.code_html(rs("nclass"),1,20)%></a></td>
<td><a href='admin_music_disk.asp?action=add&classid=<%=rs("classid")%>&sclassid=<%=rs("sclassid")%>&nclassid=<%=rs("nclassID")%>'>添加</a></td>
<td><%=TotalMNum%></td>
<td><%=TotalSNum%></td>
</tr>
<%
if i>=MaxPerPage then exit do
rs.movenext
loop
set Trs=nothing
%>
</table>

<%
'-----------------------搜索歌曲-----------------------------
elseif stype="Music" then
tu=rs("play")
%>
<table class=table cellspacing=1 cellpadding=1>
<tr height=22 align=center>
   <td width="7%"><b>序号</b></td>
   <td width="41%"><b>歌曲名字</b></td>
   <td width="31%" height=22 align=center><b>所属歌手</b></td>
   <td width="7%" height=22 align=center><b>推荐</b></td>
   <td width="7%" height=22 align=center><b>修改</b></td>
   <td width="7%" height=22 align=center><b>删除</b></td>
</tr>
<%do while not rs.eof%>
<tr height=22 align=center>
   <td><%=(i+1)%></td>
   <td align=left><a href=javascript:play('<%=rs("id")%>')><%=rs("musicName")%></a></td>
   <td><%=rs("singer")%>  <a href="admin_music.asp?action=music_add&classid=<%=rs("classid")%>&sclassid=<%=rs("sclassid")%>&nclassid=<%=rs("nclassid")%>&specialid=<%=rs("specialid")%>">[进入添歌]</a></td>
   <td><a href="admin_music_song.asp?action=music_good&act=SetisGood&id=<%=rs("id")%>&classid=<%=classid%>&sclassid=<%=sclassid%>&nclassid=<%=nclassid%>&page=<%=Currentpage%>"><%if rs("IsGood")=true then%><font color=red>撤销</font><%else%>推荐<%end if%></a></td> 
   <td><a href="admin_music_song.asp?action=music_edit&id=<%=rs("id")%>&askclassid=<%=rs("classid")%>&asknclassid=<%=rs("nclassid")%>&page=<%=Currentpage%>">修改</a></td>
   <td><a href="admin_music_song.asp?action=music_del&id=<%=rs("id")%>&classid=<%=classid%>&sclassid=<%=sclassid%>&nclassid=<%=nclassid%>&page=<%=Currentpage%>">删除</a></td>
</tr>
<%
i=i+1
if i>=maxperpage then exit do
rs.movenext
loop
%>
</table>
<%
'-----------------------搜索专辑-----------------------------
elseif stype="Special" then
%>
<table class=table cellspacing=1 cellpadding=1>
   <td width="45%"><b>专辑名称</b></td>
                <td width="25%"><b>所属歌手</b></td>
                <td width="10%"><b>添加歌曲</b></td>
                <td width="5%"><b>修改</b></td>
                <td width="5%"><b>删除</b></td>
              </tr>

<%
Set Trs= Server.CreateObject("ADODB.Recordset")
Tsql="SELECT * FROM mv_MusicList where Specialid="+cstr(rs("Specialid"))
Trs.open Tsql,conn,1,1
TotalMNum=Trs.recordcount
Trs.close

do while not rs.eof
i=i+1
%>
 <tr align=center height=25>
                <td align=left>&nbsp;<%=i%>.<a href="admin_music_song.asp?classid=<%=rs("classid")%>&sclassid=<%=rs("sclassid")%>&nclassid=<%=rs("nclassid")%>&specialid=<%=rs("specialid")%>"><font color=black><%=rs("name")%></font></a></td>
                <td><%=rs("nclass")%></td>
                <td><a href="admin_music_song.asp?action=add&specialid=<%=rs("specialid")%>"><FONT color="maroon">进入</FONT></a></td>
                <td><a href="admin_music_disk.asp?action=edit&specialid=<%=rs("specialid")%>&classid=<%=rs("classid")%>&sclassid=<%=rs("sclassid")%>&nclassid=<%=rs("nclassid")%>&page=<%=Currentpage%>">修改</a></td>
                <td><a href="admin_music_disk.asp?action=delete&specialid=<%=rs("specialid")%>&classid=<%=rs("classid")%>&sclassid=<%=rs("sclassid")%>&nclassid=<%=rs("nclassid")%>&page=<%=Currentpage%>">删除</a></td>
              </tr>
<%
	if i>=maxperpage then exit do
rs.movenext
loop
%>
</table>
<%
else
end if
end sub

function showpage(totalnumber,maxperpage,filename)
dim n
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
%>
<table class=table cellspacing=1 cellpadding=1>
<form method=Post action="<%=filename%>?keyword=<%=keyword%>&stype=<%=stype%>">
<tr><td height=30>
&nbsp;<img src='images/music/s_disk.gif' align=absMiddle border=0>&nbsp;<font class=blue><b>音乐搜索</b></font> 现有<font class=red id=00000000><%=totalnumber%></font>项记录，
共<strong><font color="<%=AlertFColor%>"><%=n%></font></strong>页，
当前第<strong><font color="<%=AlertFColor%>" id=00000000><%=CurrentPage%></font></strong>页 
<%if CurrentPage<2 then%>
&nbsp;首页&nbsp;上一页&nbsp;
<%else%>
&nbsp<a href="<%=filename%>?page=1&keyword=<%=keyword%>&stype=<%=stype%>">首页</a>&nbsp;
<a href="<%=filename%>?page=<%=CurrentPage-1%>&keyword=<%=keyword%>&stype=<%=stype%>"><font class=red id=00000000><b>上一页</b></font></a>&nbsp;
<%
end if
if n-currentpage<1 then
%>
下一页&nbsp;末页
<%else%>
<a href="<%=filename%>?page=<%=CurrentPage+1%>&keyword=<%=keyword%>&stype=<%=stype%>"><font class=red id=00000000><b>下一页</b></font></a>&nbsp;
<a href="<%=filename%>?page=<%=n%>&keyword=<%=keyword%>&stype=<%=stype%>">末页</a>
<%end if%>
</td></tr>
</form>
</table>
<% 
end function
function Search

end function
%>