⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 default.aspx.cs

📁 简易BBS源码,包括系统管理、论坛管理、用户可以看懂源码
💻 CS
📖 第 1 页 / 共 2 页
字号:
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.Net;
using System.Data.SqlClient;

namespace free.bbs
{
	/// <summary>
	/// Summary description for _default.
	/// </summary>
	public partial class _default : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label Label4;
		protected System.Web.UI.WebControls.Label Label5;

		protected System.Web.HttpBrowserCapabilities bc;

		protected System.Data.SqlClient.SqlConnection myconn;
		protected System.Data.SqlClient.SqlCommand mycomm;
		protected System.Web.UI.WebControls.Image Image1;
		protected System.Web.UI.WebControls.Image Image19;
		protected System.Web.UI.WebControls.Image Image20;
		protected System.Web.UI.WebControls.Image Image21;
		protected System.Web.UI.WebControls.Image Image22;
		protected System.Web.UI.WebControls.Image Image23;
		protected System.Web.UI.WebControls.Image Image24;
		protected System.Web.UI.WebControls.Image Image25;
		protected System.Web.UI.WebControls.Image Image26;
		protected System.Web.UI.WebControls.Image Image27;
		protected System.Web.UI.WebControls.Image Image28;
		protected System.Web.UI.WebControls.Image Image29;
		protected System.Web.UI.WebControls.Image Image30;
		protected System.Web.UI.WebControls.Image Image31;
		protected System.Web.UI.WebControls.Image Image32;
		protected System.Web.UI.WebControls.Image Image33;
		protected System.Web.UI.WebControls.Image Image34;
		protected System.Web.UI.WebControls.Image Image2;
		protected System.Web.UI.WebControls.Image Image3;
		protected System.Web.UI.WebControls.Image Image4;
		protected System.Web.UI.WebControls.Image Image5;
		protected System.Web.UI.WebControls.Image Image6;
		protected System.Web.UI.HtmlControls.HtmlTable Table3;
		protected System.Web.UI.WebControls.Label jr;
		string hostname;
		DataSet mydataset=new DataSet();
		DateTime now=DateTime.Now;
		string mysql;
		protected System.Web.UI.WebControls.Label huifu;
		protected System.Web.UI.WebControls.Label zts;
		SqlDataAdapter mydada;
		SqlDataReader read;
		//int jirifatie=0;
		protected void Page_Load(object sender, System.EventArgs e)
		{
			myconn=new SqlConnection(Session["str_connection"].ToString());
			shijian1.Text=now.ToString("yyyy-MM-dd");
			time1.Text=now.DayOfWeek.ToString();
			SqlDataReader reader;
			myconn.Open();
			bool flag1;
			try 
			{
				huiyuan.Text=Request.Cookies["free_huiyuan"].Value.ToString();
				myzhuti.NavigateUrl="myzhuti.aspx?name="+Request.Cookies["free_huiyuan"].Value.ToString()+"&amp;Page=1";	
				myhuifu.NavigateUrl="myhuifu.aspx?name="+Request.Cookies["free_huiyuan"].Value.ToString()+"&amp;Page=1";	
				Application["count"]=(Int32)Application["count"]+1;
				
				if(huiyuan.Text=="dengchu")
				{
					Panel1.Visible=true;
					Panel1.Enabled=true;
					Panel2.Visible=false;
					Panel2.Enabled=false;
					flag1=false;
				}
				else
				{
					flag1=true;
					Panel2.Visible=true;
					Panel2.Enabled=true;
					Panel1.Visible=false;
					Panel1.Enabled=false;
				}

			}
			catch 
			{
				Panel1.Visible=true;
				Panel1.Enabled=true;
				Panel2.Visible=false;
				Panel2.Enabled=false;
				flag1=false;
			}
			if(flag1==true)
			{
				//论坛图象
				mysql="SELECT face FROM huiyuan where yonghuming='"+Request.Cookies["free_huiyuan"].Value.ToString()+"'";			
				mycomm=new SqlCommand(mysql,myconn);
				reader=mycomm.ExecuteReader();
				if(reader.Read())
				{
					touxiang.Src=reader.GetString(0).ToString();
					reader.Close();
				}
				else
					reader.Close();
				mysql="SELECT COUNT(jieshoufang) FROM duanxiaoxi where jieshoufang='"+Request.Cookies["free_huiyuan"].Value.ToString()+"' and islook='0' ";		
				mycomm=new SqlCommand(mysql,myconn);
				reader=mycomm.ExecuteReader();
				if(reader.Read())
				{
					duanxin.Text=reader.GetInt32(0).ToString();
					reader.Close();
				}
				else
					reader.Close();
			}
			mysql="SELECT top 1 yonghuming FROM huiyuan order by zhuceshijian desc";			
			mycomm=new SqlCommand(mysql,myconn);
			reader=mycomm.ExecuteReader();
			if(reader.Read())
			{
				Session["xinhuiyuan"]=reader.GetString(0).ToString().Trim();
				reader.Close();
			}
			else
				reader.Close();
			
			DateTime mytime=new DateTime();
			mytime=Convert.ToDateTime(now.Date);

			mysql="SELECT COUNT(huifu_id) FROM huifu WHERE shijian<'"+mytime+"'and shijian>'"+now.Date.AddDays(-1)+"'";
			mycomm=new SqlCommand(mysql,myconn);
			reader=mycomm.ExecuteReader();
			if(reader.Read())
			{
				zuori.Text=reader.GetInt32(0).ToString();
				reader.Close();
			}
			else
				reader.Close();
			try
			{

				mysql="SELECT COUNT(postid) FROM posts WHERE shijian<'"+mytime+"'and shijian>'"+now.Date.AddDays(-1)+"'";
				mycomm=new SqlCommand(mysql,myconn);
				reader=mycomm.ExecuteReader();
				int n=0;
				if(reader.Read())
				{
					n=Convert.ToInt32((Convert.ToInt32(zuori.Text.ToString())+reader.GetInt32(0)));
					reader.Close();
				}
				else
				{
					reader.Close();
				}
				mysql="SELECT COUNT(huifu_id) FROM huifu WHERE shijian<'"+mytime+"'and shijian>'"+now.Date.AddDays(-1)+"'";
				mycomm=new SqlCommand(mysql,myconn);
				reader=mycomm.ExecuteReader();
				if(reader.Read())
				{
					zuori.Text=Convert.ToString(n+(Convert.ToInt32(zuori.Text.ToString())+reader.GetInt32(0)));
					reader.Close();
				}
				else
				{
					reader.Close();
				}
			}
			catch{}
			Application.Lock();//锁定应用程序
			mydataset.ReadXml(Server.MapPath("count.xml"));//读xml文件
			zgt.Text=mydataset.Tables["MyCount"].Rows[0]["Maxtie"].ToString();
			Session["shijian"]=mydataset.Tables["MyCount"].Rows[0]["tie_shijian"].ToString();
			Label7.Text=mydataset.Tables["MyCount"].Rows[0]["MaxCount"].ToString();
			Label8.Text=mydataset.Tables["MyCount"].Rows[0]["shijian"].ToString();
			Application.UnLock();

			try
			{
				myconn=new SqlConnection(Session["str_connection"].ToString());
				myconn.Open();
			}
			catch{}
			mydataset=new DataSet();
			//今日发贴
			//DateTime now=DateTime.Now;
			//			try
			//			{

			mycomm=new SqlCommand("SELECT COUNT(*) FROM posts WHERE shijian>='"+now.ToString("yyyy-MM-dd")+"'",myconn);
			read=mycomm.ExecuteReader();
			if(read.Read())
			{
				Application["jinritieshu"]="0";
				Application["jinritieshu"]=Convert.ToInt64(Application["jinritieshu"].ToString())+read.GetInt32(0);
				read.Close();
			}
			else
			{
				read.Close();
			}
			mycomm=new SqlCommand("SELECT COUNT(*) FROM huifu  WHERE shijian>='"+now.ToString("yyyy-MM-dd")+"'",myconn);
			read=mycomm.ExecuteReader();
			if(read.Read())
			{
				Application["jinritieshu"]=Convert.ToInt64(Application["jinritieshu"].ToString())+read.GetInt32(0);
				read.Close();
			}
			else
			{
				read.Close();
			}
			//			}
			//			catch{}

			try
			{
				//					HttpCookie CkeCount=new HttpCookie("Count");
				//					if(Request.Cookies["Count"]==null)//如果cookie为空,说明第一次载入您的页面
				//					{
						
				Response.Cookies["Count"].Value="true";
				Application.Lock();
				mydataset.ReadXml(Server.MapPath("count.xml"));
				Application["all"]=int.Parse(mydataset.Tables["MyCount"].Rows[0]["AllCount"].ToString());
				int all;
				all=int.Parse(mydataset.Tables["MyCount"].Rows[0]["AllCount"].ToString());
				mydataset.Tables["MyCount"].Rows[0]["AllCount"]=all+1;
				mydataset.WriteXml(Server.MapPath("count.xml"));
						
				if(Convert.ToInt64(mydataset.Tables["MyCount"].Rows[0]["MaxCount"])<(int)Application["user_sessions"])//如果MaxCount标签里面的值小于当前在线人数的值,就存入,不小于则什么都不做。
				{
					mydataset.Tables["MyCount"].Rows[0]["MaxCount"]=(int)Application["user_sessions"];
					mydataset.Tables["MyCount"].Rows[0]["shijian"]=now.ToString();
					mydataset.WriteXml(Server.MapPath("count.xml"));
				}
				if(Convert.ToInt64(mydataset.Tables["MyCount"].Rows[0]["Maxtie"])<(int)Application["jinritieshu"])//如果MaxCount标签里面的值小于今日发帖数数的值,就存入,不小于则什么都不做。
				{
					mydataset.Tables["MyCount"].Rows[0]["Maxtie"]=Application["jinritieshu"];
					mydataset.Tables["MyCount"].Rows[0]["tie_shijian"]=now.ToString();
					mydataset.WriteXml(Server.MapPath("count.xml"));
				}
				Application.UnLock();
				//					}
				
			}
			catch{}			
					
			try
			{
				mycomm=new SqlCommand("select count(yonghuming) 数量 from huiyuan",myconn);
				read=mycomm.ExecuteReader();
				if(read.Read())
				{
					//string huiyuanshuliang=read["数量"].ToString();
					Application["huiyuanshuliang"]=read["数量"].ToString();
					read.Close();
				}
			}
			catch{}
			try
			{
				mycomm=new SqlCommand("select count(postid) 问题总数 from posts",myconn);
				read=mycomm.ExecuteReader();
				if(read.Read())
				{
					Application["wentizongshu"]=read["问题总数"];
					read.Close();
				}
			}
			catch{}
			try
			{
				mycomm=new SqlCommand("select count(*) 回复总数 from huifu",myconn);
				read=mycomm.ExecuteReader();
				if(read.Read())
				{
					Application["huifuzongshu"]=read["回复总数"];
					read.Close();
				}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -