maintable.aspx.cs
资源名称:论坛源码.rar [点击查看]
上传用户:scene123
上传日期:2010-02-19
资源大小:3311k
文件大小:8k
源码类别:
.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>
- /// maintable 的摘要说明。
- /// </summary>
- public class maintable : System.Web.UI.Page
- {
- protected DateTime dtStartTime = DateTime.Now;
- protected System.Web.UI.WebControls.Repeater parent;
- protected System.Web.UI.WebControls.Repeater Repeater1;
- protected Wuqi.Webdiyer.AspNetPager AspNetPager1;
- protected System.Data.OleDb.OleDbCommand cmd;
- protected System.Data.OleDb.OleDbConnection conn;
- public DataSet dsPending;
- public string usercook;
- public string shownone;
- public string sql;
- public string title;
- public int pass;
- public string master;
- public string OleDbSqlforum;
- public int showpower;
- public int showpower2;
- public int showpower6;
- public int showpower7;
- public int showpower8;
- public int showpower9;
- public int todaynum;
- public int yestoday;
- protected string FilterBadWords(string msg)
- {
- string badwords="妈妈的|我靠|fuck|bitch|他妈的|性爱|法轮功|falundafa|falun|江泽民|共产党|操你妈|三级片|sex|腚|妓|娼|阴蒂|奸|尻|贱|婊|靠|叉|龟头|屄|赑|妣|肏|尻|屌";
- string[] tempstr=badwords.Split('|');
- string finalstr=msg;
- for(int i=0;i<tempstr.Length;i++)
- {
- finalstr=finalstr.Replace(tempstr[i],new String('*',tempstr[i].Length));
- }
- return finalstr;
- return msg;
- }
- protected string getModerator(string strModerators)
- {
- StringBuilder strResult = new StringBuilder();
- if (strModerators != "")
- {
- string[] strModerator = strModerators.Split('|');
- foreach (string strInfos in strModerator)
- {
- strResult.Append("<a href="user_infor.aspx?u_user=");
- strResult.Append(strInfos);
- strResult.Append("" target="_blank">");
- strResult.Append(strInfos);
- strResult.Append("</a> ");
- }
- }
- else
- {
- strResult.Append("暂无版主");
- }
- return strResult.ToString();
- }
- public string GetReply(object o)
- {
- if (Convert.IsDBNull(o) || (string)o == "")
- return "尚未回复";
- else
- return "<a href='user_infor.aspx?u_user="+o+"' target='_blank'>"+o+"</a>";
- }
- public string JudgeImage(string s_1,string s_2,string s_3,int s_4)
- {
- if (s_1=="4")
- return "ztop.gif";
- if (s_1 == "3")
- return "istop.gif";
- if (s_1!= "3"&&s_1!="4"&&s_2=="1")
- return "isbest.gif";
- if (s_3 == "1")
- return "lockfolder.gif";
- if (s_4 >= 10)
- return "hotfolder.gif";
- else
- return "folder.gif";
- }
- private void Page_Load(object sender, System.EventArgs e)
- {
- if (Request.Cookies["jhidden"]!=null)
- {
- usercook=Request.Cookies["jhidden"].Value;
- }
- //从数据表中搜索在线会员和客人数量
- conn = new OleDbConnection(ConfigurationSettings.AppSettings["cnFriends.ConnectionString"]);
- conn = new OleDbConnection(ConfigurationSettings.AppSettings["cnFriends.ConnectionString"]);
- OleDbCommand cmd4 = new OleDbCommand("select count(id) from online where username='客人' and boardid="+Request.QueryString["f2_id"]+"",conn);
- OleDbCommand cmd5 = new OleDbCommand("select count(id) from online where username<>'客人' and boardid="+Request.QueryString["f2_id"]+"",conn);
- conn.Open();
- showpower=(int)cmd4.ExecuteScalar();
- showpower2=(int)cmd5.ExecuteScalar();
- conn.Close();
- //结束
- //搜索该论坛详细信息
- sql="SELECT f2_id, f2_caption, f2_pass, f2_master, f2_todaynum,f2_yestoday FROM forum_2 where f2_id="+Request.QueryString["f2_id"]+"";
- dsPending=new DataSet();
- OleDbDataAdapter adWord=new OleDbDataAdapter(sql,conn);
- adWord.Fill(dsPending,"forum_2");
- Page.DataBind();
- title=Convert.ToString(dsPending.Tables[0].Rows[0]["f2_caption"]);
- todaynum=Convert.ToInt32(dsPending.Tables[0].Rows[0]["f2_todaynum"]);
- master=Convert.ToString(dsPending.Tables[0].Rows[0]["f2_master"]);
- pass=Convert.ToInt32(dsPending.Tables[0].Rows[0]["f2_pass"]);
- yestoday=Convert.ToInt32(dsPending.Tables[0].Rows[0]["f2_yestoday"]);
- //结束
- //获得今日发帖数和昨日发帖数
- OleDbCommand cmd6= new OleDbCommand("SELECT count(f3_id) FROM forum_3 WHERE f3_date=Date()-0 and f3_sy="+Request.QueryString["f2_id"]+"",conn);
- OleDbCommand cmd7 = new OleDbCommand("SELECT count(f4_id) FROM forum_4 WHERE f4_date=Date()-0 and f4_sy1="+Request.QueryString["f2_id"]+"",conn);
- OleDbCommand cmd8= new OleDbCommand("SELECT count(f3_id) FROM forum_3 WHERE f3_date=Date()-1 and f3_sy="+Request.QueryString["f2_id"]+"",conn);
- OleDbCommand cmd9 = new OleDbCommand("SELECT count(f4_id) FROM forum_4 WHERE f4_date=Date()-1 and f4_sy1="+Request.QueryString["f2_id"]+"",conn);
- conn.Open();
- showpower6=(int)cmd6.ExecuteScalar();
- showpower7=(int)cmd7.ExecuteScalar();
- showpower8=(int)cmd8.ExecuteScalar();
- showpower9=(int)cmd9.ExecuteScalar();
- conn.Close();
- OleDbSqlforum="update forum_2 set f2_todaynum="+showpower6+"+"+showpower7+",f2_yestoday="+showpower8+"+"+showpower9+" where f2_id="+Request.QueryString["f2_id"]+"";
- OleDbCommand cmd10=new OleDbCommand(OleDbSqlforum,conn);
- conn.Open();
- bool doredirect=true;
- try
- {
- cmd10.ExecuteNonQuery();
- }
- catch
- {
- doredirect=false;
- }
- finally
- {
- conn.Close();
- }
- if(doredirect)
- {
- }
- else
- {
- }
- //结束
- if(!Page.IsPostBack)
- {
- cmd=new OleDbCommand("select count(f3_id) from forum_3 where f3_sy="+Request.QueryString["f2_id"]+"",conn);
- conn.Open();
- AspNetPager1.RecordCount=(int)cmd.ExecuteScalar();
- if (AspNetPager1.RecordCount==0)
- {shownone="<tr align=center bgColor=#ffffff height=28><td colSpan=5>本版未添加任何记录</td></tr>";}
- conn.Close();
- DataBind();
- }
- }
- void DataBind()
- {
- cmd=new OleDbCommand("SELECT f3_id, f3_motif, f3_count, f3_face, f3_sy, f3_state, f3_top,f3_distillate, f3_name, f3_now, f3_replynum, f3_replyname from forum_3 where f3_sy="+Request.QueryString["f2_id"]+" and f3_state<>2 ORDER BY f3_top DESC ,f3_now DESC",conn);
- OleDbDataAdapter adapter=new OleDbDataAdapter(cmd);
- DataSet ds=new DataSet();
- adapter.Fill(ds,AspNetPager1.PageSize*(AspNetPager1.CurrentPageIndex-1),AspNetPager1.PageSize,"forum_3");
- Repeater1.DataSource=ds.Tables["forum_3"];
- Repeater1.DataBind();
- //动态设置用户自定义文本内容
- AspNetPager1.CustomInfoText="记录总数:<b>"+AspNetPager1.RecordCount.ToString()+"</b>";
- AspNetPager1.CustomInfoText+=" 总页数:<b>"+AspNetPager1.PageCount.ToString()+"</b>";
- AspNetPager1.CustomInfoText+=" 当前页:<font color="red"><b>"+AspNetPager1.CurrentPageIndex.ToString()+"</b></font>";
- }
- #region Web 窗体设计器生成的代码
- override protected void OnInit(EventArgs e)
- {
- //
- // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
- //
- InitializeComponent();
- base.OnInit(e);
- }
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.AspNetPager1.PageChanged += new Wuqi.Webdiyer.PageChangedEventHandler(this.AspNetPager1_PageChanged);
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- private void AspNetPager1_PageChanged(object src, Wuqi.Webdiyer.PageChangedEventArgs e)
- {
- AspNetPager1.CurrentPageIndex=e.NewPageIndex;
- DataBind();
- }
- }
- }