menu_mgr.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_menu_mgr : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- this.SetValue();
- }
- }
- protected void SetValue()
- {
- TreeNode root = new TreeNode();
- root.Text = "公告管理";
- TreeNode parent = new TreeNode();
- parent.Text = "添加公告";
- parent.Target = "main";
- parent.NavigateUrl = "announce_add.aspx";
- root.ChildNodes.Add(parent);
- ArrayList ids = new ArrayList();
- ArrayList names = new ArrayList();
- 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())
- {
- ids.Add(dr["id"].ToString());
- names.Add(dr["name"].ToString());
- }
- dr.Close();
- conn.Close();
- parent = new TreeNode();
- parent.Text = "正在發佈的公告";
- root.ChildNodes.Add(parent);
- for (int i = 0; i < ids.Count; i++)
- {
- TreeNode child = new TreeNode();
- child.Text = names[i] + "(" + this.GetCount(ids[i].ToString(), 1) + ")";
- child.Target = "main";
- child.NavigateUrl = "announce_mgr_list.aspx?type_id=" + ids[i] + "&type=1";
- parent.ChildNodes.Add(child);
- }
- parent = new TreeNode();
- parent.Text = "已過期的公告";
- root.ChildNodes.Add(parent);
- for (int i = 0; i < ids.Count; i++)
- {
- TreeNode child = new TreeNode();
- child.Text = names[i] + "(" + this.GetCount(ids[i].ToString(), 2) + ")";
- child.Target = "main";
- child.NavigateUrl = "announce_mgr_list.aspx?type_id=" + ids[i] + "&type=2";
- parent.ChildNodes.Add(child);
- }
- parent = new TreeNode();
- parent.Text = "已刪除的公告";
- root.ChildNodes.Add(parent);
- for (int i = 0; i < ids.Count; i++)
- {
- TreeNode child = new TreeNode();
- child.Text = names[i] + "(" + this.GetCount(ids[i].ToString(), 3) + ")";
- child.Target = "main";
- child.NavigateUrl = "announce_mgr_list.aspx?type_id=" + ids[i] + "&type=3";
- parent.ChildNodes.Add(child);
- }
- MenuTree.Nodes.Add(root);
- }
- protected int GetCount(string type_id, int type)
- {
- DateMgr mgr = new DateMgr();
- string today = mgr.getDate();
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- string sql = "";
- if (type == 1)
- {
- sql = "select count(id) from OA_ANNOUNCEMENT where type_id=" + type_id + " and validate_date>='" + today + "' and is_del='N'";
- }
- if (type == 2)
- {
- sql = "select count(id) from OA_ANNOUNCEMENT where type_id=" + type_id + " and validate_date<='" + today + "' and is_del='N'";
- }
- if (type == 3)
- {
- sql = "select count(id) from OA_ANNOUNCEMENT where type_id=" + type_id + " and is_del='Y'";
- }
- SqlCommand cmd = new SqlCommand(sql, conn);
- int count = Convert.ToInt32(cmd.ExecuteScalar().ToString());
- conn.Close();
- return count;
- }
- }