deal.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_computer_detail : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.         if (!IsPostBack)
  17.         {
  18.             
  19.             LoginDAO.CheckLogin(Session, Response, "../", 2);
  20.             this.SetTable();
  21.         }
  22.         if (Request.QueryString["f_id"] != null)
  23.         {
  24.             PnlApprovel.Visible = true;
  25.             PnlDeal.Visible = true;
  26.           //  PnlFlow.Visible = true;
  27.             this.SetData(Request.QueryString["f_id"]);
  28.         }
  29.     }
  30.     protected void SetTable()
  31.     {
  32.         ArrayList form_id = new ArrayList();
  33.         ArrayList operator_id = new ArrayList();
  34.         SqlConnection conn = dbConnection.getConnection();
  35.         conn.Open();
  36.         SqlTransaction tx = conn.BeginTransaction();
  37.         SqlCommand cmd = new SqlCommand("select distinct f_id from oa_computer_form_flow ", conn);
  38.         cmd.Transaction = tx;
  39.         SqlDataReader dr = cmd.ExecuteReader();
  40.         while (dr.Read())
  41.         {
  42.             form_id.Add(dr["f_id"].ToString());
  43.         }
  44.         dr.Close();
  45.               for (int i = 0; i < form_id.Count;i++ )
  46.               
  47.               {
  48.                 cmd = new SqlCommand("select top 1 operator_id from oa_computer_form_flow where is_check='N'and f_id="+form_id[i], conn);
  49.                 cmd.Transaction = tx;
  50.                 SqlDataReader  dr2 = cmd.ExecuteReader();
  51.                 while (dr2.Read())
  52.                 { 
  53.                  operator_id.Add(dr2["operator_id"].ToString());
  54.                 }
  55.                     dr2.Close(); 
  56.               }     
  57.                
  58.                 
  59.                  for(int i=0;i<form_id.Count;i++)
  60.                  {
  61.                 
  62.                     cmd = new SqlCommand("SELECT a.id, f.step f_step,f.form_id,  e.emp_name, a.date1 " +
  63.                     "FROM dbo.oa_computer_form_flow AS f INNER JOIN dbo.OA_computer_form AS a ON f.form_id = a.form_id " +
  64.                      "INNER JOIN dbo.OA_EMPLOYEE AS e ON a.emp_id = e.id WHERE (f.operator_id = " + Session["user_id"] +
  65.                     ") AND (f.is_check = 'N') and f_id="+form_id[i]+" order by a.date1 desc", conn);
  66.                     cmd.Transaction = tx;
  67.                     SqlDataReader dr1 = cmd.ExecuteReader();
  68.                     while (dr1.Read())
  69.                     {
  70.                         int f_step = Convert.ToInt32(dr1["f_step"].ToString());
  71.                         TblFlow.Visible = true;
  72.                         TableRow tr = new TableRow();
  73.                         TableCell td = new TableCell();
  74.                         td.BorderWidth = Unit.Pixel(1);
  75.                         td.Text = dr1["emp_name"].ToString();
  76.                         tr.Cells.Add(td);
  77.                         td = new TableCell();
  78.                         td.BorderWidth = Unit.Pixel(1);
  79.                         td.Text = dr1["emp_name"].ToString() + "的電腦設備報修單";
  80.                         tr.Cells.Add(td);
  81.                         td = new TableCell();
  82.                         td.BorderWidth = Unit.Pixel(1);
  83.                         td.Text = dr1["date1"].ToString();
  84.                         tr.Cells.Add(td);
  85.                         td = new TableCell();
  86.                         td.BorderWidth = Unit.Pixel(1);
  87.                         HyperLink hl = new HyperLink();
  88.                         hl.Text = "查看";
  89.                         hl.NavigateUrl = "deal.aspx?f_id=" + dr1["id"].ToString() + "&f_id1=" + dr1["form_id"].ToString();
  90.                         td.Controls.Add(hl);
  91.                         tr.Cells.Add(td);
  92.                         TblFlow.Rows.Add(tr);
  93.                        
  94.                     }
  95.                     dr1.Close();
  96.                    
  97.                     
  98.                 }
  99.               
  100.         tx.Commit();
  101.         conn.Close();
  102.     }
  103.     
  104.   
  105.     protected void SetData(string id)
  106.     {
  107.         SqlConnection conn = dbConnection.getConnection();
  108.         conn.Open();
  109.         SqlCommand cmd = new SqlCommand("select * from oa_computer_form where id=" + id, conn);
  110.         SqlDataReader dr = cmd.ExecuteReader();
  111.         if (dr.Read())
  112.         {
  113.             form_no.Text = dr["form_id"].ToString();
  114.             emp_no.Text = dr["emp_no"].ToString();
  115.             emp_name.Text = dr["emp_name"].ToString();
  116.             emp_dept.Text = dr["emp_dept"].ToString();
  117.             emp_position.Text = dr["emp_position"].ToString();
  118.             date1.Text = dr["date1"].ToString();
  119.             f_item.Text = dr["item1"].ToString();
  120.             Enddate.Text = dr["enddate"].ToString();
  121.             content.Text = dr["content"].ToString();
  122.         }
  123.         dr.Close();
  124.         conn.Close();
  125.     }
  126.     protected void RbAgree_SelectedIndexChanged(object sender, EventArgs e)
  127.     {
  128.         if (TxtComment.Text.Equals("已同意") || TxtComment.Text.Equals("不同意"))
  129.         {
  130.             if (RbAgree.SelectedValue.Equals("Y"))
  131.             {
  132.                 TxtComment.Text = "已同意";
  133.             }
  134.             else
  135.             {
  136.                 TxtComment.Text = "不同意";
  137.             }
  138.         }
  139.     }
  140.     protected void BtnOk_Click(object sender, EventArgs e)
  141.     {
  142.         SqlConnection conn = dbConnection.getConnection();
  143.         conn.Open();
  144.         SqlTransaction tx = conn.BeginTransaction();
  145.         try
  146.         {
  147.             DateMgr mgr = new DateMgr();          
  148.             SqlCommand cmd = new SqlCommand("update oa_computer_form_flow set is_check='Y', is_agree='" +
  149.             RbAgree.SelectedValue + "', comment='" + TxtComment.Text.Replace("n", "<br>") +
  150.             "', check_date='" + mgr.getDateTime() + "'  where form_id='" + Request.QueryString["f_id1"]+"'and "+
  151.             " operator_id="+Session["user_id"], conn);
  152.             cmd.Transaction = tx;
  153.             cmd.ExecuteNonQuery();         
  154.             cmd = new SqlCommand("select operator_id from oa_computer_form_flow where form_id='" +
  155.                   Request.QueryString["f_id1"]+"' and step in(select max(step) from oa_computer_form_flow where form_id='"+
  156.                   Request.QueryString["f_id1"]+"')" , conn);
  157.             cmd.Transaction = tx;
  158.             int oper_id =Convert.ToInt32(cmd.ExecuteScalar());
  159.             string total_result = "跑流程中";
  160.             string time = "";
  161.             int u_id =Convert.ToInt32( Session["user_id"]);
  162.             if (oper_id == u_id)
  163.             {
  164.                 if (RbAgree.SelectedValue.Equals("N"))
  165.                 {
  166.                     total_result = "不同意";
  167.                 }
  168.                 else
  169.                 {
  170.                     total_result = "同意";
  171.                 }
  172.                 time = mgr.getDateTime();
  173.             }
  174.             else {
  175.                 time = mgr.getDateTime();
  176.             }
  177.             cmd = new SqlCommand("update OA_computer_FORM set  status='" +
  178.                 total_result + "' where id=" + Request.QueryString["f_id"], conn);
  179.             cmd.Transaction = tx;
  180.             cmd.ExecuteNonQuery();
  181.             cmd = new SqlCommand("update OA_computer_FORM_flow set check_date='" + time + "' where id=" + Request.QueryString["f_id"]+
  182.                 "and operator_id="+Session["user_id"], conn);
  183.             cmd.Transaction = tx;
  184.             cmd.ExecuteNonQuery();
  185.             tx.Commit(); 
  186.          
  187.         }
  188.            
  189.     
  190.         catch (Exception ex)
  191.         {
  192.             Response.Write(ex.Message);
  193.            // tx.Rollback();
  194.           
  195.         }
  196.         conn.Close();
  197.         Response.Redirect("finish.aspx");
  198.     }
  199. }