repair.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:24k
源码类别:
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 : System.Web.UI.Page
- {
- SqlCommand sqlcom;
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- //LoginDAO.CheckLogin(Session, Response, "../", 2);
- int id = -1;
- try
- {
- id = Convert.ToInt32(DropDownList1.SelectedValue);
- }
- catch
- {
- }
- MultiView1.ActiveViewIndex = id;
- if (id == 0)
- {
- bind1();
- }
- else if (id == 1)
- {
- bind2();
- }
- else if (id == 2)
- {
- bind3();
- }
- else if (id == 3)
- {
- bind4();
- }
- else
- {
- }
- }
- }
- public void bind1()
- {
- Panel1.Visible = false;
- int id = 1;
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- DataSet ds = new DataSet();
- DataTable dt = new DataTable();
- dt.Columns.Add(new DataColumn("編號", typeof(int)));
- dt.Columns.Add(new DataColumn("公司名稱", typeof(string)));
- dt.Columns.Add(new DataColumn("聯絡人", typeof(string)));
- dt.Columns.Add(new DataColumn("手機號碼", typeof(string)));
- dt.Columns.Add(new DataColumn("固定電話", typeof(string)));
- dt.Columns.Add(new DataColumn("fax", typeof(string)));
- dt.Columns.Add(new DataColumn("ID", typeof(int)));
- SqlCommand sqlcom = new SqlCommand("select * from oa_company order by id", conn);
- SqlDataReader comm = sqlcom.ExecuteReader();
- if (comm.HasRows)
- {
- while (comm.Read())
- {
- DataRow row = dt.NewRow();
- row["編號"] = id;
- row["公司名稱"] = comm["company"].ToString();
- row["聯絡人"] = comm["contact_person"].ToString();
- row["手機號碼"] = comm["mobile_tel"].ToString();
- row["固定電話"] = comm["phone"].ToString();
- row["fax"] = comm["fax"].ToString();
- row["ID"] = comm["id"].ToString();
- id = id + 1;
- dt.Rows.Add(row);
- }
- }
- else
- {
- Panel1.Visible = true;
- }
- ds.Tables.Add(dt);
- GridView1.DataSource = ds;
- GridView1.DataKeyNames = new string[] { "ID" };
- GridView1.DataBind();
- comm.Close();
- conn.Close();
- set1();
- }
- public void set1()
- {
- DropDownList dll;
- string str = "";
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- for (int i = 0; i < GridView1.Rows.Count; i++)
- {
- dll = (DropDownList)(GridView1.Rows[i].FindControl("dl"));
- SqlCommand sqlcom = new SqlCommand("select equipment from OA_COMPANY where id='" + GridView1.DataKeys[i].Value.ToString() + "'", conn);
- str = sqlcom.ExecuteScalar().ToString();
- for (int j = 0; j < dll.Items.Count; j++)
- {
- if (dll.Items[j].Text.ToString().Equals(str))
- {
- dll.SelectedIndex = j;
- break;
- }
- }
- }
- conn.Close();
- }
- public void bind2()
- {
- Panel2.Visible = false;
- int id = 1;
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- DataSet ds = new DataSet();
- DataTable dt = new DataTable();
- dt.Columns.Add(new DataColumn("no", typeof(int)));
- dt.Columns.Add(new DataColumn("type", typeof(string)));
- dt.Columns.Add(new DataColumn("ID", typeof(int)));
- SqlCommand sqlcom = new SqlCommand("select id,type from OA_UNIT_TYPE", conn);
- SqlDataReader dr = sqlcom.ExecuteReader();
- if (dr.HasRows)
- {
- while (dr.Read())
- {
- DataRow row = dt.NewRow();
- row["no"] = id;
- row["type"] = dr["type"].ToString();
- row["ID"] = dr["id"].ToString();
- dt.Rows.Add(row);
- id = id + 1;
- }
- }
- else
- {
- Panel2.Visible = true;
- }
- ds.Tables.Add(dt);
- GridView2.DataSource = ds;
- GridView2.DataKeyNames = new string[] { "ID" };
- GridView2.DataBind();
- dr.Close();
- conn.Close();
- }
- public void bind3()
- {
- Panel3.Visible = false;
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- DataSet ds = new DataSet();
- DataTable dt = new DataTable();
- dt.Columns.Add(new DataColumn("ID", typeof(int)));
- dt.Columns.Add(new DataColumn("設備名稱", typeof(string)));
- SqlCommand sqlcom = new SqlCommand("select * from OA_UNIT_DETAIL order by id", conn);
- SqlDataReader dr = sqlcom.ExecuteReader();
- if (dr.HasRows)
- {
- while (dr.Read())
- {
- DataRow row = dt.NewRow();
- row["ID"] = dr["id"].ToString();
- row["設備名稱"] = dr["eq_name"].ToString();
- dt.Rows.Add(row);
- }
- }
- else
- {
- Panel3.Visible = true;
- }
- ds.Tables.Add(dt);
- GridView3.DataSource = ds;
- GridView3.DataKeyNames = new string[] { "ID" };
- GridView3.DataBind();
- dr.Close();
- conn.Close();
- set2();
- }
- public void set2()
- {
- DropDownList dll;
- string str = "";
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- for (int i = 0; i < GridView3.Rows.Count; i++)
- {
- dll = (DropDownList)(GridView3.Rows[i].FindControl("dl"));
- SqlCommand sqlcom = new SqlCommand("select eq_type from OA_UNIT_DETAIL where id='" + GridView3.DataKeys[i].Value.ToString() + "'", conn);
- str = sqlcom.ExecuteScalar().ToString();
- for (int j = 0; j < dll.Items.Count; j++)
- {
- if (dll.Items[j].Text.ToString().Equals(str))
- {
- dll.SelectedIndex = j;
- break;
- }
- }
- }
- conn.Close();
- }
- public void bind4()
- {
- Panel4.Visible = false;
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- DataSet ds = new DataSet();
- DataTable dt = new DataTable();
- dt.Columns.Add(new DataColumn("ID", typeof(int)));
- dt.Columns.Add(new DataColumn("question", typeof(string)));
- SqlCommand sqlcom = new SqlCommand("select * from OA_UNIT_QUESTION order by id", conn);
- SqlDataReader dr = sqlcom.ExecuteReader();
- if (dr.HasRows)
- {
- while (dr.Read())
- {
- DataRow row = dt.NewRow();
- row["ID"] = dr["id"].ToString();
- row["question"] = dr["question"].ToString();
- dt.Rows.Add(row);
- }
- }
- else
- {
- Panel4.Visible = true;
- }
- ds.Tables.Add(dt);
- GridView4.DataSource = ds;
- GridView4.DataKeyNames = new string[] { "ID" };
- GridView4.DataBind();
- dr.Close();
- conn.Close();
- set3();
- }
- public void set3()
- {
- DropDownList dll;
- string str = "";
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- for (int i = 0; i < GridView4.Rows.Count; i++)
- {
- dll = (DropDownList)(GridView4.Rows[i].FindControl("dl"));
- SqlCommand sqlcom = new SqlCommand("select equipment from OA_UNIT_QUESTION where id='" + GridView4.DataKeys[i].Value.ToString() + "'", conn);
- str = sqlcom.ExecuteScalar().ToString();
- for (int j = 0; j < dll.Items.Count; j++)
- {
- if (dll.Items[j].Text.ToString().Equals(str))
- {
- dll.SelectedIndex = j;
- break;
- }
- }
- }
- conn.Close();
- }
- protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
- {
- GridView1.EditIndex = e.NewEditIndex;
- bind1();
- }
- protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
- {
- int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value);
- string sqlstr = "delete from oa_company where id=" + id ;
- SqlConnection sqlcon=dbConnection.getConnection();
- sqlcon.Open();
- sqlcom = new SqlCommand(sqlstr, sqlcon);
- sqlcom.ExecuteNonQuery();
- sqlcon.Close();
- bind1();
- }
- protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
- {
- int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value);
- DropDownList dll = (DropDownList)(GridView1.Rows[e.RowIndex].FindControl("dl"));
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand comm = new SqlCommand("update oa_company set company='" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString() + "',contact_person='" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString() + "',mobile_tel='" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString() + "',phone='" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString() + "',fax='" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[5].Controls[0])).Text.ToString() + "',equipment='" + dll.SelectedItem.Text.ToString() + "'where id='" + id + "'", conn);
- comm.ExecuteNonQuery();
- conn.Close();
- GridView1.EditIndex = -1;
- bind1();
- }
- protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
- {
- GridView1.EditIndex = -1;
- bind1();
- }
- protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- int i;
- //执行循环,保证每条数据都可以更新
- for (i = -1; i < GridView1.Rows.Count; i++)
- {
- //首先判断是否是数据行
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- //当鼠标停留时更改背景色
- e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00A9FF'");
- //当鼠标移开时还原背景色
- e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
- }
- }
- }
- protected void ApprovelList1_RowCreated(object sender, GridViewRowEventArgs e)
- {
- LinkButton lbRevoke = (LinkButton)e.Row.FindControl("LbRevoke1");
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- lbRevoke.CommandArgument = GridView1.DataKeys[e.Row.RowIndex].Value.ToString();
- lbRevoke.Click += new EventHandler(lbRevoke1_Click);
- }
- }
- public void lbRevoke1_Click(object sender, EventArgs e)
- {
- Panel1.Visible = true;
- }
- protected void GridView2_RowEditing(object sender, GridViewEditEventArgs e)
- {
- GridView2.EditIndex = e.NewEditIndex;
- bind2();
- }
- protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
- {
- int id = Convert.ToInt32(GridView2.DataKeys[e.RowIndex].Value);
- string sqlstr = "delete from OA_UNIT_TYPE where id=" + id ;
- SqlConnection sqlcon=dbConnection.getConnection();
- sqlcon.Open();
- sqlcom = new SqlCommand(sqlstr, sqlcon);
- sqlcom.ExecuteNonQuery();
- sqlcon.Close();
- bind2();
- }
- protected void GridView2_RowUpdating(object sender, GridViewUpdateEventArgs e)
- {
- try
- {
- int id = Convert.ToInt32(GridView2.DataKeys[e.RowIndex].Value);
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand comm = new SqlCommand("update OA_UNIT_TYPE set type='" + ((TextBox)(GridView2.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString() + "'where id='" + id + "'", conn);
- comm.ExecuteNonQuery();
- conn.Close();
- GridView2.EditIndex = -1;
- bind2();
- }
- catch (Exception ex)
- {
- ShowMessageBox(ex.Message.ToString());
- //Response.Write(ex.Message);
- }
- }
- protected void GridView2_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
- {
- GridView2.EditIndex = -1;
- bind2();
- }
- protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- int i;
- //执行循环,保证每条数据都可以更新
- for (i = -1; i < GridView2.Rows.Count; i++)
- {
- //首先判断是否是数据行
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- //当鼠标停留时更改背景色
- e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00A9FF'");
- //当鼠标移开时还原背景色
- e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
- }
- }
- }
- protected void ApprovelList2_RowCreated(object sender, GridViewRowEventArgs e)
- {
- LinkButton lbRevoke = (LinkButton)e.Row.FindControl("LbRevoke2");
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- lbRevoke.CommandArgument = GridView2.DataKeys[e.Row.RowIndex].Value.ToString();
- lbRevoke.Click += new EventHandler(lbRevoke2_Click);
- }
- }
- public void lbRevoke2_Click(object sender, EventArgs e)
- {
- Panel2.Visible = true;
- }
- protected void GridView3_RowEditing(object sender, GridViewEditEventArgs e)
- {
- GridView3.EditIndex = e.NewEditIndex;
- bind3();
- }
- protected void GridView3_RowDeleting(object sender, GridViewDeleteEventArgs e)
- {
- int id = Convert.ToInt32(GridView3.DataKeys[e.RowIndex].Value);
- string sqlstr = "delete from OA_UNIT_DETAIL where id='" + id + "'";
- SqlConnection sqlcon=dbConnection.getConnection();
- sqlcon.Open();
- sqlcom = new SqlCommand(sqlstr, sqlcon);
- sqlcom.ExecuteNonQuery();
- sqlcon.Close();
- bind3();
- }
- protected void GridView3_RowUpdating(object sender, GridViewUpdateEventArgs e)
- {
- try
- {
- DropDownList dll = (DropDownList)(GridView3.Rows[e.RowIndex].FindControl("dl"));
- int id = Convert.ToInt32(GridView3.DataKeys[e.RowIndex].Value);
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand comm = new SqlCommand("update OA_UNIT_DETAIL set eq_name='" + ((TextBox)(GridView3.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString() + "',eq_type='" + dll.SelectedValue.ToString() + "'where id='" + id + "'", conn);
- comm.ExecuteNonQuery();
- conn.Close();
- GridView3.EditIndex = -1;
- bind3();
- }
- catch (Exception ex)
- {
- ShowMessageBox(ex.Message.ToString());
- //Response.Write(ex.Message);
- }
- }
- protected void GridView3_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
- {
- GridView3.EditIndex = -1;
- bind3();
- }
- protected void GridView3_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- int i;
- //执行循环,保证每条数据都可以更新
- for (i = -1; i < GridView3.Rows.Count; i++)
- {
- //首先判断是否是数据行
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- //当鼠标停留时更改背景色
- e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00A9FF'");
- //当鼠标移开时还原背景色
- e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
- }
- }
- }
- protected void ApprovelList3_RowCreated(object sender, GridViewRowEventArgs e)
- {
- LinkButton lbRevoke = (LinkButton)e.Row.FindControl("LbRevoke3");
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- lbRevoke.CommandArgument = GridView3.DataKeys[e.Row.RowIndex].Value.ToString();
- lbRevoke.Click += new EventHandler(lbRevoke3_Click);
- }
- }
- public void lbRevoke3_Click(object sender, EventArgs e)
- {
- Panel3.Visible = true;
- }
- protected void GridView4_RowEditing(object sender, GridViewEditEventArgs e)
- {
- GridView4.EditIndex = e.NewEditIndex;
- bind4();
- }
- protected void GridView4_RowDeleting(object sender, GridViewDeleteEventArgs e)
- {
- int id = Convert.ToInt32(GridView4.DataKeys[e.RowIndex].Value);
- string sqlstr = "delete from OA_UNIT_QUESTION where id='" + id + "'";
- SqlConnection sqlcon = dbConnection.getConnection();
- sqlcon.Open();
- sqlcom = new SqlCommand(sqlstr, sqlcon);
- sqlcom.ExecuteNonQuery();
- sqlcon.Close();
- bind4();
- }
- protected void GridView4_RowUpdating(object sender, GridViewUpdateEventArgs e)
- {
- try
- {
- DropDownList dll = (DropDownList)(GridView4.Rows[e.RowIndex].FindControl("dl"));
- int id = Convert.ToInt32(GridView4.DataKeys[e.RowIndex].Value);
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand comm = new SqlCommand("update OA_UNIT_QUESTION set question='" + ((TextBox)(GridView4.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString() + "',equipment='" + dll.SelectedValue.ToString() + "'where id='" + id + "'", conn);
- comm.ExecuteNonQuery();
- conn.Close();
- GridView4.EditIndex = -1;
- bind4();
- }
- catch (Exception ex)
- {
- ShowMessageBox(ex.Message.ToString());
- }
- }
- protected void GridView4_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
- {
- GridView4.EditIndex = -1;
- bind4();
- }
- protected void GridView4_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- int i;
- //执行循环,保证每条数据都可以更新
- for (i = -1; i < GridView4.Rows.Count; i++)
- {
- //首先判断是否是数据行
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- //当鼠标停留时更改背景色
- e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00A9FF'");
- //当鼠标移开时还原背景色
- e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
- }
- }
- }
- protected void ApprovelList4_RowCreated(object sender, GridViewRowEventArgs e)
- {
- LinkButton lbRevoke = (LinkButton)e.Row.FindControl("LbRevoke4");
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- lbRevoke.CommandArgument = GridView4.DataKeys[e.Row.RowIndex].Value.ToString();
- lbRevoke.Click += new EventHandler(lbRevoke4_Click);
- }
- }
- public void lbRevoke4_Click(object sender, EventArgs e)
- {
- Panel4.Visible = true;
- }
- protected void Btview1_Click(object sender, EventArgs e)
- {
- int id = 1;
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand sqlcom = new SqlCommand("select max(id) from oa_company", conn);
- try
- {
- id = Convert.ToInt32(sqlcom.ExecuteScalar()) + 1;
- }
- catch
- {
- }
- if (!company.Text.Equals(""))
- {
- if (!equipment.SelectedItem.Text.ToString().Equals(""))
- {
- SqlCommand comm = new SqlCommand("insert into oa_company(id,company,contact_person,mobile_tel,phone,fax,equipment)values('" + id + "','" + company.Text.ToString() + "','" + person.Text.ToString() + "','" + mobile.Text.ToString() + "','" + tel.Text.ToString() + "','" + fax.Text.ToString() + "','" + equipment.SelectedItem.Text.ToString() + "')", conn);
- comm.ExecuteNonQuery();
- conn.Close();
- }
- else
- {
- ShowMessageBox("請選擇該公司所維修的設備類型");
- }
- }
- else
- {
- ShowMessageBox("請輸入公司名稱");
- }
- bind1();
- }
- protected void Btview2_Click(object sender, EventArgs e)
- {
- int id = 1;
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand sqlcom = new SqlCommand("select max(id) from OA_UNIT_TYPE", conn);
- try
- {
- id = Convert.ToInt32(sqlcom.ExecuteScalar()) + 1;
- }
- catch
- {
- }
- if (!txttype.Text.Equals(""))
- {
- SqlCommand comm = new SqlCommand("insert into OA_UNIT_TYPE(id,type)values('" + id + "','" + txttype.Text.ToString() + "')", conn);
- comm.ExecuteNonQuery();
- conn.Close();
- }
- else
- {
- ShowMessageBox("請輸入設備名稱");
- }
- bind2();
- }
- protected void Btview3_Click(object sender, EventArgs e)
- {
- int id = 1;
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand sqlcom = new SqlCommand("select max(id) from OA_UNIT_DETAIL", conn);
- try
- {
- id = Convert.ToInt32(sqlcom.ExecuteScalar()) + 1;
- }
- catch
- {
- }
- if (!txt.Text.Equals(""))
- {
- SqlCommand comm = new SqlCommand("insert into OA_UNIT_DETAIL(id,eq_name,eq_type)values('" + id + "','" + txt.Text.ToString() + "','" + dltype.SelectedValue.ToString() + "')", conn);
- comm.ExecuteNonQuery();
- conn.Close();
- }
- else
- {
- ShowMessageBox("請輸入設備名稱");
- }
- bind3();
- }
- protected void Btview4_Click(object sender, EventArgs e)
- {
- int id = 1;
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand sqlcom = new SqlCommand("select max(id) from OA_UNIT_QUESTION", conn);
- try
- {
- id = Convert.ToInt32(sqlcom.ExecuteScalar()) + 1;
- }
- catch
- {
- }
- if (!txt1.Text.Equals(""))
- {
- SqlCommand comm = new SqlCommand("insert into OA_UNIT_QUESTION(id,question,equipment)values('" + id + "','" + txt1.Text.ToString() + "','" + type.SelectedValue.ToString() + "')", conn);
- comm.ExecuteNonQuery();
- conn.Close();
- }
- else
- {
- ShowMessageBox("請輸入設備名稱");
- }
- bind4();
- }
- protected void ShowMessageBox(string strMessage)
- {
- Response.Write(string.Format("<script>alert('{0}')</script>", strMessage));
- }
- protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
- {
- int id = -1;
- try
- {
- id = Convert.ToInt32(DropDownList1.SelectedValue);
- }
- catch
- {
- }
- MultiView1.ActiveViewIndex = id;
- if (id == 0)
- {
- bind1();
- }
- else if (id == 1)
- {
- bind2();
- }
- else if (id == 2)
- {
- bind3();
- }
- else if (id == 3)
- {
- bind4();
- }
- else
- {
- }
- }
- }