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

数据库编程

开发平台:

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,OperateNewsRs,newsid,title,content,grouptype,groupid,groupIndex,GroupInfoRs,newspoint,isLock
  8. MF_Default_Conn
  9. MF_Session_TF 
  10. if not MF_Check_Pop_TF("ME021") then Err_Show '权限判断
  11. MF_User_Conn
  12. '************************************Update
  13. if Request.QueryString("Act")="edit" then
  14. newsid=Request.QueryString("newsid")
  15. Set OperateNewsRs=server.CreateObject(G_FS_RS)
  16. OperateNewsRs.open "select title,content,addtime,groupid,newspoint,isLock from FS_ME_News where newsid="&newsid,User_Conn,1,3
  17. if not OperateNewsRs.eof then
  18. title=OperateNewsRs("title")
  19. content=OperateNewsRs("content")
  20. groupid=OperateNewsRs("groupid")
  21. newspoint=OperateNewsRs("newspoint")
  22. isLock=OperateNewsRs("isLock")
  23. If Not IsNull(groupid) And Not groupid="" then
  24. Set GroupInfoRs=User_Conn.execute("select groupid,groupname,grouptype from FS_ME_Group where groupid="&groupid)
  25. if not GroupInfoRs.eof then
  26. grouptype=GroupInfoRs("GroupType")
  27. end If
  28. groupInfoRs.close
  29. Set groupInfoRs=nothing
  30. End if
  31. OperateNewsRs.close
  32. end if
  33. elseif Request.QueryString("Act")="EditNews" then
  34. if isNumeric(Request.Form("GroupIndex")) then
  35. GroupIndex=Request.Form("GroupIndex")
  36. else
  37. GroupIndex=0
  38. end if
  39. User_Conn.Execute("Update FS_ME_News set Title='"&Request.Form("title")&"',content='"&Request.Form("Content")&"',addtime='"&Now()&"',groupid="&GroupIndex&",newspoint="&Request.Form("newspoint")&",isLock="&Request.Form("isLock")&" where newsid="&Request.QueryString("newsid"))
  40. if err.number=0 then 
  41. Response.Redirect("../success.asp?ErrCodes=<li>修改成功</li>&ErrorURL=./user/news_manage.asp")
  42. else
  43. Response.Redirect("../error.asp?ErrCodes=<li>"&err.description&"</li>")
  44. end if
  45. elseif Request.QueryString("Act")="AddNews" then
  46. if isNumeric(Request.Form("GroupIndex")) then
  47. GroupIndex=Request.Form("GroupIndex")
  48. else
  49. GroupIndex=0
  50. end if
  51. Set OperateNewsRs=server.CreateObject(G_FS_RS)
  52. OperateNewsRs.open "select title,content,addtime,groupid,newspoint,isLock from FS_ME_News",User_Conn,1,3
  53. OperateNewsRs.addNew
  54. OperateNewsRs("title")=Request.Form("title")
  55. OperateNewsRs("content")=Request.Form("content")
  56. OperateNewsRs("addtime")=Now()
  57. OperateNewsRs("groupid")=GroupIndex
  58. OperateNewsRs("newspoint")=Request.Form("newspoint")
  59. OperateNewsRs("islock")=Request.Form("islock")
  60. OperateNewsRs.update
  61. OperateNewsRs.close
  62. if err.number=0 then 
  63. Response.Redirect("../success.asp")
  64. else
  65. Response.Redirect("../error.asp?ErrCodes=<li>"&err.description&"</li>")
  66. end if
  67. end if
  68. function getDebateParentNum(ID)
  69. if ID="" then exit function
  70. Dim F_DebateID,F_Rs,FS_count
  71. FS_count=1
  72. Set F_Rs=User_Conn.Execute("Select DebateID,title,ParentID from FS_ME_GroupDebate where DebateID="&ID)
  73. if not F_Rs.eof then
  74. FS_count=FS_count+getDebateParentNum(F_Rs("ParentID"))
  75. end if
  76. F_Rs.close
  77. Set F_Rs=nothing
  78. getDebateParentNum=FS_count
  79. End function
  80. %>
  81. <html xmlns="http://www.w3.org/1999/xhtml">
  82. <HEAD>
  83. <TITLE>FoosunCMS</TITLE>
  84. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
  85. </HEAD>
  86. <script language="JavaScript" src="../../FS_Inc/PublicJS.js" type="text/JavaScript"></script>
  87. <script language="JavaScript" src="lib/UserJS.js" type="text/JavaScript"></script>
  88. <link href="../images/skin/Css_<%=Session("Admin_Style_Num")%>/<%=Session("Admin_Style_Num")%>.css" rel="stylesheet" type="text/css">
  89. <BODY LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 scroll=yes>
  90. <table width="98%" border="0" align="center" cellpadding="5" cellspacing="1" class="table">
  91.   <tr class="xingmu"> 
  92.     <td class="xingmu">公告管理</td>
  93.   </tr>
  94.   <tr class="hback"> 
  95.     <td class="hback"><a href="News_manage.asp">首页</a> | <a href="AddEditNews.asp?Act=add">发布公告</a> | <a href="javascript:history.back();">返回上一级</a></td>
  96.   </tr>
  97. </table>
  98. <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
  99.   <%
  100. if Request.QueryString("Act")="edit" then
  101. Response.Write("<form action='?Act=EditNews&newsid="&newsid&"' method='post' name='operateNews' id='operateNews'>")
  102. elseif Request.QueryString("Act")="add" then
  103. Response.Write("<form action='?Act=AddNews' method='post' name='operateNews' id='operateNews'>")
  104. end if
  105. %>
  106.   <tr class="hback"> 
  107.     <td align="right">公告标题:</td>
  108.     <td width="631"> <input name="Title" type="text" id="Title" value="<%=title%>" size="50" /> 
  109.       <font color="#FF0000">*</font><span id="Title_Alert"></span></td>
  110.   </tr>
  111.   <tr class="hback"> 
  112.     <td align="right">公告内容: </td>
  113.     <td> <textarea name="Content" cols="80" rows="15" id="Content"><%=content%></textarea> 
  114.       <font color="#FF0000">*</font><span id="Content_Alert"></span></td>
  115.   </tr>
  116.   <tr class="hback"> 
  117.     <td align="right">查看权限:</td>
  118.     <td> <select name="GType" id="GType" onChange="getFormInfo(this)">
  119.         <option value="all" <%if grouptype<>1 and grouptype<>0 then Response.Write("selected")%>>所有会员组</option>
  120.         <option value="1" <%if grouptype=1 then Response.Write("selected")%>>个人会员组</option>
  121.         <option value="0" <%if grouptype=0 then Response.Write("selected")%>>企业会员组</option>
  122.       </select> &nbsp; <span id="GroupIndexContent"> 
  123.       <%
  124. if Request.QueryString("act")="edit" then
  125. Response.Write(" |  会员组:<select name='GroupIndex' id='GroupIndex'>"&Chr(10)&Chr(13))
  126. if grouptype=1 then
  127. Set GroupInfoRs=User_Conn.execute("Select GroupID,GroupName from FS_ME_Group where GroupType=1")
  128. Response.Write("<option value='user'>所有个人会员组</option>")
  129. elseif grouptype=0 then
  130. Set GroupInfoRs=User_Conn.execute("Select GroupID,GroupName from FS_ME_Group where GroupType=0")
  131. Response.Write("<option value='corp'>所有企业会员组</option>")
  132. end if
  133. while not GroupInfoRs.eof
  134. if GroupInfoRs("GroupID")=Groupid then
  135. Response.Write("<option value='"&GroupInfoRs("GroupID")&"' selected>"&GroupInfoRs("GroupName")&"</option>")
  136. else
  137. Response.Write("<option value='"&GroupInfoRs("GroupID")&"'>"&GroupInfoRs("GroupName")&"</option>")
  138. end if
  139. GroupInfoRs.movenext
  140. wend
  141. end if
  142. %>
  143.       </span> </td>
  144.   </tr>
  145.   <tr class="hback"> 
  146.     <td align="right">积分限制:</td>
  147.     <td><input name="NewsPoint" type="text" id="NewsPoint"  value="<%=newspoint%>" size="50"/>
  148.       (积分大于多少可以查看)<span id="NewsPoint_Alert"></span></td>
  149.   </tr>
  150.   <tr class="hback"> 
  151.     <td align="right">是否锁定:</td>
  152.     <td> <%
  153.    if Request.QueryString("act")="edit" then
  154. if isLock=1 then
  155. Response.Write("<input type='radio' name='isLock' value=1 checked>是"&Chr(10)&Chr(13))
  156. Response.Write("<input type='radio' name='isLock' value=0 >否"&Chr(10)&Chr(13))
  157. elseif isLock=0 then
  158. Response.Write("<input type='radio' name='isLock' value=1 >是"&Chr(10)&Chr(13))
  159. Response.Write("<input type='radio' name='isLock' value=0 checked>否"&Chr(10)&Chr(13))
  160. end if
  161. else
  162. Response.Write("<input type='radio' name='isLock' value=1 >是"&Chr(10)&Chr(13))
  163. Response.Write("<input type='radio' name='isLock' value=0 checked>否"&Chr(10)&Chr(13))
  164. end if
  165.   %> </td>
  166.   </tr>
  167.   <tr class="hback"> 
  168.     <td align="right">&nbsp;</td>
  169.     <td><input type="Button" name="AddNewsButton" value=" 保存 " onClick="OperateNewsSubmit()"/> 
  170.       <input type="reset" name="Submit2" value=" 重置 " /></td>
  171.   </tr></form></tr>
  172. </table> 
  173. </body>
  174. <%
  175. if Request.QueryString("Act")="edit" then
  176. GroupInfoRs.close
  177. set GroupInfoRs=nothing
  178. Conn.close
  179. Set Conn=nothing
  180. User_Conn.close
  181. Set User_Conn=nothing
  182. end if
  183. %>
  184. <script language="JavaScript" type="text/JavaScript">
  185. <!--
  186. function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  187.   if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
  188.     document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  189.   else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
  190. }
  191. MM_reloadPage(true);
  192. //-->
  193. var request=true;
  194. var result;
  195. var ParamArray;
  196. try
  197. {
  198. request=new XMLHttpRequest();
  199. }catch(trymicrosoft)
  200. {
  201. try
  202. {
  203. request=new ActiveXObject("Msxml2.XMLHTTP")
  204. }catch(othermicrosoft)
  205. {
  206. try
  207. {
  208. request=new ActiveXObject("Microsoft.XMLHTTP")
  209. }catch(filed)
  210. {
  211. request=false;
  212. }
  213. }
  214. }
  215. if(!request) alert("Error initializing XMLHttpRequest!");
  216. function getFormInfo(Obj)
  217. {
  218. var typeID=Obj.value;
  219. if(isNaN(typeID))
  220. {
  221. document.getElementById("GroupIndexContent").innerHTML="";
  222. return ;
  223. }
  224. var url="getUserGroup.asp?page=News&id="+typeID+"&r="+Math.random();//构造url
  225. request.open("GET",url,true);//建立连接
  226. request.onreadystatechange = getFormInfoResult;
  227. request.send(null);//传送数据,因为数据通过url传递了,所以这里传递的是null
  228. }
  229. function getFormInfoResult()//当服务器响应的时候就使用这个方法
  230. {
  231. if(request.readyState ==4)//根据HTTP 就绪状态判断响应是否完成
  232. {
  233. if(request.status == 200)//判断请求是否成功
  234. {
  235. result=request.responseText;//获得响应的结果,也就是新的<select>
  236. document.getElementById("GroupIndexContent").innerHTML="|&nbsp;&nbsp;会员组:"+result;//将这个结果现实在客户端
  237. }
  238. }
  239. }
  240. function OperateNewsSubmit()
  241. {
  242. var flag1=isEmpty('Title','Title_Alert');
  243. var flag2=isEmpty('Content','Content_Alert');
  244. var flag3=isNumber("NewsPoint",'NewsPoint_Alert','积分请使用正整数',true)
  245. if(flag1&&flag2&&flag3)
  246. {
  247. document.operateNews.submit();
  248. }
  249. }
  250. </script>
  251. </html>