my_list.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:8k
源码类别:
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_my_list : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- LoginDAO.CheckLogin(Session, Response, "../../", 2);
- GridView1.DataKeyNames = new string[] { "form_id" };
- }
- if (Request.QueryString["form_id"] != null)
- {
- this.SetData(Request.QueryString["form_id"]);
- this.SetTable(Request.QueryString["form_id"]);
- }
- }
- public void SetData(string id)
- {
- MultiView2.ActiveViewIndex = 0;
- FormTable.Visible = true;
- lb_no.Text = id;
- }
- public void SetTable(string id)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select operator_id,is_check,is_agree,comment,check_time,step from OA_REPAIR_FLOW where form_id='" + id + "'", conn);
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.HasRows)
- {
- while (dr.Read())
- {
- TableRow tr = new TableRow();
- TableCell td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- td.Text = dr["step"].ToString();
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- SqlConnection conn1 = dbConnection.getConnection();
- conn1.Open();
- SqlCommand sqlcom = new SqlCommand("select emp_name from oa_employee where id='" + dr["operator_id"] + "'", conn1);
- td.Text = sqlcom.ExecuteScalar().ToString();
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- td.Text = "審批";
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- if (dr["is_check"].ToString().Equals("N"))
- {
- td.Text = "未處理";
- }
- else
- {
- td.Text = "已處理";
- }
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- if (dr["is_check"].ToString().Equals("Y"))
- {
- if (dr["is_agree"].ToString().Equals("Y"))
- {
- td.Text = "已完工";
- }
- else
- {
- td.Text = "未完工";
- }
- }
- else
- {
- td.Text = "<br>";
- }
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- if (!dr["comment"].ToString().Equals(""))
- {
- td.Text = dr["comment"].ToString();
- }
- else
- {
- td.Text = "<br>";
- }
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- if (!dr["check_time"].ToString().Equals(""))
- {
- td.Text = dr["check_time"].ToString();
- }
- else
- {
- td.Text = "<br>";
- }
- tr.Cells.Add(td);
- this.FlowTable.Rows.Add(tr);
- }
- }
- dr.Close();
- SqlCommand sqlcom1 = new SqlCommand("select b.emp_name as emp_name,c.name as name,c.tel as tel,a.eq_type as eq_type,a.eq_detail as eq_detail,a.content as content from OA_REPAIR_FORM_DETAIL AS a,OA_EMPLOYEE as b,OA_DEPARTMENT as c,OA_REPAIR_FORM as d where a.form_id=d.form_id and b.id=d.emp_id and c.id=a.department_id and a.form_id='" + Request.QueryString["form_id"].ToString() + "'", conn);
- SqlDataReader dr1 = sqlcom1.ExecuteReader();
- if (dr1.HasRows)
- {
- while (dr1.Read())
- {
- lb_department.Text = dr1["name"].ToString();
- lb_equipment.Text = dr1["eq_detail"].ToString();
- lb_person.Text = dr1["emp_name"].ToString();
- lb_tel.Text = dr1["tel"].ToString();
- lb_type.Text = dr1["eq_type"].ToString();
- comment.Text = dr1["content"].ToString();
- }
- }
- dr1.Close();
- SqlCommand sqlcom2 = new SqlCommand("select g.company as company,f.contact_person as person,f.mobile_tel as tel,f.phone as phone,f.fax as fax from OA_COMPANY as f,OA_COMPANY_CHECK as g where f.company=g.company and g.form_id='" + Request.QueryString["form_id"].ToString() + "'", conn);
- SqlDataReader dr2 = sqlcom2.ExecuteReader();
- if (dr2.HasRows)
- {
- while (dr2.Read())
- {
- person.Text = dr2["person"].ToString();
- phone.Text = dr2["phone"].ToString();
- tel.Text = dr2["tel"].ToString();
- fax.Text = dr2["fax"].ToString();
- }
- }
- dr2.Close();
- conn.Close();
- }
- protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- e.Row.Attributes.Add("onmouseover", "this.style.cursor='pointer';");
- e.Row.Attributes.Add("onclick", "location.href='my_list.aspx?form_id=" + GridView1.DataKeys[e.Row.RowIndex].Value.ToString() + "'");
- }
- }
- protected void ShowMessageBox(string strMessage)
- {
- Response.Write(string.Format("<script>alert('{0}')</script>", strMessage));
- }
- protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
- {
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select total_result from OA_REPAIR_FORM where form_id=" +GridView1.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
- LinkButton lbRevoke = (LinkButton)e.Row.FindControl("LbRevoke");
- string total_result = cmd.ExecuteScalar().ToString();
- if (total_result.Equals("跑流程中"))
- {
- lbRevoke.Enabled = true;
- lbRevoke.CommandArgument = GridView1.DataKeys[e.Row.RowIndex].Value.ToString();
- lbRevoke.Click += new EventHandler(lbRevoke_Click);
- }
- else
- {
- lbRevoke.OnClientClick = "";
- }
- conn.Close();
- }
- }
- void lbRevoke_Click(object sender, EventArgs e)
- {
- LinkButton lbRevoke = (LinkButton)sender;
- string id = lbRevoke.CommandArgument;
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlTransaction tx = conn.BeginTransaction();
- try
- {
- SqlCommand cmd = new SqlCommand("update OA_REPAIR_FORM set status=3, total_result='已撤銷' where form_id=" + id, conn);
- cmd.Transaction = tx;
- cmd.ExecuteNonQuery();
- cmd = new SqlCommand("update OA_REPAIR_FLOW set is_check='N', is_agree='N', comment='', " +
- "check_time='' where form_id='" + id + "'", conn);
- cmd.Transaction = tx;
- cmd.ExecuteNonQuery();
- tx.Commit();
- }
- catch (Exception ex)
- {
- Response.Write(ex.Message);
- tx.Rollback();
- }
- conn.Close();
- Response.Redirect("my_list.aspx");
- }
- }