SelRoleEmp.aspx.cs
上传用户:autodoor
上传日期:2022-08-04
资源大小:9973k
文件大小:5k
源码类别:

.net编程

开发平台:

Others

  1. using System;
  2. using System.Collections;
  3. using System.Data;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Web.UI.HtmlControls;
  8. using qminoa.DA;
  9. using qminoa.Common;
  10. namespace qminoa.Webs.Schedule
  11. {
  12. public class SelRoleEmp : qminoa.Webs.PageBase
  13. {
  14. protected System.Web.UI.WebControls.Button cmdDelAll;
  15. protected System.Web.UI.WebControls.Button cmdAddAll;
  16. protected System.Web.UI.WebControls.Button cmdDel;
  17. protected System.Web.UI.WebControls.Button cmdAdd;
  18. protected System.Web.UI.WebControls.Label Label5;
  19. protected System.Web.UI.WebControls.Label Label4;
  20. protected System.Web.UI.WebControls.ListBox lstSelEmp;
  21. protected System.Web.UI.WebControls.Label Label6;
  22. protected System.Web.UI.WebControls.Label Label2;
  23. protected System.Web.UI.WebControls.Label Label3;
  24. protected System.Web.UI.WebControls.DropDownList BranchDropList;
  25. protected System.Web.UI.WebControls.DropDownList DepartmentDropList;
  26. protected System.Web.UI.WebControls.ListBox UserList;
  27. protected System.Web.UI.WebControls.Label Label1;
  28. private void Page_Load(object sender, System.EventArgs e)
  29. {
  30. if(!IsPostBack)
  31. {
  32. this.PageBegin("我的日程",true);
  33. AdminDB admin = new AdminDB();
  34. BranchDropList.DataSource=admin.GetAllBranch();
  35. BranchDropList.DataBind();
  36. BranchDropList.Items[0].Selected=true;
  37. DepartmentDropList.DataSource=admin.GetDepByBranch(Int32.Parse(BranchDropList.SelectedItem.Value));
  38. DepartmentDropList.DataBind();
  39. DepartmentDropList.Items[0].Selected=true;
  40. UserList.DataSource=admin.GetEmpInfo(Int32.Parse(DepartmentDropList.SelectedItem.Value),"dep");
  41. UserList.DataTextField = "EmpName";
  42. UserList.DataValueField = "EmpID";
  43. UserList.DataBind();
  44. }
  45. }
  46. #region Web Form Designer generated code
  47. override protected void OnInit(EventArgs e)
  48. {
  49. //
  50. // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
  51. //
  52. InitializeComponent();
  53. base.OnInit(e);
  54. }
  55. /// <summary>
  56. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  57. /// 此方法的内容。
  58. /// </summary>
  59. private void InitializeComponent()
  60. {    
  61. this.DepartmentDropList.SelectedIndexChanged += new System.EventHandler(this.DepartmentDropList_SelectedIndexChanged);
  62. this.cmdAdd.Click += new System.EventHandler(this.cmdAdd_Click);
  63. this.cmdDel.Click += new System.EventHandler(this.cmdDel_Click);
  64. this.cmdAddAll.Click += new System.EventHandler(this.cmdAddAll_Click);
  65. this.cmdDelAll.Click += new System.EventHandler(this.cmdDelAll_Click);
  66. this.BranchDropList.SelectedIndexChanged += new System.EventHandler(this.BranchDropList_SelectedIndexChanged);
  67. this.Load += new System.EventHandler(this.Page_Load);
  68. }
  69. #endregion
  70. private void cmdAdd_Click(object sender, System.EventArgs e)
  71. {
  72. bool exist=false;
  73. foreach( ListItem li in lstSelEmp.Items)
  74. {
  75. if(li.Value==UserList.SelectedItem.Value)
  76. {
  77. exist=true;
  78. }
  79. }
  80. if(exist==false)
  81. {
  82. lstSelEmp.Items.Add(new ListItem(UserList.SelectedItem.Text,UserList.SelectedItem.Value));
  83. }
  84. }
  85. private void cmdDel_Click(object sender, System.EventArgs e)
  86. {
  87. lstSelEmp.Items.Remove(lstSelEmp.SelectedItem);
  88. }
  89. private void cmdDelAll_Click(object sender, System.EventArgs e)
  90. {
  91. for(int i=0;i<lstSelEmp.Items.Count; )
  92. lstSelEmp.Items.Remove(lstSelEmp.Items[i]);
  93. }
  94. private void cmdAddAll_Click(object sender, System.EventArgs e)
  95. {
  96. foreach(ListItem li in UserList.Items)
  97. {
  98. bool exist=false;
  99. foreach( ListItem lised in lstSelEmp.Items)
  100. if(lised.Value==li.Value)
  101. exist=true;
  102. if(exist==false)
  103. lstSelEmp.Items.Add(new ListItem(li.Text,li.Value));
  104. }
  105. }
  106. private void BranchDropList_SelectedIndexChanged(object sender, System.EventArgs e)
  107. {
  108. AdminDB admin = new AdminDB();
  109. DepartmentDropList.DataSource=admin.GetDepByBranch(Int32.Parse(BranchDropList.SelectedItem.Value));
  110. DepartmentDropList.DataBind();
  111. if(DepartmentDropList.Items.Count !=0)
  112. {
  113. UserList.DataSource=admin.GetEmpInfo(Int32.Parse(DepartmentDropList.SelectedItem.Value),"dep");
  114. UserList.DataTextField = "EmpName";
  115. UserList.DataValueField = "EmpID";
  116. UserList.DataBind();
  117. }
  118. else
  119. {
  120. UserList.Items.Clear();
  121. }
  122. }
  123. private void DepartmentDropList_SelectedIndexChanged(object sender, System.EventArgs e)
  124. {
  125. AdminDB admin = new AdminDB();
  126. UserList.DataSource=admin.GetEmpInfo(Int32.Parse(DepartmentDropList.SelectedItem.Value),"dep");
  127. UserList.DataTextField = "EmpName";
  128. UserList.DataValueField = "EmpID";
  129. UserList.DataBind();
  130. }
  131. public string pass()
  132. {
  133. string txt="";
  134. for(int j=0;j < lstSelEmp.Items.Count;j++)
  135. {
  136. txt+=lstSelEmp.Items[j];
  137. txt+=";";
  138. }
  139. return txt;
  140. }
  141. }
  142. }