using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; public partial class master : System.Web.UI.MasterPage { protected void Page_Load(object sender, EventArgs e) { SqlConnection conn = new SqlConnection("Server=localhost\\SQLEXPRESS;database=bbs;Integrated security=true"); if (Session["userid"] != null && Session["username"] != null) { username.Text = Session["username"].ToString(); lastlogin.Text = Session["lastlogin"].ToString(); string strsql = "select * from class,banzhu where class.id = banzhu.classid and userid='" + Session["userid"].ToString() + "'"; SqlCommand myComm = new SqlCommand(strsql, conn); conn.Open(); SqlDataReader myReader = myComm.ExecuteReader(); if (myReader.HasRows) { status.Text = "担任的社区版主"; string strStatus = ""; Session["banzhu"] = i.ToString(); shenfen.InnerHtml = strStatus; } else { status.Text= "您是普通会员!"; } myReader.Close(); strsql = "select * from [user] where userid ='" + Session["userid"].ToString() + "'"; myComm.CommandText = strsql; myReader = myComm.ExecuteReader(); myReader.Read(); blognum.Text = myReader["blognum"].ToString(); myReader.Close(); conn.Close(); myArticle.NavigateUrl = "article.aspx?my=" + Session["userid"].ToString(); addArticle.NavigateUrl = "articleEdit.aspx?action=add"; } string sql = "select * from class"; SqlCommand Comm = new SqlCommand(sql, conn); conn.Open(); SqlDataReader Reader = Comm.ExecuteReader(); if (Reader.HasRows) { string str = ""; online.InnerHtml = str; Reader.Close(); } else { online.InnerHtml = "没有论坛分区"; } conn.Close(); } }