employee_list_approvel.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_approvel : 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.           
  22.             EmployeeList.DataBind();
  23.             for (int i = 0; i < indexs.Count; i++)
  24.             {
  25.                 EmployeeList.Rows[Convert.ToInt32(indexs[i])].Visible = false;
  26.             }
  27.         }
  28.     }
  29.     protected void EmployeeList_RowCreated(object sender, GridViewRowEventArgs e)
  30.     {
  31.         if (e.Row.RowType == DataControlRowType.DataRow)
  32.         {
  33.             if (Request.QueryString["type"] == null)
  34.             {
  35.                 DateMgr mgr = new DateMgr();
  36.                 string time = mgr.getDateTime();
  37.                 LinkButton btn = (LinkButton)e.Row.FindControl("LbWhere");
  38.                 Label label = (Label)e.Row.FindControl("LblDepartment");
  39.                 SqlConnection conn = dbConnection.getConnection();
  40.                 conn.Open();
  41.                 SqlCommand cmd = new SqlCommand("select department_id from OA_EMPLOYEE where id=" +
  42.                     EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  43.                 int department_id = Convert.ToInt32(cmd.ExecuteScalar());
  44.                 DepartmentDAO departmentDAO = new DepartmentDAO();
  45.                 int d_length = departmentDAO.queryById(department_id).Name.Length;
  46.                 if (d_length >= 5)
  47.                 {
  48.                     label.Text = departmentDAO.queryById(department_id).Name.Substring(0, 5);
  49.                 }
  50.                 else
  51.                 {
  52.                     label.Text = departmentDAO.queryById(department_id).Name;
  53.                 }
  54.                 cmd = new SqlCommand("select f.id, f.vacation_begin, f.vacation_end, f.business_begin, f.business_end," +
  55.                     " 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=" +
  56.                     EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + " and total_result='同意'", conn);            
  57.                 SqlDataReader dr = cmd.ExecuteReader();
  58.                 int flag = 0;
  59.                 while (dr.Read())
  60.                 {
  61.                     if (dr["type"].ToString().Equals("出差"))
  62.                     {
  63.                         if (dr["business_begin"].ToString().CompareTo(time) == -1 && dr["business_end"].ToString().CompareTo(time) == 1)
  64.                         {
  65.                             flag = 1;
  66.                             btn.Text = "出差";
  67.                            // btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
  68.                             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();
  69.                            // Session["state_type"] = "1";
  70.                           //  Session["type_id"] = dr["id"].ToString();
  71.                          //   Session["state"] = btn.Text;
  72.                             
  73.                            
  74.                         }
  75.                     }
  76.                     else
  77.                     {
  78.                         if (dr["vacation_begin"].ToString().CompareTo(time) == -1 && dr["vacation_begin"].ToString().CompareTo(time) == 1)
  79.                         {
  80.                             flag = 1;
  81.                             btn.Text = dr["type"].ToString();
  82.                            // btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
  83.                           //  Session["state_type"] = "1";
  84.                            // Session["state"] = btn.Text;
  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"] = "1";
  106.                            // Session["type_id"] = dr["id"].ToString();
  107.                            // Session["state"] = btn.Text;
  108.                             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();
  109.             
  110.                         }
  111.                     }
  112.                     dr.Close();
  113.                 }
  114.                if (flag == 0)
  115.                 {
  116.                     cmd = new SqlCommand("select f.id, f.begin_time, f.end_time, t.name type ,t.sequence from OA_CH_OFF_FORM f " +
  117.                         "inner join OA_CH_OFF_TYPE t on f.off_type=t.id where total_result='同意' and emp_id=" +
  118.                             EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  119.                     dr = cmd.ExecuteReader();
  120.                     while (dr.Read())
  121.                     {
  122.                         if (dr["begin_time"].ToString().CompareTo(time) == -1 && dr["end_time"].ToString().CompareTo(time) == 1)
  123.                         {
  124.                             //try
  125.                            //{
  126.                                 flag = 1;
  127.                                 btn.Text = dr["type"].ToString();
  128.                                 //Session["state_type"] = "1";
  129.                                 // Session["type_id"] = dr["id"].ToString();
  130.                                 // Session["state"] = btn.Text;
  131.                                 // btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
  132.                                 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();
  133.                           //  }
  134.                          //   catch { }
  135.                         }
  136.                     }
  137.                     dr.Close();
  138.                 }
  139.                 
  140.                if (flag == 0)
  141.                 {
  142.                   /* Session["state_type"] = "4";
  143.                     Session["type_id"] = "0";
  144.                     btn.Text = "hello";*/
  145.                     indexs.Add(e.Row.RowIndex.ToString());
  146.                 }
  147.                 conn.Close();
  148.                
  149.               
  150.             }
  151.         }
  152.     }
  153.     protected void EmployeeList_RowDataBound(object sender, GridViewRowEventArgs e)
  154.     {
  155.         //行高亮
  156.         if (e.Row.RowType == DataControlRowType.DataRow)
  157.         {
  158.             e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor; this.style.backgroundColor='#c8dafa';this.style.cursor='pointer';");
  159.             e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
  160.             e.Row.Attributes.Add("onclick", "window.location.href='employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + "&edit=n'");
  161.         }
  162.     }
  163. }