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

📄 mainlist.aspx.cs

📁 一个C#写的WEB论坛
💻 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.Data.SqlClient;


namespace doughty_cn
{
	/// <summary>
	/// Mainlist 的摘要说明。
	/// </summary>
	public partial class Mainlist : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.HyperLink HyperLink1;
		protected System.Data.SqlClient.SqlCommand sqlSelectCommand2;
		protected System.Data.SqlClient.SqlCommand sqlInsertCommand2;
		protected System.Data.SqlClient.SqlCommand sqlUpdateCommand2;
		protected System.Data.SqlClient.SqlCommand sqlDeleteCommand2;
		protected System.Data.SqlClient.SqlConnection sqlConnection2;
		protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter2;
		protected System.Data.SqlClient.SqlCommand sqlCmddelete;
		protected System.Data.SqlClient.SqlCommand sqlSelectCommand4;
		protected System.Data.SqlClient.SqlCommand sqlInsertCommand4;
		protected System.Data.SqlClient.SqlCommand sqlUpdateCommand4;
		protected System.Data.SqlClient.SqlCommand sqlDeleteCommand4;
		protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter4;
		int PageSize,CurrentPage,PageCount;
		public string navigation;

		public void BindGrid() 
		{
			// 在此处放置用户代码以初始化页面
			if(!Page.IsPostBack)
			{
				int BID,SID,solved;
				if ((Request.QueryString["BID"]==null)||(Request.QueryString["SID"]==null))
				{
					BID=1;
					SID=200;
				}
				else
				{
					BID=System.Convert.ToInt32(Request.QueryString["BID"]);
					SID=System.Convert.ToInt32(Request.QueryString["SID"]);
				}
				if (Request.QueryString["solved"]==null)
					solved=0;
				else
					solved=System.Convert.ToInt32(Request.QueryString["solved"]);

				navigation="<font color=#ffffff>当前位置:<a href='default2.aspx'><font color=#ffffff>"+doughty_cn.inputcon.ConvertString.TitleName(this.Request.Url.ToString())+"</font></a> → "
					+"<a href='BigcalssList.aspx?BID="+BID+"'><font color=#ffffff>"+Navigation.GetBigClassName(BID)+"</font></a> → "
					+"<a href='Mainlist.aspx?BID="+BID+"&SID="+SID+"'><font color=#ffffff>"+Navigation.GetSmallClassName(SID)+"</font></a> → 帖子列表";
				HyperlinkNosolved.NavigateUrl="Mainlist.aspx?solved=0&BID="+BID+"&SID="+SID;
				HyperlinkHavesolved.NavigateUrl="Mainlist.aspx?solved=1&BID="+BID+"&SID="+SID;
				if (solved==0)
				{
					navigation=navigation+"(未解决)</font>";
					HyperlinkNosolved.Enabled=false;
				}
				else
				{
					navigation=navigation+"(已解决)</font>";
					HyperlinkHavesolved.Enabled=false;
				}
				HyperLinkAddFiles.NavigateUrl="AddFiles.aspx?BID="+BID+"&SID="+SID;
				Hyperlinksearch.NavigateUrl="search.aspx?BID="+BID+"&SID="+SID;
				HyperlinkPith.NavigateUrl="pith.aspx?BID="+BID+"&SID="+SID;

				PageSize=System.Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings["MainList"]);
				CurrentPage = 0;	
				//计算总共有多少记录
				int RecordCount = DBOperate.CalculateQRecord(BID, SID,solved);
				lblRecordCount.Text = RecordCount.ToString();
				//计算总共有多少页
				PageCount = (RecordCount+PageSize-1)/PageSize;
				if (PageCount<=0)
					PageCount=1;
				lblPageCount.Text = PageCount.ToString();
				//获取页面参数
				if (Request.QueryString["Page"] != null)
					CurrentPage=Convert.ToInt32(Request.QueryString["Page"]);
				else
					CurrentPage=1;
				if (PageCount<CurrentPage)
					CurrentPage=PageCount;
				if (CurrentPage<=0)
					CurrentPage=1;

				//ListBind();
				//设定导入的起终地址
				int StartIndex = (CurrentPage-1)*PageSize;
				this.DL_Main.DataSource= DBOperate.SelectFormForum("SELECT Q_ID, author, Q_Note, Q_Content, ImageName, HiteCounter, ReleaseTime,ReferTime, BigClass_ID, SmallClass_ID, AnsCounter, kind, solved FROM Questions WHERE (SmallClass_ID = "+SID+") AND (kind > 0) AND (kind < 5) AND (solved ="+solved+") ORDER BY kind DESC, ReleaseTime DESC",StartIndex,PageSize,"Questions");
				this.Page.DataBind();

				lnkNext.Enabled = true;
				lnkPrev.Enabled = true;
				if(CurrentPage==(PageCount))
				{
					lnkNext.Enabled = false;
				}
				else
					lnkNext.NavigateUrl=Request.CurrentExecutionFilePath+ "?solved="+solved+"&BID="+ BID.ToString()+"&SID="+ SID.ToString()+"&Page=" + Convert.ToString(CurrentPage+1);
				if(CurrentPage==1)
					lnkPrev.Enabled = false;
				else
					lnkPrev.NavigateUrl=Request.CurrentExecutionFilePath + "?solved="+solved+"&BID="+ BID.ToString()+"&SID="+ SID.ToString()+"&Page=" + Convert.ToString(CurrentPage-1);
				lblCurrentPage.Text = CurrentPage.ToString();

				ShowManagers(BID, SID);//显示版主名单,并授权管理
			}
		}

		public void ShowManagers(int BID,int SID)
		{
			//显示版主名单,并授权管理
			DataTable d = DBOperate.SelectFormForum("SELECT PKID, Bigclass_ID, Smallclass_ID, ManagerName FROM Managers");
			DataRow [] drs = d.Select("SmallClass_ID="+ SID.ToString());
			string s="";
			bool ismanager=false;
			foreach( DataRow r in drs)
			{
				if (s!="")
					s=s+",";
				s=s+"<a href=\"SendSMsg.aspx?QID="+r["ManagerName"].ToString()+"\" target=\"_blank\">"+r["ManagerName"].ToString()+"</a>";
				if (User.Identity.Name.ToString()==r["ManagerName"].ToString())
				{
					ismanager=true;
				}
			}
			if (s=="")
				LblManagers.Text="版主:暂无";
			else
				LblManagers.Text="版主:"+s;

			drs = d.Select("BigClass_ID="+ BID.ToString()+" and SmallClass_ID=0");
			s="";

			//大版主
			foreach( DataRow r in drs )
			{
				if (s!="")
					s=s+",";
				s=s+"<a href=\"SendSMsg.aspx?QID="+r["ManagerName"].ToString()+"\" target=\"_blank\">"+r["ManagerName"].ToString()+"</a>";
				if (User.Identity.Name.ToString()==r["ManagerName"].ToString())
				{
					ismanager=true;
				}
			}
			if (s=="")
				LblB.Text="大版主:暂无";
			else
				LblB.Text="大版主:"+s;


			if (!ismanager)
			{
				for (int i=0;i<DL_Main.Items.Count;i++ )
				{
					DL_Main.Items[i].FindControl("selected").Visible=false;
				}
				Panel1.Visible=false;
			}
			else
			{
				DropDownList1.DataSource=DBOperate.SelectFormForum("SELECT *,Big_Class.BigClass_Name + '-' + Small_Class.SmallClass_Name AS BSName FROM Big_Class INNER JOIN Small_Class ON Big_Class.BigClass_ID = Small_Class.BigClass_ID WHERE (Big_Class.Enable = 1) AND (Small_Class.Enable = 1) ORDER BY Small_Class.BigClass_ID");
				DropDownList1.DataBind();
			}
		}

		protected void Page_Load(object sender, System.EventArgs e)
		{
			//获得在线用户数
			if (System.Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings["BorowsArea"])>2)
			{
				if (User.Identity.Name.ToString()=="")
				{
					this.Response.Redirect("logon.aspx");
				}
			}
			if (!this.IsPostBack)
			{
				int i=(int)Application.Get("logincount");
				Lbl_UserCou.Text="在线人数:"+i.ToString();

				//判断用户是否登录
				if (Session["UserGrade"]==null)
					Session["UserGrade"]=DBOperateSite.GetUserGrade(User.Identity.Name);
				Lbl_UserGrade.Text="用户级别:"+ Session["UserGrade"].ToString();
				if ((User.Identity.Name==null)||(User.Identity.Name==""))
				{
					Lbl_UserName.Text="当前用户:过客";
					Lb_logon.Text="用户登录";
				}
				else
				{
					Lbl_UserName.Text="当前用户:"+User.Identity.Name.ToString();
					Lb_logon.Text="重新登录";
				}
				Lbl_IP.Text="用户IP:"+this.Request.UserHostAddress;

				HaveShortMsg();

				this.DL_Main.DataSource=DBOperate.SelectFormForum("SELECT *, Big_Class.BigClass_Name + '-' + Small_Class.SmallClass_Name AS BSName FROM Big_Class INNER JOIN Small_Class ON Big_Class.BigClass_ID = Small_Class.BigClass_ID WHERE (Big_Class.Enable = 1) AND (Small_Class.Enable = 1) ORDER BY Small_Class.BigClass_ID");
				BindGrid();
			}
		}

		//计算是否有短消息
		public void HaveShortMsg()
		{
			int intCount;
			intCount=DBOperate.ShortMsgCount(this.User.Identity.Name.ToString());

			if (intCount==0)
				this.Panel2.Visible=false;
			else
				this.Panel2.Visible=true;
		}


		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.sqlSelectCommand2 = new System.Data.SqlClient.SqlCommand();
			this.sqlConnection2 = new System.Data.SqlClient.SqlConnection();
			this.sqlInsertCommand2 = new System.Data.SqlClient.SqlCommand();
			this.sqlUpdateCommand2 = new System.Data.SqlClient.SqlCommand();
			this.sqlDeleteCommand2 = new System.Data.SqlClient.SqlCommand();
			this.sqlDataAdapter2 = new System.Data.SqlClient.SqlDataAdapter();
			this.sqlCmddelete = new System.Data.SqlClient.SqlCommand();
			this.sqlSelectCommand4 = new System.Data.SqlClient.SqlCommand();
			this.sqlInsertCommand4 = new System.Data.SqlClient.SqlCommand();
			this.sqlUpdateCommand4 = new System.Data.SqlClient.SqlCommand();

⌨️ 快捷键说明

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