📄 empinfo.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace eOA
{
/// <summary>
/// empinfo 的摘要说明。
/// </summary>
public class empinfo : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button DelUser;
protected System.Web.UI.WebControls.Button Up;
protected System.Web.UI.WebControls.Button Down;
protected System.Web.UI.WebControls.Label lbl;
protected System.Web.UI.WebControls.Button Add;
protected System.Web.UI.WebControls.DataGrid dg_Emp;
protected System.Web.UI.HtmlControls.HtmlForm Form2;
private void Page_Load(object sender, System.EventArgs e)
{
BindGrid();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Add.Click += new System.EventHandler(this.Add_Click);
this.DelUser.Click += new System.EventHandler(this.DelUser_Click);
this.Up.Click += new System.EventHandler(this.Up_Click);
this.Down.Click += new System.EventHandler(this.Down_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
public void DelUser_Click(object sender, System.EventArgs e)
{
Emp myEmp=new Emp ();
for (int i=0; i < dg_Emp.Items.Count ; i++)
{
int EmpID = Convert.ToInt32(dg_Emp.DataKeys[i]);
try
{
CheckBox remove = (CheckBox) dg_Emp.Items[i].FindControl("Remove");
if (remove.Checked)
{
myEmp.DeleteEmp(EmpID);
lbl.Text="用户已成功删除!!";
BindGrid();
}
}
catch
{
lbl.Text="用户删除失败!";
}
}
}
public void BindGrid()
{
Emp myEmp = new Emp ();
DataSet ds =myEmp.GetAllEmp ();
dg_Emp.DataSource = ds.Tables[0].DefaultView;
dg_Emp.DataBind();
}
public void Up_Click(object sender, System.EventArgs e)
{
Emp myEmp = new Emp ();
for (int i=0; i< dg_Emp.Items.Count; i++)
{
int EmpID = Convert.ToInt32(dg_Emp.DataKeys[i]);
CheckBox remove = (CheckBox) dg_Emp.Items[i].FindControl("Remove");
if (remove.Checked)
{
myEmp.SetEmpAdmin(EmpID);
lbl.Text="修改成功!";
BindGrid();
}
}
}
public void Down_Click(object sender, System.EventArgs e)
{
Emp myEmp = new Emp ();
for (int i=0; i< dg_Emp.Items.Count; i++)
{
int EmpID = Convert.ToInt32(dg_Emp.DataKeys[i]);
try
{
CheckBox remove = (CheckBox) dg_Emp.Items[i].FindControl("Remove");
if (remove.Checked)
{
myEmp.SetEmpNormal(EmpID);
lbl.Text="修改成功!";
BindGrid();
}
}
catch
{
lbl.Text = "操作有误!";
}
}
}
public void Add_Click(object sender, System.EventArgs e)
{
Response.Redirect("empone.aspx?from=2");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -