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