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

📄 body.aspx.cs

📁 数据配置信息 登录数据库为sa 密码123 登录界面的用户信息:shichang 密码:sc
💻 CS
字号:
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;


public partial class body : System.Web.UI.Page
{
    private void BindToDataGrid()
    {
        BLL.Class1 bl1 = new BLL.Class1();

        DataSet table = bl1.Sele();

        DataView dv = table.Tables[0].DefaultView;

      

        this.DataGrid1.DataSource = dv;
        this.DataGrid1.DataBind();

    }
    private void BindTODataGrid(int me)
    {
        BLL.Class1 bl1 = new BLL.Class1();
        string aa = bl1.getroot(this.Session["Root"].ToString());
        this.Session["Root"] = aa;

        DataSet table = bl1.Sele();

        DataView dv = table.Tables[0].DefaultView;

        dv.RowFilter = "TextID = " + me + "";

        this.DataGrid1.DataSource = dv;

        this.DataGrid1.DataBind();



    }

    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
                    
            BindToDataGrid();

          
        }
    }
    protected void DataGrid1_ItemCommand(object source, DataGridCommandEventArgs e)
    {
        if (e.CommandName == "修  改")
       {
           if (this.Session["Root"] != null && this.Session["Root"].ToString() != "0")
           {
               this.DataGrid1.EditItemIndex = e.Item.ItemIndex;
               if (this.Session["TitleID"] != null)
               {
                   this.BindTODataGrid(int.Parse(this.Session["TitleID"].ToString()));
                   return;
               }
           }
           else
           {
               this.Response.Write("<script>alert('没有权限');</script>");
           }
      }
        //else if (e.CommandName == "deleteID")
        //{
        //    UserInfo user = new UserInfo();
        //    user.TextID = int.Parse(((Label)e.Item.Cells[0].FindControl("LabelID")).Text);
        //    user.DeleText();

        //}
        //else if (e.CommandName == "更  新")
        //{
        //    UserInfo user = new UserInfo();
        //    user.TextID = int.Parse(((Label)e.Item.Cells[0].FindControl("LabelID")).Text);
        //    user.UserText = ((TextBox)e.Item.Cells[0].FindControl("TextBoxModifyBody")).Text;
        //    user.Time = DateTime.Now;
        //    user.UpdateText();
        //    this.DataGrid1.EditItemIndex = -1;
        //    if (this.Session["TitleID"] != null)
        //    {
        //        this.BindTODataGrid(int.Parse(this.Session["TitleID"].ToString()));
        //        return;
        //    }
        //}
        //else 
        //if (e.CommandName == "回复")
        //{
        //    if ((Session["User"] != null) && (Session["Root"] != null) && (Session["Root"].ToString()) != "0")
        //    {
        //        Session["TextID"] = int.Parse(((Label)e.Item.Cells[0].FindControl("LabelID")).Text);
        //        this.Response.Write("<script>window.open(' AddBack.aspx ','_blank','toolbar=no,width=490,height=260,status=no,scrollbars=no,resizable=no,menubar=no');</script>");
        //    }
        //    else
        //    {
        //        this.Response.Write("<script>alert('请登陆后再回复!');</script>");
        //        this.Server.Transfer("index.aspx");
        //    }
        //    if (this.Session["TitleID"] != null)
        //    {
        //        this.BindTODataGrid(int.Parse(this.Session["TitleID"].ToString()));
        //        return;
        //    }
        //}
       // this.BindTODataGrid();
    }
    protected void DataGrid1_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
    {
        this.DataGrid1.CurrentPageIndex = e.NewPageIndex;
        //this.BindTODataGrid();
    }

    public string StringFormatBody(string body)
    {
        body = body.Replace("[/呲牙]", "<img-src=images/facepic/face0.gif>");
        body = body.Replace("[/微笑]", "<img-src=images/facepic/face1.gif>");
        body = body.Replace("[/偷笑]", "<img-src=images/facepic/face2.gif>");
        body = body.Replace("[/害羞]", "<img-src=images/facepic/face3.gif>");
        body = body.Replace("[/色]", "<img-src=images/facepic/face4.gif>");
        body = body.Replace("[/调皮]", "<img-src=images/facepic/face5.gif>");
        body = body.Replace("[/大兵]", "<img-src=images/facepic/face6.gif>");
        body = body.Replace("[/饥饿]", "<img-src=images/facepic/face7.gif>");
        body = body.Replace("[/睡]", "<img-src=images/facepic/face8.gif>");
        body = body.Replace("[/惊讶]", "<img-src=images/facepic/face9.gif>");
        body = body.Replace("[/疑问]", "<img-src=images/facepic/face10.gif>");
        body = body.Replace("[/咒骂]", "<img-src=images/facepic/face11.gif>");
        body = body.Replace("[/大哭]", "<img-src=images/facepic/face12.gif>");
        body = body.Replace("[/抓狂]", "<img-src=images/facepic/face13.gif>");
        body = body.Replace("[/流汗]", "<img-src=images/facepic/face14.gif>");
        body = body.Replace("[/衰]", "<img-src=images/facepic/face15.gif>");
        body = body.Replace("[/难过]", "<img-src=images/facepic/face16.gif>");
        body = body.Replace("[/敲打]", "<img-src=images/facepic/face17.gif>");
        body = body.Replace("[/发怒]", "<img-src=images/facepic/face18.gif>");
        body = body.Replace("[/尴尬]", "<img-src=images/facepic/face19.gif>");
        body = body.Replace("[/困]", "<img-src=images/facepic/face20.gif>");
        body = body.Replace("[/嘘]", "<img-src=images/facepic/face21.gif>");
        body = body.Replace("[/晕]", "<img-src=images/facepic/face22.gif>");
        body = body.Replace("[/折磨]", "<img-src=images/facepic/face23.gif>");
        body = body.Replace("[/骷髅]", "<img-src=images/facepic/face24.gif>");
        body = body.Replace("[/再见]", "<img-src=images/facepic/face25.gif>");
        body = body.Replace("[/得意]", "<img-src=images/facepic/face26.gif>");
        body = body.Replace("[/奋斗]", "<img-src=images/facepic/face27.gif>");
        body = body.Replace("[/玫瑰]", "<img-src=images/facepic/face28.gif>");
        body = body.Replace("[/猪头]", "<img-src=images/facepic/face29.gif>");
        body = body.Replace("[/吻]", "<img-src=images/facepic/face30.gif>");
        body = body.Replace("[/爱心]", "<img-src=images/facepic/face31.gif>");
        body = body.Replace("[/心碎]", "<img-src=images/facepic/face32.gif>");
        body = body.Replace("[/电话]", "<img-src=images/facepic/face33.gif>");
        body = body.Replace("[/邮件]", "<img-src=images/facepic/face34.gif>");
        body = body.Replace("[/强]", "<img-src=images/facepic/face35.gif>");
        body = body.Replace("[/弱]", "<img-src=images/facepic/face36.gif>");
        body = body.Replace("[/握手]", "<img-src=images/facepic/face37.gif>");
        body = body.Replace("[/胜利]", "<img-src=images/facepic/face38.gif>");
        body = body.Replace("[/礼物]", "<img-src=images/facepic/face39.gif>");
        body = body.Replace("[/蛋糕]", "<img-src=images/facepic/face40.gif>");
        body = body.Replace("[/钱]", "<img-src=images/facepic/face41.gif>");

        body = body.Replace("\n", "<br>");
        body = body.Replace(" ", "&nbsp;");
        return body.Replace("-", " ");

    }

    protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
    {
       if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
             BLL.Class1 bl1 = new BLL.Class1();
             DataGrid DataGrid2 = (DataGrid)e.Item.FindControl("DataGrid2");
              DataSet tab = bl1.SeleBack();
             
             Label tton = (Label)e.Item.Cells[0].FindControl("LabelID");
             int TextID = int.Parse(tton.Text);
           

              DataView dv = tab.Tables[0].DefaultView;

              DataGrid2.DataSource = dv;

             DataGrid2.DataBind();

             Label LabelAuthor = (Label)e.Item.Cells[0].FindControl("LabelAuthor");
             if (Session["User"] != null && LabelAuthor.Text == Session["User"].ToString())
             {
                 Button ButtonModify = (Button)e.Item.Cells[0].FindControl("ButtonModify");
                 ButtonModify.Visible = true;
             }
        }
    }
    protected void DataGrid2_ItemCreated(object sender, DataGridItemEventArgs e)
    {

    }
    protected void DataGrid1_ItemCreated(object sender, DataGridItemEventArgs e)
    {
       // if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
       // {
       //    if (Session["Root"] != null && Session["Root"].ToString() == "1")
       //   {
       //         Button ButtonModify = (Button)e.Item.Cells[0].FindControl("ButtonModify");
       //      ButtonModify.Visible = true;
       //        Button ButtonDele = (Button)e.Item.Cells[0].FindControl("ButtonDele");
       //        ButtonDele.Visible = true;
       //   }

       //}
    }
    public string SizeFont(string str)
    {
        return ("<b><font size=2>" + str + "<font></b>");
    }

    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        //this.Session.Remove("TitleID");
        //BindTODataGrid();
    }

    public string stringUser(string str)
    {
        return "<font color=white>个性签明:</font>" + str;
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        this.Session.Remove("TitleID");
        this.Server.Transfer("index.aspx");
    }
    protected void ButtonModify_Click(object sender, EventArgs e)
    {

    }
    protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
    {

    }
    protected void DataGrid1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
}

⌨️ 快捷键说明

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