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

📄 userroles.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 System.Data.SqlClient;
using System.Windows.Forms;
using qminoa.DA;
using qminoa.Common;

namespace qminoa.Webs.sysSecurity
{
	public class UserRoles : qminoa.Webs.PageBase
	{  
		protected System.Web.UI.WebControls.DropDownList UserRoleDrop;
		protected System.Web.UI.WebControls.DataList UserRoleList;
		protected System.Web.UI.WebControls.TextBox txbLoginID;
		protected System.Web.UI.WebControls.LinkButton AddRoles;
		protected System.Web.UI.WebControls.LinkButton lbnUserUpdate;
		protected System.Web.UI.WebControls.LinkButton lbnOK;
		protected System.Web.UI.WebControls.LinkButton linkCanncel;
		
		public int UserID;

		private void Page_Load(object sender, System.EventArgs e)
		{
			this.PageBegin("用户管理",true);
			UserID=Int32.Parse(Request.QueryString["userid"]);
			if(!Page.IsPostBack)
				BindData();
		}

		private void BindData() 
		{
			AdminDB admin = new AdminDB();
            SqlDataReader dr=admin.GetEmpInfo(UserID,"emp");
             dr.Read();
			 txbLoginID.Text=dr["LoginID"].ToString();
			UserRoleList.DataSource=admin.GetUserRoles(UserID);		
            UserRoleList.DataBind();
			UserRoleDrop.DataSource=admin.GetAllRoles();
			UserRoleDrop.DataBind(); 
		}

		#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.lbnUserUpdate.Click += new System.EventHandler(this.lbnUserUpdate_Click);
			this.AddRoles.Click += new System.EventHandler(this.AddRoles_Click);
			this.UserRoleList.ItemCommand += new System.Web.UI.WebControls.DataListCommandEventHandler(this.UserRoleList_ItemCommand);
			this.lbnOK.Click += new System.EventHandler(this.lbnOK_Click);
			this.linkCanncel.Click += new System.EventHandler(this.linkCanncel_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		
		private void UserRoleList_ItemCommand(object sender, DataListCommandEventArgs e) 
		{
			AdminDB admin = new AdminDB();
			int RoleID = (int) UserRoleList.DataKeys[e.Item.ItemIndex];
			String RoleName=((System.Web.UI.WebControls.Label)e.Item.FindControl("lbRoleName")).Text;
			if (e.CommandName == "edit") 
			{   
				if(this.CheckAuth("角色管理") >= 3)
					Response.Redirect("RolesFuncUsers.aspx?roleid=" +RoleID,false);
				else
					JScript.Alert("您没有权限进行此操作!");
			}
			else if (e.CommandName == "delete") 
			{
				if(this.EmpRightCode == 4)
				{
					if(admin.DeleteRoleUser(UserID,RoleID))
					{
						JScript.Alert("删除成功!");
						BindData();
					}
					else
						JScript.Alert("删除失败!");
				}
				else
				{
					JScript.Alert("您没有权限进行此操作!");
				}
			}
			
		}

		private void lbnUserUpdate_Click(object sender, System.EventArgs e)
		{   
			if(this.EmpRightCode >= 3)
			{
				AdminDB admin = new AdminDB();
				admin.UpdateUserInfo(UserID,txbLoginID.Text);
				BindData();
			}
			else
			{
				JScript.Alert("您没有权限进行此操作!");
			}
		}

		private void lbnOK_Click(object sender, System.EventArgs e)
		{   
			if(this.EmpRightCode >= 3)
			{
				AdminDB admin = new AdminDB();
				admin.UpdateUserInfo(UserID,txbLoginID.Text);
				Response.Redirect("useradmin.aspx",false);
			}
			else
			{
				JScript.Alert("您没有权限进行此操作!");
			}
		}

		private void AddRoles_Click(object sender, System.EventArgs e)
		{   
			if(this.EmpRightCode >= 3)
			{
				AdminDB admin = new AdminDB();
				admin.AddUserRole(UserID,Int32.Parse(UserRoleDrop.SelectedItem.Value));
				BindData();
			}
			else
			{
				JScript.Alert("您没有权限进行此操作!");
			}
		}

		private void linkCanncel_Click(object sender, System.EventArgs e)
		{
			Response.Redirect("useradmin.aspx",false);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -