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

.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. /// doarticle_reply 的摘要说明。
  20. /// </summary>
  21. public class doarticle_reply : 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 System.Data.OleDb.OleDbCommand cmd6;
  30. protected System.Data.OleDb.OleDbCommand cmd7;
  31. protected System.Data.OleDb.OleDbCommand cmd8;
  32. public    DataSet dsPending;
  33. public    DataSet dsuser;
  34. public    DataSet dsPending1;
  35. protected int powerjudge;
  36. protected int usergrade;
  37. protected string powername;
  38. protected int powergrade;
  39. public    string sql;
  40. public    string sql1;
  41. public string aboutype;
  42. protected int aboutvalue;
  43. protected int f4_id;
  44. protected int f2_id;
  45. protected string OleDbSqlforum;
  46. protected string OleDbsql;
  47. protected string OleDbsqladd;
  48. protected string OleDbsqluser;
  49. protected string OleDbsqlmessage;
  50. protected string userscore;
  51. protected string usermoney;
  52. private void Page_Load(object sender, System.EventArgs e)
  53. {
  54. if (Request.Cookies["jusername"]!=null)
  55. {
  56. usercookies=Request.Cookies["jusername"].Value;
  57. }
  58. else
  59. {
  60. Response.Redirect("logine.aspx");
  61. }
  62. if (Request.QueryString["type"]=="12")
  63. {aboutype="回复删除";}
  64. conn = new OleDbConnection(ConfigurationSettings.AppSettings["cnFriends.ConnectionString"]);
  65. //搜索回复信息
  66. sql="SELECT f4_id,f4_motif,f4_content,f4_name,f4_sy1,f4_sy2  FROM forum_4  WHERE f4_id ="+Request.QueryString["f4_id"]+"";
  67. dsPending=new DataSet();
  68. OleDbDataAdapter adWord=new OleDbDataAdapter(sql,conn);
  69. adWord.Fill(dsPending,"forum_4");
  70. Page.DataBind();
  71. //判断是否为该主题所属论坛斑竹
  72. powerjudge=Convert.ToInt32(dsPending.Tables[0].Rows[0]["f4_sy1"]);
  73. powername=Convert.ToString(dsPending.Tables[0].Rows[0]["f4_name"]);
  74. dsuser=new DataSet();
  75. cmd=new OleDbCommand("select umf2_id from user_f2 where umf2_id="+powerjudge+" and um_name='"+Request.Cookies["jusername"].Value+"'",conn);
  76. OleDbDataReader objDataReader ;
  77. cmd.Connection.Open();
  78. //搜索该主题发帖人信息,判断斑竹或管理员是否有权限修改[剑气潇潇为超级用户]
  79. sql1="SELECT u_grade,u_user from userinfo  WHERE u_user ='"+powername+"'";
  80. dsPending1=new DataSet();
  81. OleDbDataAdapter adWord1=new OleDbDataAdapter(sql1,conn);
  82. adWord1.Fill(dsPending1,"userinfo");
  83. Page.DataBind();
  84. string usergrade=Convert.ToString(dsPending1.Tables[0].Rows[0]["u_grade"]);
  85. powergrade=Convert.ToInt32(usergrade);
  86. objDataReader = cmd.ExecuteReader();
  87. //judgepower
  88. if (powername!=Request.Cookies["jusername"].Value)
  89. {
  90. if ((objDataReader.Read() != true) &&Convert.ToString(Request.Cookies["jpower"].Value)!="1")
  91. {
  92. Response.Redirect("power_error.aspx");
  93. }
  94. if(powergrade<=Convert.ToInt32(Request.Cookies["jpower"].Value)&&Convert.ToString(Request.Cookies["jusername"].Value)!="剑气潇潇")
  95. {
  96. Response.Redirect("power_error.aspx");
  97. }
  98. }
  99. cmd.Connection.Close();
  100. //end
  101. //以下为执行操作代码
  102. if (Convert.ToString(Request.QueryString["action"])=="action")
  103. {
  104. string str=""+Request.QueryString["content"]+"";
  105. string str1=""+Request.QueryString["title"]+"";
  106. if (System.Text.Encoding.Default.GetByteCount(str)==0&&System.Text.Encoding.Default.GetByteCount(str1)==0)
  107. {
  108. Response.Redirect("power_error.aspx");
  109. }
  110.     {
  111. f4_id=Convert.ToInt32(Request.QueryString["f4_id"]);
  112. f2_id=Convert.ToInt32(Request.QueryString["f2_id"]);
  113. StringBuilder sb=new StringBuilder();
  114. ArrayList values=new ArrayList();
  115. sb.Append("delete from  [forum_4] where f4_id="+f4_id+"");          
  116. OleDbsql=String.Format(sb.ToString(),values.ToArray());
  117. cmd5=new OleDbCommand(OleDbsql,conn);
  118. //执行对用户金钱积分操作
  119. if (Convert.ToString(Request.QueryString["checkbox"])!="checkbox")
  120. {
  121. OleDbsqluser="update userinfo set u_fenshu=u_fenshu+("+Request.QueryString["dofenshu"]+"),u_money=u_money+("+Request.QueryString["domoney"]+") where u_user='"+powername+"' ";          
  122. cmd7=new OleDbCommand(OleDbsqluser,conn);
  123. userscore=Convert.ToString(Request.QueryString["dofenshu"]);
  124. usermoney=Convert.ToString(Request.QueryString["domoney"]);
  125. }
  126. else
  127. {
  128. userscore="0";
  129. usermoney="0";
  130. }
  131. if (Convert.ToString(Request.QueryString["ismsg"])=="1")
  132. {
  133. OleDbsqlmessage="INSERT INTO [forum_5](p_take,p_send,p_title,p_content)  values('"+powername+"','"+usercookies+"','系统通知','您的帖子因"+Request.QueryString["title"]+""+Request.QueryString["content"]+"而"+aboutype+"r积分操作:"+userscore+" 金钱操作:"+usermoney+"r"+usercookies+"留言:"+Request.QueryString["msg"]+"')";          
  134. cmd8=new OleDbCommand(OleDbsqlmessage,conn);
  135. }
  136. conn.Open();
  137. //插入数据到论坛事件记录表中
  138. OleDbsqladd="insert into [log](l_announceid,l_boardid,l_touser,l_username,l_content,l_ip) values("+f4_id+","+f2_id+",'"+powername+"','"+usercookies+"','[回复操作]删除回复,帖子编号"+f4_id+",原因:"+Request.QueryString["title"]+"  "+Request.QueryString["content"]+",积分操作:"+userscore+" 金钱操作:"+usermoney+"','"+Request.UserHostAddress+"')";          
  139. cmd6=new OleDbCommand(OleDbsqladd,conn);
  140. bool doredirect=true;
  141. try
  142. {
  143. cmd5.ExecuteNonQuery();
  144. cmd6.ExecuteNonQuery();
  145. if (Convert.ToString(Request.QueryString["checkbox"])!="checkbox")
  146. {
  147. cmd7.ExecuteNonQuery();
  148. }
  149. if (Convert.ToString(Request.QueryString["ismsg"])=="1")
  150. {
  151. cmd8.ExecuteNonQuery();
  152. }
  153. }
  154. catch
  155. {
  156. doredirect=false;
  157. }
  158. finally
  159. {
  160. conn.Close();
  161. }
  162. if(doredirect)
  163. {
  164. Response.Redirect("doarticle_closeto.aspx?f2_id="+f2_id+"");
  165. }
  166. else
  167. {
  168. Response.Redirect("index.aspx");
  169. }
  170. }
  171. }
  172. }
  173. #region Web 窗体设计器生成的代码
  174. override protected void OnInit(EventArgs e)
  175. {
  176. //
  177. // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
  178. //
  179. InitializeComponent();
  180. base.OnInit(e);
  181. }
  182. /// <summary>
  183. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  184. /// 此方法的内容。
  185. /// </summary>
  186. private void InitializeComponent()
  187. {    
  188. this.Load += new System.EventHandler(this.Page_Load);
  189. }
  190. #endregion
  191. }
  192. }