 
<!--#include file="conn.asp"-->
<!-- #include file="inc/const.asp" -->
<!--#include file=inc/char.asp-->
<!--#include file=inc/grade.asp-->
<!--#include file=chkuser.asp-->
<html>
<head>
<title><%=ForumName%>--管理页面</title>
<link rel="stylesheet" type="text/css" href="forum.css">
</head>
<BODY bgcolor="#ffffff" alink="#333333" vlink="#333333" link="#333333" topmargin="20">
<% dim pagecount,n,id,name,url,linknum,adduser
          
   if memberclass=grade(20)  then
		dim body
		set rs= server.createobject ("adodb.recordset")
		call main()
		set rs=nothing
		conn.close
		set conn=nothing
       else
Errmsg=Errmsg+"<br>"+"<li>本页面为管理员专用，请<a href=index.asp><FONT COLOR=RED>+返回论坛+</FONT></a>,感谢你的参与!"
		call Error()
    end if
	sub main()
%>
<table cellpadding=0 cellspacing=0 border=0 width=98% bgcolor=<%=atablebackcolor%> align=center>
  <tr>
    <td>
      <table cellpadding=3 cellspacing=1 border=0 width=100%>
        <tr bgcolor='<%=aTabletitlecolor%>'>
        <td align=center colspan="2">欢迎 <b><FONT COLOR=RED><%=htmlencode(membername)%> </FONT></b> 进入管理页面
        </td>
        </tr>
            <tr bgcolor=<%=tablebodycolor%>>           
          <td width="20%" valign=top>
<p align="center"><a href="admin_midimaster.asp?action=add"> <添加MIDI音乐> </a>
<p align="center"><a href="admin_midimaster.asp?action=linkinfo" > <返回管理首页> </a>
<p align="center"><a href="javascript:window.close()"> <关闭窗口> </a>
</td>  
          <td width="80%" valign=top>
<%
	if request("action") = "add" then 
		call addlink()
	elseif request("action")="edit" then
		call editlink()
        elseif request("action")="linkinfo" then
		call linkinfo()
        elseif request("action")="savenew" then
		call savenew()
	elseif request("action")="savedit" then
		call savedit()
	elseif request("action")="del" then
		call del()
	elseif request("action")="orders" then
		call orders()
	elseif request("action")="updateorders" then
		call updateorders()
	else
		call linkinfo()
	end if
%>     <p><%=body%></p>
        </td>
    </tr>
</table>

<%
end sub

sub addlink()
%>
<form action="admin_midimaster.asp?action=savenew" method = post>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td width="30%">MIDI音乐的歌名： </td>
    <td width="70%"> 
      <input type="text" name="name" size=40>
    </td>
  </tr>
  <tr> 
    <td width="30%">MIDI音乐的地址： </td>
    <td width="70%"> 
      <input type="text" name="url" size=40>
</td>
  </tr>
 <tr> 
    <td width="30%">备注(如歌星名字)： </td>
    <td width="70%"> 
      <input type="text" name="adduser" size=40>
    </td>
  </tr>
  <tr> 
    <td height="15" colspan="2"> 
      <div align="center"> 
        <input type="submit" name="Submit" value="添加">
      </div>
    </td>
  </tr>
</table>
</form>
<%
end sub

sub editlink()
	sql = "select * from music where id="+cstr(Request("id"))
	rs.open sql,conn,1,1
%>
<form action="admin_midimaster.asp?action=savedit" method=post>
<input type=hidden name=id value=<%=Request("id")%>>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td width="30%">MIDI音乐的歌名： </td>
    <td width="70%"> 
      <input type="text" name="name" size=40 value=<%=rs("name")%>>
    </td>
  </tr>
  <tr> 
    <td width="30%">MIDI音乐的地址： </td>
    <td width="70%"> 
      <input type="text" name="url" size=40 value=<%=rs("url")%>>
    </td>
  </tr>
<tr> 
    <td width="30%">备注(如歌星名字)： </td>
    <td width="70%"> 
      <input type="text" name="adduser" size=40 value=<%=rs("adduser")%>>
    </td>
  </tr>
  <tr> 
    <td height="15" colspan="2"> 
      <div align="center"> 
        <input type="submit" name="Submit" value="修改">
      </div>
    </td>
  </tr>
</table>
</form>
<%
	rs.close
end sub

sub linkinfo()
%>
           
<%
sql = " select * from music order by id desc"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "<br>还没有MIDI音乐！！！<a href=admin_midimaster.asp?action=add><font color=#ff0000>现在添加</font></a>"
response.end
else
end if 
if not isempty(request("page")) then   
pagecount=cint(request("page"))   
else   
pagecount=1   
end if
rs.pagesize=20 
rs.AbsolutePage=pagecount
%>
 <table width="100%" border="0" cellspacing="3" cellpadding="0">
              <tr>
                <td>注意事项： <br>
                  在下面，您将看到目前所有的MIDI音乐的列表。您可以进行编辑、增加和删除。 
                </td>
              </tr>
            </table>
<br>
<table border="0" cellpadding="3" cellspacing="1" width="98%" align="center"  bgcolor="#800000">
<tr>    
  <td height="20" align="center" bgcolor="#FFFFCC" colspan="6"><a href="admin_midimaster.asp?action=add" > < 增加新的MIDI音乐 ></a></td>   
 </tr> 
    <tr>
      <td height="13" align="center" bgcolor="#FFCC00" >MIDI音乐的歌名</td>
      <td height="13" align="center" bgcolor="#FFCC00">MIDI音乐的地址</td>
      <td height="13" align="center" bgcolor="#FFCC00" width="147">备注</td>
      <td height="13" align="center" bgcolor="#FFCC00" width="46">编辑</td>
      <td height="13" align="center" bgcolor="#FFCC00" width="47">删除</td>
      <td height="13" align="center" bgcolor="#FFCC00" width="47">下载</td>
    </tr>
    <% do while not rs.eof %>
    <tr>
      <td height="9" bgcolor="#FFFF99" width="30%">&nbsp;<%=rs("name")%> </td>
      <td  bgcolor="#FFFFCC" width="10%"> <%=rs("url")%></td>
      <td height="9" width="30%" bgcolor="#FFFF99">&nbsp;<%=rs("adduser")%></td>
      <td height="9" width="10%" align="center" bgcolor="#FFFFCC"><a href="admin_midimaster.asp?action=edit&id=<%=rs("id")%>">编辑</a></td>
      <td height="9" width="10%" align="center" bgcolor="#FFFFCC"><a href="admin_midimaster.asp?action=del&id=<%=rs("id")%>"><FONT COLOR=RED>删除</FONT></a></td>
      <td height="9" width="10%" align="center" bgcolor="#FFFFCC"><a href="<%=rs("url")%>">下载</a></td>
    </tr>
<% n=n+1                                                                                       
   rs.movenext                                                                                       
   if n>=rs.pagesize then exit do                                                                                       
   loop  
%>
   <tr>  
 <td height="27" align=center colspan="6" bgcolor="#FDE89F"><a href=admin_midimaster.asp?action=linkinfo&page=1>首页</a> 
<% if rs.pagecount>1 and rs.pagecount=pagecount or pagecount<>1 and rs.pagecount<>pagecount then %>
&nbsp;&nbsp<a href="admin_midimaster.asp?action=linkinfo&page=<%=pagecount-1%>">上一页</a>
<% else %>
&nbsp;上一页
<%end if%>
&nbsp;  
<%if pagecount=1 and rs.pagecount<>pagecount or pagecount<>1 and rs.pagecount<>pagecount then%>
<a href="admin_midimaster.asp?action=linkinfo&page=<%=pagecount+1%>">下一页</a>
<% else %>
下一页              
<% end if %>            
&nbsp;&nbsp<a href="admin_midimaster.asp?action=linkinfo&page=<%=rs.pagecount%>">尾页</a>&nbsp;&nbsp页次：　<font color=#ff0000><b><%=pagecount%></b></font>/<b><%=rs.pagecount%></b>页　| 共<b><%=rs.recordcount%></b>首MIDI音乐&nbsp;&nbsp(<b><%=rs.pagesize%></b>首MIDI/页)</td>  
              </tr>  
              <tr>    
                <td height="20" align="center" bgcolor="#FFFFCC" colspan="6"><a href="admin_midimaster.asp?action=add" > < 增加新的MIDI音乐 ></a></td>   
              </tr>   
            </table>   
            <br>   
            <br>   
          </td>   
            </tr>   
        </table>   
