///// <summary> ///// 查询 ///// </summary> ///// <param name="id">id</param> ///// <returns></returns> //public List<Bd_Base_Page> GetListById(Guid id) //{ // List<Bd_Base_Page> bPaseList = new List<Bd_Base_Page>(); // try // { // bPaseList = new Dal.ControlBase.BaseData<Bd_Base_Page>().GetList(); // bPaseList = bPaseList.Where(c => c.id == id).ToList<Bd_Base_Page>(); // //IEnumerable<Bd_Base_Page> querys = null; // //querys = from c in bPaseList where c.RoleType == roleType select c; // //bPaseNewList = querys.ToList<Bd_Base_Page>(); // } // catch (Exception) // { // } // return bPaseList; //} /// <summary> /// 通过角色类型 获取最大的:PageIndex /// </summary> /// <param name="roleType">角色类型</param> /// <returns></returns> public int GetPageIndexMaxByRoleType(int roleType) { int result = 0; try { List <Bd_Base_Page> bPaseList = new Bd_Base_PageBLL().GetList(); result = bPaseList.Where(w => w.RoleType == roleType).Select(ss => ss.PageIndex).Max(); } catch (Exception ex) { } return(result); }
/// <summary> /// /// </summary> public void GetPagePermissions() { try { hid_RoleType.Value = mCompany.RoleType.ToString(); User_Permissions mPost = null; if (m_UserPermissions != null) { //Session中获取登录用户页面权限 mPost = m_UserPermissions; } else { //数据库中读取用户权限 mPost = new PbProject.Logic.User.User_PermissionsBLL().GetById(mUser.DeptId); } if (mPost != null && !string.IsNullOrEmpty(mPost.Permissions)) { string strValue = "," + mPost.Permissions.Replace(",", ",") + ","; string strIndex = ","; //缓存获取菜单页面 List <Bd_Base_Page> iPostList = new PbProject.Logic.ControlBase.Bd_Base_PageBLL().GetListByCache(mCompany.RoleType); foreach (Bd_Base_Page item in iPostList) { if (strValue.Contains("," + item.PageIndex + ",") && !strIndex.Contains("," + item.ModuleIndex + ",")) { strIndex += item.ModuleIndex + ","; } } hid_ShowModuleIndex.Value = strIndex; } } catch (Exception ex) { } }
/// <summary> /// 生成菜单 /// </summary> /// <param name="type"></param> private void CreateLeft(string type) { try { PbProject.Logic.ControlBase.Bd_Base_PageBLL basePage = new PbProject.Logic.ControlBase.Bd_Base_PageBLL(); PbProject.Logic.User.User_PermissionsBLL uPermissions = new PbProject.Logic.User.User_PermissionsBLL(); List <Bd_Base_Page> iPostResult = new List <Bd_Base_Page>(); int roleType = mCompany.RoleType; //缓存获取菜单页面 List <Bd_Base_Page> iPost = basePage.GetListByCache(roleType); User_Permissions mPost = null; if (m_UserPermissions != null) { //Session中获取登录用户页面权限 mPost = m_UserPermissions; } else { //数据库中读取用户权限 mPost = uPermissions.GetById(mUser.DeptId); } string strValue = "," + mPost.Permissions.Replace(",", ",") + ","; string temp = ""; //得到一级菜单数 ArrayList listValue = new ArrayList(); ArrayList listName = new ArrayList(); for (int j = 0; j < iPost.Count; j++) { temp = "," + iPost[j].PageIndex + ","; //if (temp.Contains("138 ")) //{ // string str = temp;//测试 //} if (strValue.Contains(temp) && iPost[j].ModuleIndex.ToString() == type && iPost[j].TwoMenuIndex != 0 && iPost[j].RoleType == roleType) { if (!listValue.Contains(iPost[j].OneMenuIndex)) { listValue.Add(iPost[j].OneMenuIndex); listName.Add(iPost[j].OneMenuName); } iPostResult.Add(iPost[j]); } } //控制菜单高度 int[] iheight = new int[listValue.Count]; //生成二级菜单 string[] str = new string[listValue.Count]; for (int i = 0; i < iPostResult.Count; i++) { for (int j = 0; j < listValue.Count; j++) { if (iPostResult[i].OneMenuIndex.ToString() == listValue[j].ToString() && iPostResult[i].TwoMenuIndex != 0) { if (iPostResult[i].PageURL.Contains("/StrategyGroupList.aspx")) { //没有显示策略组的权限不显示菜单 } else if (iPostResult[i].PageName.Contains("高返政策")) { //判断是否允许放高返政策 True为有 False无 } else { string tempUrl = iPostResult[i].PageURL.IndexOf('?') < 0 ? string.Format("{0}?currentuserid={1}", iPostResult[i].PageURL, this.currentuserid.Value.ToString()) : string.Format("{0}¤tuserid={1}", iPostResult[i].PageURL, this.currentuserid.Value.ToString()); str[j] += "<li><a href=\"" + tempUrl + "\" target=\"ALLFrame\" style=\"height:30px;\">" + iPostResult[i].TwoMenuName + "</a></li>"; } iheight[j]++; } } } //追加一级菜单 for (int j = 0; j < listValue.Count; j++) { temp = str[j]; StringBuilder _sb = new StringBuilder(""); str[j] = "<h3><a href=\"javascript:void(0)\">" + listName[j].ToString() + "</a></h3><div style=\"padding: 0px;\"><ul>" + temp + _sb.ToString() + "</ul></div>"; } //合并字符串 StringBuilder sb = new StringBuilder(); for (int j = 0; j < listValue.Count; j++) { sb.Append(str[j]); } accordion.InnerHtml = sb.ToString(); } catch (Exception) { } }
/// <summary> /// 添加 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAdd_Click(object sender, EventArgs e) { string msg = ""; bool result = false; try { #region 验证数据 if (string.IsNullOrEmpty(txtModuleIndex.Text)) { msg = "数据不能为空!"; } if (string.IsNullOrEmpty(txtModuleName.Text)) { msg = "数据不能为空!"; } if (string.IsNullOrEmpty(txtOneMenuIndex.Text)) { msg = "数据不能为空!"; } if (string.IsNullOrEmpty(txtOneMenuName.Text)) { msg = "数据不能为空!"; } if (string.IsNullOrEmpty(txtTwoMenuIndex.Text)) { msg = "数据不能为空!"; } if (string.IsNullOrEmpty(txtTwoMenuName.Text)) { msg = "数据不能为空!"; } //if (string.IsNullOrEmpty(txtPageIndex.Text)) //{ // msg = "数据不能为空!"; //} if (string.IsNullOrEmpty(txtPageName.Text)) { msg = "数据不能为空!"; } if (string.IsNullOrEmpty(txtPageURL.Text)) { msg = "数据不能为空!"; } if (string.IsNullOrEmpty(txtRemark.Text)) { } #endregion if (msg == "") { /* * HashObject paramter = new HashObject(); * * paramter.Add("id", Guid.NewGuid()); * paramter.Add("ModuleIndex", txtModuleIndex.Text.Trim()); * paramter.Add("ModuleName", txtModuleName.Text.Trim()); * paramter.Add("OneMenuIndex", txtOneMenuIndex.Text.Trim()); * paramter.Add("OneMenuName", txtOneMenuName.Text.Trim()); * paramter.Add("TwoMenuIndex", txtTwoMenuIndex.Text.Trim()); * paramter.Add("TwoMenuName", txtTwoMenuName.Text.Trim()); * // 页面编号 数据库自动生成 * //paramter.Add("PageIndex", txtPageIndex.Text.Trim()); * paramter.Add("PageName", txtPageName.Text.Trim()); * paramter.Add("PageURL", txtPageURL.Text.Trim()); * paramter.Add("Remark", txtRemark.Text.Trim()); * paramter.Add("RoleType", ddlType.SelectedValue); */ Bd_Base_Page model = new Bd_Base_Page(); int _ModuleIndex = 0; int _OneMenuIndex = 0; int _TwoMenuIndex = 0; int _PageIndex = 0; int _RoleType = 1; if (int.TryParse(txtTwoMenuIndex.Text.Trim(), out _TwoMenuIndex)) { model.TwoMenuIndex = _TwoMenuIndex; } else { msg = "二级菜单编号输入错误!"; } if (int.TryParse(txtOneMenuIndex.Text.Trim(), out _OneMenuIndex)) { model.OneMenuIndex = _OneMenuIndex; } else { msg = "一级菜单编号输入错误!"; } if (int.TryParse(txtModuleIndex.Text.Trim(), out _ModuleIndex)) { model.ModuleIndex = _ModuleIndex; } else { msg = "模块编号输入错误!"; } if (int.TryParse(ddlType.SelectedValue, out _RoleType)) { model.RoleType = _RoleType; } else { msg = "请选择用户类型!"; } if (msg == "") { #region 添加 //获取最大id _PageIndex = new PbProject.Logic.ControlBase.Bd_Base_PageBLL().GetPageIndexMaxByRoleType(_RoleType); _PageIndex++; model.PageIndex = _PageIndex; //if (int.TryParse(txtPageIndex.Text.Trim(), out _PageIndex)) //{ // model.PageIndex = _PageIndex; //} //else //{ // msg = "页面编号输入错误!"; // return; //} model.id = Guid.NewGuid(); model.ModuleName = txtModuleName.Text.Trim(); model.OneMenuName = txtOneMenuName.Text.Trim(); model.TwoMenuName = txtTwoMenuName.Text.Trim(); model.PageName = txtPageName.Text.Trim(); model.PageURL = txtPageURL.Text.Trim(); model.Remark = txtRemark.Text.Trim(); result = (bool)baseDataManage.CallMethod("Bd_Base_Page", "Insert", null, new Object[] { model }); if (result) { msg = "添加成功!"; //清理缓存 //baseDataManage.CallMethod("Bd_Base_Page", "RefreshCache", null, new object[] { }); } else { msg = "添加失败!"; } #endregion } } } catch (Exception) { msg = "操作失败!"; } finally { if (result) { RepBasePageBind(); } ScriptManager.RegisterStartupScript(this, GetType(), DateTime.Now.Ticks.ToString(), "showdialog('" + msg + "');", true); } }