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

.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_close 的摘要说明。
  20. /// </summary>
  21. public class doarticle_close : 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 f3_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. public string f3title;
  53. private void Page_Load(object sender, System.EventArgs e)
  54. {
  55. if (Request.Cookies["jusername"]!=null)
  56. {
  57. usercookies=Request.Cookies["jusername"].Value;
  58. }
  59. else
  60. {
  61. Response.Redirect("logine.aspx");
  62. }
  63. if (Request.QueryString["type"]=="1")
  64. {aboutype="锁定";aboutvalue=1;}
  65. if (Request.QueryString["type"]=="2")
  66. {aboutype="解锁";aboutvalue=0;}
  67. if (Request.QueryString["type"]=="3")
  68. {aboutype="提升";}
  69. if (Request.QueryString["type"]=="4")
  70. {aboutype="删除";aboutvalue=2;}
  71. if (Request.QueryString["type"]=="5")
  72. {aboutype="移动";}
  73. if (Request.QueryString["type"]=="6")
  74. {aboutype="固顶";aboutvalue=3;}
  75. if (Request.QueryString["type"]=="7")
  76. {aboutype="总固顶";aboutvalue=4;}
  77. if (Request.QueryString["type"]=="8")
  78. {aboutype="解除固顶";aboutvalue=0;}
  79. if (Request.QueryString["type"]=="9")
  80. {aboutype="惩罚或奖励";}
  81. if (Request.QueryString["type"]=="10")
  82. {aboutype="加为精华";aboutvalue=1;}
  83. if (Request.QueryString["type"]=="11")
  84. {aboutype="精华取消";aboutvalue=0;}
  85. conn = new OleDbConnection(ConfigurationSettings.AppSettings["cnFriends.ConnectionString"]);
  86. //搜索主题信息
  87. sql="SELECT f3_id,f3_motif,f3_content,f3_name,f3_sy  FROM forum_3  WHERE f3_id ="+Request.QueryString["f3_id"]+"";
  88. dsPending=new DataSet();
  89. OleDbDataAdapter adWord=new OleDbDataAdapter(sql,conn);
  90. adWord.Fill(dsPending,"forum_3");
  91. Page.DataBind();
  92. //判断是否为该主题所属论坛斑竹
  93. powerjudge=Convert.ToInt32(dsPending.Tables[0].Rows[0]["f3_sy"]);
  94. powername=Convert.ToString(dsPending.Tables[0].Rows[0]["f3_name"]);
  95. f3title=Convert.ToString(dsPending.Tables[0].Rows[0]["f3_motif"]);
  96. dsuser=new DataSet();
  97. cmd=new OleDbCommand("select umf2_id from user_f2 where umf2_id="+powerjudge+" and um_name='"+Request.Cookies["jusername"].Value+"'",conn);
  98. OleDbDataReader objDataReader ;
  99. cmd.Connection.Open();
  100. //搜索该主题发帖人信息,判断斑竹或管理员是否有权限修改[剑气潇潇为超级用户]
  101. sql1="SELECT u_grade,u_user from userinfo  WHERE u_user ='"+powername+"'";
  102. dsPending1=new DataSet();
  103. OleDbDataAdapter adWord1=new OleDbDataAdapter(sql1,conn);
  104. adWord1.Fill(dsPending1,"userinfo");
  105. Page.DataBind();
  106. string usergrade=Convert.ToString(dsPending1.Tables[0].Rows[0]["u_grade"]);
  107. powergrade=Convert.ToInt32(usergrade);
  108. objDataReader = cmd.ExecuteReader();
  109. //judgepower
  110. if ((objDataReader.Read() != true) &&Convert.ToString(Request.Cookies["jpower"].Value)!="1")
  111. {
  112. Response.Redirect("power_error.aspx");
  113. }
  114. if(powergrade<=Convert.ToInt32(Request.Cookies["jpower"].Value)&&Convert.ToString(Request.Cookies["jusername"].Value)!="剑气潇潇")
  115. {
  116. Response.Redirect("power_error.aspx");
  117. }
  118.   cmd.Connection.Close();
  119.    
  120. //end
  121. //以下为执行操作代码
  122. if (Convert.ToString(Request.QueryString["action"])=="action")
  123. {
  124. string str=""+Request.QueryString["content"]+"";
  125. string str1=""+Request.QueryString["title"]+"";
  126. if (System.Text.Encoding.Default.GetByteCount(str)==0&&System.Text.Encoding.Default.GetByteCount(str1)==0)
  127. {
  128. Response.Redirect("power_error.aspx");
  129. }
  130. {
  131. f3_id=Convert.ToInt32(Request.QueryString["f3_id"]);
  132. f2_id=Convert.ToInt32(Request.QueryString["f2_id"]);
  133. StringBuilder sb=new StringBuilder();
  134. ArrayList values=new ArrayList();
  135. if ((Convert.ToString(Request.QueryString["type"])=="1" || Convert.ToString(Request.QueryString["type"])=="2" || Convert.ToString(Request.QueryString["type"])=="4")&&Convert.ToString(Request.QueryString["action"])=="action")
  136. {
  137. sb.Append("update [forum_3] set f3_state="+aboutvalue+" where f3_id="+f3_id+"");          
  138. }
  139. if ((Convert.ToString(Request.QueryString["type"])=="6" || Convert.ToString(Request.QueryString["type"])=="7" || Convert.ToString(Request.QueryString["type"])=="8")&&Convert.ToString(Request.QueryString["action"])=="action")
  140. {
  141. sb.Append("update [forum_3] set f3_top="+aboutvalue+" where f3_id="+f3_id+"");          
  142. }
  143. if (Convert.ToString(Request.QueryString["type"])=="3"&&Convert.ToString(Request.QueryString["action"])=="action")
  144. {
  145. sb.Append("update [forum_3] set f3_now='"+DateTime.Now+"' where f3_id="+f3_id+"");          
  146. }
  147. if ((Convert.ToString(Request.QueryString["type"])=="10"||Convert.ToString(Request.QueryString["type"])=="11")&&Convert.ToString(Request.QueryString["action"])=="action")
  148. {
  149. sb.Append("update [forum_3] set f3_distillate="+aboutvalue+" where f3_id="+f3_id+"");          
  150. }
  151. OleDbsql=String.Format(sb.ToString(),values.ToArray());
  152. cmd5=new OleDbCommand(OleDbsql,conn);
  153. //执行对用户金钱积分操作
  154. if (Convert.ToString(Request.QueryString["checkbox"])!="checkbox")
  155. {
  156. OleDbsqluser="update userinfo set u_fenshu=u_fenshu+("+Request.QueryString["dofenshu"]+"),u_money=u_money+("+Request.QueryString["domoney"]+") where u_user='"+powername+"' ";          
  157. cmd7=new OleDbCommand(OleDbsqluser,conn);
  158. userscore=Convert.ToString(Request.QueryString["dofenshu"]);
  159. usermoney=Convert.ToString(Request.QueryString["domoney"]);
  160. }
  161. else
  162. {
  163. userscore="0";
  164. usermoney="0";
  165. }
  166. if (Convert.ToString(Request.QueryString["ismsg"])=="1")
  167. {
  168. 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"]+"')";          
  169. cmd8=new OleDbCommand(OleDbsqlmessage,conn);
  170. }
  171. //插入数据到论坛事件记录表中
  172. OleDbsqladd="insert into [log](l_announceid,l_boardid,l_touser,l_username,l_content,l_ip) values("+f3_id+","+f2_id+",'"+powername+"','"+usercookies+"','[主题操作]"+aboutype+"《"+f3title+"》,原因:"+Request.QueryString["title"]+"  "+Request.QueryString["content"]+",积分操作:"+userscore+" 金钱操作:"+usermoney+"','"+Request.UserHostAddress+"')";          
  173. cmd6=new OleDbCommand(OleDbsqladd,conn);
  174. conn.Open();
  175. bool doredirect=true;
  176. try
  177. {
  178. cmd5.ExecuteNonQuery();
  179. cmd6.ExecuteNonQuery();
  180. if (Convert.ToString(Request.QueryString["checkbox"])!="checkbox")
  181. {
  182. cmd7.ExecuteNonQuery();
  183. }
  184. if (Convert.ToString(Request.QueryString["ismsg"])=="1")
  185. {
  186. cmd8.ExecuteNonQuery();
  187. }
  188. }
  189. catch
  190. {
  191. doredirect=false;
  192. }
  193. finally
  194. {
  195. conn.Close();
  196. }
  197. if(doredirect)
  198. {
  199. Response.Redirect("doarticle_closeto.aspx?f2_id="+f2_id+"");
  200. }
  201. else
  202. {
  203. Response.Redirect("index.aspx");
  204. }
  205. }
  206. }
  207. }
  208. #region Web 窗体设计器生成的代码
  209. override protected void OnInit(EventArgs e)
  210. {
  211. //
  212. // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
  213. //
  214. InitializeComponent();
  215. base.OnInit(e);
  216. }
  217. /// <summary>
  218. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  219. /// 此方法的内容。
  220. /// </summary>
  221. private void InitializeComponent()
  222. {    
  223. this.Load += new System.EventHandler(this.Page_Load);
  224. }
  225. #endregion
  226. }
  227. }