⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 useradmin.aspx.cs

📁 专业的办公oa代码下载 c#语言编写 三层结构
💻 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 + -