form.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 : System.Web.UI.Page
  13. {
  14.     string departmentid = "";
  15.     protected void Page_Load(object sender, EventArgs e)
  16.     {
  17.         if (!IsPostBack)
  18.         {
  19.             LoginDAO.CheckLogin(Session, Response, "../", 2);
  20.         }
  21.         if (Session["user"] != null)
  22.         {
  23.             DateMgr mgr = new DateMgr();
  24.             User user = (User)Session["user"];
  25.             lb_no.Text = mgr.getTime();
  26.             lb_person.Text = user.Emp_name;
  27.             lb_department.Text = user.Department.Name;
  28.             departmentid = user.Department.Id.ToString();
  29.             SqlConnection conn = dbConnection.getConnection();
  30.             conn.Open();
  31.             SqlCommand sqlcom = new SqlCommand("select tel from oa_department where id='" + departmentid + "'", conn);
  32.             try
  33.             {
  34.                 lb_tel.Text = sqlcom.ExecuteScalar().ToString();
  35.             }
  36.             catch
  37.             {
  38.             }
  39.         }
  40.     }
  41.     protected void ShowMessageBox(string strMessage)
  42.     {
  43.         Response.Write(string.Format("<script>alert('{0}')</script>", strMessage));
  44.     }
  45.     public string check_supply(string id)
  46.     {
  47.         string emp_id = id;
  48.         SqlConnection conn = dbConnection.getConnection();
  49.         conn.Open();
  50.         DateTime date = DateTime.Now;
  51.         try
  52.         {
  53.             SqlCommand cmd = new SqlCommand("select d_people,s_date,e_date from OA_DELEGATE where b_d_people='" + id + "'", conn);
  54.             SqlDataReader dr = cmd.ExecuteReader();
  55.             if (dr.HasRows)
  56.             {
  57.                 while (dr.Read())
  58.                 {
  59.                     if ((!dr["s_date"].ToString().Equals("")) && (!dr["e_date"].ToString().Equals("")))
  60.                     {
  61.                         if ((date >= Convert.ToDateTime(dr["s_date"])) && (date <= Convert.ToDateTime(dr["e_date"])))
  62.                         {
  63.                             emp_id = Convert.ToString(dr["d_people"]);
  64.                         }
  65.                         else
  66.                         {
  67.                         }
  68.                     }
  69.                 }
  70.             }
  71.         }
  72.         catch
  73.         {
  74.         }
  75.         return emp_id;
  76.     }
  77.     protected void bt_Click(object sender, EventArgs e)
  78.     {
  79.         int id = 1;
  80.         DateMgr mgr = new DateMgr();
  81.         SqlConnection conn = dbConnection.getConnection();
  82.         conn.Open();
  83.         SqlCommand sqlcom = new SqlCommand("select max(id) from OA_REPAIR_FORM", conn);
  84.         try
  85.         {
  86.             id = Convert.ToInt32(sqlcom.ExecuteScalar()) + 1;
  87.         }
  88.         catch
  89.         {
  90.         }
  91.         SqlCommand sqldep = new SqlCommand("select department_id from OA_EMPLOYEE where id='"+Session["user_id"]+"'",conn);
  92.         departmentid = sqldep.ExecuteScalar().ToString();
  93.         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"].ToString() + "','" +Convert.ToString(mgr.getTime()) + "','1','','1','跑流程中')", conn);
  94.         sqlform.ExecuteNonQuery();
  95.         id = 1;
  96.         SqlCommand sqlcom1 = new SqlCommand("select max(id) from OA_REPAIR_FORM_DETAIL", conn);
  97.         try
  98.         {
  99.             id = Convert.ToInt32(sqlcom1.ExecuteScalar()) + 1;
  100.         }
  101.         catch
  102.         {
  103.         }
  104.         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() + "','" + departmentid + "','"+dll_type.SelectedItem.ToString()+"','"+dll_equipment.SelectedItem.ToString()+"','','" + txt.Text.Replace("n", "<br>") + "')", conn);
  105.         sqldetail.ExecuteNonQuery();
  106.         id = 1;
  107.         SqlCommand sqlcom3 = new SqlCommand("select max(id) from OA_REPAIR_FLOW", conn);
  108.         try
  109.         {
  110.             id = Convert.ToInt32(sqlcom3.ExecuteScalar()) + 1;
  111.         }
  112.         catch
  113.         {
  114.         }
  115.         ArrayList last_id = new ArrayList();
  116.         ArrayList emp_id = new ArrayList();
  117.         ArrayList id1 = new ArrayList();
  118.         int ceng = 0;
  119.         last_id.Add(departmentid);
  120.         SqlCommand sqlcen = new SqlCommand("select ceng from OA_DEPARTMENT where id='"+departmentid+"'",conn);
  121.         SqlDataReader drcen = sqlcen.ExecuteReader();
  122.         if (drcen.HasRows)
  123.         {
  124.             while (drcen.Read())
  125.             {
  126.                 ceng = Convert.ToInt32(drcen["ceng"]);
  127.             }
  128.         }
  129.         drcen.Close();
  130.         for (int i = 1; i < ceng; i++)
  131.         {
  132.                 SqlCommand sqllast = new SqlCommand("select last_id from OA_DEPARTMENT where id='" + last_id[i - 1] + "'", conn);
  133.                 SqlDataReader drlast = sqllast.ExecuteReader();
  134.                 if (drlast.HasRows)
  135.                 {
  136.                     while (drlast.Read())
  137.                     {
  138.                         last_id.Add(Convert.ToString(drlast["last_id"]));
  139.                     }
  140.                 }
  141.                 drlast.Close();
  142.         }
  143.             for(int i=0;i<last_id.Count;i++)
  144.             {
  145.                 SqlCommand sqlemp = new SqlCommand("select id from OA_EMPLOYEE where position='19' and department_id='" + last_id[i].ToString() + "'", conn);
  146.                 SqlDataReader dremp = sqlemp.ExecuteReader();
  147.                 if (dremp.HasRows)
  148.                 {
  149.                     while (dremp.Read())
  150.                     {
  151.                         emp_id.Add(dremp["id"].ToString());
  152.                     }
  153.                 }
  154.                 dremp.Close();
  155.             }
  156.         if (emp_id.Count != 0)
  157.         {
  158.             for (int i = 0; i < emp_id.Count; i++)
  159.             {
  160.                 if (emp_id[i].ToString().Equals(Session["user_id"].ToString()))
  161.                 {
  162.                     emp_id.RemoveAt(i);
  163.                 }
  164.             }
  165.         }
  166.         if (emp_id.Count != 0)
  167.         {
  168.             for (int i = 0; i < emp_id.Count; i++)
  169.             {
  170.                 SqlCommand sqlflow = new SqlCommand("insert into OA_REPAIR_FLOW(id,form_id,operator_id,is_check,is_agree,comment,step)values('" + id + "','" + lb_no.Text.ToString() + "','" + emp_id[i].ToString() + "','N','','','" + (i + 1) + "')", conn);
  171.                 sqlflow.ExecuteNonQuery();
  172.                 id = id + 1;
  173.             }
  174.         }
  175.         SqlCommand sqlflow2 = new SqlCommand("insert into OA_REPAIR_FLOW(id,form_id,operator_id,is_check,is_agree,comment,step)values('" + id + "','" + lb_no.Text.ToString() + "','" + Session["user_id"].ToString() + "','N','','','" + (emp_id.Count+1) + "')", conn);
  176.         sqlflow2.ExecuteNonQuery();
  177.         Response.Redirect("my_list.aspx");
  178.     }
  179.     protected void dll_question_SelectedIndexChanged1(object sender, EventArgs e)
  180.     {
  181.         txt.Text = "";
  182.         if (dll_question.SelectedItem.ToString().Equals("其他"))
  183.         {
  184.         }
  185.         else
  186.         {
  187.             txt.Text = dll_question.SelectedItem.ToString();
  188.         }
  189.     }
  190. }