company_deallist.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:4k
源码类别:
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_company_deallist : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!(Request.QueryString["id"].ToString().Equals("")) && !(Request.QueryString["company"].ToString().Equals("")))
- {
- bind();
- }
- }
- public void bind()
- {
- string sqlstr = "";
- int id = 1;
- 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("form_id", typeof(string)));
- dt.Columns.Add(new DataColumn("department", typeof(string)));
- dt.Columns.Add(new DataColumn("apply_time", typeof(string)));
- SqlCommand sqlcom = new SqlCommand("select form_id from OA_COMPANY_CHECK where is_check='" + Request.QueryString["id"].ToString() + "' and company='" + Request.QueryString["company"].ToString() + "' order by id desc", conn);
- SqlDataReader dr = sqlcom.ExecuteReader();
- if (dr.HasRows)
- {
- while (dr.Read())
- {
- DataRow row = dt.NewRow();
- row["id"] = id;
- id = id + 1;
- row["form_id"] = dr["form_id"].ToString();
- SqlConnection sqlcon = dbConnection.getConnection();
- sqlcon.Open();
- SqlCommand sqlcom1 = new SqlCommand("select f.name as name from OA_DEPARTMENT as f,OA_REPAIR_FORM_DETAIL as g where f.id=g.department_id and g.form_id='" + dr["form_id"].ToString() + "'", sqlcon);
- SqlDataReader dr1 = sqlcom1.ExecuteReader();
- if (dr1.HasRows)
- {
- while (dr1.Read())
- {
- row["department"] = dr1["name"].ToString();
- }
- }
- dr1.Close();
- SqlCommand sqlcom2 = new SqlCommand("select apply_time from OA_REPAIR_FORM where form_id='" + dr["form_id"].ToString() + "'", sqlcon);
- SqlDataReader dr2 = sqlcom2.ExecuteReader();
- if (dr2.HasRows)
- {
- while (dr2.Read())
- {
- row["apply_time"] = SetTime(dr2["apply_time"].ToString());
- }
- }
- dr2.Close();
- dt.Rows.Add(row);
- sqlcon.Close();
- }
- }
- ds.Tables.Add(dt);
- GridView1.DataSource=ds;
- GridView1.DataKeyNames = new string[] { "form_id" };
- GridView1.DataBind();
- dr.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 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='company_deal.aspx?form_id=" + GridView1.DataKeys[e.Row.RowIndex].Value.ToString() + "'");
- }
- }
- protected void ShowMessageBox(string strMessage)
- {
- Response.Write(string.Format("<script>alert('{0}')</script>", strMessage));
- }
- }