Ejemplo n.º 1
0
        /// <summary>
        /// 获取横向导航菜单
        /// </summary>
        /// <returns></returns>
        /// 修改:李东峰 日期:2014-2-28
        /// 修改内容:增加根据visible属性判断是否显示该菜单并返回首页的url
        public void GetMenuRoot()
        {
            string    userId   = Request.Cookies["T_USERID"].Value.ToString();
            string    roleId   = bl.GetRoleId(userId);
            DataTable udt      = bl.GetUserInfo(userId);
            string    realName = udt.Rows[0]["T_USERNAME"].ToString();

            //BLLRole bl = new BLLRole();
            //string errMsg = "";
            //string realName = bl.GetUserRealNameById(userId, out errMsg);
            dt = new DataTable();
            GetTreeList();
            DataRow[] dr          = null;
            DataRow[] dr_HomePage = null;
            dr_HomePage = dt.Select("PID='000'");
            HomePageUrl = dr_HomePage[0][6].ToString();
            dr          = dt.Select("PID='00'");
            int c = 0;

            for (int i = 0; i < dr.Length; i++)
            {
                string[] nodeRoleId = dr[i][5].ToString().TrimStart(',').TrimEnd(',').Split(',');
                string   visible    = dr[i][4].ToString();
                if (nodeRoleId.Contains(roleId) && visible == "1")
                {
                    c = c + 1;
                    DataRow[] _dr = dt.Select("PID='" + dr[i][0] + "'");
                    if (_dr.Length > 0)
                    {
                        sb.AppendFormat("<a id=\"menu{4}\" runat=\"server\"  href=\"javascript:SetUrl('{0}','{1}','{2}')\" onclick=\"changeMenu({4})\" hidefocus=\"true\">{3}</a>", 1, dr[i][0], dr[i][6], dr[i][1], c);
                    }
                    else
                    {
                        if (i == 0)
                        {
                            sb.AppendFormat("<a id=\"menu{4}\" runat=\"server\"  href=\"javascript:SetUrl('{0}','{1}','{2}')\" onclick=\"changeMenu({4})\" hidefocus=\"true\">{3}</a>", 0, dr[i][0], dr[i][6], dr[i][1], c);
                        }
                        else
                        {
                            sb.AppendFormat("<a id=\"menu{4}\" runat=\"server\"  href=\"javascript:SetUrl('{0}','{1}','{2}')\" onclick=\"changeMenu({4})\" hidefocus=\"true\">{3}</a>", 0, dr[i][0], dr[i][6], dr[i][1], c);
                        }
                    }
                }
            }
            this.lblUserWelcome.Text    = realName;
            this.mu.Value               = (c + 1).ToString();
            this.dv_Menu_left.InnerHtml = sb.ToString();
        }
Ejemplo n.º 2
0
        //登录按钮
        protected void btnSure_Click(object sender, EventArgs e)
        {
            string UserName      = this.UserName.Text;
            string PassWordinput = this.PassWord.Text;

            this.UserName.Text = "";
            this.PassWord.Text = "";
            if (UserName == "")
            {
                Response.Write("<script>alert('请输入用户名!')</script>");
            }
            else if (PassWordinput == "")
            {
                Response.Write("<script>alert('请输入密码!')</script>");
            }
            if (UserName != "" && PassWordinput != "")
            {
                DataTable dt = null;
                dt = bl.GetUserInfo(UserName);
                if (dt.Rows.Count == 0 || dt == null)
                {
                    Response.Write("<script>alert('用户名不存在,请检查后重新输入!')</script>");
                }
                else
                {
                    string PassWordReal = dt.Rows[0]["T_PASSWD"].ToString();
                    if (PassWordinput != PassWordReal)
                    {
                        Response.Write("<script>alert('密码不正确,请检查后重新输入!')</script>");
                    }
                    else if (PassWordinput == PassWordReal)
                    {
                        string     userId   = dt.Rows[0]["T_USERID"].ToString();
                        HttpCookie cookieID = new HttpCookie("ID_KEY", userId);
                        HttpCookie cookieUN = new HttpCookie("T_USERID", UserName);
                        Response.Cookies.Add(cookieID);
                        Response.Cookies.Add(cookieUN);
                        Server.Transfer("Main.aspx");
                    }
                }
            }
        }