<!--#include file="function.asp"-->
<!--#include file="error.ini"-->
<!--#include file="../inc/admin_conn.asp"-->
<!--#include file="Star.inc"-->
<%
page=trim(request.querystring("page"))
AskClassid=trim(request.querystring("AskClassid"))
AskSClassid=trim(request.querystring("AskSClassid"))
AskNClassid=trim(request.querystring("AskNClassid"))
song_path=Cint(request.form("song_path"))
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"))
MusicWord=trim(request.form("MusicWord"))

founerr=false
act=request("act")
	if MusicName="" then
		errmsg=errmsg+"歌曲名称不能为空"
		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 ylmv_NClass where NClassid="&Nclassid
		rs.open sql,conn,1,1
		singer=rs("Nclass")
		rs.close
	end if
	if act="edit" and request("id")<>"" then
		sql="select * from ylmv_MusicList where id="&request("id")
		rs.open sql,conn,1,3
		rs("song_path")=song_path
		rs("Wma")=trim(Wma)
		rs("MusicName")=MusicName
		rs("classid")=classid
		rs("Sclassid")=Sclassid
		rs("Nclassid")=Nclassid
		rs("Specialid")=Specialid
		rs("singer")=trim(singer)
		rs.update
		rs.close

		sql="select * from ylmv_Box where Musicid="&request("id")
		rs.open sql,conn,1,3
		if not rs.eof then
			rs("MusicName")=MusicName
			rs.update
		end if
		rs.close

		If MusicWord<>"" Then
			Set rs=conn.execute("select id from [ylmv_MusicWord] where MusicID="&request("id"))
				If rs.bof or rs.eof Then
					conn.execute("insert into [ylmv_MusicWord] (MusicId,MusicWord,AddUser,ISShow) values ("&request("id")&",'"&MusicWord&"','master',true)")	
				Else
					conn.execute("update [ylmv_MusicWord] set MusicWord='"&MusicWord&"' where MusicId="&request("id"))
				End If
			rs.close
		End If
		call Success
		Response.End 
	elseif act="add" then
		sql="select * from ylmv_MusicList where (id is null)" 
		rs.open sql,conn,1,3
		rs.addnew
		rs("Wma")=Wma
		rs("song_path")=song_path
		rs("MusicName")=MusicName
		rs("classid")=classid
		rs("Sclassid")=Sclassid
		rs("Nclassid")=Nclassid
		if Specialid<>"" then rs("Specialid")=Specialid
		rs("singer")=singer
		rs.update
		MUSICID=rs("id")
		rs.close
		
		If MusicWord<>"" Then
			conn.execute("insert into [ylmv_MusicWord] (MusicId,MusicWord,AddUser,ISShow) values ("&MUSICID&",'"&MusicWord&"','master',true)")
		End If
		call Success
		Response.End 
		errmsg=errmsg+"<li>操作错误！请联系管理员</li>"
		call error()
		Response.End
	end if
	set rs=nothing
	conn.close
	set conn=nothing
	Response.Redirect "Songlist.asp?Classid="+AskClassid+"&SClassid="+AskSClassid+"&NClassid="+AskNClassid+"&Page="+Page
end if
sub Success
%>
<%PageName="SongSave"%>
<!--#include file="top.asp"-->
<link href="Images/Admin_Style.Css" rel="stylesheet" type="text/css">
<div align="center">
<center>
<table border="0" width="80%" cellspacing="1" cellpadding="1">
  <tr>
    <td>　
      <table border="1" width="100%" cellspacing="0" cellpadding="0" class="TableLine" bordercolor="#A4CEE4" bordercolordark="#FFFFFF">
        <tr align="center">
        <td width="100%" height="20" colspan=2 bgcolor="#96C5DE" align=center><font color="white"><b>歌曲<%if act="add" then%>添加<%else%>修改<%end if%>成功</b></font></td>
        </tr>
        <tr>
          <td>
           <table border="1" width="100%" cellspacing="0" cellpadding="3" class="TableLine" bordercolor="#A4CEE4" bordercolordark="#FFFFFF">
             <tr>
              <td width="25%" align="right">歌曲：</td>
              <td width="75%"><%=MusicName%>　</td>
            </tr>
            <tr>
              <td align="right">歌手：</td>
              <td><%=Singer%>　</td>
            </tr>
            <tr>
              <td align="right">Wma地址：</td>
              <td>跟路径<%=song_path%><%=Wma%>　</td>
            </tr>
            <tr>
              <td colspan="2" height="15" align=center><input type="button" name="button2" value=" 继续<%if act="add" then%>添加<%else%>修改<%end if%> " onclick="javascript:history.go(-1)">&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" name="button1" value=" 返回 " onclick="javascript:history.go(-2)"></td>
            </tr>
          </table>
          </td>
        </tr>
      </table>
 　 </td>
  </tr>
</table>
</div>
<%end sub%>
