form.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:3k
源码类别:
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_new_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"];
- lbno.Text = mgr.getTime();
- wtime.Text = mgr.getDateTime();
- bxmanger.Text = user.Emp_name;
- 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
- {
- tel.Text = sqlcom.ExecuteScalar().ToString();
- }
- catch
- {
- }
- }
- }
- protected void ShowMessageBox(string strMessage)
- {
- Response.Write(string.Format("<script>alert('{0}')</script>", strMessage));
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- DateMgr mgr = new DateMgr();
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- int id = 1;
- SqlCommand sqlcom1 = new SqlCommand("select max(id) as id from oa_repair", conn);
- SqlDataReader dr1 = sqlcom1.ExecuteReader();
- try
- {
- if (dr1.HasRows)
- {
- while (dr1.Read())
- {
- id = Convert.ToInt32(dr1["id"])+1;
- }
- }
- }
- catch
- {
- }
- dr1.Close();
- SqlCommand sqlcom = new SqlCommand("insert into oa_repair(id,form_id,department,lbperson,type,equipment,comment,create_time,[Level],bxperson,area)values(" + id + ",'" + lbno.Text.ToString() + "','" + department.Text.ToString() + "','" + Convert.ToInt32(Session["user_id"].ToString()) + "','" + DropDownList1.SelectedItem.ToString() + "','" + DropDownList2.SelectedItem.ToString() + "','" + TextBox1.Text.ToString() + "','" + mgr.getDate() + "','" + DropDownList3.SelectedItem.ToString().Trim() + "','" + bxperson.Text.ToString().Trim() + "','" + DropDownList4.SelectedItem.ToString().Trim() + "')", conn);
- sqlcom.ExecuteNonQuery();
- id=1;
- SqlCommand sqlcom3 = new SqlCommand("select max(id) as id from oa_repair_d", conn);
- SqlDataReader dr3 = sqlcom3.ExecuteReader();
- try
- {
- if (dr3.HasRows)
- {
- while (dr3.Read())
- {
- id = Convert.ToInt32(dr3["id"])+1;
- }
- }
- }
- catch
- {
- }
- dr3.Close();
- SqlCommand sqlcom2 = new SqlCommand("insert into oa_repair_d(id,form_id)values(" + id + ",'" + lbno.Text.ToString() + "')", conn);
- sqlcom2.ExecuteNonQuery();
- conn.Close();
- ShowMessageBox("报修成功");
- }
- }