?? index.aspx.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;
using UserInfoLib;
public partial class index : System.Web.UI.Page
{
private void BindToDataGrid()
{
DataSet table = UserInfo.Sele();
DataView dv = table.Tables[0].DefaultView;
dv.Sort = "TextID DESC";
this.DataGrid1.DataSource = dv;
int i = UserInfo.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('[/調(diào)皮]');");
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('[/發(fā)怒]');");
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 != "")
{
UserInfo user = new UserInfo();
user.UserTitle = this.TextBoxTitle.Text;
user.UserText = this.TextBoxBody.Text;
user.UserName = this.Session["User"].ToString();
user.Time = DateTime.Now;
int rows = user.InsertText();
if (rows == 1)
{
this.Response.Write("<script>alert('添加留言成功!');</script>");
CleaALL();
}
BindToDataGrid();
}
else
{
this.Response.Write("<script>alert('輸入出錯!');</script>");
}
}
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)
{
UserInfo user = new UserInfo();
user.UserName = this.TextBoxUsername.Text;
user.UserPassword = this.TextBoxPassword.Text;
string Root = user.UserRoot();
if (Root != "0")
{
this.PanelOne.Visible = false;
this.PanelTwo.Visible = true;
if (Root == "1")
{
this.TextBox1.Visible = true;
this.Button2.Visible = true;
}
else
{
this.TextBox1.Visible = false;
this.Button2.Visible = false;
}
this.LabelUserInfo.Text = this.TextBoxUsername.Text;
this.ButtonSend.Enabled = true;
this.Session["Root"] = Root;
this.Session["User"] = this.TextBoxUsername.Text;
this.FileUpload1.Visible = true;
this.LinkButtonInsert.Visible = true;
}
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 == "Jump")
{
this.Session["TitleID"] = ((Label)e.Item.Cells[0].FindControl("LabelTitle")).Text;
this.Response.Redirect("body.aspx");
}
else if (e.CommandName == "TextIDdele")
{
if ((Session["User"] != null) && (Session["Root"] != null) && (Session["Root"].ToString()) != "0")
{
UserInfo user = new UserInfo();
user.TextID = int.Parse(((Label)e.Item.Cells[0].FindControl("LabelTitle")).Text);
user.DeleText();
}
}
else if (e.CommandName == "點擊回復(fù)")
{
if ((Session["User"] != null) && (Session["Root"] != null) && (Session["Root"].ToString()) != "0")
{
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('請登陸后再回復(fù)!查看留言點擊標題!');</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() + "條回復(fù)!";
}
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();
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -