employee_list.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:9k
源码类别:
OA系统
开发平台:
ASP/ASPX
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using System.Data.SqlClient;
- public partial class web_approvel_employee_list : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- LoginDAO.CheckLogin(Session, Response, "../", 2);
- EmployeeList.DataKeyNames = new string[] { "id" };
- if (Request.QueryString["department_id"] != null)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select name from OA_DEPARTMENT where id=" + Request.QueryString["department_id"], conn);
- try
- {
- LblTitle.Text = cmd.ExecuteScalar().ToString();
- LblTitle.Text = LblTitle.Text + "在職員工列表";
- LblTitle.Visible = false;
- }
- catch { }
- conn.Close();
- }
- }
- }
- protected void EmployeeList_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- //行高亮
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- LblTitle.Visible = true;
- e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor; this.style.backgroundColor='#c8dafa';this.style.cursor='pointer';");
- e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
- e.Row.Attributes.Add("onclick", "window.location.href='employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + "&edit=n'");
- }
- }
- protected void EmployeeList_RowCreated(object sender, GridViewRowEventArgs e)
- {
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- if (Request.QueryString["type"] == null)
- {
- DateMgr mgr = new DateMgr();
- string time = mgr.getDateTime();
- LinkButton btn = (LinkButton)e.Row.FindControl("LbWhere");
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select f.id, f.vacation_begin, f.vacation_end, f.business_begin, f.business_end," +
- " 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=" +
- EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + " and total_result='同意'", conn);
- SqlDataReader dr = cmd.ExecuteReader();
- int flag = 0;
- while (dr.Read())
- {
- if (dr["type"].ToString().Equals("出差"))
- {
- if (dr["business_begin"].ToString().CompareTo(time) == -1 && dr["business_end"].ToString().CompareTo(time) == 1)
- {
- flag = 1;
- btn.Text = "出差";
- // btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
- // Session["state_type"] = "1";
- // Session["type_id"] = dr["id"].ToString();
- 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();
- }
- }
- else
- {
- if (dr["vacation_begin"].ToString().CompareTo(time) == -1 && dr["vacation_end"].ToString().CompareTo(time) == 1)
- {
- flag = 1;
- btn.Text = dr["type"].ToString();
- // btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
- //Session["state_type"] = "1";
- // Session["type_id"] = dr["id"].ToString();
- 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();
- }
- }
- }
- dr.Close();
- if (flag == 0)
- {
- ArrayList form_id = new ArrayList();
- ArrayList step1 = new ArrayList();
- ArrayList is_agree = new ArrayList();
- cmd = new SqlCommand("select a.id as 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 " +
- " where emp_id=" +
- EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
- dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- if (dr["begin_time"].ToString().CompareTo(time) == -1 && dr["end_time"].ToString().CompareTo(time) == 1)
- {
- form_id.Add(dr["id"].ToString());
- step1.Add(Convert.ToInt32(dr["step1"]));
- is_agree.Add(dr["is_agree"].ToString());
- }
- }
- dr.Close();
- if (form_id.Count > 0)
- {
- for (int j = 0; j < form_id.Count; j++)
- {
- SqlCommand cmd1 = new SqlCommand("select max(step) as step2 from oa_ch_approvel_form_flow1 where form_id=" + form_id[j], conn);
- int step2 = Convert.ToInt32(cmd1.ExecuteScalar());
- if (step2 == Convert.ToInt32(step1[j]))
- {
- if (is_agree[j].ToString().Equals("Y"))
- {
- flag = 1;
- btn.Text = "出差";
- //btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
- //Session["state_type"] = "1";
- // Session["type_id"] = dr["id"].ToString();
- // Session["state"] = btn.Text;
- 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();
- }
- }
- }
- }
- if (flag == 0)
- {
- cmd = new SqlCommand("select f.id, f.begin_time, f.end_time, t.name type ,t.sequence from OA_CH_OFF_FORM f " +
- "inner join OA_CH_OFF_TYPE t on f.off_type=t.id where total_result='同意' and emp_id=" +
- EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
- dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- if (dr["begin_time"].ToString().CompareTo(time) == -1 && dr["end_time"].ToString().CompareTo(time) == 1)
- {
- flag = 1;
- btn.Text = dr["type"].ToString();
- // Session["state_type"] = "3";
- // Session["type_id"] = dr["id"].ToString();
- 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();
- }
- }
- dr.Close();
- }
- if (flag == 0)
- {
- btn.Text = "上班";
- // Session["state_type"] = "4";
- // Session["type_id"] = "0";
- btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
- }
- conn.Close();
- Session["state"] = btn.Text;
- }
- }
- }
- }
- }