<%   
end sub   
 
sub savenew()   
if Request("name")<>"" and Request("url")<>"" then
    name=Request.form("name")
     url=Request.form("url")
    rs.open "select * from music where name='"&name&"' and url='"&url&"'",conn,1,1
    if not rs.eof  then
response.write"<br>错误信息：这个MIDI音乐已经添加过了！<a href=admin_midimaster.asp?action=add><font color=#ff0000>重新添加</font></a>"
    response.end 
    end if 
    rs.close  
    set rs= server.createobject ("adodb.recordset")             
	sql = "select * from music"   
	rs.Open sql,conn,1,3   
	linknum=rs.recordcount   
	rs.AddNew      
	rs("name") = Trim(Request.Form ("name"))    
	rs("url") = Request.Form ("url")
        rs("adduser") = Request.Form ("adduser")   
	rs.Update    
	rs.Close   
	body=body+"<br>"+"更新成功，请继续其他操作。<a href=admin_midimaster.asp?action=add><font color=#ff0000>继续添加</font></a>"   
else   
	body=body+"<br>"+"请输入完整信息。<a href=javascript:history.go(-1)><font color=#ff0000>[返回]</font></a>"   
end if   
end sub   
   
sub savedit()   
if Request("name")<>"" and Request("url")<>"" then  
    name=Request.form("name")
	url=Request.form("url")
    adduser=Request.form("adduser")
    rs.open "select * from music where name='"&name&"' and url='"&url&"'",conn,1,1
    if not rs.eof and rs.bof then
    response.write"<br>错误信息：这个MIDI音乐已经添加过了！<a href=javascript:history.go(-1)><font color=#ff0000>返回</font></a>"
    response.end 
    end if 
    rs.close  
	sql = "select * from music where id="+Cstr(request("id"))   
	rs.Open sql,conn,1,3   
	if rs.eof and rs.bof then   
	body=body+"<br>"+"错误，没有找到该歌曲。"   
	else   
	rs("name") = Trim(Request.Form ("name"))   
	rs("url") = Request.Form ("url") 
        rs("adduser") = Request.Form ("adduser")   
	rs.Update   
	end if    
	rs.Close   
	body=body+"<br>"+"更新成功，请继续其他操作。| <a href=javascript:history.go(-2)> <返回上一页></a>"  
else   
	body=body+"<br>"+"请输入完整信息。<a href=javascript:history.go(-1)><font color=#ff0000>[返回]</font></a>"   
end if  
end sub   
   
sub del   
	id = request("id")   
	sql="delete from music where id="+id   
	conn.Execute(sql)   
	body=body+"<br>"+"删除成功，请继续其他操作。| <a href=javascript:history.go(-1)><返回上一页></a>"   
end sub   
   
sub orders()   
%><br>   
            <table width="95%" border="0" cellspacing="3" cellpadding="0" align=center>   
	      <tr>   
		<td>   
<%   
	sql="select * from music where id="&cstr(request("id"))   
	rs.open sql,conn,1,1   
	if rs.eof and rs.bof then   
		response.write "没有找到相应的MIDI。"   
	else   
		response.write "<form action=admin_midimaster.asp?action=updateorders method=post>"   
		response.write ""&rs("name")&"  <input type=text name=newid size=2 value="&rs("id")&">"   
		response.write "<input type=hidden name=id value="&request("id")&">"   
		response.write "<input type=submit name=Submit value=修改></form>"   
	end if   
	rs.close   
%>   
		</td>   
	      </tr>   
              <tr bgcolor="<%=atabletitlecolor%>">    
                <td height="22" align=center><a href="admin_midimaster.asp?action=add">增加新的MIDI音乐</a></td>   
              </tr>
             <tr bgcolor="<%=atabletitlecolor%>"> 
<a href="javascript:history.back(1)"><img src="<%=picurl%>back.gif" alt="后退" border="0"></a>
</tr>   
            </table>   
<%   
end sub   
   
sub updateorders()   
	sql="update music set id="&request("newid")&" where id="&cstr(request("id"))   
	conn.execute(sql)   
	response.write "<p align=center>更新成功！</p>"   
end sub   
%>   

</body>
</html>













