employee_list_all.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_all : 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.        }
  21.    }
  22.       protected void EmployeeList_RowCreated(object sender, GridViewRowEventArgs e)
  23.      {
  24.          if (e.Row.RowType == DataControlRowType.DataRow)
  25.          {
  26.              if (Request.QueryString["type"] == null)
  27.              {
  28.                  DateMgr mgr = new DateMgr();
  29.                  string time = mgr.getDateTime();
  30.                  LinkButton btn = (LinkButton)e.Row.FindControl("LbWhere");
  31.                  Label label = (Label)e.Row.FindControl("LblDepartment");
  32.                  SqlConnection conn = dbConnection.getConnection();
  33.                 conn.Open();
  34.                 SqlCommand cmd = new SqlCommand("select department_id from OA_EMPLOYEE where id=" +
  35.                    EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  36.                  int department_id = Convert.ToInt32(cmd.ExecuteScalar());
  37.                  DepartmentDAO departmentDAO = new DepartmentDAO();
  38.                  int d_length=departmentDAO.queryById(department_id).Name.Length;
  39.                  if (d_length>=5)
  40.                  {
  41.                      label.Text = departmentDAO.queryById(department_id).Name.Substring(0, 5);
  42.                  }
  43.                  else
  44.                  {
  45.                      label.Text = departmentDAO.queryById(department_id).Name;
  46.                  }
  47.                  cmd = new SqlCommand("select f.id, f.vacation_begin, f.vacation_end, f.business_begin, f.business_end," +
  48.                      " t.name type, sequence from OA_TW_APPROVEL_FORM f inner join OA_TW_OFF_TYPE t on f.off_type=t.id where f.emp_id=" +
  49.                      EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + " and f.total_result='同意'", conn);
  50.                  SqlDataReader dr = cmd.ExecuteReader();
  51.                  int flag = 0;
  52.                  while (dr.Read())
  53.                  {
  54.                      if (dr["type"].ToString().Equals("出差"))
  55.                      {
  56.                          if (dr["business_begin"].ToString().CompareTo(time) == -1 && dr["business_end"].ToString().CompareTo(time) == 1)
  57.                          {
  58.                              flag = 1;
  59.                              btn.Text = "出差";
  60.                              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();
  61.                             // Session["state_type"] = "1";
  62.                             // Session["type_id"] = dr["id"].ToString();
  63.                          }
  64.                      }
  65.                      else
  66.                      {
  67.                          if (dr["vacation_begin"].ToString().CompareTo(time) == -1 && dr["vacation_begin"].ToString().CompareTo(time) == 1)
  68.                          {
  69.                              flag = 1;
  70.                              btn.Text = dr["type"].ToString();
  71.                              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();
  72.                            //  Session["state_type"] = "1";
  73.                            //  Session["type_id"] = dr["id"].ToString();
  74.                          }
  75.                      }
  76.                  }
  77.                  dr.Close();
  78.                  if (flag == 0)
  79.                  {
  80.                      cmd = new SqlCommand("select id, begin_time, end_time  from OA_CH_BUSINESS_FORM " +
  81.                         " where total_result='同意' and emp_id=" +
  82.                          EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  83.                      dr = cmd.ExecuteReader();
  84.                      while (dr.Read())
  85.                      {
  86.                          if (dr["begin_time"].ToString().CompareTo(time) == -1 && dr["end_time"].ToString().CompareTo(time) == 1)
  87.                          {
  88.                              flag = 1;
  89.                              btn.Text = "出差";
  90.                             // btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
  91.                             // Session["state_type"] = "1";
  92.                            //  Session["type_id"] = dr["id"].ToString();
  93.                              btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + 
  94.                                  "&state=7&state_type=2&t=0&type_id=" + dr["id"].ToString();
  95.                          }
  96.                      }
  97.                      dr.Close();
  98.                  }
  99.                  if (flag == 0)
  100.                  {
  101.                      cmd = new SqlCommand("select f.id, f.begin_time, f.end_time, t.name type ,t.sequence from OA_CH_OFF_FORM f " +
  102.                         "inner join OA_CH_OFF_TYPE t on f.off_type=t.id where total_result='同意' and emp_id=" +
  103.                              EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  104.                      dr = cmd.ExecuteReader();
  105.                      while (dr.Read())
  106.                      {
  107.                          if (dr["begin_time"].ToString().CompareTo(time) == -1 && dr["end_time"].ToString().CompareTo(time) == 1)
  108.                          {
  109.                              flag = 1;
  110.                              btn.Text = dr["type"].ToString();
  111.                            //  Session["state_type"] = "3";
  112.                            //  Session["type_id"] = dr["id"].ToString();
  113.                              btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + 
  114.                                  "&state=" + dr["sequence"].ToString() + "&state_type=3&t=0&type_id=" + dr["id"].ToString();
  115.                          }
  116.                      }
  117.                      dr.Close();
  118.                  }
  119.                  if (flag == 0)
  120.                  {
  121.                      btn.Text = "上班";
  122.                    //  Session["state_type"] = "4";
  123.                   //   Session["type_id"] = "0";
  124.                      btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();   
  125.                  }
  126.                  conn.Close();
  127.                  Session["state"] = btn.Text;
  128.              }
  129.          }
  130.      }
  131.     protected void EmployeeList_RowDataBound(object sender, GridViewRowEventArgs e)
  132.     {
  133.         //行高亮
  134.         if (e.Row.RowType == DataControlRowType.DataRow)
  135.         {
  136.             e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor; this.style.backgroundColor='#c8dafa';this.style.cursor='pointer';");
  137.             e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
  138.             e.Row.Attributes.Add("onclick", "window.location.href='employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + "&edit=n'");
  139.         }
  140.     }
  141.     
  142. }