📄 departmanage.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 Office.Model;
using Office.DAL;
using Office.BLL;
public partial class PersonManage_DepartManager : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Bind();
}
}
//数据绑定
private void Bind()
{
this.GridView1.DataSource = DepartInfoManager.GetAllDepartInfos();
this.GridView1.DataBind();
}
//添加部门
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("SaveDepartManage.aspx");
}
//数据行绑定事件
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "oldcolor=this.style.backgroundColor;this.style.backgroundColor='lightYellow'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=oldcolor");
ImageButton ibn = e.Row.FindControl("ImageButton2") as ImageButton;
if (ibn != null)
{
ibn.Attributes.Add("onclick", "return confirm('你确定要删除该部门吗?')");
}
}
}
//GridView事件处理
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
//修改
if (e.CommandName == "modify")
{
Response.Redirect("SaveDepartManage.aspx?DepartId="+e.CommandArgument.ToString());
}
//删除
if (e.CommandName == "del")
{
DepartInfoManager.DeleteDepartInfoByDepartId(Int32.Parse(e.CommandArgument.ToString()));
Bind();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -