user_board.aspx.cs
资源名称:论坛源码.rar [点击查看]
上传用户:scene123
上传日期:2010-02-19
资源大小:3311k
文件大小:5k
源码类别:
.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.Configuration;
- using System.Text;
- namespace kuangren
- {
- /// <summary>
- /// user_board 的摘要说明。
- /// </summary>
- public class user_board : System.Web.UI.Page
- {
- protected int intRunTime;
- protected DateTime dtStartTime = DateTime.Now;
- protected System.Data.OleDb.OleDbCommand cmd;
- protected System.Data.OleDb.OleDbCommand cmd1;
- protected System.Data.OleDb.OleDbCommand cmd2;
- protected System.Data.OleDb.OleDbCommand cmd3;
- protected System.Data.OleDb.OleDbCommand cmd4;
- protected System.Data.OleDb.OleDbCommand cmd5;
- protected System.Data.OleDb.OleDbCommand cmd6;
- protected System.Data.OleDb.OleDbConnection conn;
- protected System.Web.UI.WebControls.Repeater usernews;
- protected System.Web.UI.WebControls.Repeater userpower;
- public DataSet dsPending;
- public string sql;
- public float upostdel;
- public int showarticle;
- public string norecord;
- public int showpower;
- public string nopower;
- public string usercookies;
- public string messagejudge;
- public DataSet dsuser;
- public int countnews;
- public int JudgeImage(object o)
- {
- if ((int)o == 0)
- {
- return 111;
- }
- else
- {
- return 112;
- };
- }
- private void Page_Load(object sender, System.EventArgs e)
- {
- if (Request.Cookies["jusername"]!=null)
- {
- usercookies=Request.Cookies["jusername"].Value;
- }
- else
- {
- Response.Redirect("logine.aspx");
- }
- conn = new OleDbConnection(ConfigurationSettings.AppSettings["cnFriends.ConnectionString"]);
- sql="SELECT * FROM userinfo WHERE u_User = '" +usercookies+ "'";
- dsPending=new DataSet();
- OleDbDataAdapter adWord=new OleDbDataAdapter(sql,conn);
- adWord.Fill(dsPending,"userinfo");
- Page.DataBind();
- //以下为搜索用户最新的的五条短消息
- DataSet ds = new DataSet();
- OleDbDataAdapter cmd1 = new OleDbDataAdapter("select top 5 * from forum_5 where p_take='"+usercookies+"'order by p_id desc",conn);
- OleDbCommand cmd2 = new OleDbCommand("select count(p_id) from forum_5 where p_take='"+usercookies+"'",conn);
- conn.Open();
- showarticle=(int)cmd2.ExecuteScalar();
- //Create and fill the DataSet.
- cmd1.Fill(ds,"forum_5");
- //Create a second DataAdapter for the Titles table.
- //Bind the Authors table to the parent Repeater control, and call DataBind.
- usernews.DataSource = ds.Tables["forum_5"];
- Page.DataBind();
- //Close the connection.
- conn.Close();
- if (showarticle==0)
- {
- norecord="您的收件箱中没有任何内容。";
- }
- //
- //以下为判断用户最新发表文章
- DataSet dspower = new DataSet();
- OleDbDataAdapter cmd3 = new OleDbDataAdapter("select top 5 f3_id, f3_motif, f3_face, f3_sy, f3_name, f3_now from forum_3 where f3_name='"+usercookies+"'order by f3_id desc",conn);
- OleDbCommand cmd4 = new OleDbCommand("select count(f3_id) from forum_3 where f3_name='"+usercookies+"'",conn);
- conn.Open();
- showpower=(int)cmd4.ExecuteScalar();
- //Create and fill the DataSet.
- cmd3.Fill(dspower,"forum_3");
- //Create a second DataAdapter for the Titles table.
- //Bind the Authors table to the parent Repeater control, and call DataBind.
- userpower.DataSource = dspower.Tables["forum_3"];
- Page.DataBind();
- //Close the connection.
- conn.Close();
- if (showpower==0)
- {
- nopower="未发表任何文章";
- }
- //判断是否有新的短消息
- cmd5=new OleDbCommand("select p_id from forum_5 where p_take='"+usercookies+"'and p_yn=0",conn);
- OleDbCommand cmd6 = new OleDbCommand("select count(p_id) from forum_5 where p_take='"+usercookies+"'and p_yn=0",conn);
- dsuser=new DataSet();
- cmd5.Connection.Open();
- countnews=(int)cmd6.ExecuteScalar();
- OleDbDataReader objDataReader ;
- objDataReader = cmd5.ExecuteReader();
- if (objDataReader.Read() == true)
- {
- messagejudge="<img src=images/newmail.gif border=0> <a href=user_board_message.aspx><font color=red>您的收件箱中有新的短消息<b>( "+countnews+" )</b>封</font></a>";
- }
- else
- {
- messagejudge="<img src=images/newmail.gif border=0> <a href=user_board_message.aspx><font color=#999999>您的收件箱中没有新的短消息</font></a>";
- }
- cmd5.Connection.Close();
- dsuser.Clear();
- conn.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
- }
- }