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

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. public partial class web_personnel_curricula_vitae_employee_list : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.         if (!IsPostBack)
  17.         {
  18.             EmployeeList.DataKeyNames = new string[] { "id" };
  19.             if (Session["p_department_id"] != null)
  20.             {
  21.                 SqlConnection conn = dbConnection.getConnection();
  22.                 conn.Open();
  23.                 SqlCommand cmd = new SqlCommand("select name from OA_DEPARTMENT where id=" + Session["p_department_id"].ToString(), conn);
  24.                 try
  25.                 {
  26.                     LblTitle.Text = cmd.ExecuteScalar().ToString();
  27.                     if (Request.QueryString["type"] != null)
  28.                     {
  29.                         LblTitle.Text = LblTitle.Text + "離職員工列表";
  30.                     }
  31.                     else
  32.                     {
  33.                         LblTitle.Text = LblTitle.Text + "在職員工列表";
  34.                     }
  35.                     LblTitle.Visible = false;
  36.                 }
  37.                 catch { }
  38.                 conn.Close();
  39.             }
  40.             if (Request.QueryString["type"] != null)
  41.             {
  42.                 SqlDataSource1.SelectCommand = "SELECT e.id, e.emp_no, e.emp_name, e.active_date, e.dimission_date, p.name AS position FROM dbo.OA_EMPLOYEE AS e INNER JOIN dbo.OA_EMPLOYEE_POSITION AS p ON e.position = p.id WHERE (e.department_id = @department_id) and e.dimission_date<>'' ORDER BY e.emp_no";
  43.                 EmployeeList.DataBind();
  44.                 EmployeeList.Columns[4].Visible = true;
  45.                 EmployeeList.Columns[5].Visible = true;
  46.             }
  47.         }
  48.     }
  49.     protected void BtnAddEmployee_Click(object sender, EventArgs e)
  50.     {
  51.         if (Session["p_department_id"] != null)
  52.         {
  53.             Response.Redirect("employee_form.aspx?department_id=" + Session["p_department_id"].ToString());
  54.         }
  55.     }
  56.     protected void EmployeeList_RowCreated(object sender, GridViewRowEventArgs e)
  57.     {
  58.         if (e.Row.RowType == DataControlRowType.DataRow)
  59.         {
  60.             if (Request.QueryString["type"] == null)
  61.             {
  62.                 DateMgr mgr = new DateMgr();
  63.                 string time = mgr.getDateTime();
  64.                 LinkButton btn = (LinkButton)e.Row.FindControl("LbWhere");
  65.                 SqlConnection conn = dbConnection.getConnection();
  66.                 conn.Open();
  67.                 SqlCommand cmd = new SqlCommand("select f.vacation_begin, f.vacation_end, f.business_begin, f.business_end," +
  68.                     " t.name type from OA_TW_APPROVEL_FORM f inner join OA_TW_OFF_TYPE t on f.off_type=t.id where emp_id=" +
  69.                     EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + " and total_result='同意'", conn);
  70.                 SqlDataReader dr = cmd.ExecuteReader();
  71.                 int flag = 0;
  72.                 while (dr.Read())
  73.                 {
  74.                     if (dr["type"].ToString().Equals("出差"))
  75.                     {
  76.                         if (dr["business_begin"].ToString().CompareTo(time) == -1 && dr["business_end"].ToString().CompareTo(time) == 1)
  77.                         {
  78.                             flag = 1;
  79.                             btn.Text = "出差";
  80.                             btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
  81.                         }
  82.                     }
  83.                     else
  84.                     {
  85.                         if (dr["vacation_begin"].ToString().CompareTo(time) == -1 && dr["vacation_begin"].ToString().CompareTo(time) == 1)
  86.                         {
  87.                             flag = 1;
  88.                             btn.Text = dr["type"].ToString();
  89.                             btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
  90.                         }
  91.                     }
  92.                 }
  93.                 dr.Close();
  94.                 if (flag == 0)
  95.                 {
  96.                     cmd = new SqlCommand("select begin_time, end_time from OA_CH_BUSINESS_FORM where total_result='同意' and emp_id=" +
  97.                         EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  98.                     dr = cmd.ExecuteReader();
  99.                     while (dr.Read())
  100.                     {
  101.                         if (dr["begin_time"].ToString().CompareTo(time) == -1 && dr["end_time"].ToString().CompareTo(time) == 1)
  102.                         {
  103.                             flag = 1;
  104.                             btn.Text = "出差";
  105.                             btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
  106.                         }
  107.                     }
  108.                     dr.Close();
  109.                 }
  110.                 if (flag == 0)
  111.                 {
  112.                     cmd = new SqlCommand("select f.begin_time, f.end_time, t.name type from OA_CH_OFF_FORM f " +
  113.                         "inner join OA_CH_OFF_TYPE t on f.off_type=t.id where total_result='同意' and emp_id=" +
  114.                             EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  115.                     dr = cmd.ExecuteReader();
  116.                     while (dr.Read())
  117.                     {
  118.                         if (dr["begin_time"].ToString().CompareTo(time) == -1 && dr["end_time"].ToString().CompareTo(time) == 1)
  119.                         {
  120.                             flag = 1;
  121.                             btn.Text = dr["type"].ToString();
  122.                         }
  123.                     }
  124.                     dr.Close();
  125.                 }
  126.                 if (flag == 0)
  127.                 {
  128.                     btn.Text = "上班";
  129.                 }
  130.                 conn.Close();
  131.             }
  132.         }
  133.     }
  134.     protected void EmployeeList_RowDataBound(object sender, GridViewRowEventArgs e)
  135.     {
  136.         //行高亮
  137.         if (e.Row.RowType == DataControlRowType.DataRow)
  138.         {
  139.             LblTitle.Visible = true;
  140.             e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor; this.style.backgroundColor='#c8dafa';this.style.cursor='pointer';");
  141.             e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
  142.             e.Row.Attributes.Add("onclick", "window.parent.location.href='employee_show.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + "'");
  143.         }
  144.     }
  145. }