?? useradmin.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;
using qminoa.DA;
using qminoa.Common;
namespace qminoa.Webs.sysSecurity
{
public class Useradmin : qminoa.Webs.PageBase
{
protected System.Web.UI.WebControls.DropDownList UnitDrop;
protected System.Web.UI.WebControls.DropDownList BranchDrop;
protected System.Web.UI.WebControls.DataList UserList;
private void Page_Load(object sender, System.EventArgs e)
{
this.PageBegin("用戶管理",true);
if (Page.IsPostBack == false)
{
BindData();
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:該調用是 ASP.NET Web 窗體設計器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
this.UnitDrop.SelectedIndexChanged += new System.EventHandler(this.UnitDrop_SelectedIndexChanged);
this.BranchDrop.SelectedIndexChanged += new System.EventHandler(this.BranchDrop_SelectedIndexChanged);
this.UserList.ItemCommand += new System.Web.UI.WebControls.DataListCommandEventHandler(this.UserList_ItemCommand);
this.UserList.ItemDataBound += new System.Web.UI.WebControls.DataListItemEventHandler(this.OnAttachScript);
}
#endregion
private void BindData()
{
AdminDB admin = new AdminDB();
UnitDrop.DataSource=admin.GetAllBranch();
UnitDrop.DataBind();
UnitDrop.SelectedIndex=0;
BranchDrop.DataSource=admin.GetDepByBranch(Int32.Parse(UnitDrop.SelectedItem.Value));
BranchDrop.DataBind();
BranchDrop.SelectedIndex=0;
UserList.DataSource=admin.GetEmpInfo(Int32.Parse(BranchDrop.SelectedItem.Value),"dep");
UserList.DataBind();
}
private void OnAttachScript (object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{
ImageButton button = (ImageButton) e.Item.FindControl("Imagebutton4");
button.Attributes.Add ("onclick",
"return confirm (\"確定要刪除此項記錄嗎?\");");
}
}
private void UnitDrop_SelectedIndexChanged(object sender, System.EventArgs e)
{
AdminDB admin = new AdminDB();
BranchDrop.DataSource=admin.GetDepByBranch(Int32.Parse(UnitDrop.SelectedItem.Value));
BranchDrop.DataBind();
UserList.DataSource=admin.GetEmpInfo(Int32.Parse(BranchDrop.SelectedItem.Value),"dep");
UserList.DataBind();
}
private void BranchDrop_SelectedIndexChanged(object sender, System.EventArgs e)
{
AdminDB admin = new AdminDB();
UserList.DataSource=admin.GetEmpInfo(Int32.Parse(BranchDrop.SelectedItem.Value),"dep");
UserList.DataBind();
}
private void UserList_ItemCommand(object sender, DataListCommandEventArgs e)
{
AdminDB admin = new AdminDB();
int UserID = (int) UserList.DataKeys[e.Item.ItemIndex];
if (e.CommandName == "edit")
{
if(this.EmpRightCode >= 3)
Response.Redirect("UserRoles.aspx?userid=" + UserID,false);
else
JScript.Alert("您沒有權限進行此操作!");
}
else if (e.CommandName == "delete")
{
if(this.EmpRightCode == 4)
{
if(admin.DeleteFuncRoleUser(UserID,"emp"))
{
JScript.Alert("刪除成功!");
this.WriteOptLog("刪除用戶"+UserID.ToString()+"信息");
BindData();
}
else
JScript.Alert("刪除失敗!");
}
else
{
JScript.Alert("您沒有權限進行此操作!");
}
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -