You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

84 lines
2.8 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using Stone.Common;
using Stone.Entity;
using Stone.User;
namespace Stone.WinBiz.SystemData
{
public class F_Menu
{
public static void Init(TreeView leftTree)
{
TreeNode nodeMain = new TreeNode("功能菜单");
DataSet dsMenu = GetData();
DataRow[] drOnes = dsMenu.Tables[0].Select("[Levels]=1", "[Sort] asc");
foreach (DataRow drOne in drOnes)
{
string oneCode = drOne["Code"].ToString();
TreeNode nodeOne = new TreeNode(drOne["Name"].ToString(), 0, 1);
if (Convert.ToInt32(drOne["IsChild"]) == 1)
{
nodeOne = new TreeNode(drOne["Name"].ToString(), 2, 3);
nodeOne.Tag = "";
}
if (!UserInfo.UserVerify(drOne["Name"].ToString())) continue;
DataRow[] drTows = dsMenu.Tables[0].Select("[Levels]=2 and [Code] like '" + oneCode + "%'", "[Sort] asc");
foreach (DataRow drTow in drTows)
{
string towCode = drTow["Code"].ToString();
if (UserInfo.UserVerify(drTow["Name"].ToString()))
{
TreeNode nodeTow = new TreeNode(drTow["Name"].ToString(), 0, 1);
if (Convert.ToInt32(drTow["IsChild"]) == 1)
{
nodeTow = new TreeNode(drTow["Name"].ToString(), 2, 3);
nodeTow.Tag = drTow["Code"].ToString();
}
DataRow[] drThrees = dsMenu.Tables[0].Select("[Levels]=3 and [Code] like '" + towCode + "%'", "[Sort] asc");
foreach (DataRow drThree in drThrees)
{
TreeNode nodeThree = new TreeNode(drTow["Name"].ToString(), 0, 1);
if (Convert.ToInt32(drThree["IsChild"]) == 1)
{
nodeThree = new TreeNode(drThree["Name"].ToString(), 2, 3);
nodeThree.Tag = drThree["Code"].ToString();
}
nodeTow.Nodes.Add(nodeThree);
}
nodeOne.Nodes.Add(nodeTow);
}
}
nodeMain.Nodes.Add(nodeOne);
}
leftTree.Nodes.Add(nodeMain);
}
private static DataSet GetData()
{
Entity_t_Sys_Menu t_Menu = new Entity_t_Sys_Menu();
return t_Menu.GetData("[IsShow]=1");
}
}
}