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

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_computer_finish : 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.             Panform.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_computer_form where id=" + id, conn);
  34.       //  form_id = Convert.ToInt32(cmd.ExecuteScalar().ToString());
  35.         SqlCommand cmd = new SqlCommand("select * from oa_computer_form as a left join oa_computer_form_flow as b on a.form_id=b.form_id"+
  36.             " where b.id=" + id, conn);
  37.         SqlDataReader dr = cmd.ExecuteReader();
  38.         if (dr.Read())
  39.         {
  40.             form_no.Text = dr["form_id"].ToString();
  41.             emp_no.Text = dr["emp_no"].ToString();
  42.             emp_name.Text = dr["emp_name"].ToString();
  43.             emp_dept.Text = dr["emp_dept"].ToString();
  44.             emp_position.Text = dr["emp_position"].ToString();
  45.             date1.Text = dr["date1"].ToString();
  46.             f_item.Text = dr["item1"].ToString();
  47.             Enddate.Text = dr["enddate"].ToString();
  48.             content.Text = dr["content"].ToString();
  49.         }
  50.         dr.Close();
  51.         cmd = new SqlCommand("select is_agree, comment, check_date from oa_computer_form_flow where id=" + id, conn);
  52.         dr = cmd.ExecuteReader();
  53.         if (dr.Read())
  54.         {
  55.             RbAgree.SelectedValue = dr["is_agree"].ToString();
  56.             TxtComment.Text = dr["comment"].ToString();
  57.             TxtCheckDate.Text = dr["check_date"].ToString();
  58.         }
  59.         dr.Close();
  60.         conn.Close();
  61.     }
  62.     protected void ApprovelList_RowDataBound(object sender, GridViewRowEventArgs e)
  63.     {
  64.         //行高亮
  65.        
  66.         
  67.         if (e.Row.RowType == DataControlRowType.DataRow)
  68.         {
  69.           /*  SqlConnection conn = dbConnection.getConnection();
  70.             conn.Open();
  71.             SqlCommand cmd = new SqlCommand("select form_id from oa_computer_form where id='" + ApprovelList.DataKeys[e.Row.RowIndex].Value.ToString() + "'", conn);
  72.             string form_id;
  73.             form_id = cmd.ExecuteScalar().ToString();
  74.             conn.Close();*/
  75.             e.Row.Attributes.Add("onmouseover", "this.style.cursor='pointer';");
  76.             e.Row.Attributes.Add("onclick", "location.href='finish.aspx?f_id=" + ApprovelList.DataKeys[e.Row.RowIndex].Value.ToString() + "'");
  77.         }
  78.     }
  79.     protected void ApprovelList_RowCreated(object sender, GridViewRowEventArgs e)
  80.     {
  81.         if (e.Row.RowType == DataControlRowType.DataRow)
  82.         {
  83.             SqlConnection conn = dbConnection.getConnection();
  84.             conn.Open();
  85.             int step = 0;
  86.            string id = ApprovelList.DataKeys[e.Row.RowIndex].Value.ToString();
  87.            // int form_id = 0;
  88.             SqlCommand cmd = new SqlCommand("select * from oa_computer_form as a left join oa_computer_form_flow as b on a.form_id=b.form_id where"+
  89.                 " operator_id='"+Session["user_id"]+"' order by date1 desc", conn);
  90.             SqlDataReader dr = cmd.ExecuteReader();
  91.             if (dr.Read())
  92.             {
  93.                 Label label = (Label)e.Row.FindControl("LblSubject");
  94.                 label.Text = dr["emp_name"].ToString() + "的電腦設備報修單";
  95.                 step = Convert.ToInt32(dr["step"].ToString());
  96.                 //form_id = Convert.ToInt32(dr["form_id"].ToString());
  97.             }
  98.             dr.Close();
  99.             LinkButton lbRevoke = (LinkButton)e.Row.FindControl("LbRevoke");            
  100.             cmd = new SqlCommand("select is_check from oa_computer_form_flow where id=" +
  101.                 ApprovelList.DataKeys[e.Row.RowIndex].Value.ToString() + " and step in (select max(step) from oa_computer_form_flow where f_id in" +
  102.                 "(select f_id from oa_computer_form_flow where f_id=" + ApprovelList.DataKeys[e.Row.RowIndex].Value.ToString() + "))", conn);
  103.             try
  104.             {
  105.                 string is_check = cmd.ExecuteScalar().ToString();
  106.                 if (is_check.Equals("Y"))
  107.                 {
  108.                     lbRevoke.Enabled = false;
  109.                     lbRevoke.OnClientClick = "";
  110.                 }
  111.                 else
  112.                 {
  113.                     lbRevoke.CommandArgument = id;
  114.                     lbRevoke.Click += new EventHandler(lbRevoke_Click);
  115.                 }
  116.             }
  117.             catch
  118.             {
  119.                 lbRevoke.CommandArgument =id;
  120.                 lbRevoke.Click += new EventHandler(lbRevoke_Click);
  121.             }
  122.             conn.Close();
  123.         }
  124.     }
  125.     void lbRevoke_Click(object sender, EventArgs e)
  126.     {
  127.         string id = ((LinkButton)sender).CommandArgument;
  128.         SqlConnection conn = dbConnection.getConnection();
  129.         conn.Open();
  130.         SqlCommand cmd = new SqlCommand("update OA_computer_FORM_FLOW set is_check='N', is_agree='N', " +
  131.             "comment='', check_date='' where id=" + id, conn);
  132.         cmd.ExecuteNonQuery();      
  133.         conn.Close();
  134.         ApprovelList.DataBind();
  135.         Panform.Visible = false;
  136.         PnlDeal.Visible = false;
  137.     }
  138.     
  139. }