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

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_fair_form_show : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.         if (!IsPostBack)
  17.         {
  18.             if (Request.QueryString["table"] != null && Request.QueryString["id"] != null)
  19.             {
  20.                 string table = Request.QueryString["table"];
  21.                 string id = Request.QueryString["id"];
  22.                 if (table.Equals("OA_TW_APPROVEL_FORM"))
  23.                 {
  24.                     PnlTwForm.Visible = true;
  25.                     this.SetTwData(id);
  26.                 }
  27.                 else if (table.Equals("OA_CH_BUSINESS_FORM"))
  28.                 {
  29.                     PnlChBusiness.Visible = true;
  30.                     this.SetBusinessData(id);
  31.                 }
  32.                 else if (table.Equals("OA_CH_OFF_FORM"))
  33.                 {
  34.                     PnlChOff.Visible = true;
  35.                     this.SetOffData(id);
  36.                 }
  37.             }
  38.         }
  39.     }
  40.     protected void SetTwData(string id)
  41.     {
  42.         SqlConnection conn = dbConnection.getConnection();
  43.         conn.Open();
  44.         SqlCommand cmd = new SqlCommand("select a.form_id, e.emp_name, e.emp_no, p.name position, " +
  45.             "d.name department, e1.emp_name delegate, t.name off_type, a.parenthesis, a.days, a.vacation_begin, " +
  46.             "a.vacation_end, vp.name vacation_place, fp1.name flight_go_depart, fp2.name flight_go_arrive, " +
  47.             "a.flight_go_time, a.flight_back_time, fp3.name flight_back_depart, fp4.name flight_back_arrive, " +
  48.             "a.business_begin, a.business_end, a.reason, a.apply_date from OA_TW_APPROVEL_FORM a " +
  49.             "inner join OA_EMPLOYEE e on a.emp_id=e.id " +
  50.             "inner join OA_EMPLOYEE e1 on a.delegate_id=e1.id " +
  51.             "inner join OA_DEPARTMENT d on e.department_id=d.id " +
  52.             "inner join OA_EMPLOYEE_POSITION p on e.position=p.id " +
  53.             "inner join OA_TW_OFF_TYPE t on a.off_type=t.id " +
  54.             "inner join OA_VACATION_PLACE vp on a.vacation_place=vp.id " +
  55.             "inner join OA_FLIGHT_PLACE fp1 on a.flight_go_depart=fp1.id " +
  56.             "inner join OA_FLIGHT_PLACE fp2 on a.flight_go_arrive=fp2.id " +
  57.             "inner join OA_FLIGHT_PLACE fp3 on a.flight_back_depart=fp3.id " +
  58.             "inner join OA_FLIGHT_PLACE fp4 on a.flight_back_arrive=fp4.id where a.id=" + id, conn);
  59.         SqlDataReader dr = cmd.ExecuteReader();
  60.         if (dr.Read())
  61.         {
  62.             TxtFormNo.Text = dr["form_id"].ToString();
  63.             TxtEmpName.Text = dr["emp_name"].ToString();
  64.             TxtEmpNo.Text = dr["emp_no"].ToString();
  65.             TxtPosition.Text = dr["position"].ToString();
  66.             TxtDepartment.Text = dr["department"].ToString();
  67.             TxtDelegate.Text = dr["delegate"].ToString();
  68.             TxtOffType.Text = dr["off_type"].ToString();
  69.             TxtParenthesis.Text = dr["parenthesis"].ToString();
  70.             TxtDays.Text = dr["days"].ToString();
  71.             TxtVacationBegin.Text = dr["vacation_begin"].ToString();
  72.             TxtVacationEnd.Text = dr["vacation_end"].ToString();
  73.             TxtVacationPlace.Text = dr["vacation_place"].ToString();
  74.             TxtFlightGoDepart.Text = dr["flight_go_depart"].ToString();
  75.             TxtFlightGoArrive.Text = dr["flight_go_arrive"].ToString();
  76.             TxtFlightGoTime.Text = dr["flight_go_time"].ToString();
  77.             TxtFlightBackTime.Text = dr["flight_back_time"].ToString();
  78.             TxtFlightBackDepart.Text = dr["flight_back_depart"].ToString();
  79.             TxtFlightBackArrive.Text = dr["flight_back_arrive"].ToString();
  80.             TxtBusinessBegin.Text = dr["business_begin"].ToString();
  81.             TxtBusinessEnd.Text = dr["business_end"].ToString();
  82.             TxtReason.Text = dr["reason"].ToString();
  83.             TxtApplyDate.Text = dr["apply_date"].ToString();
  84.         }
  85.         dr.Close();
  86.         conn.Close();
  87.     }
  88.     protected void SetBusinessData(string id)
  89.     {
  90.         SqlConnection conn = dbConnection.getConnection();
  91.         conn.Open();
  92.         SqlCommand cmd = new SqlCommand("select a.form_id, e.emp_name, e.emp_no, p.name position, a.apply_date," +
  93.             "d.name department, a.days, a.begin_time, a.end_time, f1.name depart_place, f2.name arrive_place, " +
  94.             "a.depart_time, a.arrive_time from OA_CH_BUSINESS_FORM a inner join OA_EMPLOYEE e on a.emp_id=e.id " +
  95.             "inner join OA_DEPARTMENT d on a.department_id=d.id inner join OA_EMPLOYEE_POSITION p on " +
  96.             "e.position=p.id inner join OA_FLIGHT_PLACE f1 on a.depart_place=f1.id inner join " +
  97.             "OA_FLIGHT_PLACE f2 on a.arrive_place=f2.id where a.id=" + id, conn);
  98.         SqlDataReader dr = cmd.ExecuteReader();
  99.         if (dr.Read())
  100.         {
  101.             TxtBFormId.Text = dr["form_id"].ToString();
  102.             TxtBEmpName.Text = dr["emp_name"].ToString();
  103.             TxtBEmpNo.Text = dr["emp_no"].ToString();
  104.             TxtBPosition.Text = dr["position"].ToString();
  105.             TxtBApplyDate.Text = dr["apply_date"].ToString();
  106.             TxtBDepartment.Text = dr["department"].ToString();
  107.             TxtBDays.Text = dr["days"].ToString();
  108.             TxtBBeginTime.Text = dr["begin_time"].ToString();
  109.             TxtBEndTime.Text = dr["end_time"].ToString();
  110.             TxtBDepartPlace.Text = dr["depart_place"].ToString();
  111.             TxtBArrivePlace.Text = dr["arrive_place"].ToString();
  112.             TxtBDepartTime.Text = dr["depart_time"].ToString();
  113.             TxtBArriveTime.Text = dr["arrive_time"].ToString();
  114.         }
  115.         dr.Close();
  116.         int flag = 0;
  117.         cmd = new SqlCommand("select number, company, subject, linkman, tel, place, visa_begin, visa_end, " +
  118.             "flight_go_begin, flight_back_end, is_aboard, remark from OA_CH_BUSINESS_DETAIL where form_id=" + id +
  119.             " order by number", conn);
  120.         dr = cmd.ExecuteReader();
  121.         while (dr.Read())
  122.         {
  123.             flag = 1;
  124.             //動態創建表格行
  125.             TableRow tr1 = new TableRow();
  126.             TableCell td1 = new TableCell();
  127.             td1.BorderWidth = Unit.Pixel(1);
  128.             Label label = new Label();
  129.             label.BorderStyle = BorderStyle.None;
  130.             label.Text = dr["number"].ToString();
  131.             td1.Controls.Add(label);
  132.             tr1.Cells.Add(td1);
  133.             TableCell td2 = new TableCell();
  134.             td2.BorderWidth = Unit.Pixel(1);
  135.             label = new Label();
  136.             label.BorderStyle = BorderStyle.None;
  137.             label.Text = dr["company"].ToString();
  138.             td2.Controls.Add(label);
  139.             tr1.Cells.Add(td2);
  140.             TableCell td3 = new TableCell();
  141.             td3.BorderWidth = Unit.Pixel(1);
  142.             label = new Label();
  143.             label.BorderStyle = BorderStyle.None;
  144.             label.Text = dr["subject"].ToString();
  145.             td3.Controls.Add(label);
  146.             tr1.Cells.Add(td3);
  147.             TableCell td4 = new TableCell();
  148.             td4.BorderWidth = Unit.Pixel(1);
  149.             label = new Label();
  150.             label.BorderStyle = BorderStyle.None;
  151.             label.Text = dr["linkman"].ToString();
  152.             td4.Controls.Add(label);
  153.             tr1.Cells.Add(td4);
  154.             TableCell td5 = new TableCell();
  155.             td5.BorderWidth = Unit.Pixel(1);
  156.             label = new Label();
  157.             label.BorderStyle = BorderStyle.None;
  158.             label.Text = dr["tel"].ToString();
  159.             td5.Controls.Add(label);
  160.             tr1.Cells.Add(td5);
  161.             TableCell td6 = new TableCell();
  162.             td6.BorderWidth = Unit.Pixel(1);
  163.             label = new Label();
  164.             label.BorderStyle = BorderStyle.None;
  165.             label.Text = dr["place"].ToString();
  166.             td6.Controls.Add(label);
  167.             tr1.Cells.Add(td6);
  168.             TableCell td7 = new TableCell();
  169.             td7.BorderWidth = Unit.Pixel(1);
  170.             label = new Label();
  171.             label.BorderStyle = BorderStyle.None;
  172.             label.Text = dr["visa_begin"].ToString();
  173.             td7.Controls.Add(label);
  174.             tr1.Cells.Add(td7);
  175.             TableCell td8 = new TableCell();
  176.             td8.BorderWidth = Unit.Pixel(1);
  177.             label = new Label();
  178.             label.BorderStyle = BorderStyle.None;
  179.             label.Text = dr["visa_end"].ToString();
  180.             td8.Controls.Add(label);
  181.             tr1.Cells.Add(td8);
  182.             TableCell td9 = new TableCell();
  183.             td9.BorderWidth = Unit.Pixel(1);
  184.             label = new Label();
  185.             label.BorderStyle = BorderStyle.None;
  186.             label.Text = dr["flight_go_begin"].ToString();
  187.             td9.Controls.Add(label);
  188.             tr1.Cells.Add(td9);
  189.             TableCell td10 = new TableCell();
  190.             td10.BorderWidth = Unit.Pixel(1);
  191.             label = new Label();
  192.             label.BorderStyle = BorderStyle.None;
  193.             label.Text = dr["flight_back_end"].ToString();
  194.             td10.Controls.Add(label);
  195.             tr1.Cells.Add(td10);
  196.             TableCell td11 = new TableCell();
  197.             td11.BorderWidth = Unit.Pixel(1);
  198.             CheckBox chk = new CheckBox();
  199.             chk.Text = "國外";
  200.             chk.Enabled = false;
  201.             if (dr["is_aboard"].ToString().Equals("Y"))
  202.             {
  203.                 chk.Checked = true;
  204.             }
  205.             else
  206.             {
  207.                 chk.Checked = false;
  208.             }
  209.             td11.Controls.Add(chk);
  210.             tr1.Cells.Add(td11);
  211.             TableCell td12 = new TableCell();
  212.             td12.BorderWidth = Unit.Pixel(1);
  213.             label = new Label();
  214.             label.BorderStyle = BorderStyle.None;
  215.             label.Text = dr["remark"].ToString();
  216.             td12.Controls.Add(label);
  217.             tr1.Cells.Add(td12);
  218.             TblDetail.Rows.Add(tr1);
  219.         }
  220.         dr.Close();
  221.         conn.Close();
  222.         if (flag == 0)
  223.         {
  224.             TblDetail.Visible = false;
  225.         }    
  226.     }
  227.     protected void SetOffData(string id)
  228.     {
  229.         SqlConnection conn = dbConnection.getConnection();
  230.         conn.Open();
  231.         SqlCommand cmd = new SqlCommand("select o.form_id, e.emp_no, e.emp_name, d.name department, " +
  232.             "e.emp_name delegate, e.position position, t.name off_type, o.begin_time, o.end_time, o.hours, "+
  233.             "o.apply_date, o.parenthesis, o.reason from OA_CH_OFF_FORM o inner join OA_EMPLOYEE e on "+
  234.             "o.emp_id=e.id inner join OA_DEPARTMENT d on o.department_id=d.id inner join OA_CH_OFF_TYPE t on " +
  235.             "o.off_type=t.id where o.id=" + id, conn);
  236.         SqlDataReader dr = cmd.ExecuteReader();
  237.         if (dr.Read())
  238.         {
  239.             TxtOFormId.Text = dr["form_id"].ToString();
  240.             TxtOEmpName.Text = dr["emp_no"].ToString() + dr["emp_name"].ToString();
  241.             TxtODepartment.Text = dr["department"].ToString();
  242.             TxtODelegate.Text = dr["delegate"].ToString();
  243.             TxtOPosition.Text = dr["position"].ToString();
  244.             TxtOOffType.Text = dr["off_type"].ToString();
  245.             TxtOBeginTime.Text = dr["begin_time"].ToString();
  246.             TxtOEndTime.Text = dr["end_time"].ToString();
  247.             TxtOHours.Text = dr["hours"].ToString();
  248.             TxtOApplyDate.Text = dr["apply_date"].ToString();
  249.             TxtOParenthesis.Text = dr["parenthesis"].ToString();
  250.             TxtOReason.Text = dr["reason"].ToString();
  251.         }
  252.         dr.Close();
  253.         conn.Close();
  254.     }
  255. }