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

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.                     else
  75.                     {
  76.                         if (dr["vacation_begin"].ToString().CompareTo(time) == -1 && dr["vacation_end"].ToString().CompareTo(time) == 1)
  77.                         {
  78.                             flag = 1;
  79.                             btn.Text = dr["type"].ToString();
  80.                             // btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
  81.                             //  Session["state_type"] = "1";
  82.                             // Session["state"] = btn.Text;
  83.                             //  Session["type_id"] = dr["id"].ToString();
  84.                             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();
  85.                         }
  86.                     }
  87.                 }
  88.                 dr.Close();
  89.                 if (flag == 0)
  90.                 {
  91.                     ArrayList form_id = new ArrayList();
  92.                     ArrayList step1 = new ArrayList();
  93.                     ArrayList is_agree = new ArrayList();
  94.                     cmd = new SqlCommand("select a.id, begin_time, end_time,a.step as step1,b.step as step2,is_agree from OA_CH_BUSINESS_FORM as a left join OA_CH_APPROVEL_FORM_FLOW1 as b on a.id=b.form_id " +
  95.                         " where 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.                             form_id.Add(dr["id"].ToString());
  103.                             step1.Add(Convert.ToInt32(dr["step1"]));
  104.                         }
  105.                     }
  106.                     dr.Close();
  107.                     if (form_id.Count > 0)
  108.                     {
  109.                         for (int j = 0; j < form_id.Count; j++)
  110.                         {
  111.                             SqlCommand cmd1 = new SqlCommand("select max(step) as step2 from oa_ch_approvel_form_flow1 where form_id=" + form_id[j], conn);
  112.                             int step2 = Convert.ToInt32(cmd1.ExecuteScalar());
  113.                             if (step2 == Convert.ToInt32(step1[j]))
  114.                             {
  115.                                 //if (dr["is_agree"].ToString().Equals("Y"))
  116.                                 //    {
  117.                                 flag = 1;
  118.                                 btn.Text = "出差";
  119.                                 //btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
  120.                                 //Session["state_type"] = "1";
  121.                                 // Session["type_id"] = dr["id"].ToString();
  122.                                 // Session["state"] = btn.Text;
  123.                                 btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + "&state=7&state_type=2&t=0&type_id=" + form_id[j].ToString();
  124.                                 //    }
  125.                             }
  126.                         }
  127.                     }
  128.                     if (flag == 0)
  129.                     {
  130.                         cmd = new SqlCommand("select f.id, f.begin_time, f.end_time, t.name type ,t.sequence from OA_CH_OFF_FORM f " +
  131.                             "inner join OA_CH_OFF_TYPE t on f.off_type=t.id where total_result='同意' and emp_id=" +
  132.                                 EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  133.                         dr = cmd.ExecuteReader();
  134.                         while (dr.Read())
  135.                         {
  136.                             if (dr["begin_time"].ToString().CompareTo(time) == -1 && dr["end_time"].ToString().CompareTo(time) == 1)
  137.                             {
  138.                                 //try
  139.                                 //{
  140.                                 flag = 1;
  141.                                 btn.Text = dr["type"].ToString();
  142.                                 //Session["state_type"] = "1";
  143.                                 // Session["type_id"] = dr["id"].ToString();
  144.                                 // Session["state"] = btn.Text;
  145.                                 // btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
  146.                                 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();
  147.                                 //  }
  148.                                 //   catch { }
  149.                             }
  150.                         }
  151.                         dr.Close();
  152.                     }
  153.                     if (flag == 0)
  154.                     {
  155.                         /* Session["state_type"] = "4";
  156.                           Session["type_id"] = "0";
  157.                           btn.Text = "hello";*/
  158.                         indexs.Add(e.Row.RowIndex.ToString());
  159.                     }
  160.                     conn.Close();
  161.                 }
  162.             }
  163.         }
  164.     }
  165.     protected void EmployeeList_RowDataBound(object sender, GridViewRowEventArgs e)
  166.     {
  167.         //行高亮
  168.         if (e.Row.RowType == DataControlRowType.DataRow)
  169.         {
  170.             e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor; this.style.backgroundColor='#c8dafa';this.style.cursor='pointer';");
  171.             e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
  172.             e.Row.Attributes.Add("onclick", "window.location.href='employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + "&edit=n'");
  173.         }
  174.     }
  175. }