department_select_mult.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:5k
源码类别:
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_mult : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- this.DepartmentBind();
- this.DepartmentSelectedBind();
- }
- }
- protected void DepartmentBind()
- {
- if (Request.QueryString["department_id"] != null)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select id, code, name from OA_DEPARTMENT where last_id=" +
- Request.QueryString["department_id"] + " order by sequence, code", conn);
- SqlDataReader dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- ListItem item = new ListItem();
- item.Value = dr["id"].ToString();
- item.Text = dr["code"].ToString() + dr["name"].ToString();
- LbDepartment.Items.Add(item);
- }
- dr.Close();
- conn.Close();
- }
- }
- protected void DepartmentSelectedBind()
- {
- LbSelected.Items.Clear();
- if (Session["departmentTexts"] != null && Session["departmentValues"] != null)
- {
- ArrayList departmentTexts = (ArrayList)Session["departmentTexts"];
- ArrayList departmentValues = (ArrayList)Session["departmentValues"];
- for (int i = 0; i < departmentTexts.Count; i++)
- {
- ListItem item = new ListItem();
- item.Text = departmentTexts[i].ToString();
- item.Value = departmentValues[i].ToString();
- LbSelected.Items.Add(item);
- }
- }
- }
- protected void BtnAdd_Click(object sender, EventArgs e)
- {
- ArrayList departmentTexts = new ArrayList();
- ArrayList departmentValues = new ArrayList();
- if (Session["departmentTexts"] != null && Session["departmentValues"] != null)
- {
- departmentTexts = (ArrayList)Session["departmentTexts"];
- departmentValues = (ArrayList)Session["departmentValues"];
- }
- foreach (ListItem item in LbDepartment.Items)
- {
- if (item.Selected)
- {
- if (!departmentValues.Contains(item.Value))
- {
- departmentValues.Add(item.Value);
- departmentTexts.Add(item.Text);
- }
- }
- }
- Session["departmentTexts"] = departmentTexts;
- Session["departmentValues"] = departmentValues;
- this.DepartmentSelectedBind();
- }
- protected void BtnDelete_Click(object sender, EventArgs e)
- {
- ArrayList departmentTexts = new ArrayList();
- ArrayList departmentValues = new ArrayList();
- if (Session["departmentTexts"] != null && Session["departmentValues"] != null)
- {
- departmentTexts = (ArrayList)Session["departmentTexts"];
- departmentValues = (ArrayList)Session["departmentValues"];
- }
- foreach (ListItem item in LbSelected.Items)
- {
- if (item.Selected)
- {
- if (departmentValues.Contains(item.Value))
- {
- departmentValues.Remove(item.Value);
- departmentTexts.Remove(item.Text);
- }
- }
- }
- Session["departmentTexts"] = departmentTexts;
- Session["departmentValues"] = departmentValues;
- this.DepartmentSelectedBind();
- }
- protected void BtnAddAll_Click(object sender, EventArgs e)
- {
- ArrayList departmentTexts = new ArrayList();
- ArrayList departmentValues = new ArrayList();
- if (Session["departmentTexts"] != null && Session["departmentValues"] != null)
- {
- departmentTexts = (ArrayList)Session["departmentTexts"];
- departmentValues = (ArrayList)Session["departmentValues"];
- }
- foreach (ListItem item in LbDepartment.Items)
- {
- if (!departmentValues.Contains(item.Value))
- {
- departmentValues.Add(item.Value);
- departmentTexts.Add(item.Text);
- }
- }
- Session["departmentTexts"] = departmentTexts;
- Session["departmentValues"] = departmentValues;
- this.DepartmentSelectedBind();
- }
- protected void BtnDeleteAll_Click(object sender, EventArgs e)
- {
- Session.Remove("departmentTexts");
- Session.Remove("departmentValues");
- this.DepartmentSelectedBind();
- }
- protected void BtnCancel_Click(object sender, EventArgs e)
- {
- Session.Remove("departmentTexts");
- Session.Remove("departmentValues");
- //關閉當前窗體
- Response.Write("<script language='javascript'>window.parent.close();</script>");
- }
- }