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

数据库编程

开发平台:

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. <%
  6. 'on error resume next
  7. Dim Conn,User_Conn,OperateDebateRs,DebateID,title,content,ParentID,parentIDRs,Classid,AppointUserNumber,AppointUserGroup,isLock,AccessFile,TopicRs,TopicRs1,TopicRs2,ClassRs,UserGroupRs,CorpGroupRs,ArrayCount,selectedTF,currentTopicRs,i,ChildDebateArray
  8. Admin_Login_State
  9. MF_Default_Conn
  10. MF_User_Conn
  11. MF_Session_TF
  12. AppointUserGroup=null
  13. function getChildID(ID,self)
  14. Dim F_Rs,F_ChildID
  15. Set F_Rs=User_Conn.Execute("select DebateID,ParentID from FS_ME_GroupDebate where parentID="&ID)
  16. while not F_Rs.eof
  17. F_ChildID=F_Rs("DebateID")&","&getChildID(F_Rs("DebateID"),false)
  18. F_Rs.movenext
  19. wend
  20. F_Rs.close
  21. Set F_Rs=nothing
  22. if self then
  23. getChildID=ID&","&F_ChildID
  24. else
  25. getChildID=F_ChildID
  26. end if
  27. end function
  28. function getParentNum(parentID)
  29. Dim F_Parent_Count,F_Rs
  30. F_Parent_Count=1
  31. if not isnumeric(parentID) then exit function
  32. Set F_Rs=User_Conn.execute("Select DebateID,ParentID from FS_ME_GroupDebate where DebateID="&parentID)
  33. if not F_Rs.eof then
  34. F_Parent_Count=F_Parent_Count+getParentNum(F_Rs("ParentID"))
  35. end if
  36. F_Rs.close
  37. Set F_Rs=nothing
  38. getParentNum=F_Parent_Count
  39. end function
  40. '************************************Update
  41. if Request.QueryString("Act")="edit" then'修改界面
  42. DebateID=Request.QueryString("DebateID")
  43. Set OperateDebateRs=server.CreateObject(G_FS_RS)
  44. OperateDebateRs.open "select DebateID,title,content,addtime,ParentID,classid,AppointUserNumber,AppointUserGroup,AddTime,isLock,AccessFile from FS_ME_GroupDebate where DebateID="&DebateID,User_Conn,1,3
  45. if not OperateDebateRs.eof then
  46. title=OperateDebateRs("title")
  47. content=OperateDebateRs("content")
  48. ParentID=OperateDebateRs("ParentID")
  49. classid=OperateDebateRs("classid")
  50. AppointUserNumber=OperateDebateRs("AppointUserNumber")
  51. if OperateDebateRs("AppointUserGroup")<>"" then
  52. AppointUserGroup=split(OperateDebateRs("AppointUserGroup"),",")
  53. end if
  54. isLock=OperateDebateRs("isLock")
  55. AccessFile=OperateDebateRs("AccessFile")
  56. end if
  57. elseif Request.QueryString("Act")="EditDebate" then'修改动作
  58. if Request.Form("currentValue")<>"" then
  59. parentID=Request.Form("currentValue")
  60. elseif Request.Form("topic2")<>"" then
  61. parentID=Request.Form("topic2")
  62. elseif Request.Form("topic1")<>"" then
  63. parentID=Request.Form("topic1")
  64. elseif Request.Form("topic")<>"" then
  65. parentID=Request.Form("topic")
  66. end if 
  67. if request.Form("userGroup")="" and Request.Form("corpGroup")<>"" then
  68. AppointUserGroup=Request.Form("corpGroup")
  69. elseif request.Form("userGroup") <> "" and Request.Form("corpGroup")="" then
  70. AppointUserGroup=Request.Form("userGroup")
  71. elseif request.Form("userGroup") <> "" and Request.Form("corpGroup")<>"" then
  72. AppointUserGroup=trim(request.Form("userGroup"))&","&trim(Request.Form("corpGroup"))
  73. end if
  74. '****************验证修改数据的合理性
  75. ChildDebateArray=split(DelHeadAndEndDot(getChildID(NoSqlHack(Request("DebateID")),true)),",")
  76. for i=0 to Ubound(ChildDebateArray)
  77. if parentID=ChildDebateArray(i) then
  78. Response.Redirect("../error.asp?ErrCodes=<li>1.自己不能是自己的父类</li><li>2.自己的子类不能作为父类</li>")
  79. Response.End()
  80. end if
  81. next
  82.  if getParentNum(parentID)+Ubound(ChildDebateArray)>4 then
  83. Response.Redirect("../error.asp?ErrCodes=<li>总层级数不能大于4</li>")
  84. Response.End()
  85.  end if
  86. '****************************************
  87. User_Conn.Execute("Update FS_ME_GroupDebate set title='"&Request.Form("title")&"',content='"&Request.Form("Content")&"',parentid="&parentid&",classid="&Request.Form("DebateClass")&",AppointUserNumber='"&Request.Form("AppointUserNumber")&"',AppointUserGroup='"&AppointUserGroup&"',addtime='"&Now()&"',isLock="&Request.Form("isLock")&",AccessFile='"&Request.Form("AccessFile")&"' where DebateID="&NoSqlHack(Request("DebateID")))
  88. if err.number>0 then
  89. Response.Redirect("../error.asp?ErrCodes="&err.description&"&ErrorUrl=./user/GroupDebate_manage.asp")
  90. Response.End()
  91. else
  92. Response.Redirect("../success.asp?ErrCodes=<li>操作成功</li>&ErrorUrl=./user/GroupDebate_manage.asp")
  93. Response.End()
  94. end if
  95. elseif Request("Act")="AddDebate" then'添加动作
  96. Set OperateDebateRs=server.CreateObject(G_FS_RS)
  97. if Request("currentValue")<>"" then
  98. parentID=Request("currentValue")
  99. elseif Request("topic2")<>"" then
  100. parentID=Request("topic2")
  101. elseif Request("topic1")<>"" then
  102. parentID=Request("topic1")
  103. elseif Request("topic")<>"" then
  104. parentID=Request("topic")
  105. end if 
  106. if request.Form("userGroup")="" and Request.Form("corpGroup")<>"" then
  107. AppointUserGroup=Request.Form("corpGroup")
  108. elseif request.Form("userGroup") <> "" and Request.Form("corpGroup")="" then
  109. AppointUserGroup=Request.Form("userGroup")
  110. elseif request.Form("userGroup") <> "" and Request.Form("corpGroup")<>"" then
  111. AppointUserGroup=trim(request.Form("userGroup"))&","&trim(Request.Form("corpGroup"))
  112. end if
  113. OperateDebateRs.open "select title,content,ParentID,ClassID,addtime,AppointUserNumber,AppointUserGroup,isLock,AccessFile from FS_ME_GroupDebate",User_Conn,1,3
  114. OperateDebateRs.addNew
  115. OperateDebateRs("title")=Request.Form("title")
  116. OperateDebateRs("content")=Request.Form("Content")
  117. OperateDebateRs("ParentID")=parentID
  118. OperateDebateRs("ClassID")=Request.Form("DebateClass")
  119. OperateDebateRs("addtime")=Now()
  120. if Request.Form("AppointUserNumber")<>"" then
  121. OperateDebateRs("AppointUserNumber")=Request.Form("AppointUserNumber")
  122. end if
  123. if AppointUserGroup<>"" then
  124. OperateDebateRs("AppointUserGroup")=AppointUserGroup
  125. end if
  126. OperateDebateRs("islock")=Request.Form("islock")
  127. OperateDebateRs("AccessFile")=Request.Form("AccessFile")
  128. OperateDebateRs.update
  129. OperateDebateRs.close
  130. if err.number>0 then
  131. Response.Redirect("../error.asp?ErrCodes="&err.description&"&ErrorUrl=./user/GroupDebate_manage.asp")
  132. Response.End()
  133. else
  134. Response.Redirect("../success.asp?ErrCodes=<li>操作成功</li>&ErrorUrl=./user/GroupDebate_manage.asp")
  135. Response.End()
  136. end if
  137. end if
  138. %>
  139. <html xmlns="http://www.w3.org/1999/xhtml">
  140. <HEAD>
  141. <TITLE>FoosunCMS</TITLE>
  142. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
  143. </HEAD>
  144. <script language="JavaScript" src="../../FS_Inc/PublicJS.js" type="text/JavaScript"></script>
  145. <script language="JavaScript" src="lib/UserJS.js" type="text/JavaScript"></script>
  146. <link href="../images/skin/Css_<%=Session("Admin_Style_Num")%>/<%=Session("Admin_Style_Num")%>.css" rel="stylesheet" type="text/css">
  147. <BODY LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 scroll=yes  oncontextmenu="return false;"> 
  148. <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table"> 
  149. <%
  150. if Request.QueryString("Act")="edit" then
  151. Response.Write("<form action='?Act=EditDebate&DebateID="&DebateID&"' method='post' name='operateDebate' id='operateDebate'>")
  152. elseif Request.QueryString("Act")="add" or Request.QueryString("Act")="AddChild" then
  153. Response.Write("<form action='?Act=AddDebate' method='post' name='operateDebate' id='operateDebate'>")
  154. end if
  155. %>
  156.   <tr class="hback"> 
  157.     <td align="right" class="xingmu" ><div align="left">社群管理</div></td>
  158. <td align="right" class="xingmu"><div align="right"><a href="GroupDebate_manage.asp">返回</a></div></td>
  159. </tr> 
  160.         <tr class="hback"> 
  161.           <td align="right">社群主题:</td> 
  162.           <td width="631"> <input name="Title" type="text" id="Title" value="<%=title%>" size="50" />
  163.           <font color="#FF0000">*</font><span id="Title_Alert"></span> </td> 
  164.         </tr>      
  165. <tr class="hback">
  166.     <td align="right">讨论内容: </td>
  167.     <td>    <textarea name="Content" cols="80" rows="10" id="Content"><%=content%></textarea>
  168.     <font color="#FF0000">*</font><span id="Content_Alert"></span></td>
  169.   </tr>
  170. <tr class="hback">
  171.   <td align="right">所属主题:</td>
  172.   <td>
  173.   <%
  174. if Request.QueryString("act")<>"AddChild" then
  175. Set TopicRs=User_Conn.Execute("Select DebateID,Title,ParentID from FS_ME_GroupDebate where ParentID=0 order by addtime desc")
  176. Response.Write("<select name='Topic' id='topic' onchange=""getDebate(this,'Topic1')"">"&Chr(10)&Chr(13))
  177. Response.Write("<option value=''>请选择一级主题</option>")
  178. Response.Write("<option value='0'>一级主题</option>")
  179. while not TopicRs.eof
  180. Response.Write("<option value='"&TopicRs("DebateID")&"'>"&TopicRs("title")&"</option>")
  181. TopicRs.movenext
  182. wend
  183. Response.Write("</select>")
  184. end if
  185.   %>
  186.   <span id="Topic1_Container">
  187.   </span>&nbsp;
  188.   <span id="Topic2_Container">
  189.   </span>
  190.   <span id="current">
  191. <%
  192. Response.Write("<select name='currentValue' id='currentValue' size='1' multiple>")
  193. if Request.QueryString("act")="AddChild" then
  194. Set currentTopicRs=User_Conn.Execute("Select DebateID,title from FS_ME_Groupdebate where  DebateID="&Request.QueryString("DebateID"))
  195. if not currentTopicRs.eof then
  196. ParentID=currentTopicRs("DebateID")
  197. if ParentID=0 then
  198. Response.Write("<option value='0' selected>一级主题</option>")
  199. else
  200. Response.Write("<option value='"&ParentID&"' selected>"&currentTopicRs("title")&"</option>")
  201. end if
  202. end if
  203. else
  204. if ParentID=0 then
  205. Response.Write("<option value='0' selected>一级主题</option>")
  206. else
  207. Response.Write("<option value='"&ParentID&"' selected>"&User_Conn.execute("select title from FS_ME_Groupdebate where DebateID="&ParentID)(0)&"</option>")
  208. end if
  209. end if
  210. Response.Write("</select>")
  211. %>
  212.   </span>
  213.   </td>
  214. </tr>
  215. <tr class="hback"> 
  216. <td align="right">所属分类:</td> 
  217.     <td>
  218.   <%
  219.    i=0
  220. Set ClassRs=User_Conn.Execute("Select ClassID,Title from FS_ME_GroupDebateClass")
  221. Response.Write("<select name='DebateClass'>"&Chr(10)&Chr(13))
  222. while not ClassRs.eof
  223. if classid=ClassRs("ClassID") then
  224. Response.Write("<option value='"&ClassRs("ClassID")&"' selected>"&ClassRs("title")&"</option>")
  225. else
  226. Response.Write("<option value='"&ClassRs("ClassID")&"'>"&ClassRs("title")&"</option>")
  227. end if
  228. ClassRs.movenext
  229. wend
  230.   %>
  231. </td> 
  232.   </tr> 
  233.       <tr class="hback"> 
  234.           <td align="right">指定用户查看:</td> 
  235.           <td><textarea name="AppointUserNumber" cols="80" id="AppointUserNumber" onKeyUp="ReplaceDot('AppointUserNumber')"><%=AppointUserNumber%></textarea>
  236. </td> 
  237.       </tr>
  238.       <tr class="hback">
  239.         <td align="right">指定用户组查看:</td>
  240.         <td><select name="userGroup" size="10" multiple>
  241.           <option value="user_all" style="background-color:#014952; color:#FFFFFF;">-个人用户组-</option>
  242.   
  243.   <%
  244.    Set UserGroupRs=User_Conn.Execute("Select GroupID,GroupName from FS_ME_Group where GroupType=1")
  245. while not UserGroupRs.eof
  246. selectedTF=false
  247. if  not isNull(AppointUserGroup) then
  248. for ArrayCount=0 to Ubound(AppointUserGroup)
  249. if not isnumeric(AppointUserGroup(ArrayCount)) then exit for
  250. if Cint(trim(AppointUserGroup(ArrayCount)))=UserGroupRs("GroupID") then
  251. selectedTF=true
  252. exit for
  253. end if
  254. next
  255. end if
  256. if selectedTF then
  257. Response.Write("<option value='"&UserGroupRs("GroupID")&"' selected>"&UserGroupRs("GroupName")&"</option>")
  258. else
  259. Response.Write("<option value='"&UserGroupRs("GroupID")&"'>"&UserGroupRs("GroupName")&"</option>")
  260. end if
  261. UserGroupRs.movenext
  262. wend
  263.   %>
  264.         </select> 
  265.           <select name="corpGroup" size="10" multiple>
  266.             <option value="corp_all" style="background-color:#014952; color:#FFFFFF;">-企业用户组-</option>
  267. <%
  268. Set UserGroupRs=User_Conn.Execute("Select GroupID,GroupName from FS_ME_Group where GroupType=0")
  269. while not UserGroupRs.eof
  270. selectedTF=false
  271. if  not isNull(AppointUserGroup) then
  272. for ArrayCount=0 to Ubound(AppointUserGroup)
  273. if not isnumeric(AppointUserGroup(ArrayCount)) then exit for
  274. if Cint(trim(AppointUserGroup(ArrayCount)))=UserGroupRs("GroupID") then
  275. selectedTF=true
  276. exit for
  277. end if
  278. next
  279. end if
  280. if selectedTF then
  281. Response.Write("<option value='"&UserGroupRs("GroupID")&"' selected>"&UserGroupRs("GroupName")&"</option>")
  282. else
  283. Response.Write("<option value='"&UserGroupRs("GroupID")&"'>"&UserGroupRs("GroupName")&"</option>")
  284. end if
  285. UserGroupRs.movenext
  286. wend
  287. %>
  288.             </select></td>
  289.       </tr>
  290.       <tr class="hback">
  291.         <td align="right">锁定:</td>
  292.         <td>
  293. <%
  294. if Request.QueryString("Act")="edit" then
  295. if isLock=1 then
  296. Response.Write("<input type='radio' name='isLock' value='1' checked>是"&Chr(10)&Chr(13))
  297. Response.Write("<input type='radio' name='isLock' value='0' >否"&Chr(10)&Chr(13))
  298. elseif isLock=0 then
  299. Response.Write("<input type='radio' name='isLock' value='1' >是"&Chr(10)&Chr(13))
  300. Response.Write("<input type='radio' name='isLock' value='0' checked>否"&Chr(10)&Chr(13))
  301. end if
  302. else
  303. Response.Write("<input type='radio' name='isLock' value='1' >是"&Chr(10)&Chr(13))
  304. Response.Write("<input type='radio' name='isLock' value='0' checked>否"&Chr(10)&Chr(13))
  305. end if
  306. %>
  307. </td>
  308.       </tr>
  309.       <tr class="hback">
  310.         <td align="right">附件地址:</td>
  311.         <td><input name="AccessFile" type="text" id="AccessFile" size="50" value="<%=AccessFile%>"><span id="AccessFile_Alert"></span></td>
  312.       </tr> 
  313.       <tr class="hback"> 
  314.           <td align="right">&nbsp;</td> 
  315.           <td><input type="Button" name="OperateDebateButton" value=" 保存 " onClick="OperateDebateSubmit()"/> 
  316.             <input type="reset" name="Submit2" value=" 重置 " /></td> 
  317.       </tr> 
  318.     </form>
  319. </table> 
  320. </body>
  321. <%
  322. if Request.QueryString("Act")="edit" then
  323. TopicRs.close
  324. Set TopicRs=nothing
  325. ClassRs.close
  326. Set ClassRs=nothing
  327. OperateDebateRs.close
  328. Set OperateDebateRs=nothing
  329. UserGroupRs.close
  330. Set UserGroupRs=nothing
  331. Conn.close
  332. Set Conn=nothing
  333. User_Conn.close
  334. Set User_Conn=nothing
  335. elseif  Request.QueryString("Act")="EditDebate" then
  336. parentIDRs.close
  337. Set parentIDRs=nothing
  338. elseif Request.QueryString("Act")="AddChile" then
  339. currentTopicRs.close
  340. Set currentTopicRs=nothing
  341. end if
  342. %>
  343. <script language="JavaScript" type="text/JavaScript">
  344. <!--
  345. function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  346.   if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
  347.     document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  348.   else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
  349. }
  350. MM_reloadPage(true);
  351. //-->
  352. var request=true;
  353. var result;
  354. var ParamArray;
  355. try
  356. {
  357. request=new XMLHttpRequest();
  358. }catch(trymicrosoft)
  359. {
  360. try
  361. {
  362. request=new ActiveXObject("Msxml2.XMLHTTP")
  363. }catch(othermicrosoft)
  364. {
  365. try
  366. {
  367. request=new ActiveXObject("Microsoft.XMLHTTP")
  368. }catch(filed)
  369. {
  370. request=false;
  371. }
  372. }
  373. }
  374. if(!request) alert("Error initializing XMLHttpRequest!");
  375. function getDebate(Obj,Str)
  376. {
  377. var debateID=Obj.value;
  378. if(isNaN(debateID))
  379. {
  380. document.getElementById("Topic1_Container").innerHTML="";
  381. document.getElementById("Topic2_Container").innerHTML="";
  382. return ;
  383. }else if(debateID==0)
  384. {
  385. document.getElementById("Topic1_Container").innerHTML="";
  386. document.getElementById("Topic2_Container").innerHTML="";
  387. document.getElementById("current").innerHTML="";
  388. return ;
  389. }
  390. document.getElementById("current").innerHTML="";
  391. var url="getGroupDebate.asp?name="+Str+"&debateid="+debateID+"&r="+Math.random();//构造url
  392. request.open("GET",url,true);//建立连接
  393. request.onreadystatechange = getDebateResult;
  394. request.send(null);//传送数据,因为数据通过url传递了,所以这里传递的是null
  395. }
  396. function getDebateResult()//当服务器响应的时候就使用这个方法
  397. {
  398. if(request.readyState ==4)//根据HTTP 就绪状态判断响应是否完成
  399. {
  400. if(request.status == 200)//判断请求是否成功
  401. {
  402. result=request.responseText;//获得响应的结果,也就是新的<select>
  403. if(result.indexOf("name='Topic1'")>0)
  404. {
  405. document.getElementById("Topic1_Container").innerHTML="|&nbsp;&nbsp;"+result;//将这个结果现实在客户端
  406. document.getElementById("Topic2_Container").innerHTML=""
  407. }
  408. if(result.indexOf("name='Topic2'")>0)
  409. {
  410. document.getElementById("Topic2_Container").innerHTML="|&nbsp;&nbsp;"+result;//将这个结果现实在客户端
  411. }
  412. }
  413. }
  414. }
  415. function OperateDebateSubmit()
  416. {
  417. var flag1=isEmpty('Title','Title_Alert');
  418. var flag2=isEmpty('Content','Content_Alert');
  419. var flag3=isEmpty('AccessFile','AccessFile_Alert');
  420. if(flag1&&flag2&&flag3)
  421. {
  422. document.operateDebate.submit();
  423. }
  424. }
  425. </script>
  426. </html>