副本 employee_where.aspx.cs
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:18k
源码类别:

OA系统

开发平台:

ASP/ASPX

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using System.Data.SqlClient;
  12. using System.Drawing;
  13. public partial class web_approvel_employee_where : System.Web.UI.Page
  14. {
  15.     protected void Page_Load(object sender, EventArgs e)
  16.     {
  17.         if (!IsPostBack)
  18.         {
  19.             LoginDAO.CheckLogin(Session, Response, "../", 2);
  20.             if (Request.QueryString["e_id"] != null)
  21.             {              
  22.                 string id = Request.QueryString["e_id"];
  23.                 this.SetTable(id);
  24.                 Work_time.DataKeyNames=new string[] {"card_date"};
  25.                 GridView1.DataKeyNames = new string[] { "id" };
  26.             } 
  27.             if (Request.QueryString["state_type"] != null && Request["type_id"] != null)
  28.             {
  29.                 string type_id = Request.QueryString["type_id"]; ;
  30.                 int type = Convert.ToInt32(Request.QueryString["state_type"]);
  31.                 if (type == 1)
  32.                 {
  33.                     PnlForm1.Visible = true;
  34.                     this.SetForm1(type_id);
  35.                 }
  36.                 if (type == 2)
  37.                 {
  38.                     PnlForm2.Visible = true;
  39.                     this.SetForm2(type_id);
  40.                 }
  41.                 if (type == 3)
  42.                 {
  43.                     PnlForm3.Visible = true;
  44.                     this.SetForm3(type_id);
  45.                 }
  46.             }
  47.         }
  48.     }
  49.     protected void SetTable(string id)
  50.     {
  51.         SqlConnection conn = dbConnection.getConnection();
  52.         conn.Open();
  53.         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, "+
  54.             "e.smart_phone from OA_EMPLOYEE e inner join OA_EMPLOYEE_POSITION p on p.id=e.position inner join "+
  55.             "OA_DEPARTMENT d on e.department_id=d.id where e.id="+id, conn);
  56.         SqlDataReader dr = cmd.ExecuteReader();
  57.         TableRow tr = new TableRow();
  58.         TableCell td = new TableCell();
  59.         if (dr.Read())
  60.         {
  61.             
  62.             td.BorderWidth = Unit.Pixel(1);
  63.             td.Text = dr["department"].ToString();
  64.             tr.Cells.Add(td);
  65.             td = new TableCell();
  66.             td.BorderWidth = Unit.Pixel(1);
  67.             td.Text = dr["emp_name"].ToString();
  68.             tr.Cells.Add(td);
  69.             td = new TableCell();
  70.             td.BorderWidth = Unit.Pixel(1);
  71.             td.Text = dr["emp_no"].ToString();
  72.             tr.Cells.Add(td);
  73.             td = new TableCell();
  74.             td.BorderWidth = Unit.Pixel(1);
  75.             td.Text = dr["position"].ToString();
  76.             tr.Cells.Add(td);
  77.             td = new TableCell();
  78.             td.BorderWidth = Unit.Pixel(1);
  79.             td.Text = dr["tel_extension"].ToString();
  80.             if (td.Text.Equals(""))
  81.             {
  82.                 td.Text = " ";
  83.             }
  84.             tr.Cells.Add(td);
  85.             td = new TableCell();
  86.             td.BorderWidth = Unit.Pixel(1);
  87.             td.Text = dr["tel"].ToString();
  88.             if (td.Text.Equals(""))
  89.             {
  90.                 td.Text = " ";
  91.             }
  92.             tr.Cells.Add(td);           
  93.             td = new TableCell();
  94.             td.BorderWidth = Unit.Pixel(1);
  95.             td.Text = dr["smart_phone"].ToString();
  96.             if (td.Text.Equals(""))
  97.             {
  98.                 td.Text = " ";
  99.             }
  100.             tr.Cells.Add(td);
  101.             td = new TableCell();
  102.             td.BorderWidth = Unit.Pixel(1);
  103.             td.Text = dr["email_work"].ToString();
  104.             if (td.Text.Equals(""))
  105.             {
  106.                 td.Text = " ";
  107.             }
  108.             tr.Cells.Add(td);
  109.                 
  110.             //狀態
  111.             
  112.             TblWhere.Rows.Add(tr);
  113.         }
  114.         dr.Close();
  115.        
  116.         conn.Close();
  117.     }
  118.     protected void Work_time_RowCreated(object sender, GridViewRowEventArgs e)
  119.     {
  120.         //行高亮
  121.         ArrayList card_status = new ArrayList();
  122.        
  123.         if (e.Row.RowType == DataControlRowType.DataRow)
  124.         {
  125.             SqlConnection conn = dbConnection.getConnection();
  126.             conn.Open();
  127.             SqlCommand cmd = new SqlCommand("select card_status from oa_card_time as a left join" +
  128.                 " oa_employee as b on a.emp_card_no=b.work_card_no1 where b.id=" + Request.QueryString["e_id"] +
  129.                 " and a.card_date=" + Work_time.DataKeys[e.Row.RowIndex].Value.ToString() + " order by card_date desc ", conn);
  130.             SqlDataReader dr = cmd.ExecuteReader();
  131.             while(dr.Read())
  132.             {
  133.                 Label label0 = (Label)e.Row.FindControl("LabStatus");
  134.                 card_status.Add(dr["card_status"].ToString());
  135.                 if (card_status.IndexOf("2").Equals("-1"))
  136.                 {
  137.                     label0.Text = "正常";
  138.                 }
  139.                 else
  140.                 {
  141.                     label0.Text = "異常";
  142.                     label0.ForeColor = Color.Red;
  143.                     
  144.                 } 
  145.                
  146.             }
  147.             
  148.             dr.Close();
  149.           
  150.           
  151.         }
  152.     }
  153.     protected void Work_time_RowDataBound1(object sender, GridViewRowEventArgs e)
  154.     {
  155.         //行高亮
  156.         if (e.Row.RowType == DataControlRowType.DataRow)
  157.         {
  158.             SqlConnection conn = dbConnection.getConnection();
  159.             conn.Open();
  160.             SqlCommand cmd = new SqlCommand("select card_status from oa_card_time as a left join" +
  161.                 " oa_employee as b on a.emp_card_no=b.work_card_no1 where b.id=" + Request.QueryString["e_id"] +
  162.                 " and a.id=" + GridView1.DataKeys[e.Row.RowIndex].Value.ToString() + " order by card_date desc ", conn);
  163.             SqlDataReader dr = cmd.ExecuteReader();
  164.             while (dr.Read())
  165.             {
  166.                 Label label0 = (Label)e.Row.FindControl("LabStatus");
  167.                 if (dr["card_status"].Equals("1"))
  168.                 {
  169.                     label0.Text = "正常";
  170.                 }
  171.                 else if (dr["card_status"].Equals("2"))
  172.                 {
  173.                     label0.Text = "異常";
  174.                     label0.ForeColor = Color.Red;
  175.                 }
  176.             }
  177.         
  178.         }
  179.     }
  180.     protected void Work_time_RowDataBound(object sender, GridViewRowEventArgs e)
  181.     {
  182.         //行高亮
  183.         if (e.Row.RowType == DataControlRowType.DataRow)
  184.         {
  185.             e.Row.Attributes.Add("onmouseover", "this.style.cursor='pointer';");
  186.           //  e.Row.Attributes.Add("onclick", "top.location.href='employee_where_d.aspx?card_date=" + Work_time.DataKeys[e.Row.RowIndex].Value.ToString() + 
  187.           //     "&e_id="+Request.QueryString["e_id"]+"'");
  188.             e.Row.Attributes.Add("onclick", "window.open('employee_where_d.aspx?card_date=" + Work_time.DataKeys[e.Row.RowIndex].Value.ToString() +
  189.                "&e_id=" + Request.QueryString["e_id"] + "','','width=300,height=300,left=300,top=300')");
  190.         }
  191.     }
  192.     
  193.     protected void SetForm1(string id)
  194.     {
  195.         SqlConnection conn = dbConnection.getConnection();
  196.         conn.Open();
  197.         SqlCommand cmd = new SqlCommand("select a.form_id, e.emp_name, e.emp_no, p.name position, " +
  198.             "d.name department, e1.emp_name delegate, t.name off_type, a.parenthesis, a.days, a.vacation_begin, " +
  199.             "a.vacation_end, vp.name vacation_place, fp1.name flight_go_depart, fp2.name flight_go_arrive, " +
  200.             "a.flight_go_time, a.flight_back_time, fp3.name flight_back_depart, fp4.name flight_back_arrive, " +
  201.             "a.business_begin, a.business_end, a.reason, a.apply_date from OA_TW_APPROVEL_FORM a " +
  202.             "inner join OA_EMPLOYEE e on a.emp_id=e.id " +
  203.             "inner join OA_EMPLOYEE e1 on a.delegate_id=e1.id " +
  204.             "inner join OA_DEPARTMENT d on e.department_id=d.id " +
  205.             "inner join OA_EMPLOYEE_POSITION p on e.position=p.id " +
  206.             "inner join OA_TW_OFF_TYPE t on a.off_type=t.id " +
  207.             "inner join OA_VACATION_PLACE vp on a.vacation_place=vp.id " +
  208.             "inner join OA_FLIGHT_PLACE fp1 on a.flight_go_depart=fp1.id " +
  209.             "inner join OA_FLIGHT_PLACE fp2 on a.flight_go_arrive=fp2.id " +
  210.             "inner join OA_FLIGHT_PLACE fp3 on a.flight_back_depart=fp3.id " +
  211.             "inner join OA_FLIGHT_PLACE fp4 on a.flight_back_arrive=fp4.id where a.id=" + id, conn);
  212.         SqlDataReader dr = cmd.ExecuteReader();
  213.         if (dr.Read())
  214.         {
  215.             TxtFormNo.Text = dr["form_id"].ToString();
  216.             TxtEmpName.Text = dr["emp_name"].ToString();
  217.             TxtEmpNo.Text = dr["emp_no"].ToString();
  218.             TxtPosition.Text = dr["position"].ToString();
  219.             TxtDepartment.Text = dr["department"].ToString();
  220.             TxtDelegate.Text = dr["delegate"].ToString();
  221.             TxtOffType.Text = dr["off_type"].ToString();
  222.             TxtParenthesis.Text = dr["parenthesis"].ToString();
  223.             TxtDays.Text = dr["days"].ToString();
  224.             TxtVacationBegin.Text = dr["vacation_begin"].ToString();
  225.             TxtVacationEnd.Text = dr["vacation_end"].ToString();
  226.             TxtVacationPlace.Text = dr["vacation_place"].ToString();
  227.             TxtFlightGoDepart.Text = dr["flight_go_depart"].ToString();
  228.             TxtFlightGoArrive.Text = dr["flight_go_arrive"].ToString();
  229.             TxtFlightGoTime.Text = dr["flight_go_time"].ToString();
  230.             TxtFlightBackTime.Text = dr["flight_back_time"].ToString();
  231.             TxtFlightBackDepart.Text = dr["flight_back_depart"].ToString();
  232.             TxtFlightBackArrive.Text = dr["flight_back_arrive"].ToString();
  233.             TxtBusinessBegin.Text = dr["business_begin"].ToString();
  234.             TxtBusinessEnd.Text = dr["business_end"].ToString();
  235.             TxtReason.Text = dr["reason"].ToString();
  236.             TxtApplyDate.Text = dr["apply_date"].ToString();
  237.         }
  238.         dr.Close();
  239.         conn.Close();
  240.     }
  241.     protected void SetForm2(string id)
  242.     {
  243.         SqlConnection conn = dbConnection.getConnection();
  244.         conn.Open();
  245.         SqlCommand cmd = new SqlCommand("select a.form_id, e.emp_name, e.emp_no, p.name position, a.apply_date," +
  246.             "d.name department, a.days, a.begin_time, a.end_time, f1.name depart_place, f2.name arrive_place, " +
  247.             "a.depart_time, a.arrive_time from OA_CH_BUSINESS_FORM a inner join OA_EMPLOYEE e on a.emp_id=e.id " +
  248.             "inner join OA_DEPARTMENT d on a.department_id=d.id inner join OA_EMPLOYEE_POSITION p on " +
  249.             "e.position=p.id inner join OA_FLIGHT_PLACE f1 on a.depart_place=f1.id inner join " +
  250.             "OA_FLIGHT_PLACE f2 on a.arrive_place=f2.id where a.id=" + id, conn);
  251.         SqlDataReader dr = cmd.ExecuteReader();
  252.         if (dr.Read())
  253.         {
  254.             TxtBFormId.Text = dr["form_id"].ToString();
  255.             TxtBEmpName.Text = dr["emp_name"].ToString();
  256.             TxtBEmpNo.Text = dr["emp_no"].ToString();
  257.             TxtBPosition.Text = dr["position"].ToString();
  258.             TxtBApplyDate.Text = dr["apply_date"].ToString();
  259.             TxtBDepartment.Text = dr["department"].ToString();
  260.             TxtBDays.Text = dr["days"].ToString();
  261.             TxtBBeginTime.Text = dr["begin_time"].ToString();
  262.             TxtBEndTime.Text = dr["end_time"].ToString();
  263.             TxtBDepartPlace.Text = dr["depart_place"].ToString();
  264.             TxtBArrivePlace.Text = dr["arrive_place"].ToString();
  265.             TxtBDepartTime.Text = dr["depart_time"].ToString();
  266.             TxtBArriveTime.Text = dr["arrive_time"].ToString();
  267.         }
  268.         dr.Close();
  269.         int flag = 0;
  270.         //動態創建表格行
  271.         #region
  272.         cmd = new SqlCommand("select number, company, subject, linkman, tel, place, visa_begin, visa_end, " +
  273.             "flight_go_begin, flight_back_end, is_aboard, remark from OA_CH_BUSINESS_DETAIL where form_id=" + id +
  274.             " order by number", conn);
  275.         dr = cmd.ExecuteReader();
  276.         while (dr.Read())
  277.         {
  278.             flag = 1;
  279.             TableRow tr1 = new TableRow();
  280.             TableCell td1 = new TableCell();
  281.             td1.BorderWidth = Unit.Pixel(1);
  282.             Label label = new Label();
  283.             label.BorderStyle = BorderStyle.None;
  284.             label.Text = dr["number"].ToString();
  285.             td1.Controls.Add(label);
  286.             tr1.Cells.Add(td1);
  287.             TableCell td2 = new TableCell();
  288.             td2.BorderWidth = Unit.Pixel(1);
  289.             label = new Label();
  290.             label.BorderStyle = BorderStyle.None;
  291.             label.Text = dr["company"].ToString();
  292.             td2.Controls.Add(label);
  293.             tr1.Cells.Add(td2);
  294.             TableCell td3 = new TableCell();
  295.             td3.BorderWidth = Unit.Pixel(1);
  296.             label = new Label();
  297.             label.BorderStyle = BorderStyle.None;
  298.             label.Text = dr["subject"].ToString();
  299.             td3.Controls.Add(label);
  300.             tr1.Cells.Add(td3);
  301.             TableCell td4 = new TableCell();
  302.             td4.BorderWidth = Unit.Pixel(1);
  303.             label = new Label();
  304.             label.BorderStyle = BorderStyle.None;
  305.             label.Text = dr["linkman"].ToString();
  306.             td4.Controls.Add(label);
  307.             tr1.Cells.Add(td4);
  308.             TableCell td5 = new TableCell();
  309.             td5.BorderWidth = Unit.Pixel(1);
  310.             label = new Label();
  311.             label.BorderStyle = BorderStyle.None;
  312.             label.Text = dr["tel"].ToString();
  313.             td5.Controls.Add(label);
  314.             tr1.Cells.Add(td5);
  315.             TableCell td6 = new TableCell();
  316.             td6.BorderWidth = Unit.Pixel(1);
  317.             label = new Label();
  318.             label.BorderStyle = BorderStyle.None;
  319.             label.Text = dr["place"].ToString();
  320.             td6.Controls.Add(label);
  321.             tr1.Cells.Add(td6);
  322.             TableCell td7 = new TableCell();
  323.             td7.BorderWidth = Unit.Pixel(1);
  324.             label = new Label();
  325.             label.BorderStyle = BorderStyle.None;
  326.             label.Text = dr["visa_begin"].ToString();
  327.             td7.Controls.Add(label);
  328.             tr1.Cells.Add(td7);
  329.             TableCell td8 = new TableCell();
  330.             td8.BorderWidth = Unit.Pixel(1);
  331.             label = new Label();
  332.             label.BorderStyle = BorderStyle.None;
  333.             label.Text = dr["visa_end"].ToString();
  334.             td8.Controls.Add(label);
  335.             tr1.Cells.Add(td8);
  336.             TableCell td9 = new TableCell();
  337.             td9.BorderWidth = Unit.Pixel(1);
  338.             label = new Label();
  339.             label.BorderStyle = BorderStyle.None;
  340.             label.Text = dr["flight_go_begin"].ToString();
  341.             td9.Controls.Add(label);
  342.             tr1.Cells.Add(td9);
  343.             TableCell td10 = new TableCell();
  344.             td10.BorderWidth = Unit.Pixel(1);
  345.             label = new Label();
  346.             label.BorderStyle = BorderStyle.None;
  347.             label.Text = dr["flight_back_end"].ToString();
  348.             td10.Controls.Add(label);
  349.             tr1.Cells.Add(td10);
  350.             TableCell td11 = new TableCell();
  351.             td11.BorderWidth = Unit.Pixel(1);
  352.             CheckBox chk = new CheckBox();
  353.             chk.Text = "國外";
  354.             chk.Enabled = false;
  355.             if (dr["is_aboard"].ToString().Equals("Y"))
  356.             {
  357.                 chk.Checked = true;
  358.             }
  359.             else
  360.             {
  361.                 chk.Checked = false;
  362.             }
  363.             td11.Controls.Add(chk);
  364.             tr1.Cells.Add(td11);
  365.             TableCell td12 = new TableCell();
  366.             td12.BorderWidth = Unit.Pixel(1);
  367.             label = new Label();
  368.             label.BorderStyle = BorderStyle.None;
  369.             label.Text = dr["remark"].ToString();
  370.             td12.Controls.Add(label);
  371.             tr1.Cells.Add(td12);
  372.             TblDetail.Rows.Add(tr1);
  373.         }
  374.         dr.Close();
  375.         conn.Close();
  376.         if (flag == 0)
  377.         {
  378.             TblDetail.Visible = false;
  379.         }
  380.         #endregion
  381.     }
  382.     protected void SetForm3(string id)
  383.     {
  384.         SqlConnection conn = dbConnection.getConnection();
  385.         conn.Open();
  386.         SqlCommand cmd = new SqlCommand("select o.form_id, e.emp_no, e.emp_name, d.name department, " +
  387.             "e.emp_name delegate, e.position position, " +
  388.             "t.name off_type, o.begin_time, o.end_time, o.hours, o.apply_date, o.parenthesis, " +
  389.             "o.reason from OA_CH_OFF_FORM o inner join OA_EMPLOYEE e on o.emp_id=e.id inner join " +
  390.             "OA_DEPARTMENT d on o.department_id=d.id inner join OA_CH_OFF_TYPE t on " +
  391.             "o.off_type=t.id where o.id=" + id, conn);
  392.         SqlDataReader dr = cmd.ExecuteReader();
  393.         if (dr.Read())
  394.         {
  395.             TxtOFormId.Text = dr["form_id"].ToString();
  396.             TxtOEmpName.Text = dr["emp_no"].ToString() + dr["emp_name"].ToString();
  397.             TxtODepartment.Text = dr["department"].ToString();
  398.             TxtODelegate.Text = dr["delegate"].ToString();
  399.             TxtOPosition.Text = dr["position"].ToString();
  400.             TxtOOffType.Text = dr["off_type"].ToString();
  401.             TxtOBeginTime.Text = dr["begin_time"].ToString();
  402.             TxtOEndTime.Text = dr["end_time"].ToString();
  403.             TxtOHours.Text = dr["hours"].ToString();
  404.             TxtOApplyDate.Text = dr["apply_date"].ToString();
  405.             TxtOParenthesis.Text = dr["parenthesis"].ToString();
  406.             TxtOReason.Text = dr["reason"].ToString();
  407.         }
  408.         dr.Close();
  409.         conn.Close();
  410.     }
  411.     protected void BtnHistory_Click(object sender, EventArgs e)
  412.     {
  413.         if (Request.QueryString["e_id"] != null)
  414.         {
  415.             Response.Redirect("../personnel/curricula_vitae/employee_where.aspx?e_id="+Request.QueryString["e_id"]);
  416.         } 
  417.     }
  418.     protected void Button1_Click(object sender, EventArgs e)
  419.     {
  420.         Work_time.Visible = true;
  421.         GridView1.Visible = false;
  422.     }
  423.     protected void Button2_Click(object sender, EventArgs e)
  424.     {
  425.         Work_time.Visible = false;
  426.         GridView1.Visible = true;
  427.     }
  428. }