awardAction.asp
上传用户:jisenq
上传日期:2014-06-29
资源大小:7216k
文件大小:12k
源码类别:

数据库编程

开发平台:

ASP/ASPX

  1. <% Option Explicit %>
  2. <!--#include file="../../FS_Inc/Const.asp" -->
  3. <!--#include file="../../FS_InterFace/MF_Function.asp" -->
  4. <!--#include file="../../FS_Inc/Function.asp" -->
  5. <%'Copyright (c) 2006 Foosun Inc. Code by Einstein.Liu
  6. Dim Conn,User_Conn,awardRs,prizeRs,AwardName,AwardPic,StartDate,EndDate,PrizeGradeNum,PrizeIDS,PrizeNames,ForIndex,PrizeName,PrizeGrade,PrizePic,PrizeNum,CurrentPrizeIDS,answerNum,AnswerDesc,RightAnswer,CurrentAnswerID,CurrentAnswerIDS,prizeNeedPoint,usernumber
  7. Dim prizeID
  8. MF_Default_Conn
  9. MF_User_Conn
  10. MF_Session_TF
  11. if not MF_Check_Pop_TF("ME_award") then Err_Show 
  12. if request.QueryString("act")="addaction" then
  13. Set awardRs=Server.CreateObject(G_FS_RS)
  14. Set prizeRs=Server.CreateObject(G_FS_RS)
  15. AwardName=Request.Form("AwardName")
  16. AwardPic=Request.Form("AwardPic")
  17. StartDate=Request.Form("StartDate")
  18. EndDate=Request.Form("EndDate")
  19. PrizeGradeNum=Request.Form("PrizeGradeNum")
  20. '添加奖品
  21. for ForIndex=0 to PrizeGradeNum-1
  22. PrizeName=Request.Form("Prize_"&(ForIndex+1)&"_name")
  23. PrizeGrade=ForIndex+1
  24. prizeNeedPoint=Request.Form("NeedPoint_"&(ForIndex+1))
  25. PrizePic=Request.Form("prize_"&(ForIndex+1)&"_pic")
  26. PrizeNum=Request.Form("prize_"&(ForIndex+1)&"_number")
  27. if PrizeName="" or PrizeNum="" or not isnumeric(PrizeNum) then
  28. Response.Redirect("../error.asp?ErrCodes=<li>奖品名称可能为空</li><li>奖品数量可能为空</li><li>奖品数量中可能包含有字符</li>")
  29. Response.End()
  30. end if
  31. Set prizeRs=User_Conn.Execute("insert into FS_ME_Prize (PrizeName,NeedPoint,PrizeGrade,PrizePic,PrizeNum) values('"&PrizeName&"',"&prizeNeedPoint&","&PrizeGrade&",'"&PrizePic&"',"&PrizeNum&")")
  32. CurrentPrizeIDS=CurrentPrizeIDS&","&User_Conn.Execute("Select Max(PrizeID) from FS_ME_Prize")(0)
  33. next
  34. CurrentPrizeIDS=DelHeadAndEndDot(CurrentPrizeIDS)
  35. awardRs.open "select AwardName,AwardPic,StartDate,EndDate,PrizeIDS,opened from FS_ME_award",User_Conn,1,3
  36. awardRs.addNew
  37. awardRs("AwardName")=AwardName
  38. awardRs("AwardPic")=AwardPic
  39. awardRs("StartDate")=StartDate
  40. awardRs("EndDate")=EndDate
  41. awardRs("PrizeIDS")=CurrentPrizeIDS
  42. awardRs("opened")=0
  43. awardRs.update
  44. awardRs.close
  45. if err.number=0 then
  46. Response.Redirect("../success.asp?ErrCodes=<li>操作成功</li>&ErrorURL=user/award.asp")
  47. Response.End()
  48. end if
  49. elseif request.QueryString("act")="delete" then
  50. if not MF_Check_Pop_TF("ME029") then Err_Show 
  51. User_Conn.Execute("Delete From FS_ME_Award where awardid in ("&request.Form("DeleteAwards")&")")
  52. if err.number=0 then
  53. Response.Redirect("../success.asp?ErrCodes=<li>操作成功</li>&ErrorURL=user/award.asp")
  54. Response.End()
  55. end if
  56. elseif Request.QueryString("act")="editaction" then
  57. Set awardRs=Server.CreateObject(G_FS_RS)
  58. Set prizeRs=Server.CreateObject(G_FS_RS)
  59. AwardName=Request.Form("AwardName")
  60. AwardPic=Request.Form("AwardPic")
  61. StartDate=Request.Form("StartDate")
  62. EndDate=Request.Form("EndDate")
  63. PrizeGradeNum=Request.Form("PrizeGradeNum")
  64. '添加奖品
  65. for ForIndex=0 to PrizeGradeNum-1
  66. PrizeName=Request.Form("Prize_"&(ForIndex+1)&"_name")
  67. PrizeGrade=ForIndex+1
  68. prizeNeedPoint=Request.Form("NeedPoint_"&(ForIndex+1))
  69. PrizePic=Request.Form("prize_"&(ForIndex+1)&"_pic")
  70. PrizeNum=Request.Form("prize_"&(ForIndex+1)&"_number")
  71. if PrizeName="" or PrizeNum="" or not isnumeric(PrizeNum) then
  72. Response.Redirect("../error.asp?ErrCodes=<li>奖品名称可能为空</li><li>奖品数量可能为空</li><li>奖品数量中可能包含有字符</li>")
  73. Response.End()
  74. end if
  75. Set prizeRs=User_Conn.Execute("insert into FS_ME_Prize (PrizeName,NeedPoint,PrizeGrade,PrizePic,PrizeNum) values('"&PrizeName&"',"&prizeNeedPoint&","&PrizeGrade&",'"&PrizePic&"',"&PrizeNum&")")
  76. CurrentPrizeIDS=CurrentPrizeIDS&","&User_Conn.Execute("Select Max(PrizeID) from FS_ME_Prize")(0)
  77. next
  78. CurrentPrizeIDS=DelHeadAndEndDot(CurrentPrizeIDS)
  79. Response.Write("select AwardName,AwardPic,StartDate,EndDate,PrizeIDS,opened from FS_ME_award where awardid="&NoSqlHack(Request.QueryString("awardid")))
  80. awardRs.open "select AwardName,AwardPic,StartDate,EndDate,PrizeIDS,opened from FS_ME_award where awardid="&NoSqlHack(Request.QueryString("awardid")),User_Conn,1,3
  81. awardRs("AwardName")=AwardName
  82. awardRs("AwardPic")=AwardPic
  83. awardRs("StartDate")=StartDate
  84. awardRs("EndDate")=EndDate
  85. Response.Write("Delete From FS_ME_Prize where prizeid in("&awardRs("PrizeIDS")&")")
  86. User_Conn.execute("Delete From FS_ME_Prize where prizeid in("&awardRs("PrizeIDS")&")")
  87. awardRs("PrizeIDS")=CurrentPrizeIDS
  88. awardRs("opened")=0
  89. awardRs.update
  90. awardRs.close
  91. if err.number=0 then
  92. Response.Redirect("../success.asp?ErrCodes=<li>操作成功</li>&ErrorURL=user/award.asp")
  93. Response.End()
  94. end if
  95. elseif Request.QueryString("Act")="editPrizeaction" then
  96. Set prizeRs=Server.CreateObject(G_FS_RS)
  97. prizeRS.open  "select prizeID,PrizeName,prizeDesc,PrizePic,NeedPoint,storage,StartDate,EndDate,provider,perUserNum from FS_ME_Prize where prizeID="&NoSqlHack(request.QueryString("prizeid")),User_Conn,1,3
  98. prizeRS("PrizeName")=Request.Form("PrizeName")
  99. prizeRS("prizeDesc")=Request.Form("prizeDesc")
  100. prizeRS("NeedPoint")=Request.Form("NeedPoint")
  101. prizeRS("storage")=Request.Form("storage")
  102. prizeRS("StartDate")=Request.Form("StartDate")
  103. prizeRS("EndDate")=Request.Form("EndDate")
  104. prizeRS("provider")=Request.Form("provider")
  105. prizeRS("perUserNum")=Request.Form("perUserNum")
  106. prizeRs("PrizePic")=request.Form("PrizePic")
  107. prizeRs.update
  108. prizeRs.close
  109. if err.number=0 then
  110. Response.Redirect("../success.asp?ErrCodes=<li>操作成功</li>&ErrorURL=user/ChangePrize.asp")
  111. Response.End()
  112. end if
  113. elseif Request.QueryString("Act")="addPrizeaction" then
  114. Set prizeRs=Server.CreateObject(G_FS_RS)
  115. prizeRS.open  "select prizeID,PrizeName,prizeDesc,PrizePic,NeedPoint,storage,StartDate,EndDate,provider,perUserNum,isChange from FS_ME_Prize ",User_Conn,1,3
  116. prizeRs.addnew
  117. prizeRS("PrizeName")=Request.Form("PrizeName")
  118. prizeRS("prizeDesc")=Request.Form("prizeDesc")
  119. prizeRS("NeedPoint")=Request.Form("NeedPoint")
  120. prizeRS("storage")=Request.Form("storage")
  121. prizeRS("StartDate")=Request.Form("StartDate")
  122. prizeRS("EndDate")=Request.Form("EndDate")
  123. prizeRS("provider")=Request.Form("provider")
  124. prizeRS("perUserNum")=Request.Form("perUserNum")
  125. prizeRS("isChange")=1
  126. prizeRs("PrizePic")=request.Form("PrizePic")
  127. prizeRs.update
  128. prizeRs.close
  129. if err.number=0 then
  130. Response.Redirect("../success.asp?ErrCodes=<li>操作成功</li>&ErrorURL=user/ChangePrize.asp")
  131. Response.End()
  132. end if
  133. elseif Request.QueryString("Act")="deletePrizeaction" then
  134. User_Conn.Execute("Update FS_ME_Prize set isChange=0 where PrizeID in ("&Request.Form("DeleteChangePrize")&")")
  135. if err.number=0 then
  136. Response.Redirect("../success.asp?ErrCodes=<li>操作成功</li>&ErrorURL=user/ChangePrize.asp")
  137. Response.End()
  138. end if
  139. elseif Request("Act")="editAFPointaction" then
  140. Set awardRs=Server.CreateObject(G_FS_RS)
  141. awardRs.open "Select ATopic,needPoint,PrizePoint,APic,ADesc,AStartDate,AEndDate,AnswerIDS,RightAnswerID from FS_ME_AnswerForPoint where Aid="&NoSqlHack(Request.QueryString("AID")),User_Conn,1,3
  142. awardRs("ATopic")=Request.Form("ATopic")
  143. awardRs("needPoint")=Request.Form("needPoint")
  144. awardRs("PrizePoint")=Request.Form("PrizePoint")
  145. awardRs("APic")=Request.Form("APic")
  146. awardRs("ADesc")=Request.Form("ADesc")
  147. awardRs("AStartDate")=Request.Form("StartDate")
  148. awardRs("AEndDate")=Request.Form("EndDate")
  149. answerNum=Request.Form("AnswerNum")
  150. RightAnswer=Request.Form("rightAnswer")
  151. for ForIndex=0 to answerNum-1
  152. AnswerDesc=Request.Form("Answer_"&(ForIndex+1))
  153. if AnswerDesc="" then
  154. Response.Redirect("../error.asp?ErrCodes=<li>答案内容为空</li>")
  155. Response.End()
  156. end if
  157. User_Conn.Execute("Insert into FS_ME_Answer (AnswerDesc) values('"&AnswerDesc&"')")
  158. CurrentAnswerID=User_Conn.execute("select Max(answerid) from FS_ME_Answer")(0)
  159. if (ForIndex+1)=Cint(RightAnswer) then
  160. awardRs("RightAnswerID")=CurrentAnswerID
  161. end if
  162. CurrentAnswerIDS=CurrentAnswerIDS&","&CurrentAnswerID
  163. next
  164. User_Conn.execute("Delete From FS_ME_Answer where AnswerID in ("&awardRs("AnswerIDS")&")")
  165. awardRs("AnswerIDS")=DelHeadAndEndDot(CurrentAnswerIDS)
  166. awardRs.update
  167. awardRs.close
  168. if err.number=0 then
  169. Response.Redirect("../success.asp?ErrCodes=<li>操作成功</li>&ErrorURL=user/AnswerForPoint.asp")
  170. Response.End()
  171. end if
  172. elseif Request.QueryString("Act")="addAFPointaction" then
  173. Set awardRs=Server.CreateObject(G_FS_RS)
  174. awardRs.open "Select ATopic,needPoint,PrizePoint,APic,ADesc,AStartDate,AEndDate,AnswerIDS,RightAnswerID from FS_ME_AnswerForPoint",User_Conn,1,3
  175. awardRs.addNew
  176. awardRs("ATopic")=Request.Form("ATopic")
  177. awardRs("needPoint")=Request.Form("needPoint")
  178. awardRs("PrizePoint")=Request.Form("PrizePoint")
  179. awardRs("APic")=Request.Form("APic")
  180. awardRs("ADesc")=Request.Form("ADesc")
  181. awardRs("AStartDate")=Request.Form("StartDate")
  182. awardRs("AEndDate")=Request.Form("EndDate")
  183. answerNum=Request.Form("AnswerNum")
  184. RightAnswer=Request.Form("rightAnswer")
  185. for ForIndex=0 to answerNum-1
  186. AnswerDesc=Request.Form("Answer_"&(ForIndex+1))
  187. if AnswerDesc="" then
  188. Response.Redirect("../error.asp?ErrCodes=<li>答案内容为空</li>")
  189. Response.End()
  190. end if
  191. User_Conn.Execute("Insert into FS_ME_Answer (AnswerDesc) values('"&AnswerDesc&"')")
  192. CurrentAnswerID=User_Conn.execute("select Max(answerid) from FS_ME_Answer")(0)
  193. if (ForIndex+1)=Cint(RightAnswer) then
  194. awardRs("RightAnswerID")=CurrentAnswerID
  195. end if
  196. CurrentAnswerIDS=CurrentAnswerIDS&","&CurrentAnswerID
  197. next
  198. awardRs("AnswerIDS")=DelHeadAndEndDot(CurrentAnswerIDS)
  199. Response.Write(DelHeadAndEndDot(CurrentAnswerIDS))
  200. awardRs.update
  201. awardRs.close
  202. if err.number=0 then
  203. Response.Redirect("../success.asp?ErrCodes=<li>操作成功</li>&ErrorURL=user/AnswerForPoint.asp")
  204. Response.End()
  205. end if
  206. elseif Request.QueryString("Act")="deleteAFPointaction" then
  207. CurrentAnswerIDS=User_Conn.execute("Select AnswerIDS From FS_ME_AnswerForPoint where AID in ("&Request("DeleteAFPoint")&")")(0)
  208. User_Conn.execute("Delete From FS_ME_Answer where answerid in ("&CurrentAnswerIDS&")")
  209. User_Conn.execute("Delete From FS_ME_AnswerForPoint where AID in ("&Request("DeleteAFPoint")&")")
  210. if err.number=0 then
  211. Response.Redirect("../success.asp?ErrCodes=<li>操作成功</li>&ErrorURL=user/AnswerForPoint.asp")
  212. Response.End()
  213. end if
  214. elseif request.QueryString("Act")="open" then
  215. if not MF_Check_Pop_TF("ME030") then Err_Show 
  216. Dim awardID,resultRs,prizeNumber
  217. awardID=NoSqlHack(request.QueryString("awardiD"))
  218. Set awardRs=User_Conn.execute("Select prizeID from FS_ME_User_Prize where awardID="&awardID)
  219. while not awardRs.eof
  220. Set prizeRs=User_Conn.execute("Select PrizeNum from FS_ME_Prize where prizeID="&awardRs("prizeID"))
  221. if not PrizeRs.eof then
  222. prizeNumber=prizeRs("PrizeNum")
  223. if G_IS_SQL_DB=0 then
  224. Randomize
  225. Response.Write(awardRs("prizeID"))
  226. Set resultRs=User_Conn.execute("Select top "&prizeNumber&" id from FS_ME_User_Prize order by Rnd(-(ID+"&Rnd()&"))")
  227. Else
  228. Set resultRs=User_Conn.execute("Select top "&prizeNumber&" id from FS_ME_User_Prize order BY NEWID()")
  229. End if
  230. while not resultRs.eof
  231. User_Conn.execute("Update FS_ME_User_Prize set winner=1 where id="&resultRs("id"))
  232. resultRs.movenext
  233. wend
  234. ENd if
  235. awardRs.movenext
  236. wend
  237. awardRs.close
  238. User_Conn.execute("Update FS_ME_Award set opened=1 where awardid="&awardid)
  239. Set awardRs=nothing
  240. Set resultRs=nothing
  241. if err.number=0 then
  242. Response.Redirect("../success.asp?ErrCodes=<li>操作成功</li>&ErrorURL=user/award.asp")
  243. Response.End()
  244. end if
  245. elseif request.QueryString("Act")="deleteresult" then
  246. prizeID=NoSqlHack(request("prizeid"))
  247. usernumber=NoSqlHack(request("usernumber"))
  248. if trim(prizeID)<>"" And  trim(usernumber)<>"" then
  249. User_Conn.execute("Delete from FS_ME_User_Prize where prizeid="&prizeid&" and usernumber='"&usernumber&"'")
  250. End if
  251. response.Write("ok")
  252. Response.End()
  253. end if
  254. if err.number>0 then
  255. Response.Redirect("../error.asp?ErrCodes=<li>"&err.description&"</li>")
  256. Response.End()
  257. end if
  258. Set awardRs=nothing
  259. Set prizeRs=nothing
  260. Conn.close
  261. User_Conn.close
  262. Set Conn=nothing
  263. Set User_Conn=nothing
  264. %>