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

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