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