employee_select_single.aspx.cs
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:4k
源码类别:

OA系统

开发平台:

ASP/ASPX

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using System.Data.SqlClient;
  12. using System.Net.Mail;
  13. using System.Net;
  14. using System.Net.Sockets;
  15. public partial class web_personnel_curricula_vitae_employee_select_single : System.Web.UI.Page
  16. {
  17.     protected void Page_Load(object sender, EventArgs e)
  18.     {
  19.         if (!IsPostBack)
  20.         {
  21.             LoginDAO.CheckLogin(Session, Response, "../../", 2);
  22.             if (Session["user"] != null)
  23.             {
  24.                 User user = (User)Session["user"];
  25.                 Session["department_id"] = user.Department.Id.ToString();
  26.                 ArrayList department_id = new ArrayList();
  27.                 SqlConnection conn = dbConnection.getConnection();
  28.                 conn.Open();
  29.                 SqlCommand cmd = new SqlCommand("select id from oa_department where id=" + Session["department_id"] +
  30.                     " or last_id=" + Session["department_id"], conn);
  31.                 SqlDataReader dr1 = cmd.ExecuteReader();
  32.                 while (dr1.Read())
  33.                 {
  34.                     department_id.Add(dr1["id"].ToString());
  35.                 }
  36.                 dr1.Close();
  37.                 if (Request.QueryString["department_id"] != null)
  38.                 {
  39.                     cmd = new SqlCommand("select e.id, e.emp_no, e.emp_name, p.name position from " +
  40.                      "OA_EMPLOYEE e inner join OA_EMPLOYEE_POSITION p on e.position=p.id where " +
  41.                      "department_id=" + Request.QueryString["department_id"] + " and dimission_date=''", conn);
  42.                     SqlDataReader dr = cmd.ExecuteReader();
  43.                     while (dr.Read())
  44.                     {
  45.                         ListItem item = new ListItem();
  46.                         item.Value = dr["id"].ToString();
  47.                         item.Text = dr["emp_no"].ToString() + " " + dr["emp_name"].ToString() + dr["position"].ToString();
  48.                         LbEmp.Items.Add(item);
  49.                     }
  50.                     dr.Close();
  51.                     conn.Close();
  52.                 }
  53.                 if (Request.QueryString["department_id"] == null)
  54.                 {
  55.                     for (int i = 0; i < department_id.Count; i++)
  56.                     {
  57.                         cmd = new SqlCommand("select e.id, e.emp_no, e.emp_name, p.name position from " +
  58.                             "OA_EMPLOYEE e inner join OA_EMPLOYEE_POSITION p on e.position=p.id where " +
  59.                             "department_id=" + department_id[i] + " and dimission_date=''", conn);
  60.                         SqlDataReader dr = cmd.ExecuteReader();
  61.                         while (dr.Read())
  62.                         {
  63.                             ListItem item = new ListItem();
  64.                             item.Value = dr["id"].ToString();
  65.                             item.Text = dr["emp_no"].ToString() + " " + dr["emp_name"].ToString() + dr["position"].ToString();
  66.                             LbEmp.Items.Add(item);
  67.                         }
  68.                         dr.Close();
  69.                     }
  70.                     conn.Close();
  71.                 }
  72.             }
  73.         }
  74.     }
  75.     protected void BtnOk_Click(object sender, EventArgs e)
  76.     {
  77.         try
  78.         {
  79.             Response.Write("<script language='javascript'>window.parent.opener.setValue('" + LbEmp.SelectedValue + "','" + LbEmp.SelectedItem.Text + "');window.parent.close();</script>");
  80.         }
  81.         catch
  82.         {
  83.             Response.Write("<script language='javascript'>alert('請至少選擇一個代理人');</script>");
  84.         }
  85.     }
  86. }