protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ManagerProvider provider = new ManagerProvider(); DataTable table = provider.Select(); this.treeView.Nodes.Clear(); DataView dv = table.DefaultView; dv.RowFilter = "parent_id = 0"; Users user = new Users(); user.User_account = Session["LOGINED"].ToString(); UserProvider userProvider = new UserProvider(); DataTable table1 = userProvider.Select(user); string account = table1.Rows[0]["role_name"].ToString(); if (account.Equals("管理员")) { //加入根节点 foreach (DataRowView drv in dv) { TreeNode root = new TreeNode(drv["manage_name"].ToString(), drv["manage_id"].ToString()); this.treeView.Nodes.Add(root); } for (int i = 0; i < this.treeView.Nodes.Count; i++) { this.AddChildNode(table, this.treeView.Nodes[i]); } } else if (account.Equals("采购员")) { int j = 0; //加入根节点 foreach (DataRowView drv in dv) { j++; if (j == 1) { continue; } if (j == 3) { continue; } if (j == 4) { continue; } if (j == 5) { continue; } if (j == 6) { continue; } TreeNode root = new TreeNode(drv["manage_name"].ToString(), drv["manage_id"].ToString()); this.treeView.Nodes.Add(root); } for (int i = 0; i < this.treeView.Nodes.Count; i++) { this.AddChildNode(table, this.treeView.Nodes[i]); } } else if (account.Equals("销售员")) { int j = 0; //加入根节点 foreach (DataRowView drv in dv) { j++; if (j == 1) { continue; } if (j == 2) { continue; } if (j == 4) { continue; } if (j == 5) { continue; } if (j == 6) { continue; } TreeNode root = new TreeNode(drv["manage_name"].ToString(), drv["manage_id"].ToString()); this.treeView.Nodes.Add(root); } for (int i = 0; i < this.treeView.Nodes.Count; i++) { this.AddChildNode(table, this.treeView.Nodes[i]); } } else if (account.Equals("仓库员")) { int j = 0; //加入根节点 foreach (DataRowView drv in dv) { j++; if (j == 1) { continue; } if (j == 3) { continue; } if (j == 2) { continue; } if (j == 5) { continue; } if (j == 6) { continue; } TreeNode root = new TreeNode(drv["manage_name"].ToString(), drv["manage_id"].ToString()); this.treeView.Nodes.Add(root); } for (int i = 0; i < this.treeView.Nodes.Count; i++) { this.AddChildNode(table, this.treeView.Nodes[i]); } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ManagerProvider provider = new ManagerProvider(); DataTable table = provider.Select(); this.treeView.Nodes.Clear(); DataView dv = table.DefaultView; dv.RowFilter = "parent_id = 0"; Users user = new Users(); user.User_account = Session["LOGINED"].ToString(); user.User_Login = 1; UserProvider userProvider = new UserProvider(); DataTable table1 = userProvider.Select(user); string account = table1.Rows[0]["role_name"].ToString(); if (account.Equals("管理员")) { int j = 0; //加入根节点 foreach (DataRowView drv in dv) { j++; if (j != 1 && j != 2 && j != 6 && j != 8) { continue; } TreeNode root = new TreeNode(drv["manage_name"].ToString(), drv["manage_id"].ToString()); this.treeView.Nodes.Add(root); } for (int i = 0; i < this.treeView.Nodes.Count; i++) { this.AddChildNode(table, this.treeView.Nodes[i]); } } else if (account.Equals("采购员")) { int j = 0; //加入根节点 foreach (DataRowView drv in dv) { j++; if (j != 3 && j != 7 && j != 8) { continue; } if (j == 7) { if (Convert.ToInt32(Session["USERMANAGE"].ToString()) != 1) { continue; } } TreeNode root = new TreeNode(drv["manage_name"].ToString(), drv["manage_id"].ToString()); this.treeView.Nodes.Add(root); } for (int i = 0; i < this.treeView.Nodes.Count; i++) { this.AddChildNode(table, this.treeView.Nodes[i]); } } else if (account.Equals("销售员")) { int j = 0; //加入根节点 foreach (DataRowView drv in dv) { j++; if (j != 4 && j != 8) { continue; } TreeNode root = new TreeNode(drv["manage_name"].ToString(), drv["manage_id"].ToString()); this.treeView.Nodes.Add(root); } for (int i = 0; i < this.treeView.Nodes.Count; i++) { this.AddChildNode(table, this.treeView.Nodes[i]); } } else if (account.Equals("仓库员")) { int j = 0; //加入根节点 foreach (DataRowView drv in dv) { j++; if (j != 5 && j != 8) { continue; } TreeNode root = new TreeNode(drv["manage_name"].ToString(), drv["manage_id"].ToString()); this.treeView.Nodes.Add(root); } for (int i = 0; i < this.treeView.Nodes.Count; i++) { this.AddChildNode(table, this.treeView.Nodes[i]); } } /* * else if (account.Equals("采购商")) * { * int j = 0; * //加入根节点 * foreach (DataRowView drv in dv) * { * j++; * if (j != 7 && j != 8) * continue; * * TreeNode root = new TreeNode(drv["manage_name"].ToString(), drv["manage_id"].ToString()); * this.treeView.Nodes.Add(root); * } * * for (int i = 0; i < this.treeView.Nodes.Count; i++) * { * this.AddChildNode(table, this.treeView.Nodes[i]); * } * } */ } }