menu.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:3k
源码类别:
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_menu : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- this.MakeTree();
- }
- }
- protected void MakeTree()
- {
- TreeNode root = new TreeNode();
- root.Text = "公告通知";
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select id, name from OA_ANNOUNCEMENT_TYPE order by sequence", conn);
- SqlDataReader dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- TreeNode node = new TreeNode();
- node.Text = dr["name"].ToString()+ "(" + this.GetCount(dr["id"].ToString()) + ")";
- node.Target = "main";
- node.NavigateUrl = "announce_list.aspx?type_id=" + dr["id"].ToString();
- root.ChildNodes.Add(node);
- }
- dr.Close();
- conn.Close();
- MenuTree.Nodes.Add(root);
- }
- protected int GetCount(string type_id)
- {
- int department_id = 0;
- if (Session["user"] != null)
- {
- department_id = ((User)Session["user"]).Department.Id;
- }
- DateMgr mgr = new DateMgr();
- string today = mgr.getDate();
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- int count = 0;
- SqlCommand cmd = new SqlCommand("select id, authority from OA_ANNOUNCEMENT where type_id=" + type_id +
- " and validate_date>='" + today + "' and is_del='N'", 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)
- {
- count++;
- }
- }
- conn.Close();
- return count;
- }
- 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;
- }
- }