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

OA系统

开发平台:

ASP/ASPX

  1. using System;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4. using System.Configuration;
  5. using System.Collections;
  6. using System.Web;
  7. using System.Web.Security;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.WebControls.WebParts;
  11. using System.Web.UI.HtmlControls;
  12. public partial class web_data_repair_deal1 : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.         string userid="10";
  17.         string str = Session["user_id"].ToString();
  18.         if (!IsPostBack)
  19.         {
  20.             this.MultiView1.Visible = true;
  21.         }
  22.         if (!str.Equals(userid))
  23.         {
  24.             this.SetTable();
  25.             MultiView1.ActiveViewIndex = 0;
  26.         }
  27.         else
  28.         {
  29.             this.SetTab();
  30.             MultiView1.ActiveViewIndex = 1;
  31.         }
  32.     }
  33.     public void SetTable()
  34.     {
  35.         MultiView1.ActiveViewIndex = 0;
  36.         lb_no.Text = Request.QueryString["form_id"].ToString();
  37.         string str = "";
  38.         SqlConnection conn = dbConnection.getConnection();
  39.         conn.Open();
  40.         SqlCommand sqlcom3 = new SqlCommand("select emp_name from OA_EMPLOYEE where id='" + Request.QueryString["emp_id"] + "'", conn);
  41.         lb_person.Text = sqlcom3.ExecuteScalar().ToString();
  42.         SqlCommand sqlemp = new SqlCommand("select emp_id from OA_REPAIR_FORM where form_id='" + Request.QueryString["form_id"].ToString() + "'", conn);
  43.         str = sqlemp.ExecuteScalar().ToString();
  44.         SqlCommand sqlcom = new SqlCommand("select f.eq_type as eq_type,f.eq_detail as eq_detail,g.name as name,g.tel as tel,f.company as company,f.content as content from OA_REPAIR_FORM_DETAIL as f,OA_DEPARTMENT as g where g.id=f.department_id and f.form_id='" + Request.QueryString["form_id"].ToString() + "'", conn);
  45.         SqlDataReader dr = sqlcom.ExecuteReader();
  46.         if (dr.HasRows)
  47.         {
  48.             while (dr.Read())
  49.             {
  50.                 lb_department.Text = dr["name"].ToString();
  51.                 lb_tel.Text = dr["tel"].ToString();
  52.                 lb_type.Text = dr["eq_type"].ToString();
  53.                 lb_equipment.Text = dr["eq_detail"].ToString();
  54.                 company.Text = dr["company"].ToString();
  55.                 comment.Text = dr["content"].ToString().Replace("/n", "<br>");
  56.             }
  57.         }
  58.         dr.Close();
  59.         SqlCommand sqlcom1 = new SqlCommand("select * from OA_REPAIR_FLOW where form_id='" + Request.QueryString["form_id"].ToString() + "' order by step", conn);
  60.         SqlDataReader dr1 = sqlcom1.ExecuteReader();
  61.         if (dr1.HasRows)
  62.         {
  63.             while (dr1.Read())
  64.             {
  65.                 TableRow tr = new TableRow();
  66.                 TableCell td = new TableCell();
  67.                 td.BorderWidth = Unit.Pixel(1);
  68.                 td.Text = dr1["step"].ToString();
  69.                 tr.Cells.Add(td);
  70.                 td = new TableCell();
  71.                 td.BorderWidth = Unit.Pixel(1);
  72.                 SqlConnection conn1 = dbConnection.getConnection();
  73.                 conn1.Open();
  74.                 SqlCommand sqlcom2 = new SqlCommand("select emp_name from OA_EMPLOYEE where id='" + dr1["operator_id"].ToString() + "'", conn1);
  75.                 SqlDataReader dr2 = sqlcom2.ExecuteReader();
  76.                 if (dr2.HasRows)
  77.                 {
  78.                     while (dr2.Read())
  79.                     {
  80.                         td.Text = dr2["emp_name"].ToString();
  81.                     }
  82.                 }
  83.                 tr.Cells.Add(td);
  84.                 dr2.Close();
  85.                 conn1.Close();
  86.                 td = new TableCell();
  87.                 td.BorderWidth = Unit.Pixel(1);
  88.                 td.Text = "審批";
  89.                 tr.Cells.Add(td);
  90.                 td = new TableCell();
  91.                 td.BorderWidth = Unit.Pixel(1);
  92.                 if (dr1["is_check"].ToString().Equals("N"))
  93.                 {
  94.                     td.Text = "未處理";
  95.                 }
  96.                 else
  97.                 {
  98.                     td.Text = "已處理";
  99.                 }
  100.                 tr.Cells.Add(td);
  101.                 td = new TableCell();
  102.                 td.BorderWidth = Unit.Pixel(1);
  103.                 if (dr1["is_check"].ToString().Equals("Y"))
  104.                 {
  105.                     if (dr1["is_agree"].ToString().Equals("Y"))
  106.                     {
  107.                         td.Text = "已通知";
  108.                     }
  109.                     else
  110.                     {
  111.                         td.Text = "未通知";
  112.                     }
  113.                 }
  114.                 else
  115.                 {
  116.                     td.Text = "<br>";
  117.                 }
  118.                 tr.Cells.Add(td);
  119.                 td = new TableCell();
  120.                 td.BorderWidth = Unit.Pixel(1);
  121.                 if (!dr1["comment"].ToString().Equals(""))
  122.                 {
  123.                     td.Text = dr1["comment"].ToString();
  124.                 }
  125.                 else
  126.                 {
  127.                     td.Text = "<br>";
  128.                 }
  129.                 tr.Cells.Add(td);
  130.                 td = new TableCell();
  131.                 td.BorderWidth = Unit.Pixel(1);
  132.                 if (!dr1["check_time"].ToString().Equals(""))
  133.                 {
  134.                     td.Text = dr1["check_time"].ToString();
  135.                 }
  136.                 else
  137.                 {
  138.                     td.Text = "<br>";
  139.                 }
  140.                 tr.Cells.Add(td);
  141.                 FlowTable.Rows.Add(tr);
  142.             }
  143.         }
  144.         dr1.Close();
  145.         conn.Close();
  146.     }
  147.     public void SetTab()
  148.     {
  149.         MultiView1.ActiveViewIndex = 1;
  150.         lbno.Text = Request.QueryString["form_id"].ToString();
  151.         string str = "";
  152.         SqlConnection conn = dbConnection.getConnection();
  153.         conn.Open();
  154.         SqlCommand sqlcom3 = new SqlCommand("select emp_name from OA_EMPLOYEE where id='" + Request.QueryString["emp_id"] + "'", conn);
  155.         lbperson.Text = sqlcom3.ExecuteScalar().ToString();
  156.         SqlCommand sqlemp = new SqlCommand("select emp_id from OA_REPAIR_FORM where form_id='" + Request.QueryString["form_id"].ToString() + "'", conn);
  157.         str = sqlemp.ExecuteScalar().ToString();
  158.         SqlCommand sqlcom = new SqlCommand("select f.eq_type as eq_type,f.eq_detail as eq_detail,g.name as name,g.tel as tel, f.content as content from OA_REPAIR_FORM_DETAIL as f,OA_DEPARTMENT as g where g.id=f.department_id and f.form_id='" + Request.QueryString["form_id"].ToString() + "'", conn);
  159.         SqlDataReader dr = sqlcom.ExecuteReader();
  160.         if (dr.HasRows)
  161.         {
  162.             while (dr.Read())
  163.             {
  164.                 lbdepartment.Text = dr["name"].ToString();
  165.                 lbtel.Text = dr["tel"].ToString();
  166.                 lbtype.Text = dr["eq_type"].ToString();
  167.                 lbname.Text = dr["eq_detail"].ToString();
  168.                 connet.Text = dr["content"].ToString().Replace("/n", "<br>");
  169.             }
  170.         }
  171.         dr.Close();
  172.         SqlCommand sqlcom1 = new SqlCommand("select * from OA_REPAIR_FLOW where form_id='" + Request.QueryString["form_id"].ToString() + "' order by step", conn);
  173.         SqlDataReader dr1 = sqlcom1.ExecuteReader();
  174.         if (dr1.HasRows)
  175.         {
  176.             while (dr1.Read())
  177.             {
  178.                 TableRow tr = new TableRow();
  179.                 TableCell td = new TableCell();
  180.                 td.BorderWidth = Unit.Pixel(1);
  181.                 td.Text = dr1["step"].ToString();
  182.                 tr.Cells.Add(td);
  183.                 td = new TableCell();
  184.                 td.BorderWidth = Unit.Pixel(1);
  185.                 SqlConnection conn1 = dbConnection.getConnection();
  186.                 conn1.Open();
  187.                 SqlCommand sqlcom2 = new SqlCommand("select emp_name from OA_EMPLOYEE where id='" + dr1["operator_id"].ToString() + "'", conn1);
  188.                 SqlDataReader dr2 = sqlcom2.ExecuteReader();
  189.                 if (dr2.HasRows)
  190.                 {
  191.                     while (dr2.Read())
  192.                     {
  193.                         td.Text = dr2["emp_name"].ToString();
  194.                     }
  195.                 }
  196.                 tr.Cells.Add(td);
  197.                 dr2.Close();
  198.                 conn1.Close();
  199.                 td = new TableCell();
  200.                 td.BorderWidth = Unit.Pixel(1);
  201.                 td.Text = "審批";
  202.                 tr.Cells.Add(td);
  203.                 td = new TableCell();
  204.                 td.BorderWidth = Unit.Pixel(1);
  205.                 if (dr1["is_check"].ToString().Equals("N"))
  206.                 {
  207.                     td.Text = "未完工";
  208.                 }
  209.                 else
  210.                 {
  211.                     td.Text = "已完工";
  212.                 }
  213.                 tr.Cells.Add(td);
  214.                 td = new TableCell();
  215.                 td.BorderWidth = Unit.Pixel(1);
  216.                 if (dr1["is_check"].ToString().Equals("Y"))
  217.                 {
  218.                     if (dr1["is_agree"].ToString().Equals("Y"))
  219.                     {
  220.                         td.Text = "已完工";
  221.                     }
  222.                     else
  223.                     {
  224.                         td.Text = "未完工";
  225.                     }
  226.                 }
  227.                 else
  228.                 {
  229.                     td.Text = "<br>";
  230.                 }
  231.                 tr.Cells.Add(td);
  232.                 td = new TableCell();
  233.                 td.BorderWidth = Unit.Pixel(1);
  234.                 if (!dr1["comment"].ToString().Equals(""))
  235.                 {
  236.                     td.Text = dr1["comment"].ToString();
  237.                 }
  238.                 else
  239.                 {
  240.                     td.Text = "<br>";
  241.                 }
  242.                 tr.Cells.Add(td);
  243.                 td = new TableCell();
  244.                 td.BorderWidth = Unit.Pixel(1);
  245.                 if (!dr1["check_time"].ToString().Equals(""))
  246.                 {
  247.                     td.Text = dr1["check_time"].ToString();
  248.                 }
  249.                 else
  250.                 {
  251.                     td.Text = "<br>";
  252.                 }
  253.                 tr.Cells.Add(td);
  254.                 FlowTable.Rows.Add(tr);
  255.             }
  256.         }
  257.         dr1.Close();
  258.         conn.Close();
  259.     }
  260.     protected void RbAgree_SelectedIndexChanged(object sender, EventArgs e)
  261.     {
  262.         if (TxtComment.Text.Equals("已完工") || TxtComment.Text.Equals("未完工"))
  263.         {
  264.             if (RbAgree.SelectedValue.Equals("Y"))
  265.             {
  266.                 TxtComment.Text = "已完工";
  267.             }
  268.             else
  269.             {
  270.                 TxtComment.Text = "未完工";
  271.             }
  272.         }
  273.     }
  274.     protected void ShowMessageBox(string strMessage)
  275.     {
  276.         Response.Write(string.Format("<script>alert('{0}')</script>", strMessage));
  277.     }
  278.     protected void BtnOk_Click(object sender, EventArgs e)
  279.     {
  280.         string total_result = "跑流程中";
  281.         string time = "";
  282.         string str = "";
  283.         SqlConnection conn = dbConnection.getConnection();
  284.         conn.Open();
  285.         DateMgr mgr = new DateMgr();
  286.         SqlCommand cmd = new SqlCommand("update OA_REPAIR_FLOW set is_check='Y',is_agree='" + RbAgree.SelectedValue.ToString() + "',comment='" + TxtComment.Text.Replace("n", "<br>") + "',check_time='" + mgr.getTime().ToString() + "'where form_id='" + Request.QueryString["form_id"] + "'and operator_id='" + Session["user_id"] + "'", conn);
  287.         cmd.ExecuteNonQuery();
  288.         cmd = new SqlCommand("select max(step) from OA_REPAIR_FLOW where form_id='" + Request.QueryString["form_id"] + "'", conn);
  289.         int max_step = 1;
  290.         max_step = Convert.ToInt32(cmd.ExecuteScalar());
  291.         cmd = new SqlCommand("select step from OA_REPAIR_FORM where form_id='" + Request.QueryString["form_id"] + "'", conn);
  292.         int step = Convert.ToInt32(cmd.ExecuteScalar());
  293.         if (step == max_step)
  294.         {
  295.             if (RbAgree.SelectedValue.Equals("N"))
  296.             {
  297.                 total_result = "未完工";
  298.             }
  299.             else
  300.             {
  301.                 total_result = "已完工";
  302.             }
  303.             time = mgr.getDateTime();
  304.         }
  305.         else
  306.         {
  307.             if (RbAgree.SelectedValue.Equals("N"))
  308.             {
  309.                 total_result = "未完工";
  310.             }
  311.             time = mgr.getDateTime();
  312.         }
  313.         SqlCommand sqlcom = new SqlCommand("select emp_id from OA_REPAIR_FORM where form_id='" + Request.QueryString["form_id"].ToString() + "'", conn);
  314.         SqlDataReader dr = sqlcom.ExecuteReader();
  315.         if (dr.HasRows)
  316.         {
  317.             while (dr.Read())
  318.             {
  319.                 str = dr["emp_id"].ToString();
  320.             }
  321.         }
  322.         dr.Close();
  323.         if (MultiView1.ActiveViewIndex==1)
  324.         {
  325.             if (dll.SelectedItem != null)
  326.             {
  327.                 SqlCommand sqlpany = new SqlCommand("update OA_REPAIR_FORM_DETAIL set company='" + dll.SelectedItem.ToString() + "' where form_id='" + Request.QueryString["form_id"].ToString() + "'", conn);
  328.                 sqlpany.ExecuteNonQuery();
  329.                 int no = 1;
  330.                 SqlCommand sqlcheck = new SqlCommand("select max(id) from OA_COMPANY_CHECK", conn);
  331.                 try
  332.                 {
  333.                     no = Convert.ToInt32(sqlcheck.ExecuteScalar()) + 1;
  334.                 }
  335.                 catch
  336.                 {
  337.                 }
  338.                 SqlCommand sqlcompany = new SqlCommand("insert into OA_COMPANY_CHECK(id,company,form_id,comment,is_check,is_agree,check_time)values('" + no + "','" + dll.SelectedItem.ToString() + "','" + Request.QueryString["form_id"].ToString() + "','','N','','')", conn);
  339.                 sqlcompany.ExecuteNonQuery();
  340.             }
  341.         }
  342.         else
  343.         {
  344.         }
  345.         if (step == max_step)
  346.         {
  347.             cmd = new SqlCommand("update OA_REPAIR_FORM set step=step+1,total_result='" + total_result + "',finish_time='" + time + "'where form_id='" + Request.QueryString["form_id"] + "'", conn);
  348.             cmd.ExecuteNonQuery();
  349.         }
  350.         else
  351.         {
  352.             cmd = new SqlCommand("update OA_REPAIR_FORM set step=step+1,total_result='" + total_result + "',finish_time=''where form_id='" + Request.QueryString["form_id"] + "'", conn);
  353.             cmd.ExecuteNonQuery();
  354.         }
  355.         conn.Close();
  356.         Response.Redirect("deal_list.aspx");
  357.     }
  358.     public void SetLable()
  359.     {
  360.         person.Text = "";
  361.         tel.Text = "";
  362.         phone.Text = "";
  363.         SqlConnection conn = dbConnection.getConnection();
  364.         conn.Open();
  365.         if (dll.Items.Count > 0)
  366.         {
  367.             if (!(dll.SelectedItem.ToString().Equals("")))
  368.             {
  369.                 SqlCommand sqlcom = new SqlCommand("select contact_person,mobile_tel,phone from oa_company where company='" + dll.SelectedItem.ToString() + "'", conn);
  370.                 SqlDataReader dr = sqlcom.ExecuteReader();
  371.                 if (dr.HasRows)
  372.                 {
  373.                     while (dr.Read())
  374.                     {
  375.                         person.Text = dr["contact_person"].ToString();
  376.                         tel.Text = dr["mobile_tel"].ToString();
  377.                         phone.Text = dr["phone"].ToString();
  378.                     }
  379.                 }
  380.                 dr.Close();
  381.             }
  382.         }
  383.         conn.Close();
  384.     }
  385.     protected void dll_SelectedIndexChanged(object sender, EventArgs e)
  386.     {
  387.         SetLable();
  388.     }
  389.     protected void dltype_SelectedIndexChanged(object sender, EventArgs e)
  390.     {
  391.         person.Text = "";
  392.         tel.Text = "";
  393.         phone.Text = "";
  394.     }
  395. }