form_add.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:7k
源码类别:
OA系统
开发平台:
ASP/ASPX
- using System;
- using System.Data;
- using System.Data.SqlClient;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- public partial class web_data_repair_form_add : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- DateMgr mgr = new DateMgr();
- lb_no.Text = mgr.getTime();
- dll_department.SelectedIndex = 0;
- dll_company.SelectedIndex = 0;
- SqlCommand sqlcom = new SqlCommand("select tel from OA_DEPARTMENT where id='"+dll_department.SelectedValue.ToString()+"'",conn);
- SqlDataReader dr = sqlcom.ExecuteReader();
- if (dr.HasRows)
- {
- while (dr.Read())
- {
- lb_tel.Text = dr["tel"].ToString();
- }
- }
- dr.Close();
- SqlCommand sqlcom1 = new SqlCommand("select emp_name from OA_EMPLOYEE where id=" + Convert.ToInt32(Session["user_id"]), conn);
- SqlDataReader dr1 = sqlcom1.ExecuteReader();
- if (dr1.HasRows)
- {
- while (dr1.Read())
- {
- lb_person.Text = dr1["emp_name"].ToString();
- }
- }
- dr1.Close();
- conn.Close();
- }
- }
- protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand sqlcom = new SqlCommand("select tel from OA_DEPARTMENT where id=" + Convert.ToInt32(dll_department.SelectedValue), conn);
- SqlDataReader dr = sqlcom.ExecuteReader();
- if (dr.HasRows)
- {
- while (dr.Read())
- {
- lb_tel.Text = dr["tel"].ToString();
- }
- }
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- int id = 1;
- int step=1;
- int order_id = 0;
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand sqlemp = new SqlCommand("select id from OA_EMPLOYEE where position='19' and department_id='" + dll_department.SelectedValue.ToString() + "'", conn);
- SqlDataReader dremp = sqlemp.ExecuteReader();
- if (dremp.HasRows)
- {
- while (dremp.Read())
- {
- order_id = Convert.ToInt32(dremp["id"]);
- }
- }
- dremp.Close();
- if (order_id != 0)
- {
- DateMgr mgr = new DateMgr();
- SqlCommand sqlcom = new SqlCommand("select max(id) as id from OA_COMPANY_CHECK", conn);
- SqlDataReader dr = sqlcom.ExecuteReader();
- if (dr.HasRows)
- {
- while (dr.Read())
- {
- if (dr["id"].ToString().Equals(""))
- {
- }
- else
- {
- id = Convert.ToInt32(dr["id"]) + 1;
- }
- }
- }
- dr.Close();
- 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);
- sqlcompany.ExecuteNonQuery();
- id = 1;
- SqlCommand sqlcom1 = new SqlCommand("select max(id) as id from OA_REPAIR_FORM", conn);
- SqlDataReader dr1 = sqlcom1.ExecuteReader();
- if (dr1.HasRows)
- {
- while (dr1.Read())
- {
- if (dr1["id"].ToString().Equals(""))
- {
- }
- else
- {
- id = Convert.ToInt32(dr1["id"]) + 1;
- }
- }
- }
- dr1.Close();
- 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);
- sqlform.ExecuteNonQuery();
- id = 1;
- SqlCommand sqlcom2 = new SqlCommand("select max(id) as id from OA_REPAIR_FORM_DETAIL", conn);
- SqlDataReader dr2 = sqlcom2.ExecuteReader();
- if (dr2.HasRows)
- {
- while (dr2.Read())
- {
- if (dr2["id"].ToString().Equals(""))
- {
- }
- else
- {
- id = Convert.ToInt32(dr2["id"]) + 1;
- }
- }
- }
- dr2.Close();
- 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);
- sqldetail.ExecuteNonQuery();
- id = 1;
- SqlCommand sqlcom3 = new SqlCommand("select max(id) as id from OA_REPAIR_FLOW", conn);
- SqlDataReader dr3 = sqlcom3.ExecuteReader();
- if (dr3.HasRows)
- {
- while (dr3.Read())
- {
- if (dr3["id"].ToString().Equals(""))
- {
- }
- else
- {
- id = Convert.ToInt32(dr3["id"]) + 1;
- }
- }
- }
- dr3.Close();
- //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);
- //sqlflow.ExecuteNonQuery();
- 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);
- sqlflow1.ExecuteNonQuery();
- Response.Redirect("my_list.aspx");
- }
- else
- {
- ShowMessageBox("找不到相关流程请联系管理员");
- }
- }
- protected void ShowMessageBox(string strMessage)
- {
- Response.Write(string.Format("<script>alert('{0}')</script>", strMessage));
- }
- protected void dll_question_SelectedIndexChanged1(object sender, EventArgs e)
- {
- comment.Text = "";
- if (dll_question.SelectedItem.ToString().Equals("其他"))
- {
- }
- else
- {
- comment.Text = dll_question.SelectedItem.ToString();
- }
- }
- }