<!--#include file="tgzcm_Conn.asp"-->
<!--#include file="tgzcm_Check.asp"-->
<!--#include file="../tgzcm.Cache/tgzcm.Admin.asp"-->
<%
dim action,reurl,pid,pname,phow,pjf,ps,pj,pcolor,pic,pintro
reurl=Request.ServerVariables("Http_Referer")'来源地址
If reurl="" Then reurl="tgzcm_product.asp"
action=Trim(Request.QueryString("action"))
pid=Clng(Request.QueryString("pid"))'产品id
pname=Left(tgzcm_replace(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=tgzcm_replace(request.form("data_color")) '标题颜色
'
Sub Data_Add '作用:入库新的奖品信息
    If pname=""  Then 
	    Call tgzcm_err_c("产品名称不能为空！")
	    Response.End
    ElseIf pic="images/nopic.gif"  Then
	    Call tgzcm_err_c("请上传奖品图片！")
	    Response.End	
    End if
	Set rs = Server.CreateObject("adodb.recordset")
	sql = " select * from tgzcm_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 tgzcm_err_b("添加奖品成功,确定返回！","tgzcm_product.asp")

End sub

Sub Data_Edit '作用:编辑影片信息
   If pname=""  Then 
	    Call tgzcm_err_c("产品名称不能为空！")
	    Response.End
    ElseIf pic="images/nopic.gif"  Then
	    Call tgzcm_err_c("请上传奖品图片！")
	    Response.End	
    End if
    Set rs = Server.CreateObject("adodb.recordset")
	sql = " select * from tgzcm_product where pid="&pid&" "
	rs.Open sql, Conn, 1, 3
	If Not (rs.bof And rs.eof) Then 
		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
	End if
	rs.Close
	set rs=nothing
	Call tgzcm_err_b("修改奖品成功,确定返回！","tgzcm_product.asp")
End Sub

Sub Data_Del '作用:删除影片信息 
    Set rs_d=conn.execute(" select top 1 pid from tgzcm_product where pid="&pid&" ")
	If Not(rs_d.bof and rs_d.eof)  Then
	 conn.execute(" delete from tgzcm_product where pid="&pid&" ")'删除奖品
	Else 	
	 Call tgzcm_err_c("参数传递错误！")
	 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"),"tgzcm_index.asp")>0 Then
    gourl="tgzcm_data.asp"
Else
    gourl=session("reurl")
End If
%>
