/// <summary> /// 验证用户是否有权限操作表单功能 /// </summary> /// <param name="EmployeID"></param> /// <param name="MenuID"></param> /// <param name="toolbar"></param> public void CheckUserRight(long UserID, long MenuID, Nandasoft.WebControls.NDToolbar toolbar, Button btnQuery) { if (SessionState.IsAdmin == false) { if (toolbar != null) { for (int i = 0; i < toolbar.Items.Count; i++) { if (MenuFunctionRightQuery.CheckRightFunction1(UserID, MenuID, toolbar.Items[i].Value)) { toolbar.Items[i].Enabled = true; } else { toolbar.Items[i].Enabled = false; } } } if (btnQuery != null) { if (MenuFunctionRightQuery.CheckRightFunction1(UserID, MenuID, "Query")) { btnQuery.Enabled = true; } else { btnQuery.Enabled = false; } } } }
/// <summary> /// 人员下拉框 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void drpPersonList_SelectedIndexChanged(object sender, EventArgs e) { //将所有选中的节点清空 Node node = null; ArrayList arrNode = tvRight.CheckedNodes; for (int n = 0; n < arrNode.Count; n++) { node = (Node)arrNode[n]; node.Checked = false; } //选中用户有权限的菜单节点 if (drpPersonList.SelectedIndex != 0) { long UserID = NDConvert.ToInt64(drpPersonList.SelectedValue); DataTable dt = new RightQuery().GetUserRight(UserID); //获得用户所有有权限的菜单 for (int i = 0; i < dt.Rows.Count; i++) { long MenuID = NDConvert.ToInt64(dt.Rows[i]["MenuID"].ToString()); for (int j = 0; j < tvRight.Nodes.Count; j++) { if (MenuID == NDConvert.ToInt64(tvRight.Nodes[j].DataKey)) { tvRight.Nodes[j].Checked = true; } for (int k = 0; k < tvRight.Nodes[j].Nodes.Count; k++) { if (MenuID == NDConvert.ToInt64(tvRight.Nodes[j].Nodes[k].DataKey)) { tvRight.Nodes[j].Nodes[k].Checked = true; } if (MenuQuery.IsHaveChileMenu(NDConvert.ToInt64(tvRight.Nodes[j].Nodes[k].DataKey.ToString()))) //判断是否有子菜单,如有有子菜单说明本层是菜单,如果没有则是菜单功能项 { for (int m = 0; m < tvRight.Nodes[j].Nodes[k].Nodes.Count; m++) { if (MenuID == NDConvert.ToInt64(tvRight.Nodes[j].Nodes[k].Nodes[m].DataKey)) { tvRight.Nodes[j].Nodes[k].Nodes[m].Checked = true; } Nodes nodes = tvRight.Nodes[j].Nodes[k].Nodes[m].Nodes; for (int n = 0; n < nodes.Count; n++) { if (MenuFunctionRightQuery.CheckMenuFunctionRight(UserID, MenuID, NDConvert.ToInt64(nodes[n].DataKey))) { nodes[n].Checked = true; } } } } else { Nodes nodes = tvRight.Nodes[j].Nodes[k].Nodes; for (int n = 0; n < nodes.Count; n++) { if (MenuFunctionRightQuery.CheckMenuFunctionRight(UserID, MenuID, NDConvert.ToInt64(nodes[n].DataKey))) { nodes[n].Checked = true; } } } } } } } }