/// <summary> /// 修改密码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void butChange_onClick(object sender, EventArgs e) { try { UserInfo user = (UserInfo)Session["UserInfo"]; if (user != null) { MD5Encrypt md5Encrypt = new MD5Encrypt(); if (user.logPassword == md5Encrypt.GetMD5(this.pswOldPsw.Value)) { user.logPassword = md5Encrypt.GetMD5(this.pswNewPsw1.Value); OrgOperater orgDB = new OrgOperater(); //获取配置文件路径。 string configFile = AppDomain.CurrentDomain.BaseDirectory.ToString() + SystemConfig.databaseConfigFileName; //获取数据库实例。 YDataBase orgDb = YDataBaseConfigFile.createDataBase(configFile, SystemConfig.databaseConfigNodeName, SystemConfig.configFileKey); if (orgDb != null) { //更新数据 OrgOperater orgOper = new OrgOperater(); orgOper.orgDataBase = orgDb; bool bRet = orgOper.changePassword(user); if (bRet) { //更新成功。 YMessageBox.showAndResponseScript(this, "修改用户密码成功!", "", "window.parent.closePopupsWindow('#popups');"); } else { //更新出错。 YMessageBox.show(this, "修改用户密码出错!错误信息[" + orgOper.errorMessage + "]"); } } } else { //原密码验证出错。 YMessageBox.show(this, "原密码验证错误!"); } } else { Exception ex = new Exception("用户登陆超时,请重新登陆!"); throw ex; } } catch (Exception ex) { YMessageBox.show(this, "修改用户密码出错!错误信息[" + ex.Message + "]"); } }
/// <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 + "]"); } }
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); } }
/// <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 + "]"); } }
protected void butLogin_Click(object sender, EventArgs e) { //用户登陆 try { //校验数据 if (string.IsNullOrEmpty(this.txtUserName.Value)) { //用户名不能为空 YMessageBox.show(this, "用户名不能为空,请输入用户名后重新登录!"); return; } //获取配置文件路径。 string configFile = AppDomain.CurrentDomain.BaseDirectory.ToString() + SystemConfig.databaseConfigFileName; //获取数据库实例。 YDataBase orgDb = YDataBaseConfigFile.createDataBase(configFile, SystemConfig.databaseConfigNodeName, SystemConfig.configFileKey); if (orgDb != null) { //获取用户 OrgOperater orgOper = new OrgOperater(); orgOper.orgDataBase = orgDb; //用户密码二次加密 MD5Encrypt md5Encrypt = new MD5Encrypt(); UserInfo logUser = orgOper.getUser(this.txtUserName.Value, md5Encrypt.GetMD5(this.passUserPassword.Value)); if (logUser != null && logUser.id > 0) { //验证成功,跳转主页 FormsAuthentication.RedirectFromLoginPage(logUser.id.ToString(), false); Session.Add("UserInfo", logUser); } else { //验证失败 YMessageBox.show(this, "用户验证失败,请核对用户名和密码后重新登录!"); } } } catch (Exception ex) { YMessageBox.show(this, "用户登陆异常!异常消息[" + ex.Message + "]"); } }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { //获取菜单 try { //获取id,没有id表示新增,否则为修改 string roleId = Request.QueryString["id"]; if (!string.IsNullOrEmpty(roleId)) { this.hidRoleId.Value = roleId; } //获取配置文件路径。 string configFile = AppDomain.CurrentDomain.BaseDirectory.ToString() + SystemConfig.databaseConfigFileName; //获取数据库实例。 YDataBase orgDb = YDataBaseConfigFile.createDataBase(configFile, SystemConfig.databaseConfigNodeName, SystemConfig.configFileKey); if (orgDb != null) { RoleOperater roleOper = new RoleOperater(); roleOper.roleDataBase = orgDb; List <RoleMenuInfo> menus = roleOper.getChouseMenus(Convert.ToInt32(this.hidRoleId.Value)); this.menuGroup.DataSource = menus; this.menuGroup.DataBind(); } else { YMessageBox.show(this, "获取数据库实例失败!"); } } catch (Exception ex) { YMessageBox.showAndRedirect(this, "系统运行异常!异常信息[" + ex.Message + "]", "sys/login.aspx"); } } }
/// <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 + "]"); } }
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 + "]"); } }
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); } }
/// <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 + "]"); } }