副本 employee_where.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:18k
源码类别:
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;
- using System.Drawing;
- public partial class web_approvel_employee_where : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- LoginDAO.CheckLogin(Session, Response, "../", 2);
- if (Request.QueryString["e_id"] != null)
- {
- string id = Request.QueryString["e_id"];
- this.SetTable(id);
- Work_time.DataKeyNames=new string[] {"card_date"};
- GridView1.DataKeyNames = new string[] { "id" };
- }
- if (Request.QueryString["state_type"] != null && Request["type_id"] != null)
- {
- string type_id = Request.QueryString["type_id"]; ;
- int type = Convert.ToInt32(Request.QueryString["state_type"]);
- if (type == 1)
- {
- PnlForm1.Visible = true;
- this.SetForm1(type_id);
- }
- if (type == 2)
- {
- PnlForm2.Visible = true;
- this.SetForm2(type_id);
- }
- if (type == 3)
- {
- PnlForm3.Visible = true;
- this.SetForm3(type_id);
- }
- }
- }
- }
- protected void SetTable(string id)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select d.name department, e.emp_name,e.emp_no,e.email_work, p.name position, e.tel_extension, e.tel, "+
- "e.smart_phone from OA_EMPLOYEE e inner join OA_EMPLOYEE_POSITION p on p.id=e.position inner join "+
- "OA_DEPARTMENT d on e.department_id=d.id where e.id="+id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- TableRow tr = new TableRow();
- TableCell td = new TableCell();
- if (dr.Read())
- {
- td.BorderWidth = Unit.Pixel(1);
- td.Text = dr["department"].ToString();
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- td.Text = dr["emp_name"].ToString();
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- td.Text = dr["emp_no"].ToString();
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- td.Text = dr["position"].ToString();
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- td.Text = dr["tel_extension"].ToString();
- if (td.Text.Equals(""))
- {
- td.Text = " ";
- }
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- td.Text = dr["tel"].ToString();
- if (td.Text.Equals(""))
- {
- td.Text = " ";
- }
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- td.Text = dr["smart_phone"].ToString();
- if (td.Text.Equals(""))
- {
- td.Text = " ";
- }
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- td.Text = dr["email_work"].ToString();
- if (td.Text.Equals(""))
- {
- td.Text = " ";
- }
- tr.Cells.Add(td);
- //狀態
- TblWhere.Rows.Add(tr);
- }
- dr.Close();
- conn.Close();
- }
- protected void Work_time_RowCreated(object sender, GridViewRowEventArgs e)
- {
- //行高亮
- ArrayList card_status = new ArrayList();
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select card_status from oa_card_time as a left join" +
- " oa_employee as b on a.emp_card_no=b.work_card_no1 where b.id=" + Request.QueryString["e_id"] +
- " and a.card_date=" + Work_time.DataKeys[e.Row.RowIndex].Value.ToString() + " order by card_date desc ", conn);
- SqlDataReader dr = cmd.ExecuteReader();
- while(dr.Read())
- {
- Label label0 = (Label)e.Row.FindControl("LabStatus");
- card_status.Add(dr["card_status"].ToString());
- if (card_status.IndexOf("2").Equals("-1"))
- {
- label0.Text = "正常";
- }
- else
- {
- label0.Text = "異常";
- label0.ForeColor = Color.Red;
- }
- }
- dr.Close();
- }
- }
- protected void Work_time_RowDataBound1(object sender, GridViewRowEventArgs e)
- {
- //行高亮
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select card_status from oa_card_time as a left join" +
- " oa_employee as b on a.emp_card_no=b.work_card_no1 where b.id=" + Request.QueryString["e_id"] +
- " and a.id=" + GridView1.DataKeys[e.Row.RowIndex].Value.ToString() + " order by card_date desc ", conn);
- SqlDataReader dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- Label label0 = (Label)e.Row.FindControl("LabStatus");
- if (dr["card_status"].Equals("1"))
- {
- label0.Text = "正常";
- }
- else if (dr["card_status"].Equals("2"))
- {
- label0.Text = "異常";
- label0.ForeColor = Color.Red;
- }
- }
- }
- }
- protected void Work_time_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- //行高亮
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- e.Row.Attributes.Add("onmouseover", "this.style.cursor='pointer';");
- // e.Row.Attributes.Add("onclick", "top.location.href='employee_where_d.aspx?card_date=" + Work_time.DataKeys[e.Row.RowIndex].Value.ToString() +
- // "&e_id="+Request.QueryString["e_id"]+"'");
- e.Row.Attributes.Add("onclick", "window.open('employee_where_d.aspx?card_date=" + Work_time.DataKeys[e.Row.RowIndex].Value.ToString() +
- "&e_id=" + Request.QueryString["e_id"] + "','','width=300,height=300,left=300,top=300')");
- }
- }
- protected void SetForm1(string id)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select a.form_id, e.emp_name, e.emp_no, p.name position, " +
- "d.name department, e1.emp_name delegate, t.name off_type, a.parenthesis, a.days, a.vacation_begin, " +
- "a.vacation_end, vp.name vacation_place, fp1.name flight_go_depart, fp2.name flight_go_arrive, " +
- "a.flight_go_time, a.flight_back_time, fp3.name flight_back_depart, fp4.name flight_back_arrive, " +
- "a.business_begin, a.business_end, a.reason, a.apply_date from OA_TW_APPROVEL_FORM a " +
- "inner join OA_EMPLOYEE e on a.emp_id=e.id " +
- "inner join OA_EMPLOYEE e1 on a.delegate_id=e1.id " +
- "inner join OA_DEPARTMENT d on e.department_id=d.id " +
- "inner join OA_EMPLOYEE_POSITION p on e.position=p.id " +
- "inner join OA_TW_OFF_TYPE t on a.off_type=t.id " +
- "inner join OA_VACATION_PLACE vp on a.vacation_place=vp.id " +
- "inner join OA_FLIGHT_PLACE fp1 on a.flight_go_depart=fp1.id " +
- "inner join OA_FLIGHT_PLACE fp2 on a.flight_go_arrive=fp2.id " +
- "inner join OA_FLIGHT_PLACE fp3 on a.flight_back_depart=fp3.id " +
- "inner join OA_FLIGHT_PLACE fp4 on a.flight_back_arrive=fp4.id where a.id=" + id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- TxtFormNo.Text = dr["form_id"].ToString();
- TxtEmpName.Text = dr["emp_name"].ToString();
- TxtEmpNo.Text = dr["emp_no"].ToString();
- TxtPosition.Text = dr["position"].ToString();
- TxtDepartment.Text = dr["department"].ToString();
- TxtDelegate.Text = dr["delegate"].ToString();
- TxtOffType.Text = dr["off_type"].ToString();
- TxtParenthesis.Text = dr["parenthesis"].ToString();
- TxtDays.Text = dr["days"].ToString();
- TxtVacationBegin.Text = dr["vacation_begin"].ToString();
- TxtVacationEnd.Text = dr["vacation_end"].ToString();
- TxtVacationPlace.Text = dr["vacation_place"].ToString();
- TxtFlightGoDepart.Text = dr["flight_go_depart"].ToString();
- TxtFlightGoArrive.Text = dr["flight_go_arrive"].ToString();
- TxtFlightGoTime.Text = dr["flight_go_time"].ToString();
- TxtFlightBackTime.Text = dr["flight_back_time"].ToString();
- TxtFlightBackDepart.Text = dr["flight_back_depart"].ToString();
- TxtFlightBackArrive.Text = dr["flight_back_arrive"].ToString();
- TxtBusinessBegin.Text = dr["business_begin"].ToString();
- TxtBusinessEnd.Text = dr["business_end"].ToString();
- TxtReason.Text = dr["reason"].ToString();
- TxtApplyDate.Text = dr["apply_date"].ToString();
- }
- dr.Close();
- conn.Close();
- }
- protected void SetForm2(string id)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select a.form_id, e.emp_name, e.emp_no, p.name position, a.apply_date," +
- "d.name department, a.days, a.begin_time, a.end_time, f1.name depart_place, f2.name arrive_place, " +
- "a.depart_time, a.arrive_time from OA_CH_BUSINESS_FORM a inner join OA_EMPLOYEE e on a.emp_id=e.id " +
- "inner join OA_DEPARTMENT d on a.department_id=d.id inner join OA_EMPLOYEE_POSITION p on " +
- "e.position=p.id inner join OA_FLIGHT_PLACE f1 on a.depart_place=f1.id inner join " +
- "OA_FLIGHT_PLACE f2 on a.arrive_place=f2.id where a.id=" + id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- TxtBFormId.Text = dr["form_id"].ToString();
- TxtBEmpName.Text = dr["emp_name"].ToString();
- TxtBEmpNo.Text = dr["emp_no"].ToString();
- TxtBPosition.Text = dr["position"].ToString();
- TxtBApplyDate.Text = dr["apply_date"].ToString();
- TxtBDepartment.Text = dr["department"].ToString();
- TxtBDays.Text = dr["days"].ToString();
- TxtBBeginTime.Text = dr["begin_time"].ToString();
- TxtBEndTime.Text = dr["end_time"].ToString();
- TxtBDepartPlace.Text = dr["depart_place"].ToString();
- TxtBArrivePlace.Text = dr["arrive_place"].ToString();
- TxtBDepartTime.Text = dr["depart_time"].ToString();
- TxtBArriveTime.Text = dr["arrive_time"].ToString();
- }
- dr.Close();
- int flag = 0;
- //動態創建表格行
- #region
- cmd = new SqlCommand("select number, company, subject, linkman, tel, place, visa_begin, visa_end, " +
- "flight_go_begin, flight_back_end, is_aboard, remark from OA_CH_BUSINESS_DETAIL where form_id=" + id +
- " order by number", conn);
- dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- flag = 1;
- TableRow tr1 = new TableRow();
- TableCell td1 = new TableCell();
- td1.BorderWidth = Unit.Pixel(1);
- Label label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = dr["number"].ToString();
- td1.Controls.Add(label);
- tr1.Cells.Add(td1);
- TableCell td2 = new TableCell();
- td2.BorderWidth = Unit.Pixel(1);
- label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = dr["company"].ToString();
- td2.Controls.Add(label);
- tr1.Cells.Add(td2);
- TableCell td3 = new TableCell();
- td3.BorderWidth = Unit.Pixel(1);
- label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = dr["subject"].ToString();
- td3.Controls.Add(label);
- tr1.Cells.Add(td3);
- TableCell td4 = new TableCell();
- td4.BorderWidth = Unit.Pixel(1);
- label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = dr["linkman"].ToString();
- td4.Controls.Add(label);
- tr1.Cells.Add(td4);
- TableCell td5 = new TableCell();
- td5.BorderWidth = Unit.Pixel(1);
- label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = dr["tel"].ToString();
- td5.Controls.Add(label);
- tr1.Cells.Add(td5);
- TableCell td6 = new TableCell();
- td6.BorderWidth = Unit.Pixel(1);
- label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = dr["place"].ToString();
- td6.Controls.Add(label);
- tr1.Cells.Add(td6);
- TableCell td7 = new TableCell();
- td7.BorderWidth = Unit.Pixel(1);
- label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = dr["visa_begin"].ToString();
- td7.Controls.Add(label);
- tr1.Cells.Add(td7);
- TableCell td8 = new TableCell();
- td8.BorderWidth = Unit.Pixel(1);
- label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = dr["visa_end"].ToString();
- td8.Controls.Add(label);
- tr1.Cells.Add(td8);
- TableCell td9 = new TableCell();
- td9.BorderWidth = Unit.Pixel(1);
- label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = dr["flight_go_begin"].ToString();
- td9.Controls.Add(label);
- tr1.Cells.Add(td9);
- TableCell td10 = new TableCell();
- td10.BorderWidth = Unit.Pixel(1);
- label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = dr["flight_back_end"].ToString();
- td10.Controls.Add(label);
- tr1.Cells.Add(td10);
- TableCell td11 = new TableCell();
- td11.BorderWidth = Unit.Pixel(1);
- CheckBox chk = new CheckBox();
- chk.Text = "國外";
- chk.Enabled = false;
- if (dr["is_aboard"].ToString().Equals("Y"))
- {
- chk.Checked = true;
- }
- else
- {
- chk.Checked = false;
- }
- td11.Controls.Add(chk);
- tr1.Cells.Add(td11);
- TableCell td12 = new TableCell();
- td12.BorderWidth = Unit.Pixel(1);
- label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = dr["remark"].ToString();
- td12.Controls.Add(label);
- tr1.Cells.Add(td12);
- TblDetail.Rows.Add(tr1);
- }
- dr.Close();
- conn.Close();
- if (flag == 0)
- {
- TblDetail.Visible = false;
- }
- #endregion
- }
- protected void SetForm3(string id)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select o.form_id, e.emp_no, e.emp_name, d.name department, " +
- "e.emp_name delegate, e.position position, " +
- "t.name off_type, o.begin_time, o.end_time, o.hours, o.apply_date, o.parenthesis, " +
- "o.reason from OA_CH_OFF_FORM o inner join OA_EMPLOYEE e on o.emp_id=e.id inner join " +
- "OA_DEPARTMENT d on o.department_id=d.id inner join OA_CH_OFF_TYPE t on " +
- "o.off_type=t.id where o.id=" + id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- TxtOFormId.Text = dr["form_id"].ToString();
- TxtOEmpName.Text = dr["emp_no"].ToString() + dr["emp_name"].ToString();
- TxtODepartment.Text = dr["department"].ToString();
- TxtODelegate.Text = dr["delegate"].ToString();
- TxtOPosition.Text = dr["position"].ToString();
- TxtOOffType.Text = dr["off_type"].ToString();
- TxtOBeginTime.Text = dr["begin_time"].ToString();
- TxtOEndTime.Text = dr["end_time"].ToString();
- TxtOHours.Text = dr["hours"].ToString();
- TxtOApplyDate.Text = dr["apply_date"].ToString();
- TxtOParenthesis.Text = dr["parenthesis"].ToString();
- TxtOReason.Text = dr["reason"].ToString();
- }
- dr.Close();
- conn.Close();
- }
- protected void BtnHistory_Click(object sender, EventArgs e)
- {
- if (Request.QueryString["e_id"] != null)
- {
- Response.Redirect("../personnel/curricula_vitae/employee_where.aspx?e_id="+Request.QueryString["e_id"]);
- }
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- Work_time.Visible = true;
- GridView1.Visible = false;
- }
- protected void Button2_Click(object sender, EventArgs e)
- {
- Work_time.Visible = false;
- GridView1.Visible = true;
- }
- }