|
<%
If numErrorNo = 0 then
'-----------------------------------------------
'GENERATE THE COUPON RECORDS
'-----------------------------------------------
CP_CreatedTime = ReverseFormatYear(now())
If strDatabaseType = "mysql" Then
strQuery = "SELECT CP_ID FROM tblCactuShopCoupons ORDER BY CP_ID DESC LIMIT 0, 1"
else
strQuery = "SELECT TOP 1 CP_ID FROM tblCactuShopCoupons ORDER BY CP_ID Desc"
end if
Call ExecuteSQL(strQuery, numCursorType, objRecordSet)
If objRecordSet.recordcount>0 then numLastCouponID = objRecordSet("CP_ID") else numLastCouponID=0
objRecordSet.close
For numCounter = 1 to numQuantity
'------------------------------------------------
'GENERATE A RANDOM ID NUMBER
'------------------------------------------------
Randomize()
numRandomElement1 = Int(rnd()*26)
Randomize()
numRandomElement2 = Int(rnd()*26)
Randomize()
numRandomElement3 = Int(rnd()*26)
Randomize()
numRandomElement4 = Int(rnd()*26)
Randomize()
numRandomElement5 = Int(rnd()*26)
numThisCouponID = numLastCouponID + numCounter
CP_CouponCode= chr(numRandomElement1+65) & chr(numRandomElement2+65) & chr(numRandomElement3+65) & chr(numRandomElement4+65) & chr(numRandomElement5+65) & numThisCouponID
strQuery="INSERT INTO tblCactuShopCoupons (CP_CouponCode, CP_Reusable, CP_Used, CP_CreatedTime, CP_StartDate, CP_EndDate, CP_DiscountValue, CP_DiscountType, CP_Enabled) VALUES (" &_
"'" & CP_CouponCode & "'," &_
"'" & CP_Reusable & "'," &_
"'n'," &_
strDateDelimiter & ReverseFormatYear(CP_CreatedTime) & strDateDelimiter & "," &_
strDateDelimiter & ReverseFormatYear(CP_StartDate) & strDateDelimiter & "," &_
strDateDelimiter & ReverseFormatYear(CP_EndDate) & strDateDelimiter & "," &_
CP_DiscountValue & "," &_
"'" & CP_DiscountType & "','y')"
Call ExecuteSQL(strQuery, numCursorType, objRecordSet)
next
%>
| <% WriteString("PageTitle_Coupons") %> |
<% WriteString("ContentText_FollowCouponsCreated")
response.write(" " & FriendlyDate(CP_CreatedTime, "t") & ":
" & vbcrlf)
'-----------------------------------------------
'GENERATE LIST OF THE ID NUMBERS
'Need to lookup all coupons created with date
'same as CP_CreatedTime above.
'-----------------------------------------------
If strDatabaseType = "mysql" Then
strQuery = "SELECT * FROM tblCactuShopCoupons ORDER BY CP_ID DESC LIMIT 0, " & numQuantity
else
strQuery = "SELECT TOP " & numQuantity & " * FROM tblCactuShopCoupons ORDER BY CP_ID Desc"
end if
Call ExecuteSQL(strQuery, numCursorType, objRecordSet)
do while NOT objRecordSet.EOF
numCoupons = numCoupons + 1
If not (cint(numCoupons) > cint(numQuantity)) then
response.write(objRecordSet("CP_CouponCode") & " " & vbcrlf)
end if
objRecordSet.movenext
loop
objRecordSet.close
%> |
<%
else
'-----------------------------------------------
'DISPLAY ERRORS
'-----------------------------------------------
%>
| <% WriteString("PageTitle_Problems") %> |
| <% WriteString("ContentText_Errors") %> |
| <% =strErrorText %> |
| << <% WriteString("ContentText_BackLink") %> |
<% end if %>
|