edit.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_select_edit : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (Request.QueryString["form_id"] != null)
- {
- bind();
- SetTable(Request.QueryString["form_id"].ToString());
- }
- }
- public void bind()
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- DataSet ds = new DataSet();
- DataTable dt = new DataTable();
- dt.Columns.Add("step", typeof(Int32));
- dt.Columns.Add("emp_name", typeof(string));
- dt.Columns.Add("check_type", typeof(string));
- dt.Columns.Add("is_check", typeof(string));
- dt.Columns.Add("is_agree", typeof(string));
- dt.Columns.Add("comment", typeof(string));
- dt.Columns.Add("check_time", typeof(string));
- SqlCommand sqlcom = new SqlCommand("select case f.is_check when 'N' then '未审核' when 'Y' then '已审核' end as is_check,case f.is_agree when 'N' then '未完工' when 'Y' then '已完工' end as is_agree,f.comment as comment,f.check_time as check_time,f.step as step,g.emp_name as emp_name from OA_REPAIR_FLOW AS f,OA_EMPLOYEE AS g WHERE g.id=f.operator_id and f.form_id='" + Request.QueryString["form_id"] + "' order by f.step", conn);
- SqlDataReader dr = sqlcom.ExecuteReader();
- if (dr.HasRows)
- {
- while (dr.Read())
- {
- DataRow row = dt.NewRow();
- row["step"] = Convert.ToInt32(dr["step"]);
- row["emp_name"] = dr["emp_name"].ToString();
- row["check_time"] = SetTime(dr["check_time"].ToString());
- row["is_check"] = dr["is_check"].ToString();
- row["check_type"] = "审批";
- row["is_agree"] = dr["is_agree"].ToString();
- row["comment"] = dr["comment"].ToString();
- dt.Rows.Add(row);
- }
- }
- ds.Tables.Add(dt);
- GridView1.DataSource = ds;
- GridView1.DataBind();
- }
- public void SetTable(string id)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- 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,a.company as company 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='" + id + "'", conn);
- SqlDataReader dr1 = sqlcom1.ExecuteReader();
- if (dr1.HasRows)
- {
- while (dr1.Read())
- {
- lbno.Text = Request.QueryString["form_id"].ToString();
- lbdepartment.Text = dr1["name"].ToString();
- equipment.Text = dr1["eq_detail"].ToString();
- lbperson.Text = dr1["emp_name"].ToString();
- lbtel.Text = dr1["tel"].ToString();
- type.Text = dr1["eq_type"].ToString();
- connet.Text = dr1["content"].ToString();
- company.Text = dr1["company"].ToString();
- }
- }
- dr1.Close();
- conn.Close();
- }
- public string SetTime(string s)
- {
- string year = "";
- string month = "";
- string day = "";
- string hour = "";
- string minite = "";
- string second = "";
- if (s.Length == 14)
- {
- year = s.Substring(0, 4).ToString();
- month = s.Substring(4, 2).ToString();
- day = s.Substring(6, 2).ToString();
- hour = s.Substring(8, 2).ToString();
- minite = s.Substring(10, 2).ToString();
- second = s.Substring(12, 2).ToString();
- return year + "-" + month + "-" + day + " " + hour + ":" + minite + ":" + second;
- }
- else
- {
- return s;
- }
- }
- protected void BtnOk_Click(object sender, EventArgs e)
- {
- DateMgr mgr = new DateMgr();
- string time="";
- string total_result = "";
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- int id = 1;
- int step = 1;
- SqlCommand sqlcom = new SqlCommand("select max(id) as id from OA_REPAIR_FLOW ",conn);
- SqlDataReader dr = sqlcom.ExecuteReader();
- if (dr.HasRows)
- {
- while (dr.Read())
- {
- try
- {
- id = Convert.ToInt32(dr["id"]) + 1;
- }
- catch
- {
- }
- }
- }
- dr.Close();
- SqlCommand sqlcom1 = new SqlCommand("select max(step) as step from OA_REPAIR_FLOW where form_id='" + Request.QueryString["form_id"] + "'", conn);
- SqlDataReader dr1 = sqlcom1.ExecuteReader();
- if (dr1.HasRows)
- {
- while (dr1.Read())
- {
- try
- {
- step = Convert.ToInt32(dr1["step"]) + 1;
- }
- catch
- {
- }
- }
- }
- dr1.Close();
- string sqlstr = "insert into OA_REPAIR_FLOW(id,form_id,operator_id,is_check,is_agree,comment,check_time,step)values(" + id + ",'" + Request.QueryString["form_id"].ToString() + "','" + Session["user_id"].ToString() + "','Y','" + RbAgree.SelectedValue.ToString() + "','" + TxtComment.Text.Replace("<br>", "/n").ToString() + "','" + mgr.getTime() + "','" + step + "')";
- SqlCommand sqlcom2 = new SqlCommand(sqlstr, conn);
- sqlcom2.ExecuteNonQuery();
- if (RbAgree.SelectedValue.Equals("N"))
- {
- total_result = "未完工";
- }
- else
- {
- total_result = "已完工";
- }
- time = mgr.getDateTime();
- SqlCommand sqlcom3 = new SqlCommand("update OA_REPAIR_FORM set finish_time='" + time + "',total_result='" + total_result + "',step=" + step + " where form_id='" + Request.QueryString["form_id"]+"'", conn);
- sqlcom3.ExecuteNonQuery();
- Response.Redirect("edit_deal.aspx");
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- MultiView2.ActiveViewIndex = 0;
- }
- 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 = "未完工";
- }
- }
- }
- }