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

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_equipment_form : System.Web.UI.Page
  13. {
  14.     string departmentid = "";
  15.     string PositionId = "";
  16.     string userid = "";
  17.     int flow_id = 1;
  18.     protected void Page_Load(object sender, EventArgs e)
  19.     {
  20.         if (!IsPostBack)
  21.         {
  22.             LoginDAO.CheckLogin(Session, Response, "../", 2);
  23.         }
  24.         if (Session["user"] != null)
  25.         {
  26.             DateMgr mgr = new DateMgr();
  27.             User user = (User)Session["user"];
  28.             IFromNo.Text = mgr.getTime();
  29.             txemp_name.Text = user.Emp_name;
  30.             tbdate.Text = mgr.getDate();
  31.             tbdepartment.Text = user.Department.Full_name;
  32.             PositionId = user.PositionId.ToString();
  33.             departmentid = user.Department.Id.ToString();
  34.             userid = user.Id.ToString();
  35.         }
  36.     }
  37.     public void check()
  38.     {
  39.         SqlConnection conn = dbConnection.getConnection();
  40.         conn.Open();
  41.         string sql = "";
  42.         if (!name1.Text.Equals(""))
  43.         {
  44.             try
  45.             {
  46.                 int id = 1;
  47.                 SqlCommand cmd = new SqlCommand("select max(id) from oa_equipment_form_d", conn);
  48.                 try
  49.                 {
  50.                     id = Convert.ToInt32(cmd.ExecuteScalar().ToString()) + 1;
  51.                 }
  52.                 catch
  53.                 {
  54.                 }
  55.                 string type = "";
  56.                 string charge = "";
  57.                 if (cb_1_1.Checked)
  58.                 {
  59.                     if (type.Equals(""))
  60.                     {
  61.                         type = cb_1_1.Text.ToString();
  62.                         charge = charge1_1.Text.ToString();
  63.                     }
  64.                     else
  65.                     {
  66.                         type = type + "/" + cb_1_1.Text.ToString();
  67.                         charge = charge + "/" + charge1_1.Text.ToString();
  68.                     }
  69.                 }
  70.                 if (cb_2_1.Checked)
  71.                 {
  72.                     if (type.Equals(""))
  73.                     {
  74.                         type = cb_2_1.Text.ToString();
  75.                         charge = charge2_1.Text.ToString();
  76.                     }
  77.                     else
  78.                     {
  79.                         type = type + "/" + cb_2_1.Text.ToString();
  80.                         charge = charge + "/" + charge2_1.Text.ToString();
  81.                     }
  82.                 }
  83.                 sql = "insert into oa_equipment_form_d(id,form_id,equipment_name,standard,equipment_unit,equipment_num,cause,apply_date,type,charge,remark)values('" +id+"','"+
  84.                      IFromNo.Text.ToString() + "','" + name1.Text.ToString() + "','" + standard1.Text + "','" + unit1.Text.ToString() + "','" + num1.Text.ToString() + "','" +
  85.                     cause1.Text.ToString() + "','" + date1.Text.ToString() + "','" + type + "','" + charge + "','" + remark1.Text.ToString() + "')";
  86.                 cmd = new SqlCommand(sql, conn);
  87.                 cmd.ExecuteNonQuery();
  88.             }
  89.             catch (Exception ex)
  90.             {
  91.                 Response.Write(ex.Message);
  92.             }
  93.         }
  94.         if (!name2.Text.Equals(""))
  95.         {
  96.             try
  97.             {
  98.                 int id = 1;
  99.                 SqlCommand cmd = new SqlCommand("select max(id) from oa_equipment_form_d", conn);
  100.                 try
  101.                 {
  102.                     id = Convert.ToInt32(cmd.ExecuteScalar().ToString()) + 1;
  103.                 }
  104.                 catch
  105.                 {
  106.                 }
  107.                 string type = "";
  108.                 string charge = "";
  109.                 if (cb_1_2.Checked)
  110.                 {
  111.                     if (type.Equals(""))
  112.                     {
  113.                         type = cb_1_2.Text.ToString();
  114.                         charge = charge1_2.Text.ToString();
  115.                     }
  116.                     else
  117.                     {
  118.                         type = type + "/" + cb_1_2.Text.ToString();
  119.                         charge = charge + "/" + charge1_2.Text.ToString();
  120.                     }
  121.                 }
  122.                 if (cb_2_1.Checked)
  123.                 {
  124.                     if (type.Equals(""))
  125.                     {
  126.                         type = cb_2_2.Text.ToString();
  127.                         charge = charge2_2.Text.ToString();
  128.                     }
  129.                     else
  130.                     {
  131.                         type = type + "/" + cb_2_2.Text.ToString();
  132.                         charge = charge + "/" + charge2_2.Text.ToString();
  133.                     }
  134.                 }
  135.                 sql = "insert into oa_equipment_form_d(id,form_id,equipment_name,standard,equipment_unit,equipment_num,cause,apply_date,type,charge,remark)values('" +
  136.                     id + "','" + IFromNo.Text.ToString() + "','" + name2.Text.ToString() + "','" + standard2.Text + "','" + unit2.Text.ToString() + "','" + num2.Text.ToString() + "','" +
  137.                     cause2.Text.ToString() + "','" + date2.Text.ToString() + "','" + type + "','" + charge + "','" + remark2.Text.ToString() + "')";
  138.                 cmd = new SqlCommand(sql, conn);
  139.                 cmd.ExecuteNonQuery();
  140.             }
  141.             catch (Exception ex)
  142.             {
  143.                 Response.Write(ex.Message);
  144.             }
  145.         }
  146.         if (!name3.Text.Equals(""))
  147.         {
  148.             try
  149.             {
  150.                 int id = 1;
  151.                 SqlCommand cmd = new SqlCommand("select max(id) from oa_equipment_form_d", conn);
  152.                 try
  153.                 {
  154.                     id = Convert.ToInt32(cmd.ExecuteScalar().ToString()) + 1;
  155.                 }
  156.                 catch
  157.                 {
  158.                 }
  159.                 string type = "";
  160.                 string charge = "";
  161.                 if (cb_1_3.Checked)
  162.                 {
  163.                     if (type.Equals(""))
  164.                     {
  165.                         type = cb_1_3.Text.ToString();
  166.                         charge = charge1_3.Text.ToString();
  167.                     }
  168.                     else
  169.                     {
  170.                         type = type + "/" + cb_1_3.Text.ToString();
  171.                         charge = charge + "/" + charge1_3.Text.ToString();
  172.                     }
  173.                 }
  174.                 if (cb_2_3.Checked)
  175.                 {
  176.                     if (type.Equals(""))
  177.                     {
  178.                         type = cb_2_3.Text.ToString();
  179.                         charge = charge2_3.Text.ToString();
  180.                     }
  181.                     else
  182.                     {
  183.                         type = type + "/" + cb_2_3.Text.ToString();
  184.                         charge = charge + "/" + charge2_3.Text.ToString();
  185.                     }
  186.                 }
  187.                 sql = "insert into oa_equipment_form_d(id,form_id,equipment_name,standard,equipment_unit,equipment_num,cause,apply_date,type,charge,remark)values('" +
  188.                     id + "','" + IFromNo.Text.ToString() + "','" + name3.Text.ToString() + "','" + standard3.Text + "','" + unit3.Text.ToString() + "','" + num3.Text.ToString() + "','" +
  189.                     cause3.Text.ToString() + "','" + date3.Text.ToString() + "','" + type + "','" + charge + "','" + remark3.Text.ToString() + "')";
  190.                 cmd = new SqlCommand(sql, conn);
  191.                 cmd.ExecuteNonQuery();
  192.             }
  193.             catch (Exception ex)
  194.             {
  195.                 Response.Write(ex.Message);
  196.             }
  197.         }
  198.         if (!name4.Text.Equals(""))
  199.         {
  200.             try
  201.             {
  202.                 int id = 1;
  203.                 SqlCommand cmd = new SqlCommand("select max(id) from oa_equipment_form_d", conn);
  204.                 try
  205.                 {
  206.                     id = Convert.ToInt32(cmd.ExecuteScalar().ToString()) + 1;
  207.                 }
  208.                 catch
  209.                 {
  210.                 }
  211.                 string type = "";
  212.                 string charge = "";
  213.                 if (cb_1_4.Checked)
  214.                 {
  215.                     if (type.Equals(""))
  216.                     {
  217.                         type = cb_1_4.Text.ToString();
  218.                         charge = charge1_4.Text.ToString();
  219.                     }
  220.                     else
  221.                     {
  222.                         type = type + "/" + cb_1_4.Text.ToString();
  223.                         charge = charge + "/" + charge1_4.Text.ToString();
  224.                     }
  225.                 }
  226.                 if (cb_2_4.Checked)
  227.                 {
  228.                     if (type.Equals(""))
  229.                     {
  230.                         type = cb_2_4.Text.ToString();
  231.                         charge = charge2_4.Text.ToString();
  232.                     }
  233.                     else
  234.                     {
  235.                         type = type + "/" + cb_2_4.Text.ToString();
  236.                         charge = charge + "/" + charge2_4.Text.ToString();
  237.                     }
  238.                 }
  239.                 sql = "insert into oa_equipment_form_d(id,form_id,equipment_name,standard,equipment_unit,equipment_num,cause,apply_date,type,charge,remark)values('" +
  240.                     id + "','" + IFromNo.Text.ToString() + "','" + name4.Text.ToString() + "','" + standard4.Text + "','" + unit4.Text.ToString() + "','" + num4.Text.ToString() + "','" +
  241.                     cause4.Text.ToString() + "','" + date4.Text.ToString() + "','" + type + "','" + charge + "','" + remark4.Text.ToString() + "')";
  242.                 cmd = new SqlCommand(sql, conn);
  243.                 cmd.ExecuteNonQuery();
  244.             }
  245.             catch (Exception ex)
  246.             {
  247.                 Response.Write(ex.Message);
  248.             }
  249.         }
  250.         if (!name5.Text.Equals(""))
  251.         {
  252.             try
  253.             {
  254.                 int id = 1;
  255.                 SqlCommand cmd = new SqlCommand("select max(id) from oa_equipment_form_d", conn);
  256.                 try
  257.                 {
  258.                     id = Convert.ToInt32(cmd.ExecuteScalar().ToString()) + 1;
  259.                 }
  260.                 catch
  261.                 {
  262.                 }
  263.                 string type = "";
  264.                 string charge = "";
  265.                 if (cb_1_5.Checked)
  266.                 {
  267.                     if (type.Equals(""))
  268.                     {
  269.                         type = cb_1_5.Text.ToString();
  270.                         charge = charge1_5.Text.ToString();
  271.                     }
  272.                     else
  273.                     {
  274.                         type = type + "/" + cb_1_5.Text.ToString();
  275.                         charge = charge + "/" + charge1_5.Text.ToString();
  276.                     }
  277.                 }
  278.                 if (cb_2_5.Checked)
  279.                 {
  280.                     if (type.Equals(""))
  281.                     {
  282.                         type = cb_2_5.Text.ToString();
  283.                         charge = charge2_5.Text.ToString();
  284.                     }
  285.                     else
  286.                     {
  287.                         type = type + "/" + cb_2_5.Text.ToString();
  288.                         charge = charge + "/" + charge2_5.Text.ToString();
  289.                     }
  290.                 }
  291.                 sql = "insert into oa_equipment_form_d(id,form_id,equipment_name,standard,equipment_unit,equipment_num,cause,apply_date,type,charge,remark)values('" +
  292.                     id + "','" + IFromNo.Text.ToString() + "','" + name5.Text.ToString() + "','" + standard5.Text + "','" + unit5.Text.ToString() + "','" + num5.Text.ToString() + "','" +
  293.                     cause5.Text.ToString() + "','" + date5.Text.ToString() + "','" + type + "','" + charge + "','" + remark5.Text.ToString() + "')";
  294.                 cmd = new SqlCommand(sql, conn);
  295.                 cmd.ExecuteNonQuery();
  296.             }
  297.             catch (Exception ex)
  298.             {
  299.                 Response.Write(ex.Message);
  300.             }
  301.         }
  302.         if (!name6.Text.Equals(""))
  303.         {
  304.             try
  305.             {
  306.                 int id = 1;
  307.                 SqlCommand cmd = new SqlCommand("select max(id) from oa_equipment_form_d", conn);
  308.                 try
  309.                 {
  310.                     id = Convert.ToInt32(cmd.ExecuteScalar().ToString()) + 1;
  311.                 }
  312.                 catch
  313.                 {
  314.                 }
  315.                 string type = "";
  316.                 string charge = "";
  317.                 if (cb_1_6.Checked)
  318.                 {
  319.                     if (type.Equals(""))
  320.                     {
  321.                         type = cb_1_6.Text.ToString();
  322.                         charge = charge1_6.Text.ToString();
  323.                     }
  324.                     else
  325.                     {
  326.                         type = type + "/" + cb_1_6.Text.ToString();
  327.                         charge = charge + "/" + charge1_6.Text.ToString();
  328.                     }
  329.                 }
  330.                 if (cb_2_6.Checked)
  331.                 {
  332.                     if (type.Equals(""))
  333.                     {
  334.                         type = cb_2_6.Text.ToString();
  335.                         charge = charge2_6.Text.ToString();
  336.                     }
  337.                     else
  338.                     {
  339.                         type = type + "/" + cb_2_6.Text.ToString();
  340.                         charge = charge + "/" + charge2_6.Text.ToString();
  341.                     }
  342.                 }
  343.                 sql = "insert into oa_equipment_form_d(id,form_id,equipment_name,standard,equipment_unit,equipment_num,cause,apply_date,type,charge,remark)values('" +
  344.                     id + "','" + IFromNo.Text.ToString() + "','" + name6.Text.ToString() + "','" + standard6.Text + "','" + unit6.Text.ToString() + "','" + num6.Text.ToString() + "','" +
  345.                     cause6.Text.ToString() + "','" + date6.Text.ToString() + "','" + type + "','" + charge + "','" + remark6.Text.ToString() + "')";
  346.                 cmd = new SqlCommand(sql, conn);
  347.                 cmd.ExecuteNonQuery();
  348.             }
  349.             catch (Exception ex)
  350.             {
  351.                 Response.Write(ex.Message);
  352.             }
  353.         }
  354.         if (!name7.Text.Equals(""))
  355.         {
  356.             try
  357.             {
  358.                 int id = 1;
  359.                 SqlCommand cmd = new SqlCommand("select max(id) from oa_equipment_form_d", conn);
  360.                 try
  361.                 {
  362.                     id = Convert.ToInt32(cmd.ExecuteScalar().ToString()) + 1;
  363.                 }
  364.                 catch
  365.                 {
  366.                 }
  367.                 string type = "";
  368.                 string charge = "";
  369.                 if (cb_1_7.Checked)
  370.                 {
  371.                     if (type.Equals(""))
  372.                     {
  373.                         type = cb_1_7.Text.ToString();
  374.                         charge = charge1_7.Text.ToString();
  375.                     }
  376.                     else
  377.                     {
  378.                         type = type + "/" + cb_1_7.Text.ToString();
  379.                         charge = charge + "/" + charge1_7.Text.ToString();
  380.                     }
  381.                 }
  382.                 if (cb_2_7.Checked)
  383.                 {
  384.                     if (type.Equals(""))
  385.                     {
  386.                         type = cb_2_7.Text.ToString();
  387.                         charge = charge2_7.Text.ToString();
  388.                     }
  389.                     else
  390.                     {
  391.                         type = type + "/" + cb_2_7.Text.ToString();
  392.                         charge = charge + "/" + charge2_7.Text.ToString();
  393.                     }
  394.                 }
  395.                 sql = "insert into oa_equipment_form_d(id,form_id,equipment_name,standard,equipment_unit,equipment_num,cause,apply_date,type,charge,remark)values('" +
  396.                     id + "','" + IFromNo.Text.ToString() + "','" + name7.Text.ToString() + "','" + standard7.Text + "','" + unit7.Text.ToString() + "','" + num7.Text.ToString() + "','" +
  397.                     cause7.Text.ToString() + "','" + date7.Text.ToString() + "','" + type + "','" + charge + "','" + remark7.Text.ToString() + "')";
  398.                 cmd = new SqlCommand(sql, conn);
  399.                 cmd.ExecuteNonQuery();
  400.             }
  401.             catch (Exception ex)
  402.             {
  403.                 Response.Write(ex.Message);
  404.             }
  405.         }
  406.         if (!name8.Text.Equals(""))
  407.         {
  408.             try
  409.             {
  410.                 int id = 1;
  411.                 SqlCommand cmd = new SqlCommand("select max(id) from oa_equipment_form_d", conn);
  412.                 try
  413.                 {
  414.                     id = Convert.ToInt32(cmd.ExecuteScalar().ToString()) + 1;
  415.                 }
  416.                 catch
  417.                 {
  418.                 }
  419.                 string type = "";
  420.                 string charge = "";
  421.                 if (cb_1_8.Checked)
  422.                 {
  423.                     if (type.Equals(""))
  424.                     {
  425.                         type = cb_1_8.Text.ToString();
  426.                         charge = charge1_8.Text.ToString();
  427.                     }
  428.                     else
  429.                     {
  430.                         type = type + "/" + cb_1_8.Text.ToString();
  431.                         charge = charge + "/" + charge1_8.Text.ToString();
  432.                     }
  433.                 }
  434.                 if (cb_2_8.Checked)
  435.                 {
  436.                     if (type.Equals(""))
  437.                     {
  438.                         type = cb_2_8.Text.ToString();
  439.                         charge = charge2_8.Text.ToString();
  440.                     }
  441.                     else
  442.                     {
  443.                         type = type + "/" + cb_2_8.Text.ToString();
  444.                         charge = charge + "/" + charge2_8.Text.ToString();
  445.                     }
  446.                 }
  447.                 sql = "insert into oa_equipment_form_d(id,form_id,equipment_name,standard,equipment_unit,equipment_num,cause,apply_date,type,charge,remark)values('" +
  448.                     id + "','" + IFromNo.Text.ToString() + "','" + name8.Text.ToString() + "','" + standard8.Text + "','" + unit1.Text.ToString() + "','" + num8.Text.ToString() + "','" +
  449.                     cause8.Text.ToString() + "','" + date8.Text.ToString() + "','" + type + "','" + charge + "','" + remark8.Text.ToString() + "')";
  450.                 cmd = new SqlCommand(sql, conn);
  451.                 cmd.ExecuteNonQuery();
  452.             }
  453.             catch (Exception ex)
  454.             {
  455.                 Response.Write(ex.Message);
  456.             }
  457.         }
  458.         if (!name9.Text.Equals(""))
  459.         {
  460.             try
  461.             {
  462.                 int id = 1;
  463.                 SqlCommand cmd = new SqlCommand("select max(id) as id from oa_equipment_form_d", conn);
  464.                 try
  465.                 {
  466.                     id = Convert.ToInt32(cmd.ExecuteScalar().ToString()) + 1;
  467.                 }
  468.                 catch
  469.                 {
  470.                 }
  471.                 string type = "";
  472.                 string charge = "";
  473.                 if (cb_1_9.Checked)
  474.                 {
  475.                     if (type.Equals(""))
  476.                     {
  477.                         type = cb_1_9.Text.ToString();
  478.                         charge = charge1_9.Text.ToString();
  479.                     }
  480.                     else
  481.                     {
  482.                         type = type + "/" + cb_1_9.Text.ToString();
  483.                         charge = charge + "/" + charge1_9.Text.ToString();
  484.                     }
  485.                 }
  486.                 if (cb_2_9.Checked)
  487.                 {
  488.                     if (type.Equals(""))
  489.                     {
  490.                         type = cb_2_9.Text.ToString();
  491.                         charge = charge2_9.Text.ToString();
  492.                     }
  493.                     else
  494.                     {
  495.                         type = type + "/" + cb_2_9.Text.ToString();
  496.                         charge = charge + "/" + charge2_9.Text.ToString();
  497.                     }
  498.                 }
  499.                 sql = "insert into oa_equipment_form_d(id,form_id,equipment_name,standard,equipment_unit,equipment_num,cause,apply_date,type,charge,remark)values('" +
  500.                     id + "','" + IFromNo.Text.ToString() + "','" + name9.Text.ToString() + "','" + standard9.Text + "','" + unit9.Text.ToString() + "','" + num9.Text.ToString() + "','" +
  501.                     cause9.Text.ToString() + "','" + date9.Text.ToString() + "','" + type + "','" + charge + "','" + remark9.Text.ToString() + "')";
  502.                 cmd = new SqlCommand(sql, conn);
  503.                 cmd.ExecuteNonQuery();
  504.             }
  505.             catch (Exception ex)
  506.             {
  507.                 Response.Write(ex.Message);
  508.             }
  509.         }
  510.         conn.Close();
  511.     }
  512.     public void save(int state)
  513.     {
  514.         if (cb1.Checked || cb2.Checked || cb3.Checked || cb4.Checked || cb5.Checked || cb6.Checked)
  515.         {
  516.             if (!name1.Text.Equals("") || !name2.Text.Equals("") || !name3.Text.Equals("") || !name4.Text.Equals("") || !name5.Text.Equals("") || !name6.Text.Equals("") || !name7.Text.Equals("") || !name8.Text.Equals("") || !name9.Text.Equals(""))
  517.             {
  518.                 string type = "";
  519.                 if (cb1.Checked)
  520.                 {
  521.                     if (type.Equals(""))
  522.                     {
  523.                         type = cb1.Text.ToString();
  524.                     }
  525.                     else
  526.                     {
  527.                         type = type + "/" + cb1.Text.ToString();
  528.                     }
  529.                 }
  530.                 if (cb2.Checked)
  531.                 {
  532.                     if (type.Equals(""))
  533.                     {
  534.                         type = cb2.Text.ToString();
  535.                     }
  536.                     else
  537.                     {
  538.                         type = type + "/" + cb2.Text.ToString();
  539.                     }
  540.                 }
  541.                 if (cb3.Checked)
  542.                 {
  543.                     if (type.Equals(""))
  544.                     {
  545.                         type = cb3.Text.ToString();
  546.                     }
  547.                     else
  548.                     {
  549.                         type = type + "/" + cb3.Text.ToString();
  550.                     }
  551.                 }
  552.                 if (cb4.Checked)
  553.                 {
  554.                     if (type.Equals(""))
  555.                     {
  556.                         type = cb4.Text.ToString();
  557.                     }
  558.                     else
  559.                     {
  560.                         type = type + "/" + cb4.Text.ToString();
  561.                     }
  562.                 }
  563.                 if (cb5.Checked)
  564.                 {
  565.                     if (type.Equals(""))
  566.                     {
  567.                         type = cb5.Text.ToString();
  568.                     }
  569.                     else
  570.                     {
  571.                         type = type + "/" + cb5.Text.ToString();
  572.                     }
  573.                 }
  574.                 if (cb6.Checked)
  575.                 {
  576.                     if (type.Equals(""))
  577.                     {
  578.                         type = cb6.Text.ToString();
  579.                     }
  580.                     else
  581.                     {
  582.                         type = type + "/" + cb6.Text.ToString();
  583.                     }
  584.                 }
  585.                 SqlConnection conn = dbConnection.getConnection();
  586.                 conn.Open();
  587.                 string sql = "";
  588.                 try
  589.                 {
  590.                     int id = 1;
  591.                     SqlCommand cmd = new SqlCommand("select max(id) from oa_equipment_form", conn);
  592.                     try
  593.                     {
  594.                         id = Convert.ToInt32(cmd.ExecuteScalar().ToString()) + 1;
  595.                     }
  596.                     catch
  597.                     {
  598.                     }
  599.                     string total_result = "跑流程中";
  600.                     if (state == 2)
  601.                     {
  602.                         total_result = "未送件";
  603.                     }
  604.                     sql = "insert into oa_equipment_form(id,form_id,type,emp_id,apply_date,department_id,step,status,finish_date,total_result)values('" +
  605.                     +id + "','" + IFromNo.Text.ToString() + "','" + type + "','" + Session["user_id"] + "','" + tbdate.Text.ToString() +
  606.                     "','" + departmentid + "','1','" + state + "','','"+total_result+"')";
  607.                     cmd = new SqlCommand(sql, conn);
  608.                     cmd.ExecuteNonQuery();
  609.                     check();
  610.                     cmd = new SqlCommand("select max(id) from oa_equipment_flow", conn);
  611.                     try
  612.                     {
  613.                         flow_id = Convert.ToInt32(cmd.ExecuteScalar()) + 1;
  614.                     }
  615.                     catch (Exception ex)
  616.                     {
  617.                     }
  618.                     if (state == 1)
  619.                     {
  620.                         ArrayList id1 = new ArrayList();
  621.                         ArrayList id2 = new ArrayList();//记录上层节点职级小于登陆者的ID
  622.                         ArrayList name_1 = new ArrayList();//记录上层节点职级小于登陆者的name
  623.                         ArrayList mail_1 = new ArrayList();//记录上层节点职级小于登陆者的mail
  624.                         ArrayList last_id = new ArrayList();//记录上层节点的ID
  625.                         //判断是否为副董办公室
  626.                         if (departmentid.Equals("50"))
  627.                         {
  628.                          Response.Redirect("my_list.aspx", true);
  629.                         }
  630.                         int ceng = 0;
  631.                         cmd = new SqlCommand("select ceng from dbo.OA_DEPARTMENT where id='" + departmentid + "'", conn);
  632.                         ceng = Convert.ToInt32(cmd.ExecuteScalar()) - 3;
  633.                          if (ceng < 0 || ceng == 0)
  634.                          {
  635.                                 ceng = 0;
  636.                          }
  637.                         last_id.Add(departmentid);
  638.                         for (int i = 1; i <=ceng; i++)
  639.                         {
  640.                             cmd = new SqlCommand("select distinct last_id from oa_department where id='" + last_id[i - 1] + "'", conn);
  641.                             SqlDataReader dr1 = cmd.ExecuteReader();
  642.                             while (dr1.Read())
  643.                             {
  644.                                last_id.Add(dr1["last_id"].ToString());
  645.                             }
  646.                             dr1.Close();
  647.                         }
  648.                         for (int i = 0; i < last_id.Count; i++)
  649.                         {
  650.                             cmd = new SqlCommand("select id,email_work,emp_name from oa_employee where department_id='" + last_id[i] + "'and q_manger='1'", conn);
  651.                             SqlDataReader dr2 = cmd.ExecuteReader();
  652.                             while (dr2.Read())
  653.                             {
  654.                                 id1.Add(dr2["id"].ToString());
  655.                                 //name_1.Add(dr2["emp_name"].ToString());
  656.                                 //mail_1.Add(dr2["email_work"].ToString());
  657.                             }
  658.                             dr2.Close();
  659.                         }
  660.                         id1.Add("6");
  661.                         for (int i = 0; i < id1.Count; i++)
  662.                         {
  663.                             if (id1[i].Equals(Session["user_id"]))
  664.                             {
  665.                                 id1.RemoveAt(i);
  666.                                 //name_1.RemoveAt(i);
  667.                                 //mail_1.RemoveAt(i);
  668.                             }
  669.                         }
  670.                         foreach(string i in id1)
  671.                         {
  672.                             string str = check_supply(i);
  673.                             id2.Add(str);
  674.                             cmd = new SqlCommand("select email_work,emp_name from oa_employee where id='" + str + "'", conn);
  675.                             SqlDataReader dr3 = cmd.ExecuteReader();
  676.                             if (dr3.HasRows)
  677.                             {
  678.                                 while (dr3.Read())
  679.                                 {
  680.                                     name_1.Add(dr3["emp_name"].ToString());
  681.                                     mail_1.Add(dr3["email_work"].ToString());
  682.                                 }
  683.                             }
  684.                             dr3.Close();
  685.                         }
  686.                         if (id2.Count != 0)
  687.                         {
  688.                             for (int j = 0; j < id2.Count; j++)
  689.                             {
  690.                                 cmd = new SqlCommand("insert into oa_equipment_flow(id,form_id,operator_id,is_check,is_agree,comment,check_date,step)values('" + flow_id + "','" + IFromNo.Text.ToString() + "','" + id2[j].ToString() + "','N','N','','','" + (j + 1) + "')", conn);
  691.                                 cmd.ExecuteNonQuery();
  692.                                 flow_id = flow_id + 1;
  693.                             }
  694.                             if (state == 1)
  695.                             {
  696.                                 mail.mail_q(mail_1[0], name_1[0], txemp_name.Text, "設備申請單");
  697.                             }
  698.                             Response.Redirect("my_list.aspx");
  699.                         }
  700.                         else
  701.                         {
  702.                             ShowMessageBox("沒有找到相關處理流程, 請與管理員聯繫");
  703.                         }
  704.                     }
  705.                     else
  706.                     {
  707.                         Response.Redirect("my_list.aspx");
  708.                     }
  709.                     ShowMessageBox("申请成功");
  710.                 }
  711.                 catch (Exception ex)
  712.                 {
  713.                     Response.Write(ex.Message);
  714.                     ShowMessageBox("申请失败");
  715.                }
  716.                 conn.Close();
  717.             }
  718.             else
  719.             {
  720.                 ShowMessageBox("請填寫申請品名稱");
  721.             }
  722.         }
  723.         else
  724.         {
  725.             ShowMessageBox("請選擇設備類型");
  726.         }
  727.     }
  728.     public string check_supply(string id)
  729.     {
  730.         string emp_id = id;
  731.         SqlConnection conn = dbConnection.getConnection();
  732.         conn.Open();
  733.         DateTime date = DateTime.Now;
  734.         try
  735.         {
  736.             SqlCommand cmd = new SqlCommand("select d_people,s_date,e_date from OA_DELEGATE where b_d_people='" + id + "'", conn);
  737.             SqlDataReader dr = cmd.ExecuteReader();
  738.             if (dr.HasRows)
  739.             {
  740.                 while (dr.Read())
  741.                 {
  742.                     if ((!dr["s_date"].ToString().Equals("")) && (!dr["e_date"].ToString().Equals("")))
  743.                     {
  744.                         if ((date >= Convert.ToDateTime(dr["s_date"])) && (date <= Convert.ToDateTime(dr["e_date"])))
  745.                         {
  746.                             emp_id = Convert.ToString(dr["d_people"]);
  747.                         }
  748.                         else
  749.                         {
  750.                         }
  751.                     }
  752.                 }
  753.             }
  754.         }
  755.         catch
  756.         {
  757.         }
  758.         return emp_id;
  759.     }
  760.     protected void ShowMessageBox(string strMessage)
  761.     {
  762.         Response.Write(string.Format("<script>alert('{0}')</script>", strMessage));
  763.     }
  764.     protected void Button1_Click(object sender, EventArgs e)
  765.     {
  766.         save(1);
  767.     }
  768.     protected void Button2_Click(object sender, EventArgs e)
  769.     {
  770.         save(2);
  771.     }
  772. }