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

📄 index.aspx.cs

📁 数据配置信息 登录数据库为sa 密码123 登录界面的用户信息:shichang 密码:sc
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.IO;
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 index : System.Web.UI.Page
{
    private void BindToDataGrid()
    {
        BLL.Class1 bl1 = new BLL.Class1();
 
          DataSet table = bl1.Sele();

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

          dv.Sort = "TextID DESC";

          this.DataGrid1.DataSource = dv;
            int i = bl1.CountTextSum();
           this.Label1.Text = i.ToString();
           this.Label3.Text = this.Application["SumConunt"].ToString();
          this.Label2.Text = this.Application["CountUser"].ToString();
          //this.Label4.Text = UserInfo.SeleGG();
          this.DataGrid1.DataBind();
       
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            
            //B
            Image10.Attributes.Add("onclick", "LinkImage(1);");
            //U
            Image2.Attributes.Add("onclick", "LinkImage(2);");
            //EMAIL
            Image6.Attributes.Add("onclick", "LinkImage(3);");
            //CENTER
            Image8.Attributes.Add("onclick", "LinkImage(4);");
            //LINK
            Image3.Attributes.Add("onclick", "LinkImage(5);");
            //IMAGE
            Image4.Attributes.Add("onclick", "LinkImage(6);");

            Image0.Attributes.Add("onclick", "LinkFace('[/呲牙]');");
            Image7.Attributes.Add("onclick", "LinkFace('[/微笑]');");
            Image9.Attributes.Add("onclick", "LinkFace('[/偷笑]');");
            Image11.Attributes.Add("onclick", "LinkFace('[/害羞]');");
            Image12.Attributes.Add("onclick", "LinkFace('[/色]');");
            Image13.Attributes.Add("onclick", "LinkFace('[/调皮]');");
            Image14.Attributes.Add("onclick", "LinkFace('[/大兵]');");
            Image15.Attributes.Add("onclick", "LinkFace('[/饥饿]');");
            Image16.Attributes.Add("onclick", "LinkFace('[/睡]');");
            Image17.Attributes.Add("onclick", "LinkFace('[/惊讶]');");
            Image18.Attributes.Add("onclick", "LinkFace('[/疑问]');");
            Image19.Attributes.Add("onclick", "LinkFace('[/咒骂]');");
            Image20.Attributes.Add("onclick", "LinkFace('[/大哭]');");
            Image21.Attributes.Add("onclick", "LinkFace('[/抓狂]');");
            Image22.Attributes.Add("onclick", "LinkFace('[/流汗]');");
            Image23.Attributes.Add("onclick", "LinkFace('[/衰]');");
            Image24.Attributes.Add("onclick", "LinkFace('[/难过]');");
            Image25.Attributes.Add("onclick", "LinkFace('[/敲打]');");
            Image26.Attributes.Add("onclick", "LinkFace('[/发怒]');");
            Image27.Attributes.Add("onclick", "LinkFace('[/尴尬]');");
            Image28.Attributes.Add("onclick", "LinkFace('[/困]');");
            Image29.Attributes.Add("onclick", "LinkFace('[/嘘]');");
            Image30.Attributes.Add("onclick", "LinkFace('[/晕]');");
            Image31.Attributes.Add("onclick", "LinkFace('[/折磨]');");
            Image32.Attributes.Add("onclick", "LinkFace('[/骷髅]');");
            Image33.Attributes.Add("onclick", "LinkFace('[/再见]');");
            Image34.Attributes.Add("onclick", "LinkFace('[/得意]');");
            Image35.Attributes.Add("onclick", "LinkFace('[/奋斗]');");
            Image36.Attributes.Add("onclick", "LinkFace('[/玫瑰]');");
            Image37.Attributes.Add("onclick", "LinkFace('[/猪头]');");
            Image38.Attributes.Add("onclick", "LinkFace('[/吻]');");
            Image39.Attributes.Add("onclick", "LinkFace('[/爱心]');");
            Image40.Attributes.Add("onclick", "LinkFace('[/心碎]');");
            Image41.Attributes.Add("onclick", "LinkFace('[/电话]');");
            Image42.Attributes.Add("onclick", "LinkFace('[/邮件]');");
            Image43.Attributes.Add("onclick", "LinkFace('[/强]');");
            Image44.Attributes.Add("onclick", "LinkFace('[/弱]');");
            Image45.Attributes.Add("onclick", "LinkFace('[/握手]');");
            Image46.Attributes.Add("onclick", "LinkFace('[/胜利]');");
            Image47.Attributes.Add("onclick", "LinkFace('[/礼物]');");
            Image48.Attributes.Add("onclick", "LinkFace('[/蛋糕]');");
            Image49.Attributes.Add("onclick", "LinkFace('[/钱]');");

            this.Image1.ImageUrl = "MAC.aspx";
            BindToDataGrid();
            if (this.Session["Root"] == null)
            {
                this.PanelTwo.Visible = false;
                this.PanelOne.Visible = true;
                this.ButtonSend.Enabled = false;
                this.FileUpload1.Visible = false;
                this.LinkButtonInsert.Visible = false;
            }
            else
            {
                this.PanelTwo.Visible = true;
                this.PanelOne.Visible = false;
                this.ButtonSend.Enabled = true;
                this.FileUpload1.Visible = true;
                this.LinkButtonInsert.Visible = true;
            }

            CleaALL();
        }
    }

    private void CleaALL()
    {
        this.TextBoxTitle.Text = null;
        this.TextBoxBody.Text = null;
        this.TextBoxMAC.Text = null;
        this.TextBoxUsername.Text = null;
        this.TextBoxPassword.Text = null;

    }
    //添加记录
    protected void ButtonSend_Click(object sender, EventArgs e)
    {
        if (this.TextBoxMAC.Text == Session["ValidateCode"].ToString() && this.TextBoxTitle.Text != "" && this.TextBoxBody.Text != "")
        {
          
            BLL.Class1 bb = new BLL.Class1();
            int Userid = bb.showUserID(Session["User"].ToString());
            
           
            string usertitle = this.TextBoxTitle.Text;
            string usercontents = this.TextBoxBody.Text;
           
            DateTime  tiem = DateTime.Now;
            BLL.Class1 insert = new BLL.Class1();
            
           if(insert.inserly(usertitle,usercontents,Userid,tiem))
           {
              
                this.Response.Write("<script>alert('添加留言成功!');</script>");
                this.DataGrid1.DataBind();
            
           }
           

        }
    }

    protected void DataGrid1_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
    {
        this.DataGrid1.CurrentPageIndex = e.NewPageIndex;
        BindToDataGrid();
    }
    //重置
    protected void ButtonExit_Click(object sender, EventArgs e)
    {
        this.TextBoxUsername.Text = "";
        this.TextBoxPassword.Text = "";
    }
    //登陆
    protected void ButtonLogin_Click(object sender, EventArgs e)
    {
        string user = this.TextBoxUsername.Text;
        string pwd = this.TextBoxPassword.Text;
        BLL.Class1 BC = new BLL.Class1();
        if (BC.GetInfo(user,pwd))
        {
          
            this.PanelOne.Visible = false;
            this.PanelTwo.Visible = true;           
            this.Session["User"] = this.TextBoxUsername.Text;
            this.Session["Pwd"] = this.TextBoxPassword.Text;
            this.FileUpload1.Visible = true;
            this.LinkButtonInsert.Visible = true;
            this.ButtonSend.Enabled = true;
            this.LabelUserInfo.Text =Session["User"].ToString();
            

        }
        else
        {
            this.Response.Write("<script>alert('用户名密码错误!');</script>");
        }
        
       BindToDataGrid();
       this.CleaALL();

    }
    //修改密码
    protected void ButtonModifyPass_Click(object sender, EventArgs e)
    {
        this.Response.Write("<script>window.open('ModifyPass.aspx','_blank','toolbar=no,width=390,height=200,status=no,scrollbars=no,resizable=no,menubar=no');</script>");

    }
    //注册
    protected void ButtonLoginone_Click(object sender, EventArgs e)
    {
        this.Server.Transfer("AddUser.aspx");
    }
    //

    protected void DataGrid1_ItemCommand(object source, DataGridCommandEventArgs e)
   {
      
        if (e.CommandName == "点击回复")
        {
            if ((Session["User"] != null))
            {
                Session["TextID"] = int.Parse(((Label)e.Item.Cells[0].FindControl("LabelTitle")).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>");
            }
       }
        BindToDataGrid();
    }
    protected void DataGrid1_PageIndexChanged1(object source, DataGridPageChangedEventArgs e)
    {
        this.DataGrid1.CurrentPageIndex = e.NewPageIndex;
        BindToDataGrid();
    }
    protected void DataGrid1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        this.Session.Remove("Root");
        this.Session.Remove("User");
        this.Session.Remove("TitleID");
        this.PanelTwo.Visible = false;
        this.PanelOne.Visible = true;
        this.ButtonSend.Enabled = false;
        this.FileUpload1.Visible = false;
        this.LinkButtonInsert.Visible = false;
        CleaALL();
        BindToDataGrid();
    }
    //排序
    protected void DataGrid1_SortCommand(object source, DataGridSortCommandEventArgs e)
    {

    }
    public string BackSum(int i)
    {
        string str = null;
        if (i != 0)
        {
            str = "已有" + i.ToString() + "条回复!";
        }
        return str;
      
    }
    //上载图片
    protected void ImageButton9_Click(object sender, ImageClickEventArgs e)
    {
        this.Server.Transfer("AddImage.aspx");
        this.Session["body"] = this.TextBoxBody.Text;
    }
    protected void LinkButtonInsert_Click(object sender, EventArgs e)
    {
        string[] FileName = this.FileUpload1.FileName.Split('.');

        if (FileName[FileName.Length - 1].ToLower() == "jpg" || FileName[FileName.Length - 1].ToLower() == "jpeg"
                || FileName[FileName.Length - 1].ToLower() == "gif" || FileName[FileName.Length - 1].ToLower() == "bmp")
        {
            try
            {
                this.FileUpload1.SaveAs(this.Server.MapPath("bodyImages") + "\\" + Path.GetFileName(this.FileUpload1.PostedFile.FileName));
                this.TextBoxBody.Text = this.TextBoxBody.Text + "<br><img-src=bodyImages/" + Path.GetFileName(this.FileUpload1.PostedFile.FileName) + "><br>";
            }
            catch
            {
                this.Response.Write("<script>alert('图片路径不对!');</script>");
            }
        }
        else
        {
            this.Response.Write("<script>alert('您的图片格式不对');</script>");
            return;
        }


    }
    protected void DataGrid1_ItemCreated(object sender, DataGridItemEventArgs e)
    {

    }
    protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
    {
        //if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        //{
        //    if ((Session["User"] != null) && (Session["Root"] != null) && (Session["Root"].ToString()) == "1")
        //    {
        //        Button ButtonDele = (Button)e.Item.Cells[0].FindControl("ButtonDele");
        //        ButtonDele.Visible = true;
        //    }
        //}
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        //UserInfo user =  new UserInfo();
        //user.UserText = this.TextBox1.Text;
        //user.UpdateGG();
    }
    protected void ImageButton38_Click(object sender, ImageClickEventArgs e)
    {

    }
}

⌨️ 快捷键说明

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