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

数据库编程

开发平台:

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. <!--#include file="../../FS_Inc/Func_page.asp" -->
  6. <%'Copyright (c) 2006 Foosun Inc. Code by Einstein.Liu
  7. 'on error resume next
  8. Dim Conn,User_Conn,awardRs,prizeIDs,EndDate,awardUser,AwardID,ArrayIndex,AwardsUserArray,UserInfoRs,AwardsUserRs
  9. Dim int_RPP,int_Start,int_showNumberLink_,str_nonLinkColor_,toF_,toP10_,toP1_,toN1_,toN10_,toL_,showMorePageGo_Type_,cPageNo,i
  10. int_RPP=20 '设置每页显示数目
  11. int_showNumberLink_=8 '数字导航显示数目
  12. showMorePageGo_Type_ = 1 '是下拉菜单还是输入值跳转,当多次调用时只能选1
  13. str_nonLinkColor_="#999999" '非热链接颜色
  14. toF_="<font face=webdings title=""首页"">9</font>"   '首页 
  15. toP10_=" <font face=webdings title=""上十页"">7</font>" '上十
  16. toP1_=" <font face=webdings title=""上一页"">3</font>" '上一
  17. toN1_=" <font face=webdings title=""下一页"">4</font>" '下一
  18. toN10_=" <font face=webdings title=""下十页"">8</font>" '下十
  19. toL_="<font face=webdings title=""最后一页"">:</font>" '尾页
  20. MF_Default_Conn
  21. MF_User_Conn
  22. MF_Session_TF
  23. Set awardRs=Server.CreateObject(G_FS_RS)
  24. awardRs.open "select AwardID,AwardName,AwardPic,StartDate,EndDate,PrizeIDS,Opened from FS_ME_award",User_Conn,1,1
  25. '积分抽奖
  26. function activeAward()
  27. Dim active_TF_Rs,sql_cmd,activeTF
  28. activeTF=false
  29. sql_cmd="select AwardID from FS_ME_award where opened=0"
  30. Set active_TF_Rs=User_Conn.execute(sql_cmd)
  31. if not active_TF_Rs.eof then
  32. activeTF=true
  33. End if
  34. activeAward=activeTF
  35. active_TF_Rs.close
  36. set active_TF_Rs=Nothing
  37. End function
  38. '积分兑换
  39. Function activeAwardPoint
  40. Dim active_TF_Rs,sql_cmd,activeTF
  41. activeTF=false
  42. if  G_IS_SQL_DB=0 then
  43. sql_cmd="select AID from FS_ME_AnswerForPoint where DateDiff(d,Convert(nvarchar(10),AEndDate,120),#"&DateValue(Now)&"#)>0"
  44. Else
  45. sql_cmd="select AID from FS_ME_AnswerForPoint where DateDiff('d',Convert(nvarchar(10),AEndDate,120),'"&DateValue(Now)&"')>0"
  46. End if
  47. Set active_TF_Rs=User_Conn.execute(sql_cmd)
  48. if not active_TF_Rs then
  49. activeTF=true
  50. End if
  51. activeAwardPoint=activeTF
  52. active_TF_Rs.close
  53. set active_TF_Rs=nothing
  54. End function
  55. %>
  56. <html xmlns="http://www.w3.org/1999/xhtml">
  57. <HEAD>
  58. <TITLE>FoosunCMS</TITLE>
  59. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
  60. </HEAD>
  61. <script language="JavaScript" src="../../FS_Inc/PublicJS.js" type="text/JavaScript"></script>
  62. <script language="JavaScript" src="lib/UserJS.js" type="text/JavaScript"></script>
  63. <link href="../images/skin/Css_<%=Session("Admin_Style_Num")%>/<%=Session("Admin_Style_Num")%>.css" rel="stylesheet" type="text/css">
  64. <BODY>
  65. <table width="98%" border="0" align="center" cellpadding="5" cellspacing="1" class="table">
  66.   <tr> 
  67.     <td class="xingmu">抽奖管理</td>
  68.   </tr>
  69.   <tr>
  70.     <td class="hback">积分抽奖&nbsp;|&nbsp;<a href="ChangePrize.asp">积分兑换</a> | <a href="AnswerForPoint.asp">积分竞答</a> 
  71.       | <a href="#" onClick="history.back()">后退</a></td>
  72.   </tr>
  73. </table>
  74. <table width="98%" border="0" align="center" cellpadding="5" cellspacing="1" class="table">
  75.   <form action="awardAction.asp?act=delete" method="post" name="awardForm" id="awardForm">
  76.     <tr class="xingmu"> 
  77.       <td width="16%" align="center">主题</td>
  78.       <td width="30%" align="center">中奖会员</td>
  79.       <td width="11%" align="center">状态</td>
  80.       <td width="17%" align="center">截止时间</td>
  81.       <td width="14%" align="center"><input type="checkbox" name="Delete_CheckAll" value="all" onClick="CheckAll(this,'DeleteAwards')"></td>
  82.     </tr>
  83.     <%
  84. if not awardRs.eof then
  85. awardRs.PageSize=int_RPP
  86. cPageNo=NoSqlHack(Request.QueryString("Page"))
  87. If cPageNo="" Then cPageNo = 1
  88. If not isnumeric(cPageNo) Then cPageNo = 1
  89. cPageNo = Clng(cPageNo)
  90. If cPageNo>awardRs.PageCount Then cPageNo=awardRs.PageCount 
  91. If cPageNo<=0 Then cPageNo=1
  92. awardRs.AbsolutePage=cPageNo
  93. end if
  94. for i=0 to int_RPP
  95. if awardRs.eof then exit for
  96. Response.Write("<tr class='hback'>"&chr(10)&chr(13)) 
  97. Response.Write("<td width='30%' align='center'><a href='award_AddEdit.asp?act=edit&awardid="&awardRs("awardID")&"'>"&awardRs("awardName")&"</a></td>"&chr(10)&chr(13))
  98. Response.Write("<td width='20%'>")
  99. Response.Write("<select name='Grade_"&awardRs("AwardID")&"' onchange=""getAwardUser('"&awardRs("AwardID")&"',this.value)"">")
  100. prizeIDs=split(awardRs("prizeIDs"),",")
  101. for ArrayIndex=0 to Ubound(prizeIDs)
  102. Response.Write("<option value='"&prizeIDs(ArrayIndex)&"'>"&(ArrayIndex+1)&"等奖</option>"&chr(10)&chr(13))
  103. next
  104. Response.Write("</select>")
  105. Response.Write(" | <span id='PrizeUsers_"&awardRs("awardID")&"'>"&chr(10)&chr(13))
  106. Response.Write("<select name='AwardUsers_"&AwardID&"'>"&chr(10)&chr(13))
  107. Set AwardsUserRs=User_Conn.execute("Select UserNumber,winner From FS_ME_User_Prize where PrizeID="&prizeIDs(0)&" And awardID="&awardRs("awardID")&" and winner=1")
  108. if not AwardsUserRs.eof then
  109. while not AwardsUserRs.eof  
  110. Set UserInfoRs=User_Conn.execute("Select UserName from FS_ME_Users where UserNumber='"&AwardsUserRs("UserNumber")&"'")
  111. Response.Write("<option value='"&AwardsUserRs("UserNumber")&"'>"&UserInfoRs("UserName")&"</option>"&Chr(10)&Chr(13))
  112. AwardsUserRs.movenext
  113. Wend
  114. ELse
  115. Response.Write("<option value='-1'>暂无中奖</option>"&Chr(10)&Chr(13))
  116. End if
  117. AwardsUserRs.close
  118. Set AwardsUserRs=nothing
  119. Set UserInfoRs=nothing
  120. Response.Write("</span>")
  121. Response.Write("</td>")
  122. EndDate=awardRs("EndDate")
  123. if awardRs("Opened")=1 then
  124. Response.Write("<td align='center'>已过期</td>")
  125. Elseif DateValue(EndDate)=DateValue(Now()) Then
  126. Response.Write("<td align='center'><button onClick=""openAward("&awardRs("AwardID")&")"">开  奖</button></td>")
  127. ElseIf DateValue(EndDate)<DateValue(Now()) And awardRs("Opened")=0 then
  128. Response.Write("<td align='center'><button onClick=""openAward("&awardRs("AwardID")&")"">已过期,请开奖</button>")
  129. Else
  130. Response.Write("<td align='center'><font color=""red"">未过期</font></td>")
  131. end If
  132. Response.Write("<td align='center'>"&EndDate&"</td>")
  133. Response.Write("<td align='center'><input type='checkbox' name='DeleteAwards' value='"&awardRs("AwardID")&"'></td>")
  134. Response.Write("</tr>")
  135. awardRs.movenext
  136. next
  137. %>
  138.   </form>
  139.   <tr> 
  140.     <td align="right" colspan="6" class="hback">
  141. <%
  142. Dim displayTF
  143. if activeAward then
  144. displayTF="disabled"
  145. End if
  146. %>
  147. <input name="AddAward" type="button" value="添 加" onClick="location='award_AddEdit.asp?act=add'" <%=displayTF%>> 
  148.       <input type="Button" name="deleteAwards" onClick="AlertBeforeSubmite()" value="删 除"> 
  149.       <%
  150. response.Write fPageCount(awardRs,int_showNumberLink_,str_nonLinkColor_,toF_,toP10_,toP1_,toN1_,toN10_,toL_,showMorePageGo_Type_,cPageNo)
  151. %>
  152.     </td>
  153.   </tr>
  154. </table> 
  155. </body>
  156. <%
  157. if Request.QueryString("Act")="addGroup" then
  158. AddGroupRs.close
  159. set AddGroupRs=nothing
  160. Conn.close
  161. Set Conn=nothing
  162. User_Conn.close
  163. Set User_Conn=nothing
  164. end if
  165. %>
  166. <script language="JavaScript" type="text/JavaScript">
  167. var request=true;
  168. var result;
  169. try
  170. {
  171. request=new XMLHttpRequest();
  172. }catch(trymicrosoft)
  173. {
  174. try
  175. {
  176. request=new ActiveXObject("Msxml2.XMLHTTP")
  177. }catch(othermicrosoft)
  178. {
  179. try
  180. {
  181. request=new ActiveXObject("Microsoft.XMLHTTP")
  182. }catch(filed)
  183. {
  184. request=false;
  185. }
  186. }
  187. }
  188. if(!request) alert("Error initializing XMLHttpRequest!");
  189. function getAwardUser(Obj1,Obj2)
  190. {
  191. var url="getAwardUser.asp?AwardId="+Obj1+"&PrizeID="+Obj2+"&r="+Math.random();//构造url
  192. request.open("GET",url,true);//建立连接
  193. request.onreadystatechange = getResult;
  194. request.send(null);//传送数据,因为数据通过url传递了,所以这里传递的是nulla
  195. }
  196. function getResult(Obj)//当服务器响应的时候就使用这个方法
  197. {
  198. if(request.readyState ==4)//根据HTTP 就绪状态判断响应是否完成
  199. {
  200. if(request.status == 200)//判断请求是否成功
  201. {
  202. result=request.responseText;//获得响应的结果,也就是新的<select>
  203. var contaner=result.substring(0,result.indexOf("*"));
  204. var selectContent=result.substring(result.indexOf("*")+1,result.length);
  205. document.getElementById(contaner).innerHTML=selectContent;
  206. }
  207. }
  208. }
  209. function CheckAll(Obj,TargetName)
  210. {
  211. var CheckBoxArray;
  212. CheckBoxArray=document.getElementsByName(TargetName);
  213. for(var i=0;i<CheckBoxArray.length;i++)
  214. {
  215. if(Obj.checked)
  216. {
  217. CheckBoxArray[i].checked=true;
  218. }
  219. else
  220. {
  221. CheckBoxArray[i].checked=false;
  222. }
  223. }
  224. }
  225. function AlertBeforeSubmite()
  226. {
  227. var checkGroup=document.awardForm.DeleteAwards;
  228. var flag=false;
  229. for(var i=0;i<checkGroup.length;i++)
  230. {
  231. if(checkGroup[i].checked)
  232. {
  233. flag=true;
  234. }
  235. }
  236. if(flag)
  237. {
  238. if(confirm("确认要删除该记录?该操作将会删除用户中奖记录!"))
  239. {
  240. document.awardForm.submit();
  241. }
  242. }else
  243. {
  244. alert("请选择要删除的记录")
  245. }
  246. }
  247. function openAward(awardID)
  248. {
  249. location="awardAction.asp?act=open&awardID="+awardID+"&rnd="+Math.random();
  250. }
  251. </script>
  252. </html>