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

📄 guanli2.aspx.cs

📁 简易BBS源码,包括系统管理、论坛管理、用户可以看懂源码
💻 CS
字号:
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 free.bbs
{
	/// <summary>
	/// Summary description for guanli2.
	/// </summary>
	public partial class guanli2 : System.Web.UI.Page
	{
		protected System.Data.SqlClient.SqlConnection myconn;
		protected System.Data.SqlClient.SqlCommand mycomm;
		string sqlstr;
		SqlDataReader myread;
		string ans;
	
		protected void Page_Load(object sender, System.EventArgs e)
		{
			myconn=new SqlConnection(Session["str_connection"].ToString());
			myconn.Open();
			try
			{
				if(Request.Cookies["free_huiyuan"].Value.ToString()!="free911")
				{
					try
					{
						ans=Request.Params["ancestor_id"];
						mycomm=new SqlCommand("select neirong from ancestor where (ancestor_id="+Request.Params["ancestor_id"]+" and banzhu='"+Request.Cookies["free_huiyuan"].Value.ToString()+"')",myconn);
						myread=mycomm.ExecuteReader();
						try
						{
							myread.Read();
							Session["leibie"]=myread["neirong"].ToString().Trim();
							l_1.Text=myread["neirong"].ToString().Trim();
							myread.Close();
				
						}
						catch
						{
							myread.Close();
							Response.Redirect("guanlidenglu.aspx?ancestor_id="+Request.Params["ancestor_id"]+"");
						}
					}
					catch{
					Response.Redirect("guanlidenglu.aspx?ancestor_id="+Request.Params["ancestor_id"]+"");
					}
				}
			}
			catch
			{
				Response.Redirect("guanlidenglu.aspx?ancestor_id="+Request.Params["ancestor_id"]+"");
			}
			
			
			myconn.Close();
			BindGrid();
		}
		private void BindGrid()
		{
			//sqlstr="select huifu.huifu_id as huifu_id,huifu.neirong as neirong ,huifu.yonghuming as yonghuming,huifu.shijian as shijian  from posts, huifu  where posts.ancestor_id="+Request.Params["ancestor_id"]+" and posts.postid=huifu.post_id order by shijian desc";
			
			try
			{
				
				
				switch (d_2.SelectedIndex)
				{
					case 0:
						if(t_1.Text.Trim()=="")
							sqlstr="select huifu.huifu_id as huifu_id,huifu.neirong as neirong ,huifu.yonghuming as yonghuming,huifu.shijian as shijian  from posts, huifu  where posts.ancestor_id="+Request.Params["ancestor_id"]+" and posts.postid=huifu.post_id order by huifu.shijian ";
						else
							sqlstr="select huifu.huifu_id as huifu_id,huifu.neirong as neirong ,huifu.yonghuming as yonghuming,huifu.shijian as shijian  from posts ,huifu  where posts.ancestor_id="+Convert.ToInt32(ans)+" and posts.postid=huifu.post_id and huifu.shijian='"+t_1.Text.Trim().ToString()+"' ";
						break;
					case 1:
						if(t_1.Text.Trim()=="")
							sqlstr="select huifu.huifu_id as huifu_id,huifu.neirong as neirong ,huifu.yonghuming as yonghuming,huifu.shijian as shijian  from posts, huifu  where posts.ancestor_id="+Request.Params["ancestor_id"]+" and posts.postid=huifu.post_id order by shijian desc";
						else
							sqlstr="select huifu.huifu_id as huifu_id,huifu.neirong as neirong ,huifu.yonghuming as yonghuming,huifu.shijian as shijian  from posts, huifu  where posts.ancestor_id="+Request.Params["ancestor_id"]+" and posts.postid=huifu.post_id and huifu.shijian>='"+t_1.Text.Trim().ToString()+"'  order by shijian desc ";
						break;
					case 2:
						if(t_1.Text.Trim()=="")
							sqlstr="select huifu.huifu_id as huifu_id,huifu.neirong as neirong ,huifu.yonghuming as yonghuming,huifu.shijian as shijian  from posts, huifu  where posts.ancestor_id="+Request.Params["ancestor_id"]+" and posts.postid=huifu.post_id order by shijian desc";
						else
							sqlstr="select huifu.huifu_id as huifu_id,huifu.neirong as neirong ,huifu.yonghuming as yonghuming,huifu.shijian as shijian  from posts, huifu  where posts.ancestor_id="+Request.Params["ancestor_id"]+" and posts.postid=huifu.post_id and huifu.shijian<='"+t_1.Text.Trim().ToString()+"'  order by shijian desc ";
						break;
									
					case 3:
						if(t_1.Text.Trim()=="")
							sqlstr="select huifu.huifu_id as huifu_id,huifu.neirong as neirong ,huifu.yonghuming as yonghuming,huifu.shijian as shijian  from posts, huifu  where posts.ancestor_id="+Request.Params["ancestor_id"]+" and posts.postid=huifu.post_id order by shijian desc";
						else
							sqlstr="select huifu.huifu_id as huifu_id,huifu.neirong as neirong ,huifu.yonghuming as yonghuming,huifu.shijian as shijian  from posts, huifu  where posts.ancestor_id="+Request.Params["ancestor_id"]+" and posts.postid=huifu.post_id and huifu.shijian>'"+t_1.Text.Trim().ToString()+"'  order by shijian desc ";
						break;
					case 4:
						if(t_1.Text.Trim()=="")
							sqlstr="select huifu.huifu_id as huifu_id,huifu.neirong as neirong ,huifu.yonghuming as yonghuming,huifu.shijian as shijian  from posts, huifu  where posts.ancestor_id="+Request.Params["ancestor_id"]+" and posts.postid=huifu.post_id order by shijian desc";
						else
							sqlstr="select huifu.huifu_id as huifu_id,huifu.neirong as neirong ,huifu.yonghuming as yonghuming,huifu.shijian as shijian  from posts, huifu  where posts.ancestor_id="+Request.Params["ancestor_id"]+" and posts.postid=huifu.post_id and huifu.shijian>'"+t_1.Text.Trim().ToString()+"'  order by shijian desc ";
						break;
				}
			}
			catch{}
			myconn.Open();
			SqlDataAdapter mydra=new SqlDataAdapter(sqlstr,myconn);
			DataSet mydas=new DataSet();
			mydra.Fill(mydas,"zhuti");
			DataGrid1.DataSource=mydas.Tables["zhuti"].DefaultView;
			DataGrid1.DataBind();
			myconn.Close();
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.DataGrid1.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.DataGrid1_PageIndexChanged);
			this.DataGrid1.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_DeleteCommand);
		}
		#endregion


		protected void Button1_Click(object sender, System.EventArgs e)
		{
			BindGrid();
		}

		private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
		{
			DataGrid1.CurrentPageIndex = e.NewPageIndex;
			BindGrid();
		}

		private void DataGrid1_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			string deletecmd="delete from huifu where huifu_id=@huifu_id";
			SqlCommand mycomm=new SqlCommand(deletecmd,myconn);
			mycomm.Parameters.Add(new SqlParameter("@huifu_id",SqlDbType.Int));
			mycomm.Parameters["@huifu_id"].Value=DataGrid1.DataKeys[(int)e.Item.ItemIndex];
			mycomm.Connection.Open();
			mycomm.ExecuteNonQuery();
			mycomm.Connection.Close();
			BindGrid();
		
		}
	}
}

⌨️ 快捷键说明

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