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