announce_list.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:4k
源码类别:
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_announcement_announce_list : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- if (Request.QueryString["type_id"] != null)
- {
- this.SetTable(Request.QueryString["type_id"]);
- }
- }
- }
- protected void SetTable(string type_id)
- {
- DateMgr mgr = new DateMgr();
- string today = mgr.getDate();
- int department_id = 0;
- if (Session["user"] != null)
- {
- department_id = ((User)Session["user"]).Department.Id;
- }
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select id, subject, content, authority, validate_date, cre_user, "+
- "cre_date, attachment, attachment_save_name from OA_ANNOUNCEMENT where type_id="+type_id+
- " and validate_date>='"+today+"' and is_del='N' order by cre_date desc", conn);
- SqlDataReader dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- int flag = 0;
- if (dr["authority"].ToString().Equals("2"))
- {
- if (this.CheckDepartment(department_id, dr["id"].ToString()))
- {
- flag = 1;
- }
- }
- else
- {
- flag = 1;
- }
- if (flag == 1)
- {
- //添加表格行
- TableRow tr = new TableRow();
- TableCell td = new TableCell();
- Table tbl = new Table();
- tbl.Width = Unit.Pixel(600);
- TableHeaderRow thr = new TableHeaderRow();
- TableHeaderCell thd = new TableHeaderCell();
- thd.BorderWidth = Unit.Pixel(1);
- thd.HorizontalAlign = HorizontalAlign.Left;
- thd.BackColor = System.Drawing.Color.LightGray;
- thd.Text = dr["subject"].ToString();
- thr.Cells.Add(thd);
- tbl.Rows.Add(thr);
- TableRow tr1 = new TableRow();
- TableCell td1 = new TableCell();
- td1.BorderWidth = Unit.Pixel(1);
- string content = "發佈人:" + dr["cre_user"].ToString()+"<br>";
- content = content + "發佈時間:" + dr["cre_date"].ToString() + "<br>";
- content = content + dr["content"].ToString();
- if (content.Length > 300)
- {
- content = content.Substring(0, 300) + "...";
- }
- if (!dr["attachment"].ToString().Equals(""))
- {
- content = content + "<br>" + "附件:" + dr["attachment"].ToString();
- }
- HyperLink hl = new HyperLink();
- hl.Width = Unit.Pixel(600);
- hl.Text = content;
- hl.NavigateUrl = "announce_detail.aspx?a_id=" + dr["id"].ToString();
- td1.Controls.Add(hl);
- tr1.Cells.Add(td1);
- tbl.Rows.Add(tr1);
- td.Controls.Add(tbl);
- tr.Cells.Add(td);
- TblAnnouncement.Rows.Add(tr);
- }
- }
- dr.Close();
- conn.Close();
- }
- protected bool CheckDepartment(int department_id, string announce_id)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select department_id from OA_ANNOUNCEMENT_DEPARTMENT where a_id="+
- announce_id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- if(Convert.ToInt32(dr["department_id"].ToString()) == department_id)
- {
- dr.Close();
- conn.Close();
- return true;
- }
- }
- dr.Close();
- conn.Close();
- return false;
- }
- }