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

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.                     ArrayList form_id = new ArrayList();
  103.                     ArrayList step1 = new ArrayList();
  104.                     ArrayList is_agree = new ArrayList();
  105.                     cmd = new SqlCommand("select a.id as id, begin_time, end_time,a.step as step1,b.step as step2,is_agree from OA_CH_BUSINESS_FORM as a left join OA_CH_APPROVEL_FORM_FLOW1 as b on a.id=b.form_id " +
  106.                         " where emp_id=" +
  107.                         EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  108.                     dr = cmd.ExecuteReader();
  109.                     while (dr.Read())
  110.                     {
  111.                         if (dr["begin_time"].ToString().CompareTo(time) == -1 && dr["end_time"].ToString().CompareTo(time) == 1)
  112.                         {
  113.                             form_id.Add(dr["id"].ToString());
  114.                             step1.Add(Convert.ToInt32(dr["step1"]));
  115.                             is_agree.Add(dr["is_agree"].ToString());
  116.                         }
  117.                     }
  118.                     dr.Close();
  119.                     if (form_id.Count > 0)
  120.                     {
  121.                         for (int j = 0; j < form_id.Count; j++)
  122.                         {
  123.                             SqlCommand cmd1 = new SqlCommand("select max(step) as step2 from oa_ch_approvel_form_flow1 where form_id=" + form_id[j], conn);
  124.                             int step2 = Convert.ToInt32(cmd1.ExecuteScalar());
  125.                             if (step2 == Convert.ToInt32(step1[j]))
  126.                             {
  127.                                 if (is_agree[j].ToString().Equals("Y"))
  128.                                 {
  129.                                     flag = 1;
  130.                                     btn.Text = "出差";
  131.                                     //btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
  132.                                     //Session["state_type"] = "1";
  133.                                     // Session["type_id"] = dr["id"].ToString();
  134.                                     // Session["state"] = btn.Text;
  135.                                     btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + "&state=7&state_type=2&t=0&type_id=" + form_id[j].ToString();
  136.                                 }
  137.                             }
  138.                         }
  139.                     }
  140.                 }
  141.                 if (flag == 0)
  142.                 {
  143.                     cmd = new SqlCommand("select f.id, f.begin_time, f.end_time, t.name type ,t.sequence from OA_CH_OFF_FORM f " +
  144.                         "inner join OA_CH_OFF_TYPE t on f.off_type=t.id where total_result='同意' and emp_id=" +
  145.                             EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  146.                     dr = cmd.ExecuteReader();
  147.                     while (dr.Read())
  148.                     {
  149.                         if (dr["begin_time"].ToString().CompareTo(time) == -1 && dr["end_time"].ToString().CompareTo(time) == 1)
  150.                         {
  151.                             flag = 1;
  152.                             btn.Text = dr["type"].ToString();
  153.                            // Session["state_type"] = "3";
  154.                            // Session["type_id"] = dr["id"].ToString();
  155.                             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();
  156.                         }
  157.                     }
  158.                     dr.Close();
  159.                 }
  160.                 if (flag == 0)
  161.                 {
  162.                     btn.Text = "上班";
  163.                    // Session["state_type"] = "4";
  164.                    // Session["type_id"] = "0";
  165.                     btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
  166.                 }
  167.                 conn.Close();
  168.                // Session["state"] = btn.Text;
  169.             }
  170.         }
  171.     }
  172.     protected void EmployeeList_RowDataBound(object sender, GridViewRowEventArgs e)
  173.     {
  174.         //行高亮
  175.         if (e.Row.RowType == DataControlRowType.DataRow)
  176.         {
  177.             e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor; this.style.backgroundColor='#c8dafa';this.style.cursor='pointer';");
  178.             e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
  179.             e.Row.Attributes.Add("onclick", "window.location.href='employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + "&edit=n'");
  180.         }
  181.     }
  182. }