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