deal.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:8k
源码类别:
OA系统
开发平台:
ASP/ASPX
- using System;
- using System.Data;
- 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;
- using System.Data.SqlClient;
- public partial class web_computer_detail : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- LoginDAO.CheckLogin(Session, Response, "../", 2);
- this.SetTable();
- }
- if (Request.QueryString["f_id"] != null)
- {
- PnlApprovel.Visible = true;
- PnlDeal.Visible = true;
- // PnlFlow.Visible = true;
- this.SetData(Request.QueryString["f_id"]);
- }
- }
- protected void SetTable()
- {
- ArrayList form_id = new ArrayList();
- ArrayList operator_id = new ArrayList();
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlTransaction tx = conn.BeginTransaction();
- SqlCommand cmd = new SqlCommand("select distinct f_id from oa_computer_form_flow ", conn);
- cmd.Transaction = tx;
- SqlDataReader dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- form_id.Add(dr["f_id"].ToString());
- }
- dr.Close();
- for (int i = 0; i < form_id.Count;i++ )
- {
- cmd = new SqlCommand("select top 1 operator_id from oa_computer_form_flow where is_check='N'and f_id="+form_id[i], conn);
- cmd.Transaction = tx;
- SqlDataReader dr2 = cmd.ExecuteReader();
- while (dr2.Read())
- {
- operator_id.Add(dr2["operator_id"].ToString());
- }
- dr2.Close();
- }
- for(int i=0;i<form_id.Count;i++)
- {
- cmd = new SqlCommand("SELECT a.id, f.step f_step,f.form_id, e.emp_name, a.date1 " +
- "FROM dbo.oa_computer_form_flow AS f INNER JOIN dbo.OA_computer_form AS a ON f.form_id = a.form_id " +
- "INNER JOIN dbo.OA_EMPLOYEE AS e ON a.emp_id = e.id WHERE (f.operator_id = " + Session["user_id"] +
- ") AND (f.is_check = 'N') and f_id="+form_id[i]+" order by a.date1 desc", conn);
- cmd.Transaction = tx;
- SqlDataReader dr1 = cmd.ExecuteReader();
- while (dr1.Read())
- {
- int f_step = Convert.ToInt32(dr1["f_step"].ToString());
- TblFlow.Visible = true;
- TableRow tr = new TableRow();
- TableCell td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- td.Text = dr1["emp_name"].ToString();
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- td.Text = dr1["emp_name"].ToString() + "的電腦設備報修單";
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- td.Text = dr1["date1"].ToString();
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- HyperLink hl = new HyperLink();
- hl.Text = "查看";
- hl.NavigateUrl = "deal.aspx?f_id=" + dr1["id"].ToString() + "&f_id1=" + dr1["form_id"].ToString();
- td.Controls.Add(hl);
- tr.Cells.Add(td);
- TblFlow.Rows.Add(tr);
- }
- dr1.Close();
- }
- tx.Commit();
- conn.Close();
- }
- protected void SetData(string id)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select * from oa_computer_form where id=" + id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- form_no.Text = dr["form_id"].ToString();
- emp_no.Text = dr["emp_no"].ToString();
- emp_name.Text = dr["emp_name"].ToString();
- emp_dept.Text = dr["emp_dept"].ToString();
- emp_position.Text = dr["emp_position"].ToString();
- date1.Text = dr["date1"].ToString();
- f_item.Text = dr["item1"].ToString();
- Enddate.Text = dr["enddate"].ToString();
- content.Text = dr["content"].ToString();
- }
- dr.Close();
- conn.Close();
- }
- protected void RbAgree_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (TxtComment.Text.Equals("已同意") || TxtComment.Text.Equals("不同意"))
- {
- if (RbAgree.SelectedValue.Equals("Y"))
- {
- TxtComment.Text = "已同意";
- }
- else
- {
- TxtComment.Text = "不同意";
- }
- }
- }
- protected void BtnOk_Click(object sender, EventArgs e)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlTransaction tx = conn.BeginTransaction();
- try
- {
- DateMgr mgr = new DateMgr();
- SqlCommand cmd = new SqlCommand("update oa_computer_form_flow set is_check='Y', is_agree='" +
- RbAgree.SelectedValue + "', comment='" + TxtComment.Text.Replace("n", "<br>") +
- "', check_date='" + mgr.getDateTime() + "' where form_id='" + Request.QueryString["f_id1"]+"'and "+
- " operator_id="+Session["user_id"], conn);
- cmd.Transaction = tx;
- cmd.ExecuteNonQuery();
- cmd = new SqlCommand("select operator_id from oa_computer_form_flow where form_id='" +
- Request.QueryString["f_id1"]+"' and step in(select max(step) from oa_computer_form_flow where form_id='"+
- Request.QueryString["f_id1"]+"')" , conn);
- cmd.Transaction = tx;
- int oper_id =Convert.ToInt32(cmd.ExecuteScalar());
- string total_result = "跑流程中";
- string time = "";
- int u_id =Convert.ToInt32( Session["user_id"]);
- if (oper_id == u_id)
- {
- if (RbAgree.SelectedValue.Equals("N"))
- {
- total_result = "不同意";
- }
- else
- {
- total_result = "同意";
- }
- time = mgr.getDateTime();
- }
- else {
- time = mgr.getDateTime();
- }
- cmd = new SqlCommand("update OA_computer_FORM set status='" +
- total_result + "' where id=" + Request.QueryString["f_id"], conn);
- cmd.Transaction = tx;
- cmd.ExecuteNonQuery();
- cmd = new SqlCommand("update OA_computer_FORM_flow set check_date='" + time + "' where id=" + Request.QueryString["f_id"]+
- "and operator_id="+Session["user_id"], conn);
- cmd.Transaction = tx;
- cmd.ExecuteNonQuery();
- tx.Commit();
- }
- catch (Exception ex)
- {
- Response.Write(ex.Message);
- // tx.Rollback();
- }
- conn.Close();
- Response.Redirect("finish.aspx");
- }
- }