私有字符串Url =
受保護的void Page_Load(對象發送方,EventArgs e)
{
字符串路徑=系統。IO . path . get filename(HttpContext。current . request . path);
服務器。execute(" frm judge . aspx ");
//如果(!頁面。IsPostBack)
//{
This.lbNowTime.Text = "今天是:"+系統。datetime . now . tostring(" d ")+"+system。datetime . now . tostring(" dddd ");
this . bind tree();
//}
}
私有void bindTree()
{
嘗試
{
//根據角色生成權限樹
SqlConnection con = cDataBaseLink。creat connection();
con . Open();
SqlCommand cmd = new SqlCommand();
cmd。連接= con
string RoleID = Session["RoleID"]。ToString();
cmd。CommandText = "select A.*,B.RightParent,B.rightName from TabRoleRight as A,TabRights as B其中A.roleid='" + RoleID +",A . rigid = B . rigid and right parent = ' ' ";
sqldata adapter sda = new sqldata adapter();
sda。SelectCommand = cmd
數據集ds =新數據集();
sda。Fill(ds,“parent”);
int row = ds。tables[" parent "]. rows . count;
for(int I = 0;我& lt排;i++)
{
getUrl(ds。表格[“父項”]。行[i][0]。ToString()。trim());
TreeNode tn =新的TreeNode(ds。表格[“父項”]。第[i][3]行。ToString(),ds。表格[“父項”]。行[i][0]。ToString(),"",Url,target);
這個。樹形視圖1。nodes . Add(TN);
cmd。CommandText = "select A.*,B.RightParent,B.rightName from TabRoleRight as A,TabRights as B其中A.roleid='" + RoleID +",A . rigid = B . rigid and right parent = ' "+ds表[“父表”]。行[i][0]。ToString()+" ' ";
sda。dispose();
sda = new sqldata adapter();
sda。SelectCommand = cmd
數據集sds =新數據集();
sda。Fill(sds,“子”);
int count = sds。tables[" Child "]. rows . count;
for(int j = 0;j & lt數數;j++)
{
getUrl(sds。表[“子表”]。行[j][0]。ToString()。trim());
TreeNode stn =新的TreeNode(sds。表[“子表”]。行[j][3]。ToString(),sds。表[“子表”]。行[j][0]。ToString(),"",Url,target);
tn。child nodes . Add(stn);
cmd。CommandText = "select A.*,B.RightParent,B.rightName from TabRoleRight as A,TabRights as B其中A.roleid='" + RoleID +",A . rigid = B . rigid and right parent = ' "+SDS。表[“子表”]。行[j][0]。ToString()+" ' ";
sda。dispose();
sda = new sqldata adapter();
sda。SelectCommand = cmd
數據集dslast =新數據集();
sda。Fill(dslast,“最後”);
int last = dslast。tables[" last "]. rows . count;
for(int m = 0;m & lt最後;m++)
{
getUrl(dslast。表格["最後壹個"]。行數[m][0]。ToString()。trim());
TreeNode stnc =新的TreeNode(dslast。表格["最後壹個"]。行數[m][3]。ToString(),dslast。表格["最後壹個"]。行數[m][0]。ToString(),"",Url,target);
stn。child nodes . Add(stnc);
}
}
}
con . Close();
}
catch(異常錯誤)
{
string js = @ " & lt腳本語言= ' javascript ' & gtwindow . top . location = ' default . aspx ';& lt/script >;
回應。寫(js);
}
}
私有void getUrl(字符串RoleID)
{
開關(RoleID)
{
案例“01”:target = " ";URL = " ~/index . aspx ";打破;
案例“22”:target = " ";URL = " ~/index . aspx ";打破;
案例“44”:target = " my frame ";URL = " ~/index . aspx ";打破;
案例“0102”:target = " my frame ";URL = " ~/role manager . aspx ";打破;
案例“0103”:target = " my frame ";URL = " ~/right set . aspx ";打破;
case " 0101 ":target = " my frame ";URL = " ~/change password 1 . aspx ";打破;
案例“0104”:target = " my frame ";URL = " ~/user manager . aspx ";打破;
案例“04”:target = " my frame ";URL = " ~/check . aspx ";打破;
案例“05”:target = " my frame ";URL = " ~/suit manager . aspx ";打破;
案例“06”:target = " my frame ";URL = " ~/removeinquery . aspx ";打破;
案例“07”:target = " my frame ";URL = " ~/remove out query . aspx ";打破;
案例“08”:target = " my frame ";URL = " ~/stock query . aspx ";打破;
案例“09”:target = " my frame ";URL = " ~/out send query . aspx ";打破;
case " 10 ":target = " my frame ";URL = " ~/inroot query . aspx ";打破;
case " 11 ":target = " my frame ";URL = " ~/outreturnquery . aspx ";打破;
案例“12”:target = " my frame ";URL = " ~/stock in . aspx ";打破;
案例“13”:target = " my frame ";URL = " ~/stock out . aspx ";打破;
案例“14”:target = " my frame ";URL = " ~/remove . aspx ";打破;
案例“15”:target = " my frame ";URL = " ~/bill . aspx ";打破;
案例“16”:target = " my frame ";URL = " ~/root in . aspx ";打破;
案例“17”:target = " my frame ";URL = " ~/root compart . aspx ";打破;
案例“18”:target = " my frame ";URL = " ~/root out . aspx ";打破;
案例“19”:target = " my frame ";URL = " ~/ready . aspx ";打破;
案例“03”:target = " my frame ";URL = " ~/cancel . aspx ";打破;
默認值:target =Url =打破;
}
}
生成節點時指定Url,方法靈活。
這要看妳自己的情況。
我的手表可能和妳的不壹樣,這無關緊要。