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

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_form_add : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.         if (!IsPostBack)
  17.         {
  18.             SqlConnection conn = dbConnection.getConnection();
  19.             conn.Open();
  20.             DateMgr mgr = new DateMgr();
  21.             lb_no.Text = mgr.getTime();
  22.             dll_department.SelectedIndex = 0;
  23.             dll_company.SelectedIndex = 0;
  24.             SqlCommand sqlcom = new SqlCommand("select tel from OA_DEPARTMENT where id='"+dll_department.SelectedValue.ToString()+"'",conn);
  25.             SqlDataReader dr = sqlcom.ExecuteReader();
  26.             if (dr.HasRows)
  27.             {
  28.                 while (dr.Read())
  29.                 {
  30.                     lb_tel.Text = dr["tel"].ToString();
  31.                 }
  32.             }
  33.             dr.Close();
  34.             SqlCommand sqlcom1 = new SqlCommand("select emp_name from OA_EMPLOYEE where id=" + Convert.ToInt32(Session["user_id"]), conn);
  35.             SqlDataReader dr1 = sqlcom1.ExecuteReader();
  36.             if (dr1.HasRows)
  37.             {
  38.                 while (dr1.Read())
  39.                 {
  40.                     lb_person.Text = dr1["emp_name"].ToString();
  41.                 }
  42.             }
  43.             dr1.Close();
  44.             conn.Close();
  45.         }
  46.     }
  47.     protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
  48.     {
  49.         SqlConnection conn = dbConnection.getConnection();
  50.         conn.Open();
  51.         SqlCommand sqlcom = new SqlCommand("select tel from OA_DEPARTMENT where id=" + Convert.ToInt32(dll_department.SelectedValue), conn);
  52.         SqlDataReader dr = sqlcom.ExecuteReader();
  53.         if (dr.HasRows)
  54.         {
  55.             while (dr.Read())
  56.             {
  57.                 lb_tel.Text = dr["tel"].ToString();
  58.             }
  59.         }
  60.     }
  61.     protected void Button1_Click(object sender, EventArgs e)
  62.     {
  63.         int id = 1;
  64.         int step=1;
  65.         int order_id = 0;
  66.         SqlConnection conn = dbConnection.getConnection();
  67.         conn.Open();
  68.         SqlCommand sqlemp = new SqlCommand("select id from OA_EMPLOYEE where position='19' and department_id='" + dll_department.SelectedValue.ToString() + "'", conn);
  69.         SqlDataReader dremp = sqlemp.ExecuteReader();
  70.         if (dremp.HasRows)
  71.         {
  72.             while (dremp.Read())
  73.             {
  74.                 order_id = Convert.ToInt32(dremp["id"]);
  75.             }
  76.         }
  77.         dremp.Close();
  78.         if (order_id != 0)
  79.         {
  80.             DateMgr mgr = new DateMgr();
  81.             SqlCommand sqlcom = new SqlCommand("select max(id) as id from OA_COMPANY_CHECK", conn);
  82.             SqlDataReader dr = sqlcom.ExecuteReader();
  83.             if (dr.HasRows)
  84.             {
  85.                 while (dr.Read())
  86.                 {
  87.                     if (dr["id"].ToString().Equals(""))
  88.                     {
  89.                     }
  90.                     else
  91.                     {
  92.                         id = Convert.ToInt32(dr["id"]) + 1;
  93.                     }
  94.                 }
  95.             }
  96.             dr.Close();
  97.             SqlCommand sqlcompany = new SqlCommand("insert into OA_COMPANY_CHECK(id,company,form_id,comment,is_check,is_agree,check_time)values(" + id + ",'" + dll_company.SelectedItem.ToString() + "','" + lb_no.Text.ToString() + "','" + comment.Text.Replace("<br>", "/n").ToString() + "','N','','')", conn);
  98.             sqlcompany.ExecuteNonQuery();
  99.             id = 1;
  100.             SqlCommand sqlcom1 = new SqlCommand("select max(id) as id from OA_REPAIR_FORM", conn);
  101.             SqlDataReader dr1 = sqlcom1.ExecuteReader();
  102.             if (dr1.HasRows)
  103.             {
  104.                 while (dr1.Read())
  105.                 {
  106.                     if (dr1["id"].ToString().Equals(""))
  107.                     {
  108.                     }
  109.                     else
  110.                     {
  111.                         id = Convert.ToInt32(dr1["id"]) + 1;
  112.                     }
  113.                 }
  114.             }
  115.             dr1.Close();
  116.             SqlCommand sqlform = new SqlCommand("insert into OA_REPAIR_FORM(id,form_id,emp_id,apply_time,step,finish_time,status,total_result)values(" + id + ",'" + lb_no.Text.ToString() + "','" + Session["user_id"] + "','" + mgr.getTime() + "','1','','1','跑流程中')", conn);
  117.             sqlform.ExecuteNonQuery();
  118.             id = 1;
  119.             SqlCommand sqlcom2 = new SqlCommand("select max(id) as id from OA_REPAIR_FORM_DETAIL", conn);
  120.             SqlDataReader dr2 = sqlcom2.ExecuteReader();
  121.             if (dr2.HasRows)
  122.             {
  123.                 while (dr2.Read())
  124.                 {
  125.                     if (dr2["id"].ToString().Equals(""))
  126.                     {
  127.                     }
  128.                     else
  129.                     {
  130.                         id = Convert.ToInt32(dr2["id"]) + 1;
  131.                     }
  132.                 }
  133.             }
  134.             dr2.Close();
  135.             SqlCommand sqldetail = new SqlCommand("insert into OA_REPAIR_FORM_DETAIL(id,form_id,department_id,eq_type,eq_detail,company,conteNt)values(" + id + ",'" + lb_no.Text.ToString() + "','" + dll_department.SelectedValue.ToString() + "','" + dll_type.SelectedItem.ToString() + "','" + dll_equipment.SelectedItem.ToString() + "','" + dll_company.SelectedItem.ToString() + "','" + comment.Text.ToString() + "')", conn);
  136.             sqldetail.ExecuteNonQuery();
  137.             id = 1;
  138.             SqlCommand sqlcom3 = new SqlCommand("select max(id) as id from OA_REPAIR_FLOW", conn);
  139.             SqlDataReader dr3 = sqlcom3.ExecuteReader();
  140.             if (dr3.HasRows)
  141.             {
  142.                 while (dr3.Read())
  143.                 {
  144.                     if (dr3["id"].ToString().Equals(""))
  145.                     {
  146.                     }
  147.                     else
  148.                     {
  149.                         id = Convert.ToInt32(dr3["id"]) + 1;
  150.                     }
  151.                 }
  152.             }
  153.             dr3.Close();
  154.             //SqlCommand sqlflow = new SqlCommand("insert into OA_REPAIR_FLOW(id,form_id,operator_id,is_check,is_agree,comment,check_time,step)values(" + id + ",'" + lb_no.Text + "','" + Session["user_id"].ToString() + "','N','','','','1')", conn);
  155.             //sqlflow.ExecuteNonQuery();
  156.             SqlCommand sqlflow1 = new SqlCommand("insert into OA_REPAIR_FLOW(id,form_id,operator_id,is_check,is_agree,comment,check_time,step)values(" + id + ",'" + lb_no.Text + "','" + order_id + "','N','','','','1')", conn);
  157.             sqlflow1.ExecuteNonQuery();
  158.             Response.Redirect("my_list.aspx");
  159.         }
  160.         else
  161.         {
  162.             ShowMessageBox("找不到相关流程请联系管理员");
  163.         }
  164.     }
  165.     protected void ShowMessageBox(string strMessage)
  166.     {
  167.         Response.Write(string.Format("<script>alert('{0}')</script>", strMessage));
  168.     }
  169.     protected void dll_question_SelectedIndexChanged1(object sender, EventArgs e)
  170.     {
  171.         comment.Text = "";
  172.         if (dll_question.SelectedItem.ToString().Equals("其他"))
  173.         {
  174.         }
  175.         else
  176.         {
  177.             comment.Text = dll_question.SelectedItem.ToString();
  178.         }
  179.     }
  180. }