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

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.                     cmd = new SqlCommand("select id, begin_time, end_time  from OA_CH_BUSINESS_FORM "+                 
  95.                         " where total_result='同意' and emp_id=" +
  96.                         EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  97.                     dr = cmd.ExecuteReader();
  98.                     while (dr.Read())
  99.                     {
  100.                         if (dr["begin_time"].ToString().CompareTo(time) == -1 && dr["end_time"].ToString().CompareTo(time) == 1)
  101.                         {
  102.                             flag = 1;
  103.                             btn.Text = "出差";
  104.                           //  btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
  105.                           //  Session["state_type"] = "2";
  106.                            // Session["type_id"] = dr["id"].ToString();
  107.                             btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + "&state=7&state_type=2&t=0&type_id=" + dr["id"].ToString();
  108.                         }
  109.                     }
  110.                     dr.Close();
  111.                 }
  112.                 if (flag == 0)
  113.                 {
  114.                     cmd = new SqlCommand("select f.id, f.begin_time, f.end_time, t.name type ,t.sequence from OA_CH_OFF_FORM f " +
  115.                         "inner join OA_CH_OFF_TYPE t on f.off_type=t.id where total_result='同意' and emp_id=" +
  116.                             EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  117.                     dr = cmd.ExecuteReader();
  118.                     while (dr.Read())
  119.                     {
  120.                         if (dr["begin_time"].ToString().CompareTo(time) == -1 && dr["end_time"].ToString().CompareTo(time) == 1)
  121.                         {
  122.                             flag = 1;
  123.                             btn.Text = dr["type"].ToString();
  124.                           //  Session["state_type"] = "3";
  125.                          //   Session["type_id"] = dr["id"].ToString();
  126.                             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();
  127.                         }
  128.                     }
  129.                     dr.Close();
  130.                 }
  131.                 if (flag == 0)
  132.                 {
  133.                     btn.Text = "上班";
  134.                   //  Session["state_type"] = "4";
  135.                    // Session["type_id"] = "0";
  136.                     btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
  137.                 }
  138.                 conn.Close();
  139.                 Session["state"] = btn.Text;
  140.             }
  141.         }
  142.     }
  143. }