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

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_system_authority_employee_list : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.         if (!IsPostBack)
  17.         {
  18.             EmployeeList.DataKeyNames = new string[] { "id" };
  19.         }
  20.     }
  21.     protected void EmployeeList_RowCreated(object sender, GridViewRowEventArgs e)
  22.     {
  23.         if (e.Row.RowType == DataControlRowType.DataRow)
  24.         {
  25.             Label lbl = (Label)e.Row.FindControl("LblDepartment");
  26.             SqlConnection conn = dbConnection.getConnection();
  27.             conn.Open();
  28.             SqlCommand cmd = new SqlCommand("select department_id from OA_EMPLOYEE where id="+EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  29.             int department_id = Convert.ToInt32(cmd.ExecuteScalar().ToString());
  30.             conn.Close();
  31.             DepartmentDAO departmentDAO = new DepartmentDAO();
  32.             Department department = departmentDAO.queryById(department_id);
  33.             lbl.Text = department.Full_name;
  34.         }
  35.     }
  36.     protected void EmployeeList_RowDataBound(object sender, GridViewRowEventArgs e)
  37.     {
  38.         //行高亮
  39.         if (e.Row.RowType == DataControlRowType.DataRow)
  40.         {
  41.             e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;");
  42.             e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
  43.         }
  44.     }
  45. }