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

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