employee_list1.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.                 }
  91.                 dr.Close();
  92.                 if (flag == 0)
  93.                 {
  94.                     ArrayList form_id = new ArrayList();
  95.                     ArrayList step1 = new ArrayList();
  96.                     ArrayList is_agree = new ArrayList();
  97.                     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 " +
  98.                         " where emp_id=" +
  99.                         EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  100.                     dr = cmd.ExecuteReader();
  101.                     while (dr.Read())
  102.                     {
  103.                         if (dr["begin_time"].ToString().CompareTo(time) == -1 && dr["end_time"].ToString().CompareTo(time) == 1)
  104.                         {
  105.                             form_id.Add(dr["id"].ToString());
  106.                             step1.Add(Convert.ToInt32(dr["step1"]));
  107.                             is_agree.Add(dr["is_agree"].ToString());
  108.                         }
  109.                     }
  110.                     dr.Close();
  111.                     if (form_id.Count > 0)
  112.                     {
  113.                         for (int j = 0; j < form_id.Count; j++)
  114.                         {
  115.                             SqlCommand cmd1 = new SqlCommand("select max(step) as step2 from oa_ch_approvel_form_flow1 where form_id=" + form_id[j], conn);
  116.                             int step2 = Convert.ToInt32(cmd1.ExecuteScalar());
  117.                             if (step2 == Convert.ToInt32(step1[j]))
  118.                             {
  119.                                 if (is_agree[j].ToString().Equals("Y"))
  120.                                 {
  121.                                     flag = 1;
  122.                                     btn.Text = "出差";
  123.                                     //btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
  124.                                     //Session["state_type"] = "1";
  125.                                     // Session["type_id"] = dr["id"].ToString();
  126.                                     // Session["state"] = btn.Text;
  127.                                     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();
  128.                                 }
  129.                             }
  130.                         }
  131.                     }
  132.                 }
  133.                 if (flag == 0)
  134.                 {
  135.                     cmd = new SqlCommand("select f.id, f.begin_time, f.end_time, t.name type ,t.sequence from OA_CH_OFF_FORM f " +
  136.                         "inner join OA_CH_OFF_TYPE t on f.off_type=t.id where total_result='同意' and emp_id=" +
  137.                             EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  138.                     dr = cmd.ExecuteReader();
  139.                     while (dr.Read())
  140.                     {
  141.                         if (dr["begin_time"].ToString().CompareTo(time) == -1 && dr["end_time"].ToString().CompareTo(time) == 1)
  142.                         {
  143.                             if (dr["is_agree"].ToString().Equals("Y"))
  144.                             {
  145.                                 if (dr["step1"].ToString().Equals(dr["step2"].ToString()))
  146.                                 {
  147.                                     flag = 1;
  148.                                     btn.Text = dr["type"].ToString();
  149.                                     //  Session["state_type"] = "3";
  150.                                     //   Session["type_id"] = dr["id"].ToString();
  151.                                     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();
  152.                                 }
  153.                             }
  154.                         }
  155.                     }
  156.                     dr.Close();
  157.                 }
  158.                 if (flag == 0)
  159.                 {
  160.                     btn.Text = "上班";
  161.                   //  Session["state_type"] = "4";
  162.                    // Session["type_id"] = "0";
  163.                     btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
  164.                 }
  165.                 conn.Close();
  166.                 Session["state"] = btn.Text;
  167.             }
  168.         }
  169.     }
  170. }