employee_list_search1.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_search : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- EmployeeList.DataKeyNames = new string[] { "id" };
- }
- }
- protected void BtnOk_Click(object sender, EventArgs e)
- {
- if (RbType.SelectedValue.Equals("emp_no"))
- {
- SqlDataSource1.SelectCommand = "SELECT e.id, e.emp_no, e.emp_name, p.name AS position, e.tel, e.smart_phone, " +
- "e.tel_extension FROM dbo.OA_EMPLOYEE AS e INNER JOIN dbo.OA_EMPLOYEE_POSITION AS p ON e.position = p.id " +
- "WHERE e.emp_no like '%" + TxtValue.Text.Trim() + "%' and"+
- "p.sequence>=(select sequence from oa_employee_position as a inner join oa_employee as b on a.id=b.position where b.id=@user_id)"+
- "ORDER BY e.emp_no";
- }
- if (RbType.SelectedValue.Equals("emp_name"))
- {
- SqlDataSource1.SelectCommand = "SELECT e.id, e.emp_no, e.emp_name, p.name AS position, e.tel, e.smart_phone, " +
- "e.tel_extension FROM dbo.OA_EMPLOYEE AS e INNER JOIN dbo.OA_EMPLOYEE_POSITION AS p ON e.position = p.id " +
- "WHERE e.emp_name like '%" + TxtValue.Text.Trim() + "%'and"+
- "p.sequence>=(select sequence from oa_employee_position as a inner join oa_employee as b on a.id=b.position where b.id=@user_id)"+
- "ORDER BY e.emp_no";
- }
- EmployeeList.Visible = true;
- EmployeeList.DataBind();
- }
- 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");
- Label label = (Label)e.Row.FindControl("LblDepartment");
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select department_id from OA_EMPLOYEE where id=" +
- EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
- int department_id = Convert.ToInt32(cmd.ExecuteScalar());
- DepartmentDAO departmentDAO = new DepartmentDAO();
- int d_length = departmentDAO.queryById(department_id).Name.Length;
- if (d_length >= 5)
- {
- label.Text = departmentDAO.queryById(department_id).Name.Substring(0, 5);
- }
- else
- {
- label.Text = departmentDAO.queryById(department_id).Name;
- }
- 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 f.emp_id=" +
- EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString() + " and f.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)
- {
- cmd = new SqlCommand("select id, begin_time, end_time from OA_CH_BUSINESS_FORM " +
- " 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 = "出差";
- // btn.PostBackUrl = "employee_where.aspx?e_id=" + EmployeeList.DataKeys[e.Row.RowIndex].Value.ToString();
- // Session["state_type"] = "2";
- // Session["type_id"] = dr["id"].ToString();
- 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();
- }
- }
- dr.Close();
- }
- 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;
- }
- }
- }
- protected void EmployeeList_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- //行高亮
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- 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'");
- }
- }
- }