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

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_deal_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.                 PnlFlow.Visible = true;
  23.                 PnlApprovel.Visible = true;
  24.                 PnlDeal.Visible = true;
  25.                 this.SetValue(Request.QueryString["f_id"]);
  26.                 this.SetAmtValue(Request.QueryString["f_id1"]);
  27.                 FlowList.DataKeyNames = new string[] { "id" };
  28.             }
  29.             if (Request.QueryString["o_id"] != null)
  30.             {
  31.                 OffFlowList.Visible = true;
  32.                 PnlOff.Visible = true;
  33.                 PnlDeal.Visible = true;
  34.                 this.SetOffValue(Request.QueryString["o_id"]);
  35.                 OffFlowList.DataKeyNames = new string[] { "id" };
  36.             }
  37.         }
  38.     }
  39.     protected void SetMainTable()
  40.     {
  41.         SqlConnection conn = dbConnection.getConnection();
  42.         conn.Open();
  43.         string user_id = "0";
  44.         if (Session["user_id"] != null)
  45.         {
  46.             user_id = Session["user_id"].ToString();
  47.         }
  48.         ArrayList ids = new ArrayList();
  49.         ArrayList form_ids = new ArrayList();
  50.         ArrayList is_businesses = new ArrayList();
  51.         ArrayList f_steps = new ArrayList();
  52.         SqlCommand cmd = new SqlCommand("SELECT id, form_id, is_business, step FROM dbo.OA_CH_APPROVEL_FORM_FLOW  " +
  53.             " WHERE (operator_id = " + user_id + ") AND (is_check = 'N')  ", conn);
  54.         SqlDataReader dr = cmd.ExecuteReader();
  55.         while (dr.Read())
  56.         {
  57.             ids.Add(dr["id"].ToString());
  58.             form_ids.Add(dr["form_id"].ToString());
  59.             is_businesses.Add(dr["is_business"].ToString());
  60.             f_steps.Add(dr["step"].ToString());
  61.         }
  62.         dr.Close();
  63.         for (int i = ids.Count - 1; i >= 0; i--)
  64.         {
  65.             int f_step = Convert.ToInt32(f_steps[i]);
  66.             if (is_businesses[i].Equals("Y"))
  67.             {
  68.                 cmd = new SqlCommand("select e.emp_name, b.apply_date, b.step,b.id from OA_CH_BUSINESS_FORM b inner join " +
  69.                     "OA_EMPLOYEE e on b.emp_id=e.id where b.id=" + form_ids[i]+"and state=1", conn);
  70.                 dr = cmd.ExecuteReader();
  71.                 if (dr.Read())
  72.                 {
  73.                     int b_step = Convert.ToInt32(dr["step"].ToString()) + 1;
  74.                     if (b_step == f_step)
  75.                     {
  76.                         TblFlow.Visible = true;
  77.                         TableRow tr = new TableRow();
  78.                         TableCell td = new TableCell();
  79.                         td.BorderWidth = Unit.Pixel(1);
  80.                         td.Text = dr["emp_name"].ToString();
  81.                         tr.Cells.Add(td);
  82.                         td = new TableCell();
  83.                         td.BorderWidth = Unit.Pixel(1);
  84.                         td.Text = dr["emp_name"].ToString() + "的出差單";
  85.                         tr.Cells.Add(td);
  86.                         td = new TableCell();
  87.                         td.BorderWidth = Unit.Pixel(1);
  88.                         td.Text = dr["apply_date"].ToString();
  89.                         tr.Cells.Add(td);
  90.                         td = new TableCell();
  91.                         td.BorderWidth = Unit.Pixel(1);
  92.                         HyperLink hl = new HyperLink();
  93.                         hl.Text = "查看";
  94.                         hl.NavigateUrl = "deal_list.aspx?f_id=" + ids[i].ToString()+"&f_id1="+dr["id"].ToString();
  95.                         td.Controls.Add(hl);
  96.                         tr.Cells.Add(td);
  97.                         TblFlow.Rows.Add(tr);
  98.                     }
  99.                 }
  100.                 dr.Close();
  101.             }
  102.             else
  103.             {
  104.                 cmd = new SqlCommand("select e.emp_name, o.apply_date, t.name off_type, o.step,o.id from OA_CH_OFF_FORM o "+
  105.                     "inner join OA_EMPLOYEE e on o.emp_id=e.id inner join OA_CH_OFF_TYPE t on o.off_type=t.id "+
  106.                     "where o.id=" + form_ids[i] + " and state=1", conn);
  107.                 dr = cmd.ExecuteReader();
  108.                 if (dr.Read())
  109.                 {
  110.                     int b_step = Convert.ToInt32(dr["step"].ToString()) + 1;
  111.                     if (f_step == b_step)
  112.                     {
  113.                         TblFlow.Visible = true;
  114.                         TableRow tr = new TableRow();
  115.                         TableCell td = new TableCell();
  116.                         td.BorderWidth = Unit.Pixel(1);
  117.                         td.Text = dr["emp_name"].ToString();
  118.                         tr.Cells.Add(td);
  119.                         td = new TableCell();
  120.                         td.BorderWidth = Unit.Pixel(1);
  121.                         td.Text = dr["emp_name"].ToString() + "的" + dr["off_type"].ToString() + "單";
  122.                         tr.Cells.Add(td);
  123.                         td = new TableCell();
  124.                         td.BorderWidth = Unit.Pixel(1);
  125.                         td.Text = dr["apply_date"].ToString();
  126.                         tr.Cells.Add(td);
  127.                         td = new TableCell();
  128.                         td.BorderWidth = Unit.Pixel(1);
  129.                         HyperLink hl = new HyperLink();
  130.                         hl.Text = "查看";
  131.                         hl.NavigateUrl = "deal_list.aspx?o_id=" + ids[i].ToString()+"&o_id1="+dr["id"].ToString();
  132.                         td.Controls.Add(hl);
  133.                         tr.Cells.Add(td);
  134.                         TblFlow.Rows.Add(tr);
  135.                     }
  136.                 }
  137.                 dr.Close();
  138.             }
  139.         }
  140.         conn.Close();
  141.     }
  142.     protected void SetValue(string id)
  143.     {
  144.         SqlConnection conn = dbConnection.getConnection();
  145.         conn.Open();
  146.         int form_id = 0;
  147.         string is_business = "";
  148.         SqlCommand cmd = new SqlCommand("select form_id, is_business from OA_CH_APPROVEL_FORM_FLOW where id="+id, conn);
  149.         SqlDataReader dr = cmd.ExecuteReader();
  150.         if (dr.Read())
  151.         {
  152.             form_id = Convert.ToInt32(dr["form_id"].ToString());
  153.             is_business = dr["is_business"].ToString();
  154.         }
  155.         dr.Close();
  156.         FormId.Value = form_id.ToString();
  157.         if (is_business.Equals("Y"))
  158.         {
  159.             PnlApprovel.Visible = true;
  160.             cmd = new SqlCommand("select a.form_id, e.emp_name, e.emp_no, p.name position, a.apply_date," +
  161.                 "d.name department, a.days, a.begin_time, a.end_time,  depart_place, arrive_place, " +
  162.                 "a.depart_time, a.arrive_time from OA_CH_BUSINESS_FORM a inner join OA_EMPLOYEE e on a.emp_id=e.id " +
  163.                 "inner join OA_DEPARTMENT d on a.department_id=d.id inner join OA_EMPLOYEE_POSITION p on " +
  164.                 "e.position=p.id  where a.id=" + form_id, conn);
  165.             dr = cmd.ExecuteReader();
  166.             if (dr.Read())
  167.             {
  168.                 TxtFormId.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.                 TxtApplyDate.Text = dr["apply_date"].ToString();
  173.                 TxtDepartment.Text = dr["department"].ToString();
  174.                 TxtDays.Text = dr["days"].ToString();
  175.                 TxtBeginTime.Text = dr["begin_time"].ToString();
  176.                 TxtEndTime.Text = dr["end_time"].ToString();
  177.                 TxtDepartPlace.Text = dr["depart_place"].ToString();
  178.                 TxtArrivePlace.Text = dr["arrive_place"].ToString();
  179.                 TxtDepartTime.Text = dr["depart_time"].ToString();
  180.                 TxtArriveTime.Text = dr["arrive_time"].ToString();
  181.             }
  182.             dr.Close();
  183.         }
  184.         conn.Close();
  185.         this.SetTable(form_id);
  186.     }
  187.     protected void SetOffValue(string id)
  188.     {
  189.         SqlConnection conn = dbConnection.getConnection();
  190.         conn.Open();
  191.         int form_id = 0;
  192.         SqlCommand cmd = new SqlCommand("select form_id from OA_CH_APPROVEL_FORM_FLOW where id="+id, conn);
  193.         form_id = Convert.ToInt32(cmd.ExecuteScalar().ToString());
  194.         cmd = new SqlCommand("select o.form_id, e.emp_no, e.emp_name, d.name department, " +
  195.             "e.emp_name delegate, p.name position, " +
  196.             "t.name off_type, o.begin_time, o.end_time, o.hours, o.apply_date, o.parenthesis, " +
  197.             "o.reason from  OA_CH_OFF_FORM o  inner join OA_EMPLOYEE e on o.emp_id=e.id inner join " +
  198.             "OA_DEPARTMENT d on o.department_id=d.id inner join OA_CH_OFF_TYPE t on " +
  199.             "o.off_type=t.id inner join OA_EMPLOYEE_POSITION p on e.position=p.id where o.id=" + form_id, conn);
  200.         SqlDataReader dr = cmd.ExecuteReader();
  201.         if (dr.Read())
  202.         {
  203.             TxtOffFormId.Text = dr["form_id"].ToString();
  204.             TxtOffEmpName.Text = dr["emp_no"].ToString() + dr["emp_name"].ToString();
  205.             TxtOffDepartment.Text = dr["department"].ToString();
  206.             TxtDelegate.Text = dr["delegate"].ToString();
  207.             TxtOffPosition.Text = dr["position"].ToString();
  208.             TxtOffType2.Text = dr["off_type"].ToString();
  209.             TxtOffBeginTime.Text = dr["begin_time"].ToString();
  210.             TxtOffEndTime.Text = dr["end_time"].ToString();
  211.             TxtHours.Text = dr["hours"].ToString();
  212.             TxtOffApplyDate.Text = dr["apply_date"].ToString();
  213.             TxtParenthesis.Text = dr["parenthesis"].ToString();
  214.             TxtReason.Text = dr["reason"].ToString();
  215.         }
  216.         dr.Close();
  217.         conn.Close();
  218.     }
  219.     protected void SetTable(int form_id)
  220.     {
  221.         SqlConnection conn = dbConnection.getConnection();
  222.         conn.Open();
  223.         int flag = 0;
  224.         SqlCommand cmd = new SqlCommand("select * from OA_CH_BUSINESS_DETAIL where form_id=" + form_id +
  225.             " order by number", conn);
  226.       SqlDataReader  dr = cmd.ExecuteReader();
  227.         while (dr.Read())
  228.         {
  229.             flag = 1;
  230.             //動態創建表格行
  231.             TableRow tr1 = new TableRow();
  232.             TableCell td1 = new TableCell();
  233.             td1.BorderWidth = Unit.Pixel(1);
  234.             Label label = new Label();
  235.             label.BorderStyle = BorderStyle.None;
  236.             label.Text = dr["number"].ToString();
  237.             td1.Controls.Add(label);
  238.             tr1.Cells.Add(td1);
  239.             TableCell td2 = new TableCell();
  240.             td2.BorderWidth = Unit.Pixel(1);
  241.             label = new Label();
  242.             label.BorderStyle = BorderStyle.None;
  243.             label.Text = dr["date"].ToString();
  244.             td2.Controls.Add(label);
  245.             tr1.Cells.Add(td2);
  246.             TableCell td3 = new TableCell();
  247.             td3.BorderWidth = Unit.Pixel(1);
  248.             label = new Label();
  249.             label.BorderStyle = BorderStyle.None;
  250.             label.Text = dr["d_start"].ToString();
  251.             td3.Controls.Add(label);
  252.             tr1.Cells.Add(td3);
  253.             TableCell td4 = new TableCell();
  254.             td4.BorderWidth = Unit.Pixel(1);
  255.             label = new Label();
  256.             label.BorderStyle = BorderStyle.None;
  257.             label.Text = dr["d_end"].ToString();
  258.             td4.Controls.Add(label);
  259.             tr1.Cells.Add(td4);
  260.             TableCell td5 = new TableCell();
  261.             td5.BorderWidth = Unit.Pixel(1);
  262.             label = new Label();
  263.             label.BorderStyle = BorderStyle.None;
  264.             label.Text = dr["tool"].ToString();
  265.             td5.Controls.Add(label);
  266.             tr1.Cells.Add(td5);
  267.             TableCell td6 = new TableCell();
  268.             td6.BorderWidth = Unit.Pixel(1);
  269.             label = new Label();
  270.             label.BorderStyle = BorderStyle.None;
  271.             label.Text = dr["content"].ToString();
  272.             td6.Controls.Add(label);
  273.             tr1.Cells.Add(td6);
  274.             TableCell td7 = new TableCell();
  275.             td7.BorderWidth = Unit.Pixel(1);
  276.             label = new Label();
  277.             label.BorderStyle = BorderStyle.None;
  278.             label.Text = dr["remark"].ToString();
  279.             td7.Controls.Add(label);
  280.             tr1.Cells.Add(td7);
  281.             TblDetail.Rows.Add(tr1);
  282.         }
  283.        
  284.         dr.Close();
  285.         conn.Close();
  286.         if (flag == 0)
  287.         {
  288.             TblDetail.Visible = false;
  289.         }
  290.     }
  291.     protected void SetAmtValue(string id)
  292.     {
  293.         SqlConnection conn = dbConnection.getConnection();
  294.         conn.Open();
  295.         SqlCommand cmd = new SqlCommand("select * from OA_CH_BUSINESS_DETAIL1 where form_id=" + id, conn);
  296.         SqlDataReader dr = cmd.ExecuteReader();
  297.         while (dr.Read())
  298.         {
  299.             TxtFAmt1.Text = dr["f_eat"].ToString();
  300.             TxtFRemark1.Text = dr["f_eat_remark"].ToString();
  301.             TxtFAmt2.Text = dr["f_house"].ToString();
  302.             TxtFRemark2.Text = dr["f_house_remark"].ToString();
  303.             TxtFAmt3.Text = dr["f_move"].ToString();
  304.             TxtFRemark3.Text = dr["f_move_remark"].ToString();
  305.             TxtFAmt4.Text = dr["f_other"].ToString();
  306.             TxtFRemark4.Text = dr["f_other_remark"].ToString();
  307.             TxtFAmt5.Text = dr["f_total"].ToString();
  308.             TxtFRemark5.Text = dr["f_total_remark"].ToString();
  309.         }
  310.         dr.Close();
  311.         conn.Close();
  312.     }
  313.     protected void FlowList_RowCreated(object sender, GridViewRowEventArgs e)
  314.     {
  315.         if (e.Row.RowType == DataControlRowType.DataRow)
  316.         {
  317.             SqlConnection conn = dbConnection.getConnection();
  318.             conn.Open();
  319.             SqlCommand cmd = new SqlCommand("select apply_type, is_check, is_agree, comment from " +
  320.                 "OA_CH_APPROVEL_FORM_FLOW where id=" + FlowList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  321.             SqlDataReader dr = cmd.ExecuteReader();
  322.             if (dr.Read())
  323.             {
  324.                 Label label = (Label)e.Row.FindControl("LblApplyType");
  325.                 if (dr["apply_type"].ToString().Equals("1"))
  326.                 {
  327.                     label.Text = "會簽";
  328.                 }
  329.                else if (dr["apply_type"].ToString().Equals("3"))
  330.                 {
  331.                     label.Text = "代理";
  332.                 }
  333.                 else
  334.                 {
  335.                     label.Text = "審批";
  336.                 }
  337.                 label = (Label)e.Row.FindControl("LblIsCheck");
  338.                 if (dr["is_check"].ToString().Equals("N"))
  339.                 {
  340.                     label.Text = "未處理";
  341.                 }
  342.                 else
  343.                 {
  344.                     label.Text = "已處理";
  345.                     label = (Label)e.Row.FindControl("LblIsAgree");
  346.                     if (dr["is_agree"].ToString().Equals("Y"))
  347.                     {
  348.                         label.Text = "已同意";
  349.                     }
  350.                     else
  351.                     {
  352.                         label.Text = "不同意";
  353.                     }
  354.                 }
  355.                 label = (Label)e.Row.FindControl("LblComment");
  356.                 label.Text = dr["comment"].ToString();
  357.             }
  358.             dr.Close();
  359.             conn.Close();
  360.         }
  361.     }
  362.     protected void OffFlowList_RowCreated(object sender, GridViewRowEventArgs e)
  363.     {
  364.         if (e.Row.RowType == DataControlRowType.DataRow)
  365.         {
  366.             SqlConnection conn = dbConnection.getConnection();
  367.             conn.Open();
  368.             SqlCommand cmd = new SqlCommand("select apply_type, is_check, is_agree, comment from " +
  369.                 "OA_CH_APPROVEL_FORM_FLOW where id=" + OffFlowList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  370.             SqlDataReader dr = cmd.ExecuteReader();
  371.             if (dr.Read())
  372.             {
  373.                 Label label = (Label)e.Row.FindControl("LblApplyType");
  374.                 if (dr["apply_type"].ToString().Equals("1"))
  375.                 {
  376.                     label.Text = "會簽";
  377.                 }
  378.                 else if (dr["apply_type"].ToString().Equals("3"))
  379.                 {
  380.                     label.Text = "代理";
  381.                 }
  382.                 else
  383.                 {
  384.                     label.Text = "審批";
  385.                 }
  386.                 label = (Label)e.Row.FindControl("LblIsCheck");
  387.                 if (dr["is_check"].ToString().Equals("N"))
  388.                 {
  389.                     label.Text = "未處理";
  390.                 }
  391.                 else
  392.                 {
  393.                     label.Text = "已處理";
  394.                     label = (Label)e.Row.FindControl("LblIsAgree");
  395.                     if (dr["is_agree"].ToString().Equals("Y"))
  396.                     {
  397.                         label.Text = "已同意";
  398.                     }
  399.                     else
  400.                     {
  401.                         label.Text = "不同意";
  402.                     }
  403.                 }
  404.                 label = (Label)e.Row.FindControl("LblComment");
  405.                 label.Text = dr["comment"].ToString();
  406.             }
  407.             dr.Close();
  408.             conn.Close();
  409.         }
  410.     }
  411.     protected void RbAgree_SelectedIndexChanged(object sender, EventArgs e)
  412.     {
  413.         if (TxtComment.Text.Equals("已同意") || TxtComment.Text.Equals("不同意"))
  414.         {
  415.             if (RbAgree.SelectedValue.Equals("Y"))
  416.             {
  417.                 TxtComment.Text = "已同意";
  418.             }
  419.             else
  420.             {
  421.                 TxtComment.Text = "不同意";
  422.             }
  423.         }
  424.        // this.SetTable(Convert.ToInt32(FormId.Value));
  425.     }
  426.     protected void BtnOk_Click(object sender, EventArgs e)
  427.     {
  428.         SqlConnection conn = dbConnection.getConnection();
  429.         conn.Open();
  430.         SqlTransaction tx = conn.BeginTransaction();
  431.         try
  432.         {
  433.             int flow_id = 0;
  434.             if (Request.QueryString["f_id"] != null)
  435.             {
  436.                 flow_id = Convert.ToInt32(Request.QueryString["f_id"]);
  437.             }
  438.             else if (Request.QueryString["o_id"] != null)
  439.             {
  440.                 flow_id = Convert.ToInt32(Request.QueryString["o_id"]);
  441.             }
  442.             string is_business = "";
  443.             DateMgr mgr = new DateMgr();
  444.             SqlCommand cmd = new SqlCommand("update OA_CH_APPROVEL_FORM_FLOW set is_check='Y', is_agree='" +
  445.                 RbAgree.SelectedValue + "', comment='" + TxtComment.Text.Replace("n", "<br>") + "', check_date='" + mgr.getDateTime() +
  446.                 "' where id=" + flow_id, conn);
  447.             cmd.Transaction = tx;
  448.             cmd.ExecuteNonQuery();
  449.             cmd = new SqlCommand("select form_id, is_business from OA_CH_APPROVEL_FORM_FLOW where id=" + flow_id, conn);
  450.             cmd.Transaction = tx;
  451.             SqlDataReader dr = cmd.ExecuteReader();
  452.             int form_id = 0;
  453.             if (dr.Read())
  454.             {
  455.                 form_id = Convert.ToInt32(dr["form_id"].ToString());
  456.                 is_business = dr["is_business"].ToString();                
  457.             }
  458.             dr.Close();
  459.             if (is_business.Equals("Y"))
  460.             {
  461.                 cmd = new SqlCommand("select max(step) from OA_CH_APPROVEL_FORM_FLOW where form_id=" + form_id + " and is_business='Y'", conn);
  462.                 cmd.Transaction = tx;
  463.                 int max_step = Convert.ToInt32(cmd.ExecuteScalar());
  464.                 cmd = new SqlCommand("select step from OA_CH_BUSINESS_FORM where id=" + form_id, conn);
  465.                 cmd.Transaction = tx;
  466.                 int step = Convert.ToInt32(cmd.ExecuteScalar());
  467.                 string total_result = "跑流程中";
  468.                 string time = "";
  469.                 if (max_step == step + 1)
  470.                 {
  471.                     if (RbAgree.SelectedValue.Equals("N"))
  472.                     {
  473.                         total_result = "不同意";
  474.                     }
  475.                     else
  476.                     {
  477.                         total_result = "同意";
  478.                     }
  479.                     time = mgr.getDateTime();
  480.                 }
  481.                 else
  482.                 {
  483.                     if (RbAgree.SelectedValue.Equals("N"))
  484.                     {
  485.                         total_result = "不同意";
  486.                         time = mgr.getDateTime();
  487.                     }
  488.                 }
  489.                 cmd = new SqlCommand("update OA_CH_BUSINESS_FORM set step=step+1, total_result='" +
  490.                     total_result + "', finish_date='" + time + "' where id=" + form_id, conn);
  491.                 cmd.Transaction = tx;
  492.                 cmd.ExecuteNonQuery();
  493.                 //mail
  494.                 ArrayList name1 = new ArrayList();
  495.                 ArrayList mail1 = new ArrayList();
  496.                 cmd = new SqlCommand("select top 1 a.email_work,a.emp_name from oa_employee as a inner join " +
  497.                    "OA_CH_APPROVEL_FORM_FLOW as b on b.operator_id=a.id left join OA_CH_BUSINESS_FORM as c " +
  498.                      "on b.form_id=c.id where b.step=c.step+1 and c.id=" + form_id + " and is_business='Y' order by position desc", conn);
  499.                 cmd.Transaction = tx;
  500.                 SqlDataReader dr3 = cmd.ExecuteReader();
  501.                 while (dr3.Read())
  502.                 {
  503.                     name1.Add(dr3["emp_name"].ToString());
  504.                     mail1.Add(dr3["email_work"].ToString());
  505.                    // mail.mail_q(mail1[0], name1[0], TxtEmpName.Text, "中幹出差申請單");
  506.                 } dr3.Close();
  507.                 //   
  508.             }
  509.             else
  510.             {
  511.                 cmd = new SqlCommand("select max(step) from OA_CH_APPROVEL_FORM_FLOW where form_id=" + form_id + " and is_business='N'", conn);
  512.                 cmd.Transaction = tx;
  513.                 int max_step = Convert.ToInt32(cmd.ExecuteScalar());
  514.                 cmd = new SqlCommand("select step from OA_CH_OFF_FORM where id=" + form_id, conn);
  515.                 cmd.Transaction = tx;
  516.                 int step = Convert.ToInt32(cmd.ExecuteScalar());
  517.                 string total_result = "跑流程中";
  518.                 string time = "";
  519.                 if (max_step == step + 1)
  520.                 {
  521.                     if (RbAgree.SelectedValue.Equals("N"))
  522.                     {
  523.                         total_result = "不同意";
  524.                     }
  525.                     else
  526.                     {
  527.                         total_result = "同意";
  528.                     }
  529.                     time = mgr.getDateTime();
  530.                 }
  531.                 else
  532.                 {
  533.                     if (RbAgree.SelectedValue.Equals("N"))
  534.                     {
  535.                         total_result = "不同意";
  536.                         time = mgr.getDateTime();
  537.                     }
  538.                 }
  539.                 cmd = new SqlCommand("update OA_CH_OFF_FORM set step=step+1, total_result='" +
  540.                     total_result + "', finish_date='" + time + "' where id=" + form_id, conn);
  541.                 cmd.Transaction = tx;
  542.                 cmd.ExecuteNonQuery();
  543.                 //mail
  544.                 ArrayList name1 = new ArrayList();
  545.                 ArrayList mail1 = new ArrayList();
  546.                 cmd = new SqlCommand("select top 1 a.email_work,a.emp_name from oa_employee as a inner join " +
  547.                    "OA_CH_APPROVEL_FORM_FLOW as b on b.operator_id=a.id left join OA_CH_OFF_FORM as c " +
  548.                      "on b.form_id=c.id where b.step=c.step+1 and c.id=" + form_id + " order by position desc", conn);
  549.                 cmd.Transaction = tx;
  550.                 SqlDataReader dr3 = cmd.ExecuteReader();
  551.                 while (dr3.Read())
  552.                 {
  553.                     name1.Add(dr3["emp_name"].ToString());
  554.                     mail1.Add(dr3["email_work"].ToString());
  555.                    // mail.mail_q(mail1[0], name1[0], TxtOffEmpName.Text, "中幹請假單");
  556.                 } dr3.Close();
  557.                 //   
  558.             }
  559.             tx.Commit();
  560.         }
  561.         catch (Exception ex)
  562.         {
  563.             Response.Write(ex.ToString());
  564.             tx.Rollback();
  565.         }
  566.         conn.Close();
  567.         try
  568.         {
  569.             Response.Redirect("finish_list.aspx");
  570.         }
  571.         catch (Exception ex)
  572.         {
  573.             Response.Write(ex.Message);
  574.         }
  575.     }
  576. }