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

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_tw_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.             ApprovelList.DataKeyNames = new string[] { "id" };
  20.         }
  21.         if (Request.QueryString["f_id"] != null)
  22.         {
  23.             PnlApprovel.Visible = true;
  24.             PnlDeal.Visible = true;
  25.             this.SetData(Request.QueryString["f_id"]);
  26.         }
  27.     }
  28.     protected void SetData(string id)
  29.     {
  30.         SqlConnection conn = dbConnection.getConnection();
  31.         conn.Open();
  32.         int form_id = 0;
  33.         SqlCommand cmd = new SqlCommand("select form_id from OA_TW_APPROVEL_FORM_FLOW where id=" + id, conn);
  34.         form_id = Convert.ToInt32(cmd.ExecuteScalar().ToString());
  35.         cmd = new SqlCommand("select a.form_id, e.emp_name, e.emp_no, p.name position, " +
  36.             "d.name department, e1.emp_name delegate, t.name off_type, a.parenthesis, a.days, a.vacation_begin, " +
  37.             "a.vacation_end, vp.name vacation_place, fp1.name flight_go_depart, fp2.name flight_go_arrive, " +
  38.             "a.flight_go_time, a.flight_back_time, fp3.name flight_back_depart, fp4.name flight_back_arrive, " +
  39.             "a.business_begin, a.business_end, a.reason, a.apply_date, b.name business_place " +
  40.             "from OA_TW_APPROVEL_FORM a " +
  41.             "inner join OA_EMPLOYEE e on a.emp_id=e.id " +
  42.             "inner join OA_EMPLOYEE e1 on a.delegate_id=e1.id " +
  43.             "inner join OA_DEPARTMENT d on e.department_id=d.id " +
  44.             "inner join OA_EMPLOYEE_POSITION p on e.position=p.id " +
  45.             "inner join OA_TW_OFF_TYPE t on a.off_type=t.id " +
  46.             "inner join OA_VACATION_PLACE vp on a.vacation_place=vp.id " +
  47.             "inner join OA_FLIGHT_PLACE fp1 on a.flight_go_depart=fp1.id " +
  48.             "inner join OA_FLIGHT_PLACE fp2 on a.flight_go_arrive=fp2.id " +
  49.             "inner join OA_FLIGHT_PLACE fp3 on a.flight_back_depart=fp3.id " +
  50.             "inner join OA_FLIGHT_PLACE fp4 on a.flight_back_arrive=fp4.id " +
  51.             "inner join OA_BUSINESS_PLACE b on a.business_place=b.id where a.id=" + form_id, conn);
  52.         SqlDataReader dr = cmd.ExecuteReader();
  53.         if (dr.Read())
  54.         {
  55.             TxtFormNo.Text = dr["form_id"].ToString();
  56.             TxtEmpName.Text = dr["emp_name"].ToString();
  57.             TxtEmpNo.Text = dr["emp_no"].ToString();
  58.             TxtPosition.Text = dr["position"].ToString();
  59.             TxtDepartment.Text = dr["department"].ToString();
  60.             TxtDelegate.Text = dr["delegate"].ToString();
  61.             TxtOffType.Text = dr["off_type"].ToString();
  62.             TxtParenthesis.Text = dr["parenthesis"].ToString();
  63.             TxtDays.Text = dr["days"].ToString();
  64.             TxtVacationBegin.Text = dr["vacation_begin"].ToString();
  65.             TxtVacationEnd.Text = dr["vacation_end"].ToString();
  66.             TxtVacationPlace.Text = dr["vacation_place"].ToString();
  67.             TxtFlightGoDepart.Text = dr["flight_go_depart"].ToString();
  68.             TxtFlightGoArrive.Text = dr["flight_go_arrive"].ToString();
  69.             TxtFlightGoTime.Text = dr["flight_go_time"].ToString();
  70.             TxtFlightBackTime.Text = dr["flight_back_time"].ToString();
  71.             TxtFlightBackDepart.Text = dr["flight_back_depart"].ToString();
  72.             TxtFlightBackArrive.Text = dr["flight_back_arrive"].ToString();
  73.             TxtBusinessBegin.Text = dr["business_begin"].ToString();
  74.             TxtBusinessEnd.Text = dr["business_end"].ToString();
  75.             TxtReason.Text = dr["reason"].ToString();
  76.             TxtApplyDate.Text = dr["apply_date"].ToString();
  77.             TxtBusinessPlace.Text = dr["business_place"].ToString();
  78.         }
  79.         dr.Close();
  80.         cmd = new SqlCommand("select is_agree, comment, check_date from OA_TW_APPROVEL_FORM_FLOW where id="+id, conn);
  81.         dr = cmd.ExecuteReader();
  82.         if (dr.Read())
  83.         {
  84.             RbAgree.SelectedValue = dr["is_agree"].ToString();
  85.             TxtComment.Text = dr["comment"].ToString();
  86.             TxtCheckDate.Text = dr["check_date"].ToString();
  87.         }
  88.         dr.Close();
  89.         conn.Close();
  90.     }
  91.     protected void ApprovelList_RowDataBound(object sender, GridViewRowEventArgs e)
  92.     {
  93.         //行高亮
  94.         if (e.Row.RowType == DataControlRowType.DataRow)
  95.         {
  96.             e.Row.Attributes.Add("onmouseover", "this.style.cursor='pointer';");
  97.             e.Row.Attributes.Add("onclick", "location.href='finish_list.aspx?f_id=" + ApprovelList.DataKeys[e.Row.RowIndex].Value.ToString() + "'");
  98.         }
  99.     }
  100.     protected void ApprovelList_RowCreated(object sender, GridViewRowEventArgs e)
  101.     {
  102.         if (e.Row.RowType == DataControlRowType.DataRow)
  103.         {
  104.             SqlConnection conn = dbConnection.getConnection();
  105.             conn.Open();
  106.             int step = 0;
  107.             string id = ApprovelList.DataKeys[e.Row.RowIndex].Value.ToString();
  108.             int form_id = 0;
  109.             SqlCommand cmd = new SqlCommand("select e.emp_name, t.name off_type, f.step,f.is_agree, f.form_id" +
  110.                 " from OA_TW_APPROVEL_FORM_FLOW f " +
  111.                 "inner join OA_TW_APPROVEL_FORM a on f.form_id=a.id inner join OA_EMPLOYEE e on a.emp_id=e.id " +
  112.                 "inner join OA_TW_OFF_TYPE t on a.off_type=t.id where f.id=" + id, conn);
  113.             SqlDataReader dr = cmd.ExecuteReader();
  114.             if (dr.Read())
  115.             {
  116.                 Label label = (Label)e.Row.FindControl("LblSubject");
  117.                 label.Text = dr["emp_name"].ToString() + "的" + dr["off_type"].ToString() + "單";
  118.                 Label label1 = (Label)e.Row.FindControl("LblStatus");
  119.                 if (dr["is_agree"].ToString().Equals("Y"))
  120.                 {
  121.                     label1.Text = "同意";
  122.                 }
  123.                 else
  124.                 {
  125.                     label1.Text = "不同意";
  126.                 }
  127.                 step = Convert.ToInt32(dr["step"].ToString());
  128.                 form_id = Convert.ToInt32(dr["form_id"].ToString());
  129.             }
  130.             dr.Close();
  131.             LinkButton lbRevoke = (LinkButton)e.Row.FindControl("LbRevoke");
  132.             cmd = new SqlCommand("select is_check from OA_TW_APPROVEL_FORM_FLOW where form_id=" +
  133.                 form_id + " and step>" + step + " order by step", conn);
  134.             try
  135.             {
  136.                 string is_check = cmd.ExecuteScalar().ToString();
  137.                 if (is_check.Equals("Y"))
  138.                 {
  139.                     lbRevoke.Enabled = false;
  140.                     lbRevoke.OnClientClick = "";
  141.                 }
  142.                 else
  143.                 {
  144.                     lbRevoke.CommandArgument = id;
  145.                     lbRevoke.Click += new EventHandler(lbRevoke_Click);
  146.                 }
  147.             }
  148.             catch
  149.             {
  150.                 lbRevoke.CommandArgument = id;
  151.                 lbRevoke.Click += new EventHandler(lbRevoke_Click);
  152.             }
  153.             conn.Close();
  154.         }
  155.     }
  156.     void lbRevoke_Click(object sender, EventArgs e)
  157.     {
  158.         string id = ((LinkButton)sender).CommandArgument;
  159.         SqlConnection conn = dbConnection.getConnection();
  160.         conn.Open();
  161.         SqlCommand cmd = new SqlCommand("update OA_TW_APPROVEL_FORM_FLOW set is_check='N', is_agree='N', " +
  162.             "comment='', check_date='' where id=" + id, conn);
  163.         cmd.ExecuteNonQuery();
  164.         cmd = new SqlCommand("select form_id from OA_TW_APPROVEL_FORM_FLOW where id=" + id, conn);
  165.         int form_id = Convert.ToInt32(cmd.ExecuteScalar());
  166.         cmd = new SqlCommand("update OA_TW_APPROVEL_FORM set step=0 where id=" + form_id, conn);
  167.         cmd.ExecuteNonQuery();
  168.         conn.Close();
  169.         ApprovelList.DataBind();
  170.        PnlApprovel.Visible = false;
  171.        PnlDeal.Visible = false;
  172.     }
  173. }