edit_replyarticleto.aspx.cs
上传用户:scene123
上传日期:2010-02-19
资源大小:3311k
文件大小:5k
源码类别:

.net编程

开发平台:

C#

  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Web;
  7. using System.Web.SessionState;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.HtmlControls;
  11. using System.Data.OleDb;
  12. using System.Configuration;
  13. using System.Text;
  14. using System.Web.Security;
  15. using System.Security.Cryptography;
  16. namespace kuangren
  17. {
  18. /// <summary>
  19. /// edit_replyarticleto 的摘要说明。
  20. /// </summary>
  21. public class edit_replyarticleto : System.Web.UI.Page
  22. {
  23. public string usercookies;
  24. protected int intRunTime;
  25. protected DateTime dtStartTime = DateTime.Now; 
  26. protected System.Data.OleDb.OleDbConnection conn;
  27. protected System.Data.OleDb.OleDbCommand cmd;
  28. protected System.Data.OleDb.OleDbCommand cmd5;
  29. protected string OleDbforum3;
  30. public    DataSet dsPending;
  31. public    DataSet dsuser;
  32. public    DataSet dsPending1;
  33. protected int powerjudge;
  34. protected int usergrade;
  35. protected string powername;
  36. protected int powergrade;
  37. public    string sql;
  38. public    string sql1;
  39. protected string updatecontent;
  40. protected string judgeupdater;
  41. public int userjudge2;
  42. public int userjudge3;
  43. private void Page_Load(object sender, System.EventArgs e)
  44. {
  45. if (Request.Cookies["jusername"]!=null)
  46. {
  47. usercookies=Request.Cookies["jusername"].Value;
  48. }
  49. else
  50. {
  51. Response.Redirect("logine.aspx");
  52. }
  53. string str=""+Request.Form["subject"]+"";
  54. string str1=""+Request.Form["content"]+"";
  55. userjudge2=System.Text.Encoding.Default.GetByteCount(str);
  56. userjudge3=System.Text.Encoding.Default.GetByteCount(str1);
  57. if  (userjudge2>50||userjudge3>16240||userjudge3==0)
  58. {
  59. Response.Redirect("announcerror.aspx");
  60. }
  61. conn = new OleDbConnection(ConfigurationSettings.AppSettings["cnFriends.ConnectionString"]);
  62. //搜索主题信息
  63. sql="SELECT f4_id,f4_motif,f4_content,f4_name,f4_sy1,f4_sy2  FROM forum_4  WHERE f4_id ="+Request.Form["f4_id"]+"";
  64. dsPending=new DataSet();
  65. OleDbDataAdapter adWord=new OleDbDataAdapter(sql,conn);
  66. adWord.Fill(dsPending,"forum_4");
  67. Page.DataBind();
  68. //判断是否为该主题所属论坛斑竹
  69. powerjudge=Convert.ToInt32(dsPending.Tables[0].Rows[0]["f4_sy1"]);
  70. powername=Convert.ToString(dsPending.Tables[0].Rows[0]["f4_name"]);
  71. dsuser=new DataSet();
  72. cmd=new OleDbCommand("select umf2_id from user_f2 where umf2_id="+powerjudge+" and um_name='"+Request.Cookies["jusername"].Value+"'",conn);
  73. OleDbDataReader objDataReader ;
  74. cmd.Connection.Open();
  75. //搜索该主题发帖人信息,判断斑竹或管理员是否有权限修改[剑气潇潇为超级用户]
  76. sql1="SELECT u_grade,u_user from userinfo  WHERE u_user ='"+powername+"'";
  77. dsPending1=new DataSet();
  78. OleDbDataAdapter adWord1=new OleDbDataAdapter(sql1,conn);
  79. adWord1.Fill(dsPending1,"userinfo");
  80. Page.DataBind();
  81. string usergrade=Convert.ToString(dsPending1.Tables[0].Rows[0]["u_grade"]);
  82. powergrade=Convert.ToInt32(usergrade);
  83. objDataReader = cmd.ExecuteReader();
  84. //judgepower
  85. if (powername!=Request.Cookies["jusername"].Value)
  86. {
  87. if ((objDataReader.Read() != true) &&Convert.ToString(Request.Cookies["jpower"].Value)!="1")
  88. {
  89. Response.Redirect("power_error.aspx");
  90. }
  91. if(powergrade<=Convert.ToInt32(Request.Cookies["jpower"].Value)&&Convert.ToString(Request.Cookies["jusername"].Value)!="剑气潇潇")
  92. {
  93. Response.Redirect("power_error.aspx");
  94. }
  95. }
  96. //end
  97. cmd.Connection.Close();
  98. //end
  99. //执行修改
  100. //判断修改帖子者
  101. if (powername!=Request.Cookies["jusername"].Value)
  102. {
  103. if (Convert.ToInt32(Request.Cookies["jpower"].Value)==1)
  104. {judgeupdater="管理员";}
  105. if (Convert.ToInt32(Request.Cookies["jpower"].Value)==2)
  106. {judgeupdater="版主";}
  107. }
  108. else
  109. {
  110. judgeupdater="作者";
  111. }
  112. updatecontent=Request.Form["content"]+"[color=#FF0000]——该回复被"+judgeupdater+"于"+DateTime.Now+"修改过[/color]";
  113. OleDbforum3="update [forum_4]  SET f4_motif='"+Request.Form["subject"]+"',f4_content='"+updatecontent+"',f4_face='"+Request.Form["f3_face"]+"'where f4_id="+Request.Form["f4_id"]+"";          
  114. cmd5=new OleDbCommand(OleDbforum3,conn);
  115. conn.Open();
  116. bool doredirect=true;
  117. try
  118. {
  119. cmd5.ExecuteNonQuery();
  120. }
  121. catch
  122. {
  123. doredirect=false;
  124. }
  125. finally
  126. {
  127. conn.Close();
  128. }
  129. if(doredirect)
  130. {
  131. }
  132. else
  133. {
  134. Response.Redirect("index.aspx");
  135. }
  136. //执行结束
  137. }
  138. #region Web 窗体设计器生成的代码
  139. override protected void OnInit(EventArgs e)
  140. {
  141. //
  142. // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
  143. //
  144. InitializeComponent();
  145. base.OnInit(e);
  146. }
  147. /// <summary>
  148. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  149. /// 此方法的内容。
  150. /// </summary>
  151. private void InitializeComponent()
  152. {    
  153. this.Load += new System.EventHandler(this.Page_Load);
  154. }
  155. #endregion
  156. }
  157. }