<!--#include file="QvodCms_Conn.asp"-->
<!--#include file="QvodCms_Check.asp"-->
<%
dim action,reurl,pid,pname,phow,pjf,ps,pj,pcolor,pic,pintro
reurl=Request.ServerVariables("Http_Referer")'来源地址
If reurl="" Then reurl="qvodcms_product.asp"
action=Trim(Request.QueryString("action"))
pid=Clng(Request.QueryString("pid"))'产品id
pname=Left(Trim(request.form("p_name")),255)'产品名称
phow=Clng(request.form("p_how"))'产品当量
pjf=Clng(request.form("p_jf"))'产品积分
pic=Trim(request.form("data_smallpic"))'产品图片
pintro=Trim(request.form("p_intro"))'影片简介
pcolor=Trim(request.form("data_color")) '标题颜色
Call OpenConn()
Sub Data_Add '作用:入库新的奖品信息
    If pname=""  Then 
	    Call qvodcms_err("产品名称不能为空！")
	    Response.End
    ElseIf pic="images/nopic.gif"  Then
	    Call qvodcms_err("请上传奖品图片！")
	    Response.End	
    End if
	Set rs = Server.CreateObject("adodb.recordset")
	sql = " select * from qvodcms_product "
	rs.Open sql, Conn, 1, 3
	rs.AddNew
	rs("pname")=pname
	rs("pcolor")=pcolor
	rs("pic")=pic
	rs("pjf")=pjf
	rs("pj")=phow
	rs("ps")=phow
	rs("pabout")=pintro
	rs("ptime")=now()
	rs.update
	rs.Close
	Set rs=nothing
	Call QvodCms_Err_Url("添加奖品成功,确定返回！","qvodcms_product.asp")

End sub

Sub Data_Edit '作用:编辑影片信息
   If pname=""  Then 
	    Call qvodcms_err("产品名称不能为空！")
	    Response.End
    ElseIf pic="images/nopic.gif"  Then
	    Call qvodcms_err("请上传奖品图片！")
	    Response.End	
    End if
    Set rs = Server.CreateObject("adodb.recordset")
	sql = " select * from qvodcms_product where pid="&pid&" "
	rs.Open sql, Conn, 1, 3
	If Not (rs.bof And rs.eof) Then 
	    phowa=rs("pj")
		rs("pname")=pname
	    rs("pcolor")=pcolor
	    rs("pic")=pic
	    rs("pjf")=pjf
	    rs("pj")=phow
		if phowa<>phow then
	    rs("ps")=phow
		End If
	    rs("pabout")=pintro
	    rs("ptime")=now()
		rs.update
	End if
	rs.Close
	set rs=nothing
	Call QvodCms_Err_Url("修改奖品成功,确定返回！","qvodcms_product.asp")
End Sub

Sub Data_Del '作用:删除影片信息 
    Set rs_d=conn.execute(" select top 1 pid from qvodcms_product where pid="&pid&" ")
	If Not(rs_d.bof and rs_d.eof)  Then
	 conn.execute(" delete from qvodcms_product where pid="&pid&" ")'删除奖品
	Else 	
	 Call qvodcms_err("参数传递错误！")
	 Response.End()
	End If
    rs_d.close:Set rs_d=Nothing
	Response.Redirect(reurl)
End Sub

%>
<%If action="add" Then%><%Call Data_Add%>
<%ElseIf action="edit" Then%><%Call Data_Edit%>
<%ElseIf action="del" Then%><%Call Data_Del%>
<%ElseIf action="elite" Then%><%Call Data_Eli%>
<%ElseIf action="status" Then%><%Call Data_Sta%>
<%End If%>
<%
Dim gourl
If session("reurl")="" or instr(session("reurl"),"QvodCms_Index.asp")>0 Then
    gourl="qvodcms_data.asp"
Else
    gourl=session("reurl")
End If
Call CloseConn()
%>
