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

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_begin"].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.                     cmd = new SqlCommand("select id, begin_time, end_time from OA_CH_BUSINESS_FORM where total_result='同意' and emp_id=" +
  87.                         EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  88.                     dr = cmd.ExecuteReader();
  89.                     while (dr.Read())
  90.                     {
  91.                         if (dr["begin_time"].ToString().CompareTo(time) == -1 && dr["end_time"].ToString().CompareTo(time) == 1)
  92.                         {
  93.                             flag = 1;
  94.                             btn.Text = "出差";
  95.                             btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
  96.                             Session["state_type"] = "2";
  97.                             Session["type_id"] = dr["id"].ToString();
  98.                         }
  99.                     }
  100.                     dr.Close();
  101.                 }
  102.                 if (flag == 0)
  103.                 {
  104.                     cmd = new SqlCommand("select f.id, f.begin_time, f.end_time, t.name type from OA_CH_OFF_FORM f " +
  105.                         "inner join OA_CH_OFF_TYPE t on f.off_type=t.id where total_result='同意' and emp_id=" +
  106.                             EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  107.                     dr = cmd.ExecuteReader();
  108.                     while (dr.Read())
  109.                     {
  110.                         if (dr["begin_time"].ToString().CompareTo(time) == -1 && dr["end_time"].ToString().CompareTo(time) == 1)
  111.                         {
  112.                             flag = 1;
  113.                             btn.Text = dr["type"].ToString();
  114.                             Session["state_type"] = "3";
  115.                             Session["type_id"] = dr["id"].ToString();
  116.                         }
  117.                     }
  118.                     dr.Close();
  119.                 }
  120.                 if (flag == 0)
  121.                 {
  122.                     btn.Text = "上班";
  123.                     Session["state_type"] = "4";
  124.                     Session["type_id"] = "0";
  125.                     btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
  126.                 }
  127.                 if (flag == 1)
  128.                 {
  129.                     indexs.Add(e.Row.RowIndex.ToString());
  130.                 }
  131.                 conn.Close();
  132.                 Session["state"] = btn.Text;
  133.             }
  134.         }
  135.     }
  136.     protected void EmployeeList_RowDataBound(object sender, GridViewRowEventArgs e)
  137.     {
  138.         //行高亮
  139.         if (e.Row.RowType == DataControlRowType.DataRow)
  140.         {
  141.             e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor; this.style.backgroundColor='#c8dafa';this.style.cursor='pointer';");
  142.             e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
  143.             e.Row.Attributes.Add("onclick", "window.location.href='employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + "&edit=n'");
  144.         }
  145.     }
  146. }