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