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

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_ch_finish_list : 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.             this.SetMainTable();
  20.             if (Request.QueryString["f_id"] != null)
  21.             {
  22.                 PnlApprovel.Visible = true;
  23.                 PnlDeal.Visible = true;
  24.                 this.SetValue(Request.QueryString["f_id"]);
  25.             }
  26.             if (Request.QueryString["o_id"] != null)
  27.             {
  28.                 PnlFlow.Visible = true;
  29.                 PnlOff.Visible = true;
  30.                 PnlDeal.Visible = true;
  31.                 this.SetOffValue(Request.QueryString["o_id"]);
  32.             }
  33.         }
  34.     }
  35.     protected void SetMainTable()
  36.     {
  37.         SqlConnection conn = dbConnection.getConnection();
  38.         conn.Open();
  39.         string user_id = "0";
  40.         if (Session["user_id"] != null)
  41.         {
  42.             user_id = Session["user_id"].ToString();
  43.         }
  44.         ArrayList ids = new ArrayList();
  45.         ArrayList form_ids = new ArrayList();
  46.         ArrayList is_businesses = new ArrayList();
  47.         SqlCommand cmd = new SqlCommand("SELECT f.id, f.form_id, f.is_business FROM dbo.OA_CH_APPROVEL_FORM_FLOW AS f " +
  48.             " WHERE (f.operator_id = " + user_id + ") AND (f.is_check = 'Y')", conn);
  49.         SqlDataReader dr = cmd.ExecuteReader();
  50.         while (dr.Read())
  51.         {
  52.             ids.Add(dr["id"].ToString());
  53.             form_ids.Add(dr["form_id"].ToString());
  54.             is_businesses.Add(dr["is_business"].ToString());
  55.         }
  56.         dr.Close();
  57.         for (int i = ids.Count - 1; i >= 0; i--)
  58.         {
  59.             if (is_businesses[i].Equals("Y"))
  60.             {
  61.                 cmd = new SqlCommand("select e.emp_name, b.apply_date, b.step from OA_CH_BUSINESS_FORM b inner join " +
  62.                     "OA_EMPLOYEE e on b.emp_id=e.id where b.id=" + form_ids[i], conn);
  63.                 dr = cmd.ExecuteReader();
  64.                 if (dr.Read())
  65.                 {
  66.                     TblFlow.Visible = true;
  67.                     TableRow tr = new TableRow();
  68.                     TableCell td = new TableCell();
  69.                     td.BorderWidth = Unit.Pixel(1);
  70.                     td.Text = dr["emp_name"].ToString();
  71.                     tr.Cells.Add(td);
  72.                     td = new TableCell();
  73.                     td.BorderWidth = Unit.Pixel(1);
  74.                     td.Text = dr["emp_name"].ToString() + "的出差單";
  75.                     tr.Cells.Add(td);
  76.                     td = new TableCell();
  77.                     td.BorderWidth = Unit.Pixel(1);
  78.                     td.Text = dr["apply_date"].ToString();
  79.                     tr.Cells.Add(td);
  80.                     td = new TableCell();
  81.                     td.BorderWidth = Unit.Pixel(1);
  82.                     HyperLink hl = new HyperLink();
  83.                     hl.Text = "查看";
  84.                     hl.NavigateUrl = "finish_list.aspx?f_id=" + ids[i].ToString();
  85.                     td.Controls.Add(hl);
  86.                     tr.Cells.Add(td);
  87.                     TblFlow.Rows.Add(tr);
  88.                 }
  89.                 dr.Close();
  90.             }
  91.             else
  92.             {
  93.                 cmd = new SqlCommand("select e.emp_name, o.apply_date, t.name off_type from OA_CH_OFF_FORM o " +
  94.                     "inner join OA_EMPLOYEE e on o.emp_id=e.id inner join OA_CH_OFF_TYPE t on o.off_type=t.id " +
  95.                     "where o.id=" + form_ids[i], conn);
  96.                 dr = cmd.ExecuteReader();
  97.                 if (dr.Read())
  98.                 {
  99.                     TblFlow.Visible = true;
  100.                     TableRow tr = new TableRow();
  101.                     TableCell td = new TableCell();
  102.                     td.BorderWidth = Unit.Pixel(1);
  103.                     td.Text = dr["emp_name"].ToString();
  104.                     tr.Cells.Add(td);
  105.                     td = new TableCell();
  106.                     td.BorderWidth = Unit.Pixel(1);
  107.                     td.Text = dr["emp_name"].ToString() + "的" + dr["off_type"].ToString() + "單";
  108.                     tr.Cells.Add(td);
  109.                     td = new TableCell();
  110.                     td.BorderWidth = Unit.Pixel(1);
  111.                     td.Text = dr["apply_date"].ToString();
  112.                     tr.Cells.Add(td);
  113.                     td = new TableCell();
  114.                     td.BorderWidth = Unit.Pixel(1);
  115.                     HyperLink hl = new HyperLink();
  116.                     hl.Text = "查看";
  117.                     hl.NavigateUrl = "finish_list.aspx?o_id=" + ids[i].ToString();
  118.                     td.Controls.Add(hl);
  119.                     tr.Cells.Add(td);
  120.                     TblFlow.Rows.Add(tr);
  121.                 }
  122.                 dr.Close();
  123.             }
  124.         }
  125.         conn.Close();
  126.     }
  127.     protected void SetValue(string id)
  128.     {
  129.         SqlConnection conn = dbConnection.getConnection();
  130.         conn.Open();
  131.         int form_id = 0;
  132.         string is_business = "";
  133.         SqlCommand cmd = new SqlCommand("select form_id, is_agree, comment, check_date, is_business from OA_CH_APPROVEL_FORM_FLOW where id=" + id, conn);
  134.         SqlDataReader dr = cmd.ExecuteReader();
  135.         if (dr.Read())
  136.         {
  137.             form_id = Convert.ToInt32(dr["form_id"].ToString());
  138.             RbAgree.SelectedValue = dr["is_agree"].ToString();
  139.             TxtComment.Text = dr["comment"].ToString();
  140.             is_business = dr["is_business"].ToString();
  141.         }
  142.         dr.Close();
  143.         FormId.Value = form_id.ToString();
  144.         if (is_business.Equals("Y"))
  145.         {
  146.             PnlApprovel.Visible = true;
  147.             cmd = new SqlCommand("select a.form_id, e.emp_name, e.emp_no, p.name position, a.apply_date," +
  148.                 "d.name department, a.days, a.begin_time, a.end_time, f1.name depart_place, f2.name arrive_place, " +
  149.                 "a.depart_time, a.arrive_time from OA_CH_BUSINESS_FORM a inner join OA_EMPLOYEE e on a.emp_id=e.id " +
  150.                 "inner join OA_DEPARTMENT d on a.department_id=d.id inner join OA_EMPLOYEE_POSITION p on " +
  151.                 "e.position=p.id inner join OA_FLIGHT_PLACE f1 on a.depart_place=f1.id inner join " +
  152.                 "OA_FLIGHT_PLACE f2 on a.arrive_place=f2.id where a.id=" + form_id, conn);
  153.             dr = cmd.ExecuteReader();
  154.             if (dr.Read())
  155.             {
  156.                 TxtFormId.Text = dr["form_id"].ToString();
  157.                 TxtEmpName.Text = dr["emp_name"].ToString();
  158.                 TxtEmpNo.Text = dr["emp_no"].ToString();
  159.                 TxtPosition.Text = dr["position"].ToString();
  160.                 TxtApplyDate.Text = dr["apply_date"].ToString();
  161.                 TxtDepartment.Text = dr["department"].ToString();
  162.                 TxtDays.Text = dr["days"].ToString();
  163.                 TxtBeginTime.Text = dr["begin_time"].ToString();
  164.                 TxtEndTime.Text = dr["end_time"].ToString();
  165.                 TxtDepartPlace.Text = dr["depart_place"].ToString();
  166.                 TxtArrivePlace.Text = dr["arrive_place"].ToString();
  167.                 TxtDepartTime.Text = dr["depart_time"].ToString();
  168.                 TxtArriveTime.Text = dr["arrive_time"].ToString();
  169.             }
  170.             dr.Close();
  171.         }
  172.         conn.Close();
  173.         this.SetTable(form_id);
  174.     }
  175.     protected void SetOffValue(string id)
  176.     {
  177.         SqlConnection conn = dbConnection.getConnection();
  178.         conn.Open();
  179.         int form_id = 0;
  180.         SqlCommand cmd = new SqlCommand("select form_id, is_agree, comment, check_date from OA_CH_APPROVEL_FORM_FLOW where id=" + id, conn);
  181.         SqlDataReader dr = cmd.ExecuteReader();
  182.         if (dr.Read())
  183.         {
  184.             form_id = Convert.ToInt32(dr["form_id"].ToString());
  185.             RbAgree.SelectedValue = dr["is_agree"].ToString();
  186.             TxtComment.Text = dr["comment"].ToString();
  187.             LblCheckDate.Text = dr["check_date"].ToString();
  188.         }
  189.         dr.Close();
  190.         cmd = new SqlCommand("select o.form_id, e.emp_no, e.emp_name, d.name department, " +
  191.             "e.emp_name delegate, e.position position, " +
  192.             "t.name off_type, o.begin_time, o.end_time, o.hours, o.apply_date, o.parenthesis, " +
  193.             "o.reason from OA_CH_OFF_FORM o inner join OA_EMPLOYEE e on o.emp_id=e.id inner join " +
  194.             "OA_DEPARTMENT d on o.department_id=d.id inner join OA_CH_OFF_TYPE t on " +
  195.             "o.off_type=t.id where o.id=" + form_id, conn);
  196.         dr = cmd.ExecuteReader();
  197.         if (dr.Read())
  198.         {
  199.             TxtOffFormId.Text = dr["form_id"].ToString();
  200.             TxtOffEmpName.Text = dr["emp_no"].ToString() + dr["emp_name"].ToString();
  201.             TxtOffDepartment.Text = dr["department"].ToString();
  202.             TxtDelegate.Text = dr["delegate"].ToString();
  203.             TxtOffPosition.Text = dr["position"].ToString();
  204.             TxtOffType2.Text = dr["off_type"].ToString();
  205.             TxtOffBeginTime.Text = dr["begin_time"].ToString();
  206.             TxtOffEndTime.Text = dr["end_time"].ToString();
  207.             TxtHours.Text = dr["hours"].ToString();
  208.             TxtOffApplyDate.Text = dr["apply_date"].ToString();
  209.             TxtParenthesis.Text = dr["parenthesis"].ToString();
  210.             TxtReason.Text = dr["reason"].ToString();
  211.         }
  212.         dr.Close();
  213.         conn.Close();
  214.     }
  215.     protected void SetTable(int form_id)
  216.     {
  217.         SqlConnection conn = dbConnection.getConnection();
  218.         conn.Open();
  219.         int flag = 0;
  220.         SqlCommand cmd = new SqlCommand("select number, company, subject, linkman, tel, place, visa_begin, visa_end, " +
  221.             "flight_go_begin, flight_back_end, is_aboard, remark from OA_CH_BUSINESS_DETAIL where form_id=" + form_id +
  222.             " order by number", conn);
  223.         SqlDataReader dr = cmd.ExecuteReader();
  224.         while (dr.Read())
  225.         {
  226.             flag = 1;
  227.             //動態創建表格行
  228.             TableRow tr1 = new TableRow();
  229.             TableCell td1 = new TableCell();
  230.             td1.BorderWidth = Unit.Pixel(1);
  231.             Label label = new Label();
  232.             label.BorderStyle = BorderStyle.None;
  233.             label.Text = dr["number"].ToString();
  234.             td1.Controls.Add(label);
  235.             tr1.Cells.Add(td1);
  236.             TableCell td2 = new TableCell();
  237.             td2.BorderWidth = Unit.Pixel(1);
  238.             label = new Label();
  239.             label.BorderStyle = BorderStyle.None;
  240.             label.Text = dr["company"].ToString();
  241.             td2.Controls.Add(label);
  242.             tr1.Cells.Add(td2);
  243.             TableCell td3 = new TableCell();
  244.             td3.BorderWidth = Unit.Pixel(1);
  245.             label = new Label();
  246.             label.BorderStyle = BorderStyle.None;
  247.             label.Text = dr["subject"].ToString();
  248.             td3.Controls.Add(label);
  249.             tr1.Cells.Add(td3);
  250.             TableCell td4 = new TableCell();
  251.             td4.BorderWidth = Unit.Pixel(1);
  252.             label = new Label();
  253.             label.BorderStyle = BorderStyle.None;
  254.             label.Text = dr["linkman"].ToString();
  255.             td4.Controls.Add(label);
  256.             tr1.Cells.Add(td4);
  257.             TableCell td5 = new TableCell();
  258.             td5.BorderWidth = Unit.Pixel(1);
  259.             label = new Label();
  260.             label.BorderStyle = BorderStyle.None;
  261.             label.Text = dr["tel"].ToString();
  262.             td5.Controls.Add(label);
  263.             tr1.Cells.Add(td5);
  264.             TableCell td6 = new TableCell();
  265.             td6.BorderWidth = Unit.Pixel(1);
  266.             label = new Label();
  267.             label.BorderStyle = BorderStyle.None;
  268.             label.Text = dr["place"].ToString();
  269.             td6.Controls.Add(label);
  270.             tr1.Cells.Add(td6);
  271.             TableCell td7 = new TableCell();
  272.             td7.BorderWidth = Unit.Pixel(1);
  273.             label = new Label();
  274.             label.BorderStyle = BorderStyle.None;
  275.             label.Text = dr["visa_begin"].ToString();
  276.             td7.Controls.Add(label);
  277.             tr1.Cells.Add(td7);
  278.             TableCell td8 = new TableCell();
  279.             td8.BorderWidth = Unit.Pixel(1);
  280.             label = new Label();
  281.             label.BorderStyle = BorderStyle.None;
  282.             label.Text = dr["visa_end"].ToString();
  283.             td8.Controls.Add(label);
  284.             tr1.Cells.Add(td8);
  285.             TableCell td9 = new TableCell();
  286.             td9.BorderWidth = Unit.Pixel(1);
  287.             label = new Label();
  288.             label.BorderStyle = BorderStyle.None;
  289.             label.Text = dr["flight_go_begin"].ToString();
  290.             td9.Controls.Add(label);
  291.             tr1.Cells.Add(td9);
  292.             TableCell td10 = new TableCell();
  293.             td10.BorderWidth = Unit.Pixel(1);
  294.             label = new Label();
  295.             label.BorderStyle = BorderStyle.None;
  296.             label.Text = dr["flight_back_end"].ToString();
  297.             td10.Controls.Add(label);
  298.             tr1.Cells.Add(td10);
  299.             TableCell td11 = new TableCell();
  300.             td11.BorderWidth = Unit.Pixel(1);
  301.             CheckBox chk = new CheckBox();
  302.             chk.Text = "國外";
  303.             chk.Enabled = false;
  304.             if (dr["is_aboard"].ToString().Equals("Y"))
  305.             {
  306.                 chk.Checked = true;
  307.             }
  308.             else
  309.             {
  310.                 chk.Checked = false;
  311.             }
  312.             td11.Controls.Add(chk);
  313.             tr1.Cells.Add(td11);
  314.             TableCell td12 = new TableCell();
  315.             td12.BorderWidth = Unit.Pixel(1);
  316.             label = new Label();
  317.             label.BorderStyle = BorderStyle.None;
  318.             label.Text = dr["remark"].ToString();
  319.             td12.Controls.Add(label);
  320.             tr1.Cells.Add(td12);
  321.             TblDetail.Rows.Add(tr1);
  322.         }
  323.         dr.Close();
  324.         conn.Close();
  325.         if (flag == 0)
  326.         {
  327.             TblDetail.Visible = false;
  328.         }
  329.     }
  330. }