reply_articleto.aspx.cs
资源名称:论坛源码.rar [点击查看]
上传用户:scene123
上传日期:2010-02-19
资源大小:3311k
文件大小:6k
源码类别:
.net编程
开发平台:
C#
- using System;
- using System.Collections;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Web;
- using System.Web.SessionState;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.HtmlControls;
- using System.Data.OleDb;
- using System.Text;
- using System.Configuration;
- using System.Web.Security;
- using System.Security.Cryptography;
- using System.IO;
- namespace kuangren
- {
- /// <summary>
- /// reply_articleto 的摘要说明。
- /// </summary>
- public class reply_articleto : System.Web.UI.Page
- {
- protected int intRunTime;
- protected DateTime dtStartTime = DateTime.Now;
- protected System.Data.OleDb.OleDbCommand cmd;
- protected System.Data.OleDb.OleDbCommand cmd3;
- protected System.Data.OleDb.OleDbCommand cmd4;
- protected System.Data.OleDb.OleDbCommand cmd5;
- protected System.Data.OleDb.OleDbConnection conn;
- public string OleDbSqlvisited;
- public string OleDbSqlforum;
- public DataSet dsPending;
- public DataSet dsPending3;
- public string sql;
- public string sql3;
- protected string lastmotif;
- protected string OleDbuser;
- public int userjudge2;
- public int userjudge3;
- public int sum1;
- public int sum2;
- public int sum3;
- public int sum4;
- public int sum5;
- private void Page_Load(object sender, System.EventArgs e)
- {
- if (Request.Cookies["jusername"]==null)
- {
- Response.Redirect("logine.aspx");
- }
- string str1=""+Request.Form["content"]+"";
- userjudge3=System.Text.Encoding.Default.GetByteCount(str1);
- if (userjudge2>50||userjudge3>16240||userjudge3==0)
- {
- Response.Redirect("announcerror.aspx");
- }
- OleDbConnection con;
- string OleDbsql;
- OleDbCommand cmd;
- StringBuilder sb=new StringBuilder();
- ArrayList values=new ArrayList();
- 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}')");
- values.Add(Request.Form["subject"]);
- values.Add(Request.Form["content"]);
- values.Add(Request.Form["f3_face"]);
- values.Add(Request.Form["f3_name"]);
- values.Add(Convert.ToInt32(Request.Form["f2_sy"]));
- values.Add(Convert.ToInt32(Request.Form["f3_sy"]));
- values.Add(Request.UserHostAddress);
- if(Request.Form["f3_html"]!="")
- values.Add(0);
- else
- values.Add(1);
- OleDbsql=String.Format(sb.ToString(),values.ToArray());
- con=new OleDbConnection(ConfigurationSettings.AppSettings["cnFriends.ConnectionString"]);
- cmd=new OleDbCommand(OleDbsql,con);
- 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"]+"";
- cmd3=new OleDbCommand(OleDbSqlvisited,con);
- sql="SELECT f3_motif from forum_3 where f3_id="+Request.Form["f3_sy"]+" order by f3_id desc";
- dsPending=new DataSet();
- OleDbDataAdapter adWord=new OleDbDataAdapter(sql,con);
- adWord.Fill(dsPending,"forum_3");
- lastmotif=Convert.ToString(dsPending.Tables[0].Rows[0]["f3_motif"]);
- 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"]+"";
- cmd4=new OleDbCommand(OleDbSqlforum,con);
- 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"]+"'";
- cmd5=new OleDbCommand(OleDbuser,con);
- con.Open();
- bool doredirect=true;
- try
- {
- cmd.ExecuteNonQuery();
- cmd3.ExecuteNonQuery();
- cmd4.ExecuteNonQuery();
- cmd5.ExecuteNonQuery();
- }
- catch
- {
- doredirect=false;
- }
- finally
- {
- con.Close();
- }
- if(doredirect)
- {
- }
- else
- {
- Response.Redirect("index.aspx");
- }
- //定义发帖统计
- 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";
- dsPending3=new DataSet();
- OleDbDataAdapter adWord3=new OleDbDataAdapter(sql3,con);
- adWord3.Fill(dsPending3,"forum_2");
- Page.DataBind();
- sum1=Convert.ToInt32(dsPending3.Tables[0].Rows[0]["sum1"]);
- sum2=Convert.ToInt32(dsPending3.Tables[0].Rows[0]["sum2"]);
- sum3=Convert.ToInt32(dsPending3.Tables[0].Rows[0]["sum3"])+1;
- sum4=Convert.ToInt32(dsPending3.Tables[0].Rows[0]["sum4"]);
- sum5=sum1+sum2;
- //结束
- //写文件
- using (StreamWriter sw = new StreamWriter(Server.MapPath("Writerfile1.aspx"),false,System.Text.Encoding.GetEncoding("gb2312")))
- {
- // Add some text to the file.
- sw.Write("<table width='100%' border='0' cellspacing='0' cellpadding='0'>");
- sw.WriteLine("<tr> ");
- sw.WriteLine("<td width='50%'>今日发贴:<font color=#ff0000><b>"+sum3+"</b></font> 篇</td>");
- sw.Write("<td width='50%'>主题总数:<b>"+sum1+"</b> 篇 </td>");
- sw.Write("</tr>");
- sw.Write("<tr>");
- sw.Write("<td width='50%'>昨日发贴:<b>"+sum4+"</b> 篇 </td>");
- sw.Write("<td width='50%'>帖子总数:<b>"+sum5+"</b> 篇 </td>");
- sw.Write("</tr>");
- sw.Write("</table>");
- sw.Close();
- }
- //结束
- con.Close();
- }
- #region Web 窗体设计器生成的代码
- override protected void OnInit(EventArgs e)
- {
- //
- // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
- //
- InitializeComponent();
- base.OnInit(e);
- }
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- }
- }