form.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 : System.Web.UI.Page
- {
- string departmentid = "";
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- LoginDAO.CheckLogin(Session, Response, "../", 2);
- }
- if (Session["user"] != null)
- {
- DateMgr mgr = new DateMgr();
- User user = (User)Session["user"];
- lb_no.Text = mgr.getTime();
- lb_person.Text = user.Emp_name;
- lb_department.Text = user.Department.Name;
- departmentid = user.Department.Id.ToString();
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand sqlcom = new SqlCommand("select tel from oa_department where id='" + departmentid + "'", conn);
- try
- {
- lb_tel.Text = sqlcom.ExecuteScalar().ToString();
- }
- catch
- {
- }
- }
- }
- protected void ShowMessageBox(string strMessage)
- {
- Response.Write(string.Format("<script>alert('{0}')</script>", strMessage));
- }
- public string check_supply(string id)
- {
- string emp_id = id;
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- DateTime date = DateTime.Now;
- try
- {
- SqlCommand cmd = new SqlCommand("select d_people,s_date,e_date from OA_DELEGATE where b_d_people='" + id + "'", conn);
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.HasRows)
- {
- while (dr.Read())
- {
- if ((!dr["s_date"].ToString().Equals("")) && (!dr["e_date"].ToString().Equals("")))
- {
- if ((date >= Convert.ToDateTime(dr["s_date"])) && (date <= Convert.ToDateTime(dr["e_date"])))
- {
- emp_id = Convert.ToString(dr["d_people"]);
- }
- else
- {
- }
- }
- }
- }
- }
- catch
- {
- }
- return emp_id;
- }
- protected void bt_Click(object sender, EventArgs e)
- {
- int id = 1;
- DateMgr mgr = new DateMgr();
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand sqlcom = new SqlCommand("select max(id) from OA_REPAIR_FORM", conn);
- try
- {
- id = Convert.ToInt32(sqlcom.ExecuteScalar()) + 1;
- }
- catch
- {
- }
- SqlCommand sqldep = new SqlCommand("select department_id from OA_EMPLOYEE where id='"+Session["user_id"]+"'",conn);
- departmentid = sqldep.ExecuteScalar().ToString();
- 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);
- sqlform.ExecuteNonQuery();
- id = 1;
- SqlCommand sqlcom1 = new SqlCommand("select max(id) from OA_REPAIR_FORM_DETAIL", conn);
- try
- {
- id = Convert.ToInt32(sqlcom1.ExecuteScalar()) + 1;
- }
- catch
- {
- }
- 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);
- sqldetail.ExecuteNonQuery();
- id = 1;
- SqlCommand sqlcom3 = new SqlCommand("select max(id) from OA_REPAIR_FLOW", conn);
- try
- {
- id = Convert.ToInt32(sqlcom3.ExecuteScalar()) + 1;
- }
- catch
- {
- }
- ArrayList last_id = new ArrayList();
- ArrayList emp_id = new ArrayList();
- ArrayList id1 = new ArrayList();
- int ceng = 0;
- last_id.Add(departmentid);
- SqlCommand sqlcen = new SqlCommand("select ceng from OA_DEPARTMENT where id='"+departmentid+"'",conn);
- SqlDataReader drcen = sqlcen.ExecuteReader();
- if (drcen.HasRows)
- {
- while (drcen.Read())
- {
- ceng = Convert.ToInt32(drcen["ceng"]);
- }
- }
- drcen.Close();
- for (int i = 1; i < ceng; i++)
- {
- SqlCommand sqllast = new SqlCommand("select last_id from OA_DEPARTMENT where id='" + last_id[i - 1] + "'", conn);
- SqlDataReader drlast = sqllast.ExecuteReader();
- if (drlast.HasRows)
- {
- while (drlast.Read())
- {
- last_id.Add(Convert.ToString(drlast["last_id"]));
- }
- }
- drlast.Close();
- }
- for(int i=0;i<last_id.Count;i++)
- {
- SqlCommand sqlemp = new SqlCommand("select id from OA_EMPLOYEE where position='19' and department_id='" + last_id[i].ToString() + "'", conn);
- SqlDataReader dremp = sqlemp.ExecuteReader();
- if (dremp.HasRows)
- {
- while (dremp.Read())
- {
- emp_id.Add(dremp["id"].ToString());
- }
- }
- dremp.Close();
- }
- if (emp_id.Count != 0)
- {
- for (int i = 0; i < emp_id.Count; i++)
- {
- if (emp_id[i].ToString().Equals(Session["user_id"].ToString()))
- {
- emp_id.RemoveAt(i);
- }
- }
- }
- if (emp_id.Count != 0)
- {
- for (int i = 0; i < emp_id.Count; i++)
- {
- 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);
- sqlflow.ExecuteNonQuery();
- id = id + 1;
- }
- }
- 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);
- sqlflow2.ExecuteNonQuery();
- Response.Redirect("my_list.aspx");
- }
- protected void dll_question_SelectedIndexChanged1(object sender, EventArgs e)
- {
- txt.Text = "";
- if (dll_question.SelectedItem.ToString().Equals("其他"))
- {
- }
- else
- {
- txt.Text = dll_question.SelectedItem.ToString();
- }
- }
- }