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

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_approvel_employee_list_search : 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.         }
  20.     }
  21.     protected void BtnOk_Click(object sender, EventArgs e)
  22.     {
  23.         if (RbType.SelectedValue.Equals("emp_no"))
  24.         {
  25.             SqlDataSource1.SelectCommand = "SELECT e.id, e.emp_no, e.emp_name, p.name AS position, e.tel, e.smart_phone, " +
  26.                 "e.tel_extension FROM dbo.OA_EMPLOYEE AS e INNER JOIN dbo.OA_EMPLOYEE_POSITION AS p ON e.position = p.id " +
  27.                 "WHERE e.emp_no like '%" + TxtValue.Text.Trim() + "%' and"+
  28.                 "p.sequence>=(select sequence from oa_employee_position as a inner join oa_employee as b on a.id=b.position where b.id=@user_id)"+
  29.                 "ORDER BY e.emp_no";
  30.         }
  31.         if (RbType.SelectedValue.Equals("emp_name"))
  32.         {
  33.             SqlDataSource1.SelectCommand = "SELECT e.id, e.emp_no, e.emp_name, p.name AS position, e.tel, e.smart_phone, " +
  34.                 "e.tel_extension FROM dbo.OA_EMPLOYEE AS e INNER JOIN dbo.OA_EMPLOYEE_POSITION AS p ON e.position = p.id " +
  35.                 "WHERE e.emp_name like '%" + TxtValue.Text.Trim() + "%'and"+
  36.                  "p.sequence>=(select sequence from oa_employee_position as a inner join oa_employee as b on a.id=b.position where b.id=@user_id)"+
  37.                 "ORDER BY e.emp_no";
  38.         }
  39.         EmployeeList.Visible = true;
  40.         EmployeeList.DataBind();
  41.     }
  42.     protected void EmployeeList_RowCreated(object sender, GridViewRowEventArgs e)
  43.     {
  44.         if (e.Row.RowType == DataControlRowType.DataRow)
  45.         {
  46.             if (Request.QueryString["type"] == null)
  47.             {
  48.                 DateMgr mgr = new DateMgr();
  49.                 string time = mgr.getDateTime();
  50.                 LinkButton btn = (LinkButton)e.Row.FindControl("LbWhere");
  51.                 Label label = (Label)e.Row.FindControl("LblDepartment");
  52.                 SqlConnection conn = dbConnection.getConnection();
  53.                 conn.Open();
  54.                 SqlCommand cmd = new SqlCommand("select department_id from OA_EMPLOYEE where id=" +
  55.                     EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  56.                 int department_id = Convert.ToInt32(cmd.ExecuteScalar());
  57.                 DepartmentDAO departmentDAO = new DepartmentDAO();
  58.                 int d_length = departmentDAO.queryById(department_id).Name.Length;
  59.                 if (d_length >= 5)
  60.                 {
  61.                     label.Text = departmentDAO.queryById(department_id).Name.Substring(0, 5);
  62.                 }
  63.                 else
  64.                 {
  65.                     label.Text = departmentDAO.queryById(department_id).Name;
  66.                 }
  67.                 cmd = new SqlCommand("select f.id, f.vacation_begin, f.vacation_end, f.business_begin, f.business_end," +
  68.                     " t.name type ,sequence from OA_TW_APPROVEL_FORM f inner join OA_TW_OFF_TYPE t on f.off_type=t.id where f.emp_id=" +
  69.                     EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + " and f.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.                           //  Session["state_type"] = "1";
  82.                           //  Session["type_id"] = dr["id"].ToString();
  83.                             btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + "&state=" + dr["sequence"].ToString() + "&state_type=1&t=1&type_id=" + dr["id"].ToString();
  84.                         }
  85.                     }
  86.                     else
  87.                     {
  88.                         if (dr["vacation_begin"].ToString().CompareTo(time) == -1 && dr["vacation_end"].ToString().CompareTo(time) == 1)
  89.                         {
  90.                             flag = 1;
  91.                             btn.Text = dr["type"].ToString();
  92.                            // btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
  93.                            // Session["state_type"] = "1";
  94.                            // Session["type_id"] = dr["id"].ToString();
  95.                             btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + "&state=" + dr["sequence"].ToString() + "&state_type=1&t=1&type_id=" + dr["id"].ToString();
  96.                         }
  97.                     }
  98.                 }
  99.                 dr.Close();
  100.               if (flag == 0)
  101.                 {
  102.                     cmd = new SqlCommand("select id, begin_time, end_time  from OA_CH_BUSINESS_FORM " +
  103.                         " where total_result='同意' and emp_id="  +
  104.                         EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  105.                     dr = cmd.ExecuteReader();
  106.                     while (dr.Read())
  107.                     {
  108.                         if (dr["begin_time"].ToString().CompareTo(time) == -1 && dr["end_time"].ToString().CompareTo(time) == 1)
  109.                         {
  110.                             flag = 1;
  111.                             btn.Text = "出差";
  112.                            // btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
  113.                            // Session["state_type"] = "2";
  114.                            // Session["type_id"] = dr["id"].ToString();
  115.                             btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + "&state=7&state_type=2&t=0&type_id=" + dr["id"].ToString();
  116.                         }
  117.                     }
  118.                     dr.Close();
  119.                 }
  120.                 if (flag == 0)
  121.                 {
  122.                     cmd = new SqlCommand("select f.id, f.begin_time, f.end_time, t.name type ,t.sequence from OA_CH_OFF_FORM f " +
  123.                         "inner join OA_CH_OFF_TYPE t on f.off_type=t.id where total_result='同意' and emp_id=" +
  124.                             EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  125.                     dr = cmd.ExecuteReader();
  126.                     while (dr.Read())
  127.                     {
  128.                         if (dr["begin_time"].ToString().CompareTo(time) == -1 && dr["end_time"].ToString().CompareTo(time) == 1)
  129.                         {
  130.                             flag = 1;
  131.                             btn.Text = dr["type"].ToString();
  132.                            // Session["state_type"] = "3";
  133.                            // Session["type_id"] = dr["id"].ToString();
  134.                             btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + "&state=" + dr["sequence"].ToString() + "&state_type=3&t=0&type_id=" + dr["id"].ToString();
  135.                         }
  136.                     }
  137.                     dr.Close();
  138.                 }
  139.                 if (flag == 0)
  140.                 {
  141.                     btn.Text = "上班";
  142.                    // Session["state_type"] = "4";
  143.                    // Session["type_id"] = "0";
  144.                     btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
  145.                 }
  146.                 conn.Close();
  147.                // Session["state"] = btn.Text;
  148.             }
  149.         }
  150.     }
  151.     protected void EmployeeList_RowDataBound(object sender, GridViewRowEventArgs e)
  152.     {
  153.         //行高亮
  154.         if (e.Row.RowType == DataControlRowType.DataRow)
  155.         {
  156.             e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor; this.style.backgroundColor='#c8dafa';this.style.cursor='pointer';");
  157.             e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
  158.             e.Row.Attributes.Add("onclick", "window.location.href='employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + "&edit=n'");
  159.         }
  160.     }
  161. }