weather.aspx.cs
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:5k
源码类别:

OA系统

开发平台:

ASP/ASPX

  1. using System;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4. using System.Configuration;
  5. using System.Collections;
  6. using System.Web;
  7. using System.Web.Security;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.WebControls.WebParts;
  11. using System.Web.UI.HtmlControls;
  12. public partial class weather : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.         if (!IsPostBack)
  17.         {
  18.             bind1();
  19.             bind2();
  20.         }
  21.     }
  22.     public void bind1()
  23.     {
  24.         string department_id = "";
  25.         DateMgr mgr = new DateMgr();
  26.         string today = mgr.getDate();
  27.         DataSet ds = new DataSet();
  28.         DataTable dt = new DataTable();
  29.         dt.Columns.Add("id", typeof(Int32));
  30.         dt.Columns.Add("subject", typeof(string));
  31.         SqlConnection conn = dbConnection.getConnection();
  32.         conn.Open();
  33.         SqlCommand sqlcom1 = new SqlCommand("select department_id from oa_employee where id='"+Session["user_id"]+"'",conn);
  34.         department_id = sqlcom1.ExecuteScalar().ToString();
  35.         SqlCommand sqlcom = new SqlCommand("select  id,subject,authority from OA_ANNOUNCEMENT  where validate_date >='" + today + "' and is_del='N'", conn);
  36.         SqlDataReader dr = sqlcom.ExecuteReader();
  37.         if (dr.HasRows)
  38.         {
  39.             while (dr.Read())
  40.             {
  41.                 SqlConnection conn1 = dbConnection.getConnection();
  42.                 conn1.Open();
  43.                 if (dr["authority"].ToString().Equals("1"))
  44.                 {
  45.                     DataRow row = dt.NewRow();
  46.                     row["id"] = Convert.ToInt32(dr["id"]);
  47.                     row["subject"] = dr["subject"].ToString();
  48.                     dt.Rows.Add(row);
  49.                 }
  50.                 else
  51.                 {
  52.                     SqlCommand sqlcom2 = new SqlCommand("select * from OA_ANNOUNCEMENT_DEPARTMENT where a_id='" + dr["id"] + "' and department_id='" + department_id + "'", conn1);
  53.                     SqlDataReader dr2 = sqlcom2.ExecuteReader();
  54.                     if (dr2.HasRows)
  55.                     {
  56.                         DataRow row = dt.NewRow();
  57.                         row["id"] = Convert.ToInt32(dr["id"]);
  58.                         row["subject"] = dr["subject"].ToString();
  59.                         dt.Rows.Add(row);
  60.                     }
  61.                     else
  62.                     {
  63.                     }
  64.                 }
  65.             }
  66.         }
  67.         dr.Close();
  68.         ds.Tables.Add(dt);
  69.         GridView1.DataSource = ds;
  70.         GridView1.DataBind();
  71.         GridView1.DataKeyNames = new string[] { "id" };
  72.         conn.Close();
  73.     }
  74.     /*public void bind2()
  75.     {
  76.         User user = (User)Session["user"];
  77.         string department = user.Department.Name;
  78.         SqlConnection conn = dbConnection.getConnection();
  79.         conn.Open();
  80.         DataSet ds_1 = new DataSet();
  81.         DataTable dt_1 = new DataTable();
  82.         dt_1.Columns.Add("form_id", typeof(string));
  83.         dt_1.Columns.Add("subject", typeof(string));
  84.         dt_1.Columns.Add("emp_id", typeof(string));
  85.         SqlCommand sqlcom1 = new SqlCommand("select f.create_time as create_time,f.equipment as equipment,g.destine_time as destine_time from OA_REPAIR as f,OA_REPAIR_D as g where f.form_id=g.form_id and g.destine_time is not null and g.complete_time is null and f.department='" + department.Trim() + "' order by destine_time desc", conn);
  86.         SqlDataReader dr1 = sqlcom1.ExecuteReader();
  87.         if (dr1.HasRows)
  88.         {
  89.             while (dr1.Read())
  90.             {
  91.                 DataRow row = dt_1.NewRow();
  92.                 row["form_id"] = dr1["create_time"].ToString()+"报修的";
  93.                 row["emp_id"] = dr1["equipment"].ToString();
  94.                 row["subject"] = dr1["create_time"].ToString() + "报修的" + dr1["equipment"].ToString() + "问题的预计维修时间∶" + dr1["destine_time"].ToString(); ;
  95.                 dt_1.Rows.Add(row);
  96.             }
  97.         }
  98.         ds_1.Tables.Add(dt_1);
  99.         GridView2.DataSource = ds_1;
  100.         GridView2.DataBind();
  101.         GridView2.DataKeyNames = new string[] { "form_id" };
  102.         dr1.Close();
  103.         conn.Close();
  104.     }*/
  105.     protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
  106.     {
  107.         GridView1.PageIndex = e.NewPageIndex;
  108.         bind1();
  109.     }
  110.    /* protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
  111.     {
  112.         GridView2.PageIndex = e.NewPageIndex;
  113.         bind2();
  114.     }*/
  115. }