blank.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_personnel_curricula_vitae_blank : 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.             EmployeeDimissionList.DataKeyNames = new string[] { "id" };
  21.             if (Session["p_department_id"] != null)
  22.             {
  23.                 SqlConnection conn = dbConnection.getConnection();
  24.                 conn.Open();
  25.                 SqlCommand cmd = new SqlCommand("select name from OA_DEPARTMENT where id=" + Session["p_department_id"].ToString(), conn);
  26.                 try
  27.                 {
  28.                     string department = cmd.ExecuteScalar().ToString();
  29.                     LblTitle2.Text = department + "離職員工列表";
  30.                     LblTitle1.Text = department + "在職員工列表";
  31.                     LblTitle1.Visible = false;
  32.                     LblTitle2.Visible = false;
  33.                     if (Request.QueryString["type"].Equals("1")) 
  34.                     {
  35.                         LblTitle2.Visible = true;
  36.                       EmployeeDimissionList.Visible = true; 
  37.                     }
  38.                 }
  39.                 catch { }
  40.                 conn.Close();
  41.             }
  42.         }
  43.     }
  44.     protected void EmployeeList_RowCreated(object sender, GridViewRowEventArgs e)
  45.     {
  46.         if (e.Row.RowType == DataControlRowType.DataRow)
  47.         {
  48.             if (Request.QueryString["type"] == null)
  49.             {
  50.                 DateMgr mgr = new DateMgr();
  51.                 string time = mgr.getDateTime();
  52.                 LinkButton btn = (LinkButton)e.Row.FindControl("LbWhere");
  53.                 SqlConnection conn = dbConnection.getConnection();
  54.                 conn.Open();
  55.                 SqlCommand cmd = new SqlCommand("select f.vacation_begin, f.vacation_end, f.business_begin, f.business_end," +
  56.                     " t.name type from OA_TW_APPROVEL_FORM f inner join OA_TW_OFF_TYPE t on f.off_type=t.id where emp_id=" +
  57.                     EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + " and total_result='同意'", conn);
  58.                 SqlDataReader dr = cmd.ExecuteReader();
  59.                 int flag = 0;
  60.                 while (dr.Read())
  61.                 {
  62.                     if (dr["type"].ToString().Equals("出差"))
  63.                     {
  64.                         if (dr["business_begin"].ToString().CompareTo(time) == -1 && dr["business_end"].ToString().CompareTo(time) == 1)
  65.                         {
  66.                             flag = 1;
  67.                             btn.Text = "出差";
  68.                             btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.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.                         }
  79.                     }
  80.                 }
  81.                 dr.Close();
  82.                 if (flag == 0)
  83.                 {
  84.                     cmd = new SqlCommand("select begin_time, end_time from OA_CH_BUSINESS_FORM where total_result='同意' and emp_id=" +
  85.                         EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  86.                     dr = cmd.ExecuteReader();
  87.                     while (dr.Read())
  88.                     {
  89.                         if (dr["begin_time"].ToString().CompareTo(time) == -1 && dr["end_time"].ToString().CompareTo(time) == 1)
  90.                         {
  91.                             flag = 1;
  92.                             btn.Text = "出差";
  93.                             btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
  94.                         }
  95.                     }
  96.                     dr.Close();
  97.                 }
  98.                 if (flag == 0)
  99.                 {
  100.                     cmd = new SqlCommand("select f.begin_time, f.end_time, t.name type from OA_CH_OFF_FORM f " +
  101.                         "inner join OA_CH_OFF_TYPE t on f.off_type=t.id where total_result='同意' and emp_id=" +
  102.                             EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  103.                     dr = cmd.ExecuteReader();
  104.                     while (dr.Read())
  105.                     {
  106.                         if (dr["begin_time"].ToString().CompareTo(time) == -1 && dr["end_time"].ToString().CompareTo(time) == 1)
  107.                         {
  108.                             flag = 1;
  109.                             btn.Text = dr["type"].ToString();
  110.                         }
  111.                     }
  112.                     dr.Close();
  113.                 }
  114.                 if (flag == 0)
  115.                 {
  116.                     btn.Text = "上班";
  117.                 }
  118.                 conn.Close();
  119.             }
  120.         }
  121.     }
  122.     protected void EmployeeList_RowDataBound(object sender, GridViewRowEventArgs e)
  123.     {
  124.         //行高亮
  125.         if (e.Row.RowType == DataControlRowType.DataRow)
  126.         {
  127.             try
  128.             {
  129.                 LblTitle1.Visible = true;
  130.                 e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor; this.style.backgroundColor='#c8dafa';this.style.cursor='pointer';");
  131.                 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
  132.                 e.Row.Attributes.Add("onclick", "window.parent.location.href='employee_show.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + "'");
  133.             }
  134.             catch { }
  135.         }
  136.     }
  137.     protected void EmployeeDimissionList_RowDataBound(object sender, GridViewRowEventArgs e)
  138.     {
  139.         //行高亮
  140.         if (e.Row.RowType == DataControlRowType.DataRow)
  141.         {
  142.             try
  143.             {
  144.                 LblTitle2.Visible = true;
  145.                 e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor; this.style.backgroundColor='#c8dafa';this.style.cursor='pointer';");
  146.                 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
  147.                 e.Row.Attributes.Add("onclick", "window.parent.location.href='employee_show.aspx?e_id=" + EmployeeDimissionList.DataKeys[e.Row.RowIndex].Value.ToString() + "'");
  148.             }
  149.             catch { }
  150.         }
  151.     }
  152.    
  153. }