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

.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.Text;
  13. using System.Configuration;
  14. using System.Web.Security;
  15. using System.Security.Cryptography;
  16. using System.IO;
  17. namespace kuangren
  18. {
  19. /// <summary>
  20. /// reply_articleto 的摘要说明。
  21. /// </summary>
  22. public class reply_articleto : System.Web.UI.Page
  23. {
  24. protected int intRunTime;
  25. protected DateTime dtStartTime = DateTime.Now;
  26. protected System.Data.OleDb.OleDbCommand cmd;
  27. protected System.Data.OleDb.OleDbCommand cmd3;
  28. protected System.Data.OleDb.OleDbCommand cmd4;
  29. protected System.Data.OleDb.OleDbCommand cmd5;
  30. protected System.Data.OleDb.OleDbConnection conn;
  31. public string OleDbSqlvisited;
  32. public string OleDbSqlforum;
  33. public    DataSet dsPending;
  34. public    DataSet dsPending3;
  35. public string sql;
  36. public string sql3;
  37. protected string lastmotif;
  38. protected string OleDbuser;
  39. public int userjudge2;
  40. public int userjudge3;
  41. public int sum1;
  42. public int sum2;
  43. public int sum3;
  44. public int sum4;
  45. public int sum5;
  46. private void Page_Load(object sender, System.EventArgs e)
  47. {
  48. if (Request.Cookies["jusername"]==null)
  49. {
  50. Response.Redirect("logine.aspx");
  51. }
  52. string str1=""+Request.Form["content"]+"";
  53. userjudge3=System.Text.Encoding.Default.GetByteCount(str1);
  54. if  (userjudge2>50||userjudge3>16240||userjudge3==0)
  55. {
  56. Response.Redirect("announcerror.aspx");
  57. }
  58. OleDbConnection con;
  59. string OleDbsql;
  60. OleDbCommand cmd;
  61. StringBuilder sb=new StringBuilder();
  62. ArrayList values=new ArrayList();
  63. sb.Append("INSERT INTO [forum_4] (f4_motif,f4_content,f4_face,f4_name,f4_sy1,f4_sy2,f4_uip,f4_html)  values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')"); 
  64.             
  65. values.Add(Request.Form["subject"]);
  66. values.Add(Request.Form["content"]); 
  67. values.Add(Request.Form["f3_face"]);
  68. values.Add(Request.Form["f3_name"]);
  69. values.Add(Convert.ToInt32(Request.Form["f2_sy"]));
  70. values.Add(Convert.ToInt32(Request.Form["f3_sy"]));
  71. values.Add(Request.UserHostAddress);
  72. if(Request.Form["f3_html"]!="")
  73. values.Add(0);
  74. else
  75. values.Add(1);
  76. OleDbsql=String.Format(sb.ToString(),values.ToArray());
  77. con=new OleDbConnection(ConfigurationSettings.AppSettings["cnFriends.ConnectionString"]);
  78. cmd=new OleDbCommand(OleDbsql,con);
  79. OleDbSqlvisited="update [forum_3] set f3_replynum=f3_replynum+1,f3_now='"+DateTime.Now+"',f3_replyname='"+Request.Cookies["jusername"].Value+"' where f3_id="+Request.Form["f3_sy"]+"";          
  80. cmd3=new OleDbCommand(OleDbSqlvisited,con);
  81. sql="SELECT f3_motif  from forum_3 where f3_id="+Request.Form["f3_sy"]+" order by f3_id desc";
  82. dsPending=new DataSet();
  83. OleDbDataAdapter adWord=new OleDbDataAdapter(sql,con);
  84. adWord.Fill(dsPending,"forum_3");
  85. lastmotif=Convert.ToString(dsPending.Tables[0].Rows[0]["f3_motif"]);
  86. OleDbSqlforum="update [forum_2] set f2_replynum=f2_replynum+1,f2_lastpostuser='"+Request.Cookies["jusername"].Value+"',f2_lastposttime='"+DateTime.Now+"',f2_lastrootid="+Request.Form["f3_sy"]+",f2_lasttopic='"+lastmotif+"' where f2_id="+Request.Form["f2_sy"]+"";          
  87. cmd4=new OleDbCommand(OleDbSqlforum,con);
  88. OleDbuser="update [userinfo]  SET u_post=u_post+1,u_money=u_money+1,u_fenshu=u_fenshu+1 where u_user='"+Request.Form["f3_name"]+"'";          
  89. cmd5=new OleDbCommand(OleDbuser,con);
  90. con.Open();
  91. bool doredirect=true;
  92. try
  93. {
  94. cmd.ExecuteNonQuery();
  95. cmd3.ExecuteNonQuery();
  96. cmd4.ExecuteNonQuery();
  97. cmd5.ExecuteNonQuery();
  98. }
  99. catch
  100. {
  101. doredirect=false;
  102. }
  103. finally
  104. {
  105. con.Close();
  106. }
  107. if(doredirect)
  108. {
  109. }
  110. else
  111. {
  112. Response.Redirect("index.aspx");
  113. }
  114. //定义发帖统计
  115. sql3="SELECT sum(f2_topicnum) as  sum1,sum(f2_replynum) as sum2,sum(f2_todaynum) as sum3,sum(f2_yestoday) as sum4  FROM forum_2";
  116. dsPending3=new DataSet();
  117. OleDbDataAdapter adWord3=new OleDbDataAdapter(sql3,con);
  118. adWord3.Fill(dsPending3,"forum_2");
  119. Page.DataBind();
  120. sum1=Convert.ToInt32(dsPending3.Tables[0].Rows[0]["sum1"]);
  121. sum2=Convert.ToInt32(dsPending3.Tables[0].Rows[0]["sum2"]);
  122. sum3=Convert.ToInt32(dsPending3.Tables[0].Rows[0]["sum3"])+1;
  123. sum4=Convert.ToInt32(dsPending3.Tables[0].Rows[0]["sum4"]);
  124. sum5=sum1+sum2;
  125. //结束
  126. //写文件
  127. using (StreamWriter sw = new StreamWriter(Server.MapPath("Writerfile1.aspx"),false,System.Text.Encoding.GetEncoding("gb2312")))
  128. {
  129. // Add some text to the file.
  130. sw.Write("<table width='100%' border='0' cellspacing='0' cellpadding='0'>");
  131. sw.WriteLine("<tr> ");
  132. sw.WriteLine("<td width='50%'>今日发贴:<font color=#ff0000><b>"+sum3+"</b></font> 篇</td>");
  133. sw.Write("<td width='50%'>主题总数:<b>"+sum1+"</b> 篇 </td>");
  134. sw.Write("</tr>");
  135. sw.Write("<tr>");
  136. sw.Write("<td width='50%'>昨日发贴:<b>"+sum4+"</b> 篇 </td>");
  137. sw.Write("<td width='50%'>帖子总数:<b>"+sum5+"</b> 篇 </td>");  
  138. sw.Write("</tr>");
  139. sw.Write("</table>");
  140. sw.Close();
  141. }
  142. //结束
  143. con.Close();
  144. }
  145. #region Web 窗体设计器生成的代码
  146. override protected void OnInit(EventArgs e)
  147. {
  148. //
  149. // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
  150. //
  151. InitializeComponent();
  152. base.OnInit(e);
  153. }
  154. /// <summary>
  155. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  156. /// 此方法的内容。
  157. /// </summary>
  158. private void InitializeComponent()
  159. {    
  160. this.Load += new System.EventHandler(this.Page_Load);
  161. }
  162. #endregion
  163. }
  164. }