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

OA系统

开发平台:

ASP/ASPX

  1. using System;
  2. using System.Drawing;
  3. using System.Data;
  4. using System.Data.SqlClient;
  5. using System.Configuration;
  6. using System.Collections;
  7. using System.Web;
  8. using System.Web.Security;
  9. using System.Web.UI;
  10. using System.Web.UI.WebControls;
  11. using System.Web.UI.WebControls.WebParts;
  12. using System.Web.UI.HtmlControls;
  13. public partial class web_equipment_deal : System.Web.UI.Page
  14. {
  15.     string form_id = "";
  16.     protected void Page_Load(object sender, EventArgs e)
  17.     {
  18.         if (!IsPostBack)
  19.         {
  20.             this.MultiView1.Visible = true;
  21.             form_id = Request.QueryString["form_id"];
  22.             TextBox1.Text = form_id;
  23.             TextBox2.Text = Request.QueryString["emp_name"];
  24.             this.SetTable();
  25.         }
  26.     }
  27.     public void SetTable()
  28.     {
  29.         SqlConnection conn = dbConnection.getConnection();
  30.         conn.Open();
  31.         SqlCommand cmd = new SqlCommand("select operator_id,is_check,is_agree,comment,check_date,step from oa_equipment_flow where form_id='" + form_id + "'", conn);
  32.         SqlDataReader dr = cmd.ExecuteReader();
  33.         if (dr.HasRows)
  34.         {
  35.             while (dr.Read())
  36.             {
  37.                 TableRow tr = new TableRow();
  38.                 TableCell td = new TableCell();
  39.                 td.BorderWidth = Unit.Pixel(1);
  40.                 td.Text = dr["step"].ToString();
  41.                 tr.Cells.Add(td);
  42.                 td = new TableCell();
  43.                 td.BorderWidth = Unit.Pixel(1);
  44.                 SqlConnection conn1 = dbConnection.getConnection();
  45.                 conn1.Open();
  46.                 SqlCommand sqlcom = new SqlCommand("select emp_name from oa_employee where id='"+dr["operator_id"]+"'",conn1);
  47.                 td.Text = sqlcom.ExecuteScalar().ToString();
  48.                 tr.Cells.Add(td);
  49.                 td = new TableCell();
  50.                 td.BorderWidth = Unit.Pixel(1);
  51.                 td.Text = "審批";
  52.                 tr.Cells.Add(td);
  53.                 td = new TableCell();
  54.                 td.BorderWidth = Unit.Pixel(1);
  55.                 if (dr["is_check"].ToString().Equals("N"))
  56.                 {
  57.                     td.Text = "未處理";
  58.                 }
  59.                 else
  60.                 {
  61.                     td.Text = "已處理";
  62.                 }
  63.                 tr.Cells.Add(td);
  64.                 td = new TableCell();
  65.                 td.BorderWidth = Unit.Pixel(1);
  66.                 if (dr["is_check"].ToString().Equals("Y"))
  67.                 {   
  68.                     if (dr["is_agree"].ToString().Equals("Y"))
  69.                     {
  70.                        
  71.                         td.Text = "已同意";
  72.                     }
  73.                     else
  74.                     {
  75.                         td.Text = "不同意";
  76.                     }
  77.                 }
  78.                 else
  79.                 {
  80.                     td.Text = "<br>";
  81.                 }
  82.                 tr.Cells.Add(td);
  83.                 td = new TableCell();
  84.                 td.BorderWidth = Unit.Pixel(1);
  85.                 if (!dr["comment"].ToString().Equals(""))
  86.                 {
  87.                     td.Text = dr["comment"].ToString();
  88.                 }
  89.                 else
  90.                 {
  91.                     td.Text = "<br>";
  92.                 }
  93.                 tr.Cells.Add(td);
  94.                 td = new TableCell();
  95.                 td.BorderWidth = Unit.Pixel(1);
  96.                 if (!dr["check_date"].ToString().Equals(""))
  97.                 {
  98.                     td.Text = dr["check_date"].ToString();
  99.                 }
  100.                 else
  101.                 {
  102.                     td.Text = "<br>";
  103.                 }
  104.                 tr.Cells.Add(td);
  105.                 FlowTable.Rows.Add(tr);
  106.             }
  107.         }
  108.     }
  109.     protected void BtnOk_Click(object sender, EventArgs e)
  110.     {
  111.         string total_result = "跑流程中";
  112.         string time = "";
  113.         SqlConnection conn = dbConnection.getConnection();
  114.         conn.Open();
  115.         DateMgr mgr = new DateMgr();
  116.         SqlCommand cmd = new SqlCommand("update oa_equipment_flow set is_check='Y',is_agree='" + RbAgree.SelectedValue.ToString() + "',comment='" + TxtComment.Text.Replace("n", "<br>") + "',check_date='" + mgr.getDateTime() + "'where form_id='" + Request.QueryString["form_id"] + "'and operator_id='" + Session["user_id"] + "'", conn);
  117.         cmd.ExecuteNonQuery();
  118.         cmd = new SqlCommand("select max(step) from oa_equipment_flow where form_id='" + Request.QueryString["form_id"] + "'", conn);
  119.         int max_step = 1;
  120.         max_step = Convert.ToInt32(cmd.ExecuteScalar());
  121.         cmd = new SqlCommand("select step from oa_equipment_form where form_id='" + Request.QueryString["form_id"] + "'", conn);
  122.         int step = Convert.ToInt32(cmd.ExecuteScalar());
  123.         if (step  == max_step)
  124.         {
  125.             if (RbAgree.SelectedValue.Equals("N"))
  126.             {
  127.                 total_result = "不同意";
  128.             }
  129.             else
  130.             {
  131.                 total_result = "同意";
  132.             }
  133.             time = mgr.getDateTime();
  134.         }
  135.         else
  136.         {
  137.             if (RbAgree.SelectedValue.Equals("N"))
  138.             {
  139.                 total_result = "不同意";
  140.             }
  141.             time = mgr.getDateTime();
  142.         }
  143.         if (step == max_step)
  144.         {
  145.             cmd = new SqlCommand("update oa_equipment_form set step=step+1,total_result='" + total_result + "',finish_date='" + time + "'where form_id='" + Request.QueryString["form_id"] + "'", conn);
  146.             cmd.ExecuteNonQuery();
  147.         }
  148.         else
  149.         {
  150.             cmd = new SqlCommand("update oa_equipment_form set step=step+1,total_result='" + total_result + "',finish_date=''where form_id='" + Request.QueryString["form_id"] + "'", conn);
  151.             cmd.ExecuteNonQuery();
  152.         }
  153.         if ((step + 1) <= max_step)
  154.         {
  155.             if (RbAgree.SelectedValue.Equals("Y"))
  156.             {
  157.                 ArrayList name1 = new ArrayList();
  158.                 ArrayList mail1 = new ArrayList();
  159.                 cmd = new SqlCommand("select f.email_work,f.emp_name from oa_employee as f,oa_equipment_flow as g where f.id=g.operator_id and form_id='" + Request.QueryString["form_id"] + "'and step='" + (step + 1) + "'", conn);
  160.                 SqlDataReader dr = cmd.ExecuteReader();
  161.                 if (dr.HasRows)
  162.                 {
  163.                     while (dr.Read())
  164.                     {
  165.                         name1.Add(dr["emp_name"].ToString());
  166.                         mail1.Add(dr["email_work"].ToString());
  167.                     }
  168.                 }
  169.                 mail.mail_q(mail1[0], name1[0], TextBox2.Text, "設備申請單");
  170.                 dr.Close();
  171.             }
  172.         }
  173.         conn.Close();
  174.         Response.Redirect("deal_list.aspx");
  175.     }
  176.     protected void RbAgree_SelectedIndexChanged(object sender, EventArgs e)
  177.     {
  178.         if (TxtComment.Text.Equals("已同意") || TxtComment.Text.Equals("不同意"))
  179.         {
  180.             if (RbAgree.SelectedValue.Equals("Y"))
  181.             {
  182.                 TxtComment.Text = "已同意";
  183.             }
  184.             else
  185.             {
  186.                 TxtComment.Text = "不同意";
  187.             }
  188.         }
  189.     }
  190.     protected void ShowMessageBox(string strMessage)
  191.     {
  192.         Response.Write(string.Format("<script>alert('{0}')</script>", strMessage));
  193.     }
  194.     protected void TextBox2_TextChanged(object sender, EventArgs e)
  195.     {
  196.     }
  197.     protected void MultiView1_ActiveViewChanged(object sender, EventArgs e)
  198.     {
  199.     }
  200. }