1 Star 0 Fork 0

申健/wewanda

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Default.aspx.cs 10.72 KB
一键复制 编辑 原始数据 按行查看 历史
申健 提交于 2024-03-19 22:27 . 提交所有
using System;
using System.Data;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using FIH;
using System.Collections.Generic;
using System.Threading;
using DBML;
using System.Management;
using Dev.UserFunction;
public partial class _Default : BasePage
{
public _Default()
: base("_Default")
{
//base.ShowList = true;
//Navigation = "后台管理";
//TitleName = "数据字典管理";
//base.PageState = this.PageState;
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//从查询条件表中删除历史记录
SearchCondition.DeleteOldSearchCondition(1, Profile.UserCode, Page);
if (Profile.IsCustomer)
{
Response.Redirect("BillStatus.aspx");
//MainDefault.Attributes["src"] = "BillStatus.aspx";
}
else
{
Response.Redirect("Desktop.aspx");
//MainDefault.Attributes["src"] = "Desktop.aspx";
}
//this.litMeun.Text = SetMenu();
}
//定位到登陆界面
if (Session[PubFunction.User_ID] == null)
{
Response.Redirect("user\\login");
}
//使得别的界面不能后退到此界面
Response.Buffer = true;
Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
Response.Expires = 0;
Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
Response.Cache.SetNoStore();
Response.Expires = 0;
Response.AppendHeader("pragma", "no-cache");
Response.AppendHeader("cache-control", "private");
Response.Cache.SetExpires(DateTime.Now.AddSeconds(-60));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetValidUntilExpires(false);
}
private string SetMenu()
{
System.Text.StringBuilder meun = new StringBuilder();
meun.Append("<ul class=\"nav navbar-form pull-left\" role=\"navigation\">");
IList<RoleModule> myRoleModuleList;
if (Profile.IsCustomer)
{
myRoleModuleList = myRoleModuleDAL.FindAllByConditionRole(Profile.OperRoleCode);
}
else
{
myRoleModuleList = myRoleModuleDAL.FindAllByCondition(Profile.UserCode);
}
foreach (var item in myRoleModuleList.Where(n => n.PModuleCode == "1000"))
{
meun.Append("<li class=\"dropdown\">");
var SubData = myRoleModuleList.Where(n => n.PModuleCode == item.ModuleCode);
if (SubData.Count() > 0)
{
meun.AppendFormat("<a class=\"dropdown-toggle\" id=\"t{1}\" role=\"button\" data-toggle=\"dropdown\" href=\"#\">{0}<b class=\"caret\"></b></a>", item.ModuleNameCN, item.ModuleCode);
meun.AppendFormat("<ul class=\"dropdown-menu\" role=\"menu\" aria-labelledby=\"t{0}\">", item.ModuleCode);
foreach (var sub in SubData)
{
meun.AppendFormat("<li><a href=\"{0}\" target=\"MainDefault\"><i class=\"fa fa-user\"></i>{1}</a></li>", sub.ModulePage, sub.ModuleNameCN);
}
meun.Append(" </ul>");
}
meun.Append("</li>");
}
meun.Append("<li >"); //class=\"dropdown\"
meun.AppendFormat("<a onclick=\"logout()\" href=\"#\">退出<b ></b></a>"); //class=\"caret\"
//class=\"dropdown-toggle\"
meun.Append("</li>");
meun.Append("</ul>");
return meun.ToString();
}
//创建菜单
private void CreateMenu(Menu MainMenu)
{
//清除所有菜单
MainMenu.Items.Clear();
//获得第一級菜單[PModuleCode = "1000"]在RoleModule表的记录集合X
RoleModule myRoleModule = new RoleModule();
myRoleModule.PModuleCode = "1000";
IList<RoleModule> myRoleModuleList = new List<RoleModule>();
myRoleModuleList = myRoleModuleDAL.FindAllByCondition(myRoleModule);
//获得该用户具有的OperRoleCode在RoleOperRoleFunction表中对应的记录集合Y
RoleOperRoleFunctionDAL myRoleOperRoleFunctionDAL = new RoleOperRoleFunctionDAL();
IList<RoleOperRoleFunction> myRoleOperRoleFunctionList = new List<RoleOperRoleFunction>();
//myRoleOperRoleFunctionList = myRoleOperRoleFunctionDAL.FindMenuItem(Profile.OperRoleCode.Trim());
//检查记录集合X的ModuleCode是否在记录集合Y中存在
//此處是比較roleModule表(一級菜單) 和 roleOperRoleFunction表(角色權限表,某個模塊下的按鈕) ModuleCode 進行了排序,所以一級菜單在最前面。
//Bayou 由于在保存權限的時候沒有把一級權限保存,所以把部分代碼注釋掉、這樣把所有的一級菜單全列出來。
//循环一级菜单
for (int i = 0; i < myRoleModuleList.Count; i++)
{
//for (int j = 0; j < myRoleOperRoleFunctionList.Count; j++)
//{
// if (myRoleOperRoleFunctionList[j].ModuleCode == (myRoleModuleList[i].ModuleCode) )
// {
//取出改模块下的子菜单
myRoleOperRoleFunctionList = myRoleOperRoleFunctionDAL.FindMenuItem(Profile.OperRoleCode.Trim(), myRoleModuleList[i].ModuleCode);
MenuItem myMenuItem = new MenuItem();
myMenuItem.Value = myRoleModuleList[i].ModuleCode;
myMenuItem.Text = myRoleModuleList[i].ModuleNameCN;
myMenuItem.Target = "MainDefault";
myMenuItem.NavigateUrl = AdjustUrl(myRoleModuleList[i].ModulePage);
//假如存在子节点
//if (IsExistChildNodes(myRoleModuleList[i].ModuleCode) == true)
if (myRoleOperRoleFunctionList.Count>0)
{
MainMenu.Items.Add(myMenuItem);
CreateSubMenu(myMenuItem);
}
// }
//}
}
}
RoleModuleDAL myRoleModuleDAL = new RoleModuleDAL();
private void CreateSubMenu(MenuItem RefMenuItem)
{
//获得本菜單[PModuleCode = MenuItem.Value]在RoleModule表的记录集合X
RoleModule myRoleModule = new RoleModule();
myRoleModule.PModuleCode = RefMenuItem.Value;
IList<RoleModule> myRoleModuleList = new List<RoleModule>();
myRoleModuleList = myRoleModuleDAL.FindAllByCondition(myRoleModule);
//获得该用户具有的OperRoleCode在RoleOperRoleFunction表中对应的记录集合Y
RoleOperRoleFunctionDAL myRoleOperRoleFunctionDAL = new RoleOperRoleFunctionDAL();
IList<RoleOperRoleFunction> myRoleOperRoleFunctionList = new List<RoleOperRoleFunction>();
myRoleOperRoleFunctionList = myRoleOperRoleFunctionDAL.FindMenuItem(Profile.OperRoleCode.Trim());
//检查记录集合X的ModuleCode是否在记录集合Y中存在
for (int i = 0; i < myRoleModuleList.Count; i++)
{
for (int j = 0; j < myRoleOperRoleFunctionList.Count; j++)
{
if (myRoleOperRoleFunctionList[j].ModuleCode == myRoleModuleList[i].ModuleCode)
{
if (UDF.GetAppSettingValue("SysFlag") == "888")
{
/*
if (RefMenuItem.Value == "1002")
{
if (myRoleModuleList[i].ModuleCode == "3012") //HK 提货区域
{
continue;
}
}
*/
if (RefMenuItem.Value == "1020")
{
if ((myRoleModuleList[i].ModuleCode == "7011") || (myRoleModuleList[i].ModuleCode == "7007") || (myRoleModuleList[i].ModuleCode == "7010")) //导宋的单
{
continue;
}
}
}
if (UDF.GetAppSettingValue("SysFlag") == "1")
{
if (RefMenuItem.Value == "1020")
{
if (myRoleModuleList[i].ModuleCode == "7009") ////未下单客户
{
continue;
}
}
}
MenuItem myMenuItem = new MenuItem();
myMenuItem.Value = myRoleModuleList[i].ModuleCode;
myMenuItem.Text = myRoleModuleList[i].ModuleNameCN;
myMenuItem.Target = "MainDefault";
myMenuItem.NavigateUrl = AdjustUrl(myRoleModuleList[i].ModulePage);
RefMenuItem.ChildItems.Add(myMenuItem);
//假如存在子节点
if (IsExistChildNodes(myRoleModuleList[i].ModuleCode) == true)
{
CreateSubMenu(myMenuItem);
}
}
}
}
}
/// <summary>
/// 是否存在子节点
/// </summary>
protected bool IsExistChildNodes(string ModuleCode)
{
//定义实例
RoleModule myRoleModule = new RoleModule();
myRoleModule.PModuleCode = ModuleCode;
IList<RoleModule> myRoleModuleList = new List<RoleModule>();
myRoleModuleList = myRoleModuleDAL.FindAllByCondition(myRoleModule);
if (myRoleModuleList.Count > 0)
{
return true;
}
else return false;
}
protected void MenuItemClick(object sender, MenuEventArgs e)
{
Menu myMenu = (Menu)sender;
string SS = myMenu.SelectedValue.ToLower();
if ((myMenu.SelectedValue.ToLower().Equals("logout") == true) || (myMenu.SelectedValue.ToLower().Equals("登出") == true))
{
Session.Abandon();
Session.Clear();
FormsAuthentication.SignOut();
//重新设定Profile
Profile.UserCode = "";
Profile.IsCustomer = false;
Response.Redirect("Login.aspx");
}
}
/// <summary>
/// 对UrlPage进行过滤
/// </summary>
private string AdjustUrl(string UrlPage)
{
if (UrlPage == null)
{
return "";
}
else if (UrlPage.ToLower().Contains(".aspx") == false)
{
return "";
}
else
{
return UrlPage;
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/shen_jian15814332402/wewanda.git
git@gitee.com:shen_jian15814332402/wewanda.git
shen_jian15814332402
wewanda
wewanda
master

搜索帮助