<!--#include file="conn.asp"--><%seo_title="Score change Discount Voucher-"&sitename%>
<!--#include file="IncAsp/WrzcNethtml_top.asp"-->
<div align="center">
<table cellpadding="0" cellspacing="0" class="all_t1">
<tr><td class="all_l_td" valign="top">
<!--#include file="IncAsp/WrzcNethtml_log.asp"--><div class="d5"></div>
</td>
<td valign="top" class="all_c_td">
<table width="99%" border="0" cellpadding="0" cellspacing="0">
<tr><td class="sort">&nbsp;<IMG src="Skin/<%=WrzcNethtml_skin%>/home.gif" border=0 align="absmiddle">   
	<a href="index.html">Home</a> >>&nbsp;Score change Discount Voucher
</td></tr>
<tr><td height=5></td></tr>
<%
if Request.Cookies("WrzcNethtml")("user_name")="" then
response.redirect "login.asp?comurl=rule.asp"
response.end
end if
user_name=Request.Cookies("WrzcNethtml")("user_name")
chklogin(user_name)
Function RndNumber(MaxNum,MinNum)
Randomize 
RndNumber=int((MaxNum-MinNum+1)*rnd+MinNum)
RndNumber=RndNumber
End Function

if request("action")="go" then
rule_id=request("rule_id")
chkid(rule_id)

	rrr=RndNumber(10000,99999)
	for i=1 to 3
		set rs=server.CreateObject("adodb.recordset")
		rs.Open "select quan_no from WrzcNethtml_quan where quan_type=1 order by quan_id desc",conn,1,1
		do while not rs.eof
		z=mid(rs("quan_no"),4,5)
		if rrr=z then rrr=RndNumber(10000,99999)
		rs.movenext
		loop
		rs.Close
		set rs=nothing
	next
	quan_no="u"&right(year(now()),2)&rrr&RndNumber(100,999)
	set rss=server.createobject("adodb.recordset")
	sql="select * from WrzcNethtml_rule where rule_id="&rule_id&" order by rule_id desc"
	rss.open sql,conn,1,1
	if not rss.eof then
	
		set rsu=server.createobject("adodb.recordset")
		sql="select * from WrzcNethtml_user where username='"&user_name&"'"
		rsu.open sql,conn,1,3
		if not rsu.eof then
			if rsu("savemoneyz")>=rss("rule_jifen") then
				set rs=server.CreateObject("adodb.recordset")
				rs.Open "select * from WrzcNethtml_quan",conn,1,3
				rs.AddNew
					rs("quan_cash")=rss("rule_cash")
					rs("quan_man")=rss("rule_man")
					rs("quan_date")=date()+30
					rs("quan_no")=quan_no
					rs("quan_pass")=RndNumber(10000000,99999999)
					rs("quan_is")=0
					rs("quan_type")=1
					rs("user_name")=user_name
					rs("quan_jifen")=rss("rule_jifen")
					rs("quan_time")=now()
				rs.Update
				rs.Close
				set rs=nothing
				rsu("savemoneyz")=rsu("savemoneyz")-rss("rule_jifen")
				rsu.update
			else
				Response.Write "<script language=javascript>alert('Sorry,you did't have enough Score'); window.location.href='rule.asp';</script>"
				Response.end
			end if
		else
			Response.Write "<script language=javascript>alert('Error!'); window.location.href='rule.asp';</script>"
			Response.end
		end if
		rsu.close
		set rsu=nothing
	else
		Response.Write "<script language=javascript>alert('Error!'); window.location.href='rule.asp';</script>"
		Response.end
	end if
	rss.Close
	set rss=nothing
	Response.Write "<script language=javascript>alert('Success,click to Manage Discount Voucher'); window.location.href='rulelog.asp';</script>"
	Response.end
end if















set rs=server.createobject("adodb.recordset")
sql="select * from WrzcNethtml_rule order by rule_id desc"
rs.open sql,conn,1,1
if rs.eof then%><tr><td align="center" height="30">No Data</td></tr>
<%else%>

<tr><td class="sorta">
<table border="0" cellpadding="5" cellspacing="0" width="100%">
<%do while not rs.eof%>

	<tr>
		<td align="center" width="290" height="150"><img src="<%=rs("rule_pic")%>"></td>
		<td style="line-height:150%;">
			Save:<%=fuhao%><%=rs("rule_cash")*hui%><br>
			When Subtotal more then <%=fuhao%><%=rs("rule_man")*hui%><br>
			Score:<%=rs("rule_jifen")%><br>
			Your Score:<%yjifen=Conn.Execute("Select sum(savemoneyz) from WrzcNethtml_user where username='"&user_name&"'")(0)%><%=yjifen%>
		</td>
		<td align="center" width="120" style="line-height:150%;">
		<%if yjifen>=rs("rule_jifen") then%>
		<a href="rule.asp?action=go&rule_id=<%=rs("rule_id")%>" onClick="return confirm('Confirm?')"><u>Change</u></a>
		<%else%>
		<font color="#ff0000">Sorry,you did't have enough Score<br></font>
		<%end if%>
		</td>
	</tr>
	<tr><td colspan=3 height=2 background=Img/dot_menu.gif></td></tr>

<%rs.movenext
loop%>
</table>
</td></tr>
<%end if
rs.close
set rs=nothing%></table>
</td></tr></table></div>
<!--#include file="IncAsp/WrzcNethtml_copy.asp"-->