employee_select.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:6k
源码类别:
OA系统
开发平台:
ASP/ASPX
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using System.Data.SqlClient;
- public partial class web_personnel_department_department_select : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- this.ListEmployeeBind();
- this.ListSelectedBind();
- }
- }
- //ListEmployee綁定
- protected void ListEmployeeBind()
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- string department_id = "0";
- if (Request.QueryString["department_id"] != null)
- {
- department_id = Request.QueryString["department_id"];
- }
- string sql = "select e.id, e.emp_no, e.emp_name, p.name as position from " +
- "OA_EMPLOYEE e inner join OA_EMPLOYEE_POSITION p on e.position=p.id where is_del='N'" +
- " and department_id=" + department_id + " and dimission_date=''";
- SqlCommand cmd = new SqlCommand(sql, conn);
- try
- {
- SqlDataReader dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- ListItem item = new ListItem();
- item.Value = dr["id"].ToString();
- item.Text = dr["emp_no"].ToString() + " " + dr["emp_name"].ToString() + " " + dr["position"].ToString();
- ListEmployee.Items.Add(item);
- }
- dr.Close();
- }
- catch (Exception ex)
- {
- Response.Write(ex.Message);
- }
- conn.Close();
- }
- protected void BtnAdd_Click(object sender, EventArgs e)
- {
- ArrayList employeeValueList = new ArrayList();
- ArrayList employeeTextList = new ArrayList();
- if (Session["employeeValue"] != null)
- {
- employeeValueList = (ArrayList)Session["employeeValue"];
- }
- if (Session["employeeText"] != null)
- {
- employeeTextList = (ArrayList)Session["employeeText"];
- }
- foreach (ListItem item in ListEmployee.Items)
- {
- if (item.Selected)
- {
- if (!employeeValueList.Contains(item.Value))
- {
- employeeValueList.Add(item.Value);
- employeeTextList.Add(item.Text);
- }
- }
- }
- Session["employeeText"] = employeeTextList;
- Session["employeeValue"] = employeeValueList;
- this.ListSelectedBind();
- }
- //ListSelected 綁定
- protected void ListSelectedBind()
- {
- ListSelected.Items.Clear();
- ArrayList employeeValueList = new ArrayList();
- ArrayList employeeTextList = new ArrayList();
- if (Session["employeeValue"] != null)
- {
- employeeValueList = (ArrayList)Session["employeeValue"];
- }
- if (Session["employeeText"] != null)
- {
- employeeTextList = (ArrayList)Session["employeeText"];
- }
- for (int i = 0; i < employeeValueList.Count; i++)
- {
- ListItem item = new ListItem();
- item.Text = employeeTextList[i].ToString();
- item.Value = employeeValueList[i].ToString();
- ListSelected.Items.Add(item);
- }
- }
- protected void BtnDelete_Click(object sender, EventArgs e)
- {
- ArrayList employeeValueList = new ArrayList();
- ArrayList employeeTextList = new ArrayList();
- if (Session["employeeValue"] != null)
- {
- employeeValueList = (ArrayList)Session["employeeValue"];
- }
- if (Session["employeeText"] != null)
- {
- employeeTextList = (ArrayList)Session["employeeText"];
- }
- if (employeeValueList.Count > 0)
- {
- foreach (ListItem item in ListSelected.Items)
- {
- if (item.Selected)
- {
- employeeValueList.Remove(item.Value);
- employeeTextList.Remove(item.Text);
- }
- }
- }
- Session["employeeText"] = employeeTextList;
- Session["employeeValue"] = employeeValueList;
- this.ListSelectedBind();
- }
- protected void BtnAddAll_Click(object sender, EventArgs e)
- {
- ArrayList employeeValueList = new ArrayList();
- ArrayList employeeTextList = new ArrayList();
- if (Session["employeeValue"] != null)
- {
- employeeValueList = (ArrayList)Session["employeeValue"];
- }
- if (Session["employeeText"] != null)
- {
- employeeTextList = (ArrayList)Session["employeeText"];
- }
- foreach (ListItem item in ListEmployee.Items)
- {
- if (!employeeValueList.Contains(item.Value))
- {
- employeeValueList.Add(item.Value);
- employeeTextList.Add(item.Text);
- }
- }
- Session["employeeText"] = employeeTextList;
- Session["employeeValue"] = employeeValueList;
- this.ListSelectedBind();
- }
- protected void BtnDeleteAll_Click(object sender, EventArgs e)
- {
- ArrayList employeeValueList = new ArrayList();
- ArrayList employeeTextList = new ArrayList();
- if (Session["employeeValue"] != null)
- {
- employeeValueList = (ArrayList)Session["employeeValue"];
- }
- if (Session["employeeText"] != null)
- {
- employeeTextList = (ArrayList)Session["employeeText"];
- }
- if (employeeValueList.Count > 0)
- {
- foreach (ListItem item in ListSelected.Items)
- {
- employeeValueList.Remove(item.Value);
- employeeTextList.Remove(item.Text);
- }
- }
- Session["employeeText"] = employeeTextList;
- Session["employeeValue"] = employeeValueList;
- this.ListSelectedBind();
- }
- protected void BtnCancel_Click(object sender, EventArgs e)
- {
- Session.Remove("employeeText");
- Session.Remove("employeeValue");
- //關閉當前窗體
- Response.Write("<script language='javascript'>window.parent.close();</script>");
- }
- }