employee_list_work1.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_work : 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.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 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();
- }
- }
- 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();
- }
- }
- }
- 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 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();
- }
- }
- 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();
- }
- if (flag == 1)
- {
- indexs.Add(e.Row.RowIndex.ToString());
- Response.Write(e.Row.RowIndex.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'");
- }
- }
- }