<!-- #include file="setup.asp" -->
<%
if adminpassword<>session("pass") then
response.redirect "admin.asp?menu=login"
end if
if membercode<6 then
error2("权限不够")
end if
log(""&Request.ServerVariables("script_name")&"<br>"&Request.ServerVariables("Query_String")&"<br>"&Request.form&"")
%>
<!--#include file="music/musi-cconn.asp"-->
<%

id=int(request("id"))
IF Request("menu")="del"  Then
   Conn.Execute("Delete From music Where id="&id&"")
   Response.Redirect "music-play.asp"
End IF
if Request.ServerVariables("request_method") = "POST"  then
musicname=HTMLEncode(trim(request.Form("musicname")))
singer=HTMLEncode(trim(request.Form("singer")))
files=HTMLEncode(trim(request.Form("file")))
lanmu=HTMLEncode(trim(request.Form("lanmu")))
if musicname=empty or lanmu=empty or files=empty  or singer=empty  then
error2("资料不完全")
end if

if Request("action")="edit" then
conn.execute("update music set musicname='"&musicname&"',singer='"&singer&"',file='"&files&"',lanmu='"&lanmu&"'  where id="&id&"")
Response.Redirect "music-play.asp"
end if
if Request("action")="add" then
conn.execute("insert into music (musicname,singer,file,lanmu) values ('"&musicname&"','"&singer&"','"&files&"','"&lanmu&"')")
response.redirect "music-play.asp"
end if
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>『同策』管理</title>

</head>

<body>
<table width="<%=dkuan%>"  border="0" align="center" cellpadding="2" cellspacing="1" class=a2>
  <tr class=a1> 
    <td height="25" align="center"> 所属类别</td>
    <td height="25" align="center"> <strong>歌手姓名</strong></td>
    <td height="25" align="center"> 歌曲名字</td>
    <td height="25" align="center"> 歌曲地址</td>
    <td colspan="2" height="25"> 
      <div align="center">操作</div>
    </td>
  </tr>
  <%
count=conn.execute("Select count(id) from music")(0)
pagesetup=10 '设定每页的显示数量
PageCount = cint(Request.QueryString("ToPage"))
TotalPage=cint(count/pagesetup)  '总页数
if TotalPage < count/pagesetup then TotalPage=TotalPage+1
if PageCount > TotalPage then PageCount = TotalPage
if PageCount <1 then PageCount = 1

Set rs=conn.execute("select  top "&pagesetup*PageCount&" * from music order by id desc" ) 
if rs.eof  then
response.write "<div align=center><font size=2>还没有曲目</font></div>" 
else
if TotalPage>1 then RS.Move (PageCount-1) * pagesetup

i = 0
Do While Not RS.EOF and i<pagesetup
%>
  <tr class=a3> 
    <form action="music-play.asp?action=edit" method="post">

      <td>
        <input name="lanmu" type="text" id="lanmu" value="<%=rs("lanmu")%>" size="8">
      </td>

      <td> 
        <input name="singer" type="text" id="singer" value="<%=rs("singer")%>" size="8">
      </td>
      <td> 
        <div align="center"> 
          <input name="musicname" type="text" id="musicname" value="<%=rs("musicname")%>" size="15">
          <input name="id" type="hidden" id="id" value="<%=rs("id")%>">
        </div>
      </td>
      <td> 
        <div align="center"> 
          <input name="file" type="text" id="file" value="<%=rs("file")%>" size="30">
        </div>
      </td>
      <td nowrap> 
        <div align="center"> 
          <input name="Submit2" type="submit" class="button1" value="修改">
        </div>
      </td>
      <td nowrap> 
        <div align="center"><a href="?menu=del&id=<%=Rs("id")%>" onClick="checkclick('确定删除')">删除</a></div>
      </td>
    </form>
  </tr>
  <%
i=i+1
   rs.movenext
	loop
	rs.close
  %>
  <tr> 
    <td colspan="6" class=a4> 
      <div align="right"><b>共有 <font color=990000><%=count%></font> 条 [

<script>
PageCount=<%=TotalPage%> //总页数
topage=<%=PageCount%>   //当前停留页
for (var i=1; i <= PageCount; i++) {
if (i <= topage+3 && i >= topage-3 || i==1 || i==PageCount){
if (i > topage+4 || i < topage-2 && i!=1 && i!=2 ){document.write(" ... ");}
if (topage==i){document.write("<font color=red> "+ i +" </font>");}
else{
document.write("<a href=?menu=<%=Request.QueryString("menu")%>&topage="+i+">"+ i +"</a> ");
}
}
}
</script>]</b> </div>
    </td>
  </tr><%end if%>
</table>
<table width="<%=dkuan%>"  border="0" align="center" cellpadding="2" cellspacing="1" class=a2>

  <form action="music-play.asp?action=add" method="post" name="form" >
    <tr class=a3> 
      <td> <p align="right">歌曲信息：</td>
      <td>   <strong>歌手:</strong>  <input name="singer" type="text" class="input01"  size="20"　title="singer"> 
     　　  <strong>歌曲名字:</strong>
        <input name="musicname" type="text" class="input01"  size="20" title="music"> 
       </td>
    </tr>
    <tr class=a4> 
      <td> <div align="right">歌曲地址：</div></td>
      <td> <input name="file" type="text" id="file" value="" size="35"> <select name="lanmu">
    <option selected>所属类别</option>
    <option value="华人男歌手">华人男歌手</option>
    <option value="华人女歌手">华人女歌手</option>
    <option value="华人组合">华人组合</option>
    <option value="日韩歌曲">日韩歌曲</option>
    <option value="欧美歌曲">欧美歌曲</option>
    <option value="影视歌曲">影视歌曲</option>
    <option value="音乐其它">音乐其它</option>
  </select></td>
    </tr>
    <tr class=a3> 
      <td> <div align="right"></div></td>
      <td> <input name="Submit" type="submit" class="button1" value=" 增 加 "> 
        &nbsp;&nbsp;&nbsp; <input name="Submit1" type="reset" class="button1" value=" 重 设 "></td>
    </tr>
  </form>
</table>
<%
set rs=nothing   
conn.close   
set conn=nothing
%>
</body>
</html>

