/// <summary>
        /// 删除数据
        /// 作者:董帅 创建时间:2013-5-4 23:07:57
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void butDeleteItems_Click(object sender, EventArgs e)
        {
            try
            {
                string   s      = Request["chkPage"];
                string[] dicIds = new string[0];
                if (!string.IsNullOrEmpty(s))
                {
                    dicIds = s.Split(','); //要删除的字典id
                }

                if (dicIds.Length > 0)
                {
                    //获取配置文件路径。
                    string configFile = AppDomain.CurrentDomain.BaseDirectory.ToString() + SystemConfig.databaseConfigFileName;

                    //获取数据库实例。
                    YDataBase orgDb = YDataBaseConfigFile.createDataBase(configFile, SystemConfig.databaseConfigNodeName, SystemConfig.configFileKey);

                    if (orgDb != null)
                    {
                        MenuOperater menuOper = new MenuOperater();
                        menuOper.menuDataBase = orgDb;

                        //删除字典项
                        int[] dicIntIds = new int[dicIds.Length];
                        for (int i = 0; i < dicIds.Length; i++)
                        {
                            dicIntIds[i] = Convert.ToInt32(dicIds[i]);
                        }

                        if (menuOper.deletePages(dicIntIds))
                        {
                            this.Response.Redirect("setPage_list.aspx?menuId=" + this.hidMenuId.Value);
                        }
                        else
                        {
                            YMessageBox.show(this, "删除数据失败!错误信息[" + menuOper.errorMessage + "]");
                        }
                    }
                    else
                    {
                        YMessageBox.show(this, "获取数据库实例失败!");
                    }
                }
                else
                {
                    YMessageBox.show(this, "没有选择要删除的页面!");
                }
            }
            catch (Exception ex)
            {
                YMessageBox.show(this, "系统运行异常!异常信息[" + ex.Message + "]");
            }
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                //获取用户信息。
                UserInfo user = (UserInfo)Session["UserInfo"];
                try
                {
                    if (user != null)
                    {
                        this.userName.InnerText = user.name;
                        this.logName.InnerText  = user.logName;
                    }
                    else
                    {
                        YMessageBox.showAndRedirect(this, "用户登陆超时,请重新登陆!", "sys/login.aspx");
                    }
                }
                catch (Exception ex)
                {
                    YMessageBox.showAndRedirect(this, "系统运行异常!异常信息[" + ex.Message + "]", "sys/login.aspx");
                }

                //获取菜单
                try
                {
                    //获取配置文件路径。
                    string configFile = AppDomain.CurrentDomain.BaseDirectory.ToString() + SystemConfig.databaseConfigFileName;

                    //获取数据库实例。
                    YDataBase orgDb = YDataBaseConfigFile.createDataBase(configFile, SystemConfig.databaseConfigNodeName, SystemConfig.configFileKey);

                    if (orgDb != null)
                    {
                        MenuOperater menuOper = new MenuOperater();
                        menuOper.menuDataBase = orgDb;

                        List <MenuInfo> menus = menuOper.getMainPageMunus(user.id);
                        this.menuGroup.DataSource = menus;
                        this.menuGroup.DataBind();
                    }
                    else
                    {
                        YMessageBox.show(this, "获取数据库实例失败!");
                    }
                }
                catch (Exception ex)
                {
                    YMessageBox.showAndRedirect(this, "系统运行异常!异常信息[" + ex.Message + "]", "sys/login.aspx");
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!this.IsPostBack)
                {
                    this.menuId = Request.QueryString["menuId"];
                    if (!string.IsNullOrEmpty(this.menuId))
                    {
                        this.hidMenuId.Value = menuId;
                    }

                    string pageId = Request.QueryString["pageId"];
                    if (!string.IsNullOrEmpty(pageId))
                    {
                        this.hidPageId.Value = pageId;
                        //获取页面信息。
                        string    configFile = AppDomain.CurrentDomain.BaseDirectory.ToString() + SystemConfig.databaseConfigFileName;
                        YDataBase orgDb      = YDataBaseConfigFile.createDataBase(configFile, SystemConfig.databaseConfigNodeName, SystemConfig.configFileKey);

                        if (orgDb != null)
                        {
                            MenuOperater menuOper = new MenuOperater();
                            menuOper.menuDataBase = orgDb;
                            PageInfo page = menuOper.getPage(Convert.ToInt32(this.hidPageId.Value));

                            if (page != null)
                            {
                                this.txtFileDetail.Value = page.detail;
                                this.txtFilePath.Value   = page.filePath;
                            }
                            else
                            {
                                YMessageBox.show(this, "获取页面信息失败!错误信息[" + menuOper.errorMessage + "]");
                                return;
                            }
                        }
                        else
                        {
                            YMessageBox.show(this, "创建数据库操作对象失败!");
                            return;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                YMessageBox.show(this, "程序异常," + ex.Message);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 删除菜单。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void butDeleteItem_Click(object sender, EventArgs e)
        {
            try
            {
                string[] ids = Request["chkItem"].Split(',');

                if (ids.Length > 0)
                {
                    //获取配置文件路径。
                    string configFile = AppDomain.CurrentDomain.BaseDirectory.ToString() + SystemConfig.databaseConfigFileName;

                    //获取数据库实例。
                    YDataBase orgDb = YDataBaseConfigFile.createDataBase(configFile, SystemConfig.databaseConfigNodeName, SystemConfig.configFileKey);

                    if (orgDb != null)
                    {
                        MenuOperater menuOper = new MenuOperater();
                        menuOper.menuDataBase = orgDb;

                        //删除数据
                        int[] intIds = new int[ids.Length];
                        for (int i = 0; i < intIds.Length; i++)
                        {
                            intIds[i] = Convert.ToInt32(ids[i]);
                        }

                        if (menuOper.deleteItem(intIds))
                        {
                            YMessageBox.showAndResponseScript(this, "删除数据成功!", "", "window.parent.menuButtonOnClick('系统菜单','icon-menu','sys/menu/menu_list.aspx')");
                        }
                        else
                        {
                            YMessageBox.show(this, "删除数据失败!错误信息[" + menuOper.errorMessage + "]");
                        }
                    }
                    else
                    {
                        YMessageBox.show(this, "获取数据库实例失败!");
                    }
                }
                else
                {
                    YMessageBox.show(this, "没有选择要删除的分组!");
                }
            }
            catch (Exception ex)
            {
                YMessageBox.show(this, "系统运行异常!异常信息[" + ex.Message + "]");
            }
        }
        /// <summary>
        /// 绑定数据。
        /// </summary>
        private void bindData()
        {
            //获取菜单
            try
            {
                //获取配置文件路径。
                string configFile = AppDomain.CurrentDomain.BaseDirectory.ToString() + SystemConfig.databaseConfigFileName;

                //获取数据库实例。
                YDataBase orgDb = YDataBaseConfigFile.createDataBase(configFile, SystemConfig.databaseConfigNodeName, SystemConfig.configFileKey);

                if (orgDb != null)
                {
                    MenuOperater menuOper = new MenuOperater();
                    menuOper.menuDataBase = orgDb;

                    //绑定分组
                    List <PageInfo> pages = menuOper.getPageByMenuId(Convert.ToInt32(this.hidMenuId.Value));
                    if (pages != null)
                    {
                        this.pageList.DataSource = pages;
                        this.pageList.DataBind();
                    }
                    else
                    {
                        YMessageBox.show(this, "获取数据失败!");
                    }
                }
                else
                {
                    YMessageBox.show(this, "获取数据库实例失败!");
                }
            }
            catch (Exception ex)
            {
                YMessageBox.show(this, "系统运行异常!异常信息[" + ex.Message + "]");
            }
        }
        protected void butSave_Click(object sender, EventArgs e)
        {
            try
            {
                //创建菜单对象
                PageInfo page = new PageInfo();

                //菜单名称
                if (string.IsNullOrEmpty(this.txtFilePath.Value))
                {
                    YMessageBox.show(this, "路径不能为空!");
                    return;
                }
                else
                {
                    page.filePath = this.txtFilePath.Value;
                }

                page.detail = this.txtFileDetail.Value;
                page.menuId = Convert.ToInt32(this.hidMenuId.Value);

                //父菜单
                if (string.IsNullOrEmpty(this.hidPageId.Value))
                {
                    page.id = -1;
                }
                else
                {
                    page.id = Convert.ToInt32(this.hidPageId.Value);
                }

                //获取配置文件路径。
                string configFile = AppDomain.CurrentDomain.BaseDirectory.ToString() + SystemConfig.databaseConfigFileName;

                //获取数据库实例。
                YDataBase menuDb = YDataBaseConfigFile.createDataBase(configFile, SystemConfig.databaseConfigNodeName, SystemConfig.configFileKey);

                if (menuDb != null)
                {
                    MenuOperater menuOper = new MenuOperater();
                    menuOper.menuDataBase = menuDb;

                    if (string.IsNullOrEmpty(this.hidPageId.Value))
                    {
                        //新增菜单
                        int iRet = menuOper.createNewPage(page);
                        if (iRet > 0)
                        {
                            YMessageBox.showAndResponseScript(this, "保存成功!", "", "window.location.href='setPage_list.aspx?menuId=" + this.hidMenuId.Value + "';");
                        }
                        else
                        {
                            YMessageBox.show(this, "创建页面出错!错误信息[" + menuOper.errorMessage + "]");
                        }
                    }
                    else
                    {
                        //修改菜单
                        page.id = Convert.ToInt32(this.hidPageId.Value);
                        bool bRet = menuOper.changePage(page);
                        if (bRet)
                        {
                            YMessageBox.showAndResponseScript(this, "保存成功!", "", "window.location.href='setPage_list.aspx?menuId=" + this.hidMenuId.Value + "';");
                        }
                        else
                        {
                            YMessageBox.show(this, "修改页面出错!错误信息[" + menuOper.errorMessage + "]");
                        }
                    }
                }
                else
                {
                    YMessageBox.show(this, "获取数据库实例失败!");
                }
            }
            catch (Exception ex)
            {
                YMessageBox.show(this, "保存数据出错!错误信息[" + ex.Message + "]");
            }
        }
Beispiel #7
0
        protected void Application_AcquireRequestState(object sender, EventArgs e)
        {
            string reqFile = Request.Path.ToString();

            //判断请求是否在background里。
            if ("/" != Request.ApplicationPath.ToString())
            {
                reqFile = reqFile.Replace(Request.ApplicationPath.ToString(), "");
            }

            if (reqFile.IndexOf("/background") == 0 && reqFile.IndexOf("/background/sys/login.aspx") != 0)
            {
                string   strNoFilterFiles = System.Configuration.ConfigurationManager.AppSettings["noFilterFiles"].ToString();
                string[] noFilterFiles    = null;
                if (!string.IsNullOrEmpty(strNoFilterFiles))
                {
                    noFilterFiles = strNoFilterFiles.Split(',');
                }

                if (noFilterFiles != null && noFilterFiles.Length > 0)
                {
                    //判断请求文件是否不在过滤范围之内。
                    string extName = reqFile.Substring(reqFile.LastIndexOf("."));
                    for (int i = 0; i < noFilterFiles.Length; i++)
                    {
                        if (extName == noFilterFiles[i])
                        {
                            return;
                        }
                    }
                }

                HttpApplication app  = (HttpApplication)sender;
                UserInfo        user = (UserInfo)app.Session["UserInfo"];
                if (null != user)
                {
                    if (user.id == 1)
                    {
                        return;
                    }



                    //查询页面是否与菜单关联。
                    string configFile = AppDomain.CurrentDomain.BaseDirectory.ToString() + SystemConfig.databaseConfigFileName;

                    MenuOperater oper = MenuOperater.createMenuOperater(configFile, SystemConfig.databaseConfigNodeName, SystemConfig.configFileKey);
                    if (oper != null)
                    {
                        if (oper.pageExists(reqFile))
                        {
                            //页面关联,需要进行权限验证。
                            RoleOperater roleOper = RoleOperater.createRoleOperater(configFile, SystemConfig.databaseConfigNodeName, SystemConfig.configFileKey);
                            if (roleOper != null)
                            {
                                if (!roleOper.pageAllowRequest(user.id, reqFile))
                                {
                                    //页面不允许访问。
                                    Response.Redirect("~/background/sys/stop.aspx?waringText=你正试图访问未经授权的页面!", true);
                                }
                            }
                            else
                            {
                                //访问权限数据库初始化出错。
                                Response.Redirect("~/background/sys/stop.aspx?waringText=访问权限数据库初始失败!", true);
                            }
                        }
                    }
                    else
                    {
                        //页面数据库初始化失败。
                        Response.Redirect("~/background/sys/stop.aspx?waringText=页面关联数据库初始失败!", true);
                    }
                }
                else
                {
                    //登陆超时。
                    //Response.Write("用户登陆超时!");
                    Response.Redirect("~/background/sys/login.aspx", true);
                }
            }
        }
Beispiel #8
0
        protected void butSave_Click(object sender, EventArgs e)
        {
            try
            {
                //创建菜单对象
                MenuInfo menu = new MenuInfo();

                //菜单名称
                if (string.IsNullOrEmpty(this.txtMenuName.Value))
                {
                    YMessageBox.show(this, "菜单名称不能为空!");
                    return;
                }
                else
                {
                    menu.name = this.txtMenuName.Value;
                }

                menu.url         = this.txtMenuURL.Value;
                menu.icon        = this.txtMenuICON.Value;
                menu.desktopIcon = this.txtMenuDesktopICON.Value;
                menu.order       = Convert.ToInt32(this.txtMenuOrder.Value);

                //父菜单
                if (string.IsNullOrEmpty(this.hidParentId.Value))
                {
                    menu.parentID = -1;
                }
                else
                {
                    menu.parentID = Convert.ToInt32(this.hidParentId.Value);
                }

                //获取配置文件路径。
                string configFile = AppDomain.CurrentDomain.BaseDirectory.ToString() + SystemConfig.databaseConfigFileName;

                //获取数据库实例。
                YDataBase orgDb = YDataBaseConfigFile.createDataBase(configFile, SystemConfig.databaseConfigNodeName, SystemConfig.configFileKey);

                if (orgDb != null)
                {
                    MenuOperater menuOper = new MenuOperater();
                    menuOper.menuDataBase = orgDb;

                    if (string.IsNullOrEmpty(this.hidMenuId.Value))
                    {
                        //新增菜单
                        int iRet = menuOper.createNewMenu(menu);
                        if (iRet > 0)
                        {
                            if (this.txtMenuURL.Disabled)
                            {
                                //分组
                                YMessageBox.showAndResponseScript(this, "保存成功!", "", "window.parent.menuButtonOnClick('系统菜单','icon-menu','sys/menu/menu_list.aspx?id=" + iRet.ToString() + "');window.parent.closePopupsWindow('#popups');");
                            }
                            else
                            {
                                //菜单
                                YMessageBox.showAndResponseScript(this, "保存成功!", "", "window.parent.menuButtonOnClick('系统菜单','icon-menu','sys/menu/menu_list.aspx?id=" + this.hidParentId.Value + "');window.parent.closePopupsWindow('#popups');");
                            }
                        }
                        else
                        {
                            YMessageBox.show(this, "创建菜单出错!错误信息[" + menuOper.errorMessage + "]");
                        }
                    }
                    else
                    {
                        //修改菜单
                        menu.id = Convert.ToInt32(this.hidMenuId.Value);
                        bool bRet = menuOper.changeMenu(menu);
                        if (bRet)
                        {
                            if (this.txtMenuURL.Disabled)
                            {
                                //分组
                                YMessageBox.showAndResponseScript(this, "保存成功!", "", "window.parent.menuButtonOnClick('系统菜单','icon-menu','sys/menu/menu_list.aspx?id=" + menu.id.ToString() + "');window.parent.closePopupsWindow('#popups');");
                            }
                            else
                            {
                                //菜单
                                YMessageBox.showAndResponseScript(this, "保存成功!", "", "window.parent.menuButtonOnClick('系统菜单','icon-menu','sys/menu/menu_list.aspx?id=" + menu.parentID.ToString() + "');window.parent.closePopupsWindow('#popups');");
                            }
                        }
                        else
                        {
                            YMessageBox.show(this, "修改菜单出错!错误信息[" + menuOper.errorMessage + "]");
                        }
                    }
                }
                else
                {
                    YMessageBox.show(this, "获取数据库实例失败!");
                }
            }
            catch (Exception ex)
            {
                YMessageBox.show(this, "保存数据出错!错误信息[" + ex.Message + "]");
            }
        }
Beispiel #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!this.IsPostBack)
                {
                    //判断编辑菜单类型,group是分组,item是菜单,默认是分组
                    string pageType = Request.QueryString["pageType"];
                    if (string.IsNullOrEmpty(pageType) || pageType == "group")
                    {
                        this.txtMenuURL.Disabled         = true;
                        this.txtMenuDesktopICON.Disabled = true;
                    }

                    //获取父id
                    string parentId = Request.QueryString["parentId"];
                    if (!string.IsNullOrEmpty(parentId))
                    {
                        this.hidParentId.Value = parentId;
                    }

                    //获取id,没有id表示新增,否则为修改
                    string menuId = Request.QueryString["id"];
                    if (!string.IsNullOrEmpty(menuId))
                    {
                        //修改,获取数据
                        //获取配置文件路径。
                        string configFile = AppDomain.CurrentDomain.BaseDirectory.ToString() + SystemConfig.databaseConfigFileName;

                        //获取数据库实例。
                        YDataBase orgDb = YDataBaseConfigFile.createDataBase(configFile, SystemConfig.databaseConfigNodeName, SystemConfig.configFileKey);

                        if (orgDb != null)
                        {
                            MenuOperater menuOper = new MenuOperater();
                            menuOper.menuDataBase = orgDb;

                            MenuInfo menu = menuOper.getMenu(Convert.ToInt32(menuId));
                            if (menu != null)
                            {
                                this.hidMenuId.Value          = menu.id.ToString();
                                this.txtMenuName.Value        = menu.name;
                                this.txtMenuURL.Value         = menu.url;
                                this.txtMenuICON.Value        = menu.icon;
                                this.txtMenuDesktopICON.Value = menu.desktopIcon;
                                this.txtMenuOrder.Value       = menu.order.ToString();
                            }
                            else
                            {
                                YMessageBox.show(this, "未找到指定的菜单!");
                            }
                        }
                        else
                        {
                            YMessageBox.show(this, "获取数据库实例失败!");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                YMessageBox.show(this, ex.Message);
            }
        }
Beispiel #10
0
        /// <summary>
        /// 绑定数据。
        /// </summary>
        private void bindData()
        {
            //获取菜单
            try
            {
                //获取配置文件路径。
                string configFile = AppDomain.CurrentDomain.BaseDirectory.ToString() + SystemConfig.databaseConfigFileName;

                //获取数据库实例。
                YDataBase orgDb = YDataBaseConfigFile.createDataBase(configFile, SystemConfig.databaseConfigNodeName, SystemConfig.configFileKey);

                if (orgDb != null)
                {
                    MenuOperater menuOper = new MenuOperater();
                    menuOper.menuDataBase = orgDb;

                    //绑定分组
                    List <MenuInfo> menus = menuOper.getMenuByParentId(-1);
                    if (menus != null)
                    {
                        this.menuGroups.DataSource = menus;
                        this.menuGroups.DataBind();
                    }
                    else
                    {
                        return;
                    }

                    //设置选中的分组id
                    if (string.IsNullOrEmpty(this.selectGroupId.Value) && menus.Count > 0)
                    {
                        this.selectGroupId.Value = menus[0].id.ToString();

                        //设置标题和图标
                        this.groupTitle = menus[0].name;
                        this.groupIcon  = menus[0].icon;
                    }
                    else
                    {
                        //设置标题和图标
                        foreach (MenuInfo m in menus)
                        {
                            if (m.id.ToString() == this.selectGroupId.Value)
                            {
                                this.groupTitle = m.name;
                                this.groupIcon  = m.icon;
                            }
                        }
                    }

                    //获取子菜单
                    if (menus.Count > 0)
                    {
                        List <MenuInfo> childMenus = menuOper.getMenuByParentId(Convert.ToInt32(this.selectGroupId.Value));

                        if (childMenus != null)
                        {
                            this.childs.DataSource = childMenus;
                            this.childs.DataBind();
                        }
                    }
                }
                else
                {
                    YMessageBox.show(this, "获取数据库实例失败!");
                }
            }
            catch (Exception ex)
            {
                YMessageBox.show(this, "系统运行异常!异常信息[" + ex.Message + "]");
            }
        }