📄 guestbook.aspx.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;
using System.Data.OleDb;
using Model;
public partial class UI_guestbook : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.panHead.Attributes.Add("onmousedown", "Mdown()");
this.panHead.Attributes.Add("onmouseup", "Mup()");
page();
}
}
#region 分页
protected void page()
{
PagedDataSource pds=new PagedDataSource ();
pds.DataSource = (new InterGuestbook()).getListGuestBook();
pds.AllowPaging = true;
pds.PageSize = 3;
lblTotalNum.Text ="/"+pds.PageCount.ToString()+" page";
pds.CurrentPageIndex = int.Parse (lblCurrent .Text)-1 ;
lbtnBack.CommandArgument = lblCurrent.Text;
if (pds.IsFirstPage)
{
ibtnPrev.Visible = false ;
ibtnNext.Visible = true;
}
if (pds.IsLastPage)
{
ibtnNext.Visible = false;
ibtnPrev.Visible = true;
}
if (pds.IsFirstPage && pds.IsLastPage)
{
ibtnNext.Visible = false;
ibtnPrev.Visible = false;
}
if (!pds.IsLastPage && !pds.IsFirstPage)
{
ibtnNext.Visible = true;
ibtnPrev.Visible = true;
}
this.dlLy.DataSource = pds;
this.dlLy.DataBind();
}
#endregion
protected void ibtnNext_Click(object sender, ImageClickEventArgs e)
{
lblCurrent.Text = Convert.ToString(int.Parse(lblCurrent.Text) + 1);
page();
}
protected void ibtnPrev_Click(object sender, ImageClickEventArgs e)
{
lblCurrent.Text = Convert.ToString(int.Parse(lblCurrent.Text) - 1);
page();
}
/// <summary>
/// 发送留言
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSend_Click(object sender, EventArgs e)
{
InterGuestbook addLy = new InterGuestbook();
string picPath = Request.Form["bookface"].ToString();
addLy.setGuestBook(txtName.Text, txtEmail.Text, txtCommend.Text, picPath);
lblCurrent.Text = "1";
panPage.Visible = true;//显示留言列表
PanManage.Visible = false;//隐藏单条留言
panOpenWindow.Visible = false;//隐藏回复留言
this.lbtnBack.Text = "留言本";
page();
}
/// <summary>
/// 显示单条留言内容
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void LinkButton1_Command(object sender, CommandEventArgs e)
{
if (e.CommandName == "lbtnContent")
{
this.panPage .Visible = false;//隐藏留言列表
this.PanManage .Visible = true ;//显示单条留言
this.lbtnBack.Text = "返回";
InterGuestbook getLy = new InterGuestbook();
guestbook[] gb = getLy.only(e.CommandArgument.ToString());
this.Repeater1.DataSource = gb;
this.DataBind();
this.lbtnDel.CommandArgument = e.CommandArgument.ToString();
this.lbtnRecontent.CommandArgument = e.CommandArgument.ToString();
}
}
/// <summary>
/// 返回留言列表
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lbtnBack_Click(object sender, EventArgs e)
{
lblCurrent.Text = lbtnBack.CommandArgument;
this.lbtnBack.Text = "留言本";
this.panOpenWindow.Visible = false ;
this.PanManage .Visible = false;
this.panPage .Visible = true ;
page();
}
/// <summary>
/// 显示回复留言
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lbtnRecontent_Click1(object sender, EventArgs e)
{
InterGuestbook getLy = new InterGuestbook();
guestbook[] gb = getLy.only(lbtnRecontent.CommandArgument);
this.TextBox1.Text = gb[0].Recontent;
this.panOpenWindow.Visible = true;
}
/// <summary>
/// 发送回复
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Button1_Click(object sender, EventArgs e)
{
panOpenWindow.Visible = false;
InterGuestbook igb = new InterGuestbook();
igb.setReGuestBook(this.TextBox1.Text, lbtnRecontent.CommandArgument);
bidnRpt();
}
/// <summary>
/// 绑定单条留言内容
/// </summary>
private void bidnRpt()
{
InterGuestbook getLy = new InterGuestbook();
guestbook[] gb = getLy.only(lbtnRecontent.CommandArgument);
this.Repeater1.DataSource = gb;
this.DataBind();
}
/// <summary>
/// 删除留言
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lbtnDel_Click(object sender, EventArgs e)
{
this.panOpenWindow.Visible = false;
InterGuestbook delLy = new InterGuestbook();
if (!delLy.delGuestBook(lbtnDel.CommandArgument))
{
ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('删除失败!');", true);
}
else
{
ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('删除成功!');", true);
lblCurrent.Text = lbtnBack.CommandArgument;
this.lbtnBack.Text = "留言本";
this.PanManage.Visible = false;
this.panPage.Visible = true;
page();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -