📄 guanli1.aspx.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 guanli1.
/// </summary>
public partial class guanli1 : 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
{
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();
}
}
catch
{
try
{
mycomm=new SqlCommand("select zhuti from posts where postid="+Request.Params["post_id"]+" ",myconn);
}
catch
{
Response.Redirect("error1.aspx");
}
myread=mycomm.ExecuteReader();
try
{
myread.Read();
l_1.Text="主题:"+myread["zhuti"].ToString().Trim();
myread.Close();
}
catch
{}
}
myconn.Close();
BindGrid();
}
private void BindGrid()
{
try
{
string str=Request.Params["post_id"];
sqlstr="select huifu.huifu_id as huifu_id,huifu.neirong as neirong ,huifu.yonghuming as yonghuming,huifu.shijian as shijian from posts ,huifu where huifu.post_id="+Request.Params["post_id"]+" and posts.postid=huifu.post_id order by huifu.shijian ";
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 huifu.post_id="+Request.Params["post_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 huifu.post_id="+Request.Params["post_id"]+" 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 huifu.post_id="+Request.Params["post_id"]+" and posts.postid=huifu.post_id order by 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 huifu.post_id="+Request.Params["post_id"]+" and posts.postid=huifu.post_id and huifu.shijian>='"+t_1.Text.Trim().ToString()+"'order by huifu.shijian ";
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 huifu.post_id="+Request.Params["post_id"]+" and posts.postid=huifu.post_id order by 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 huifu.post_id="+Request.Params["post_id"]+" and posts.postid=huifu.post_id and huifu.shijian<='"+t_1.Text.Trim().ToString()+"'order by huifu.shijian ";
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 huifu.post_id="+Request.Params["post_id"]+" and posts.postid=huifu.post_id order by 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 huifu.post_id="+Request.Params["post_id"]+" and posts.postid=huifu.post_id and huifu.shijian>'"+t_1.Text.Trim().ToString()+"'order by huifu.shijian ";
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 huifu.post_id="+Request.Params["post_id"]+" and posts.postid=huifu.post_id order by 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 huifu.post_id="+Request.Params["post_id"]+" and posts.postid=huifu.post_id and huifu.shijian<'"+t_1.Text.Trim().ToString()+"'order by huifu.shijian ";
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)
{
Response.Write("nihao");
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 + -