Code Description: Table t_hg_catalog script: Create Table [T_HG_CATALOG] ([ID] [INT] Identity (1, 1) Not Null, [Catalog_name] [varchar] (30) collate chinese_prc_ci_as not null, [PARENT_ID] [INT] NULL , [Remark] [varchar] (128) COLLATE Chinese_PRC_CI_AS NULL, [State] [smallint] NOT NULL CONSTRAINT [DF_T_hg_catalog_State] DEFAULT (0), CONSTRAINT [PK_t_hg_catalog] PRIMARY KEY CLUSTERED ([ID]) ON [PRIMARY]) ON [ PRIMARY] GO, a category record If there is a last level category, the parent_id = 'superior category ID', if it is the highest level, there is no higher class category parent_id = nullCheckpermitFromTable function is to determine if the current login user is right to have permission Because the system requires permission and no permission to display different url.inittreeView functions is the entry of the entire code, the external call is called, from this function. Parameter, I don't say much, I can see it! The inittree function is a Recursive function lookup current class has no lower class category, if the mind is not very clear, it is best not to see this function! :) Will go into the magic land! The effect after the code is executed: #Region initializes the TreeView control of the display column structure
///
IF (rows! = null) {if (Rows.Length> 0) {return true;} else {/ * * If the current column has no permissions, the upper column in the query system has permissions, if there is Returning True, if you have been found The highest level column has no operational permissions, then confirm that the user does not have operation permission for the current column. --- Wang Haibo * / rows = dstree.tables ["Catalog"]. SELECT ("ID =" pcatalogid);
IF (Rows.Length> 0 && rows [0] ["Parent_ID"]. TOSTRING (). Trim ()! = "" {ix (CheckpermitFromTable (PUSERID, ROWS [0] ["Parent_ID"]. Tostring () ) // [recursive call] return true;
Return False;}}}} catch (sqlexception se) {ErrorMessage = se.MESSAGE; RETURN FALSE;}} ///
strsql1 = "select * from t_hg_power where user_id = '" PUSERID "'"
DataSet DS = New DataSet (); // Get Column Data SqlDataAdapter SQLADPT = New SqlDataAdapter (Strsql, CN);
SQLADPT.FILL (DS, "Catalog");
// Get user-column permission rights data sqladpt = new sqldataadapter (strsql1, cn); SQLADPT.FILL (DS, "Power"); return DS;} catch (sqlexception se) {errorMessage = se.MESSAGE; RETURN NULL;}}
///
TV.nodes.clear (); tv.imageurl = rootimageurl;
For (int i = 0; i TN1.Expanded = true; TV.Nodes.Add (TN1); INITTREE (TV.Nodes [i] .nodes, ds.tables [0] .rows [i] ["id"]. TOSTRING (), PUSERID); Plevel = 0; // Tree Layer Restore} // Initialize the first level tree node end // Initialization populates TreeView's dataset} /// PLEVEL ; // Tree level plus 1INT PCURLEVEL = plevel; for (int i = 0; i Case 2: tmpnd.imageurl = "/ images / iCO03.GIF"; Break; Case 3: tmpnd.imageurl = "/ images / state_normal.gif"; Break; } IF (CheckpermitFromTable (PUSERID, DRV ["Id"]. TOSTRING ()) TMPND.NAVIGATEURL = "/ admin / hg_info_manage.aspx? CID =" DRV ["ID"]. Tostring () "& catalogname =" DRV ["Catalog_name"]. TOSTRING (); else tmpnd.navigateURL = "/ info / hg_info_index.aspx? CID =" DRV ["ID"]. Tostring () "& catalogname =" DRV ["Catalog_name" ] .Tostring (); nds.add (tmpnd); intid = DRV ["Parent_ID"]. TOSTRING (); INITTREE (Tmpnd.nodes, Tmpnd.id, PUSERID); plevel = pcurlevel;} } #ndregion