SelRoleEmp.aspx.cs
上传用户:autodoor
上传日期:2022-08-04
资源大小:9973k
文件大小:5k
- using System;
- using System.Collections;
- using System.Data;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.HtmlControls;
- using qminoa.DA;
- using qminoa.Common;
- namespace qminoa.Webs.Schedule
- {
- public class SelRoleEmp : qminoa.Webs.PageBase
- {
- protected System.Web.UI.WebControls.Button cmdDelAll;
- protected System.Web.UI.WebControls.Button cmdAddAll;
- protected System.Web.UI.WebControls.Button cmdDel;
- protected System.Web.UI.WebControls.Button cmdAdd;
- protected System.Web.UI.WebControls.Label Label5;
- protected System.Web.UI.WebControls.Label Label4;
- protected System.Web.UI.WebControls.ListBox lstSelEmp;
- protected System.Web.UI.WebControls.Label Label6;
- protected System.Web.UI.WebControls.Label Label2;
- protected System.Web.UI.WebControls.Label Label3;
- protected System.Web.UI.WebControls.DropDownList BranchDropList;
- protected System.Web.UI.WebControls.DropDownList DepartmentDropList;
- protected System.Web.UI.WebControls.ListBox UserList;
- protected System.Web.UI.WebControls.Label Label1;
-
- private void Page_Load(object sender, System.EventArgs e)
- {
- if(!IsPostBack)
- {
- this.PageBegin("我的日程",true);
- AdminDB admin = new AdminDB();
- BranchDropList.DataSource=admin.GetAllBranch();
- BranchDropList.DataBind();
- BranchDropList.Items[0].Selected=true;
- DepartmentDropList.DataSource=admin.GetDepByBranch(Int32.Parse(BranchDropList.SelectedItem.Value));
- DepartmentDropList.DataBind();
- DepartmentDropList.Items[0].Selected=true;
- UserList.DataSource=admin.GetEmpInfo(Int32.Parse(DepartmentDropList.SelectedItem.Value),"dep");
- UserList.DataTextField = "EmpName";
- UserList.DataValueField = "EmpID";
- UserList.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.DepartmentDropList.SelectedIndexChanged += new System.EventHandler(this.DepartmentDropList_SelectedIndexChanged);
- this.cmdAdd.Click += new System.EventHandler(this.cmdAdd_Click);
- this.cmdDel.Click += new System.EventHandler(this.cmdDel_Click);
- this.cmdAddAll.Click += new System.EventHandler(this.cmdAddAll_Click);
- this.cmdDelAll.Click += new System.EventHandler(this.cmdDelAll_Click);
- this.BranchDropList.SelectedIndexChanged += new System.EventHandler(this.BranchDropList_SelectedIndexChanged);
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- private void cmdAdd_Click(object sender, System.EventArgs e)
- {
- bool exist=false;
- foreach( ListItem li in lstSelEmp.Items)
- {
- if(li.Value==UserList.SelectedItem.Value)
- {
- exist=true;
- }
- }
- if(exist==false)
- {
- lstSelEmp.Items.Add(new ListItem(UserList.SelectedItem.Text,UserList.SelectedItem.Value));
- }
- }
- private void cmdDel_Click(object sender, System.EventArgs e)
- {
- lstSelEmp.Items.Remove(lstSelEmp.SelectedItem);
- }
- private void cmdDelAll_Click(object sender, System.EventArgs e)
- {
- for(int i=0;i<lstSelEmp.Items.Count; )
- lstSelEmp.Items.Remove(lstSelEmp.Items[i]);
- }
- private void cmdAddAll_Click(object sender, System.EventArgs e)
- {
- foreach(ListItem li in UserList.Items)
- {
- bool exist=false;
- foreach( ListItem lised in lstSelEmp.Items)
- if(lised.Value==li.Value)
- exist=true;
- if(exist==false)
- lstSelEmp.Items.Add(new ListItem(li.Text,li.Value));
- }
- }
- private void BranchDropList_SelectedIndexChanged(object sender, System.EventArgs e)
- {
- AdminDB admin = new AdminDB();
- DepartmentDropList.DataSource=admin.GetDepByBranch(Int32.Parse(BranchDropList.SelectedItem.Value));
- DepartmentDropList.DataBind();
- if(DepartmentDropList.Items.Count !=0)
- {
- UserList.DataSource=admin.GetEmpInfo(Int32.Parse(DepartmentDropList.SelectedItem.Value),"dep");
- UserList.DataTextField = "EmpName";
- UserList.DataValueField = "EmpID";
- UserList.DataBind();
- }
- else
- {
- UserList.Items.Clear();
- }
- }
- private void DepartmentDropList_SelectedIndexChanged(object sender, System.EventArgs e)
- {
- AdminDB admin = new AdminDB();
- UserList.DataSource=admin.GetEmpInfo(Int32.Parse(DepartmentDropList.SelectedItem.Value),"dep");
- UserList.DataTextField = "EmpName";
- UserList.DataValueField = "EmpID";
- UserList.DataBind();
- }
- public string pass()
- {
- string txt="";
- for(int j=0;j < lstSelEmp.Items.Count;j++)
- {
- txt+=lstSelEmp.Items[j];
- txt+=";";
- }
- return txt;
- }
- }
- }