employee_list_approvel.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:8k
源码类别:
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_approvel : System.Web.UI.Page
- {
- ArrayList indexs = new ArrayList();
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- LoginDAO.CheckLogin(Session, Response, "../", 2);
- EmployeeList.DataKeyNames = new string[] { "id" };
- EmployeeList.DataBind();
- for (int i = 0; i < indexs.Count; i++)
- {
- EmployeeList.Rows[Convert.ToInt32(indexs[i])].Visible = false;
- }
- }
- }
- 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;
- }
- 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 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();
- 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();
- // Session["state_type"] = "1";
- // Session["type_id"] = dr["id"].ToString();
- // Session["state"] = btn.Text;
- }
- }
- else
- {
- if (dr["vacation_begin"].ToString().CompareTo(time) == -1 && dr["vacation_begin"].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["state"] = btn.Text;
- // 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"] = "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=" + 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)
- {
- //try
- //{
- flag = 1;
- btn.Text = dr["type"].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();
- 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();
- // }
- // catch { }
- }
- }
- dr.Close();
- }
- if (flag == 0)
- {
- /* Session["state_type"] = "4";
- Session["type_id"] = "0";
- btn.Text = "hello";*/
- indexs.Add(e.Row.RowIndex.ToString());
- }
- conn.Close();
- }
- }
- }
- 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'");
- }
- }
- }