⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 left.aspx.cs

📁 通过配置表中的各列支持绝大部分的基础数据
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using  Microsoft.Web.UI.WebControls;
using comm.include;
namespace comm
{
	/// <summary>
	/// left 的摘要说明。
	/// </summary>
	public class left : System.Web.UI.Page
	{
		protected Microsoft.Web.UI.WebControls.TreeView TreeView1;
		include.Db db=new comm.include.Db();
         string database;
         string Ip;
         string usr;
         string pwd;
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			if(!this.IsPostBack)
			{
//                if(this.Application["system"]==null)
                if(this.Session["system"]==null)
                {
                    this.database="";
                    this.Ip="";
                    db.Msgbox("非法登陆!","警告",this.Page);
                    this.Dispose();
                }
                else
                {
//                    db.DataBase=this.Application["system"].ToString().Trim();
//                    db.IP =this.Application["ip"].ToString().Trim();
//                    db.Usr=this.Application["usr"].ToString().Trim();
//                    db.Pwd =this.Application["pwd"].ToString().Trim();
                    db.DataBase=this.Session["system"].ToString().Trim();
                    db.IP =this.Session["ip"].ToString().Trim();
                    db.Usr=this.Session["usr"].ToString().Trim();
                    db.Pwd =this.Session["pwd"].ToString().Trim();
                }
                this.database=db.DataBase;
                this.Ip =db.IP;
                this.usr =db.Usr;
                this.pwd =db.Pwd;
				this.TreeView1.Visible =true;
				string table=System.Configuration.ConfigurationSettings.AppSettings["Menu_Table"];
				int right=0;
//                if(this.Application["right"]!=null)
//                {
//                    right=(int)this.Application["right"];
//                }
                if(this.Session["right"]!=null)
                {
                    right=(int)this.Session["right"];
                }
                Occur_Menu(table,right);
			}
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		#region 菜单生成
		public bool Occur_Menu(string tablename,int right)
		{
             
			menu("0",null,tablename,right);
			
			return true;
		}
		#endregion

		public void menu(string parent_id,TreeNode ptn,string tablename,int right)
		{
           
			string sql="select * from "+tablename+" where parent=" + int.Parse(parent_id) ;
            if(right>0)
            {
                sql+=" AND ACCESS_right<="+right;
            }
            sql+="ORDER BY [INDEX] ";
			DataSet ds=new DataSet();
			ds=db.GetDataSet(sql,this.Page);
			if(ds==null)
			{
				return ;
			}
			for(int i=0;i<ds.Tables[0].Rows.Count;i++)
			{
				Microsoft.Web.UI.WebControls.TreeNode tn=new TreeNode();
				tn.ID=ds.Tables[0].Rows[i]["id"].ToString().Trim();
				//tn.Parent=ds.Tables[0].Rows[i]["parent"].ToString().Trim();
				tn.NavigateUrl=ds.Tables[0].Rows[i]["url"].ToString().Trim();
				tn.Text =ds.Tables[0].Rows[i]["Caption"].ToString().Trim();
				tn.Target="mainFrame";
				if(ptn==null)
				{
					this.TreeView1.Nodes.Add(tn);
					this.menu(tn.ID,tn,tablename,right);
				}
				else
				{
					ptn.Nodes.Add(tn);
					this.menu(tn.ID,tn,tablename,right);
				}
			}
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -