📄 manager.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;
namespace NETManage.Web.Admin
{
public partial class Manager : PageBase//System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
IsLogin();
if (!Page.IsPostBack)
{
NETManage.BLL.Manager mbll = new NETManage.BLL.Manager();
DataSet ds = mbll.GetAllList();
ViewState["ds"] = ds;
GVBind();
}
}
protected void GVBind()
{
DataSet ds = (DataSet)ViewState["ds"];
GV_Manager.DataSource = ds;
GV_Manager.DataKeyNames = new string[] { "Login_Name" };
GV_Manager.DataBind();
}
protected void Button_Default_Click(object sender, EventArgs e)
{
Response.Redirect("Default.aspx");
}
protected void Button_Logout_Click(object sender, EventArgs e)
{
Response.Redirect("logout.aspx");
}
protected void Button_Add_Click(object sender, EventArgs e)
{
Response.Redirect("EditManager.aspx");
}
protected void Button_Edit_Click(object sender, EventArgs e)
{
string Login_Name = string.Empty;
try
{
Login_Name = this.GV_Manager.SelectedDataKey.Value.ToString();
}
catch
{
MsgBox("请先选择要操作的记录!");
}
if (Login_Name != null && Login_Name.Length > 0)
{
Response.Redirect("EditManager.aspx?Login_Name=" + Login_Name);
}
else
{
MsgBox("请先选择要操作的记录!");
}
}
protected void Button_DEL_Click(object sender, EventArgs e)
{
string Login_Name = string.Empty;
try
{
Login_Name = this.GV_Manager.SelectedDataKey.Value.ToString();
}
catch
{
MsgBox("请先选择要操作的记录!");
}
if (Login_Name != null && Login_Name.Length > 0)
{
if (Login_Name == "admin")
{
MsgBox("不能删除超级管理员!");
return;
}
NETManage.BLL.Manager mbll = new NETManage.BLL.Manager();
try
{
mbll.Delete(Login_Name);
Response.Redirect("Manager.aspx");
}
catch (Exception ee)
{
MsgBox("删除失败!" + ee.Message);
}
}
else
{
MsgBox("请先选择要操作的记录!");
}
}
protected void GV_Manager_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView theGrid = sender as GridView; // refer to the GridView
int newPageIndex = 0;
if (-2 == e.NewPageIndex)
{ // when click the "GO" Button
TextBox txtNewPageIndex = null;
//GridViewRow pagerRow = theGrid.Controls[0].Controls[theGrid.Controls[0].Controls.Count - 1] as GridViewRow; // refer to PagerTemplate
GridViewRow pagerRow = theGrid.BottomPagerRow; //GridView较DataGrid提供了更多的API,获取分页块可以使用BottomPagerRow 或者TopPagerRow,当然还增加了HeaderRow和FooterRow
if (null != pagerRow)
{
txtNewPageIndex = pagerRow.FindControl("txtNewPageIndex") as TextBox; // refer to the TextBox with the NewPageIndex value
}
if (null != txtNewPageIndex)
{
newPageIndex = int.Parse(txtNewPageIndex.Text) - 1; // get the NewPageIndex
}
}
else
{ // when click the first, last, previous and next Button
newPageIndex = e.NewPageIndex;
}
// check to prevent form the NewPageIndex out of the range
newPageIndex = newPageIndex < 0 ? 0 : newPageIndex;
newPageIndex = newPageIndex >= theGrid.PageCount ? theGrid.PageCount - 1 : newPageIndex;
theGrid.PageIndex = newPageIndex;
GVBind();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -