예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.parent_id = DTRequest.GetQueryInt("parent_id");

            this.keywords = DTRequest.GetQueryString("keywords", true);

            if (!Page.IsPostBack)
            {
                //检查权限
                ChkAdminLevel("plugin_menu", DTEnums.ActionEnum.Show.ToString());

                //绑定类别
                TreeBind();

                //绑定路径
                SiteMapBind();

                //绑定数据
                BLL.menu  bll   = new BLL.menu();
                DataTable _list = bll.GetList(0, CombSqlTxt(this.keywords), "sort_id asc,id asc", this.parent_id);
                this.rptList.DataSource = _list;
                this.rptList.DataBind();

                //插入关键词
                this.txtKeywords.Text = Utils.Htmls(this.keywords);
            }
        }
예제 #2
0
파일: List.aspx.cs 프로젝트: tcld2269/HM_ED
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            string id = lblpId.Text;

            if (string.IsNullOrEmpty(id))
            {
                MessageBox.Show(this, "请选择要删除的菜单!");
                return;
            }

            BLL.menu menuBll = new BLL.menu();
            if (menuBll.GetList("parentId=" + id).Tables[0].Rows.Count > 0)
            {
                MessageBox.Show(this, "请先删除下级菜单!");
                return;
            }

            bll.Delete(int.Parse(id));
            lblpId.Text             = "";
            txtMenuName.Text        = "";
            ddrParent.SelectedValue = "0";
            txtOrder.Text           = "";
            txtUrl.Text             = "";
            bindParentMenuAdd();
            BindData();
        }
예제 #3
0
        private void TreeBind()
        {
            BLL.menu  bll = new BLL.menu();
            DataTable dt  = bll.GetList(0, "", "sort_id asc,id asc", 0);

            this.ddlParentId.Items.Clear();
            this.ddlParentId.Items.Add(new ListItem("无父级分类", "0"));
            foreach (DataRow dr in dt.Rows)
            {
                string Id         = dr["id"].ToString();
                int    ClassLayer = int.Parse(dr["class_layer"].ToString());
                string Title      = dr["title"].ToString().Trim();

                if (ClassLayer == 1)
                {
                    this.ddlParentId.Items.Add(new ListItem(Title, Id));
                }
                else
                {
                    Title = "├ " + Title;
                    Title = Utils.StringOfChar(ClassLayer - 1, " ") + Title;
                    this.ddlParentId.Items.Add(new ListItem(Title, Id));
                }
            }
        }
예제 #4
0
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            //检查权限
            ChkAdminLevel("plugin_menu", DTEnums.ActionEnum.Delete.ToString());
            BLL.menu bll = new BLL.menu();

            int      sucCount   = 0; //成功数量
            int      errorCount = 0; //失败数量
            Repeater rptList    = new Repeater();

            rptList = this.rptList;
            for (int i = 0; i < rptList.Items.Count; i++)
            {
                int      id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
                CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
                if (cb.Checked)
                {
                    if (bll.Delete(id))
                    {
                        sucCount++;
                    }
                    else
                    {
                        errorCount++;
                    }
                }
            }
            AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "删除菜单内容成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志
            JscriptMsg("成功删除 " + sucCount + " 条,失败 " + errorCount + " 条!", Utils.CombUrlTxt("index.aspx", "keywords={0}", this.keywords));
        }
예제 #5
0
        private bool DoEdit(int _id)
        {
            try
            {
                BLL.menu   bll   = new BLL.menu();
                Model.menu model = bll.GetModel(_id);

                model.title    = txtName.Text;
                model.link_url = txtUrl.Text;
                //如果选择的父ID不是自己,则更改
                int parentId = int.Parse(ddlParentId.SelectedValue);
                if (parentId != model.id)
                {
                    model.parent_id = parentId;
                }
                model.open_mode = rblMode.SelectedValue;
                model.is_lock   = int.Parse(rblHide.SelectedValue);
                model.sort_id   = Utils.StrToInt(txtSort.Text, 99);
                model.css_txt   = txtCssTxt.Text;
                //判断上传图片
                if (this.imgUpload.HasFile)
                {
                    //上传前先删除原图片
                    if (!string.IsNullOrEmpty(model.img_url))
                    {
                        Utils.DeleteFile(model.img_url);
                    }
                    Model.upLoad upfile = new Web.UI.UpLoad().fileSaveAs(this.imgUpload.PostedFile, 0, false, false);
                    if (upfile.status > 0)
                    {
                        model.img_url = upfile.path;
                    }
                }
                else
                {
                    //判断是否需要删除原图
                    if (txtIconUrl.Text.Trim() == "" && !string.IsNullOrEmpty(model.img_url))
                    {
                        Utils.DeleteFile(model.img_url);
                    }
                    model.img_url = txtIconUrl.Text.Trim();
                }
                if (bll.Update(model))
                {
                    AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改菜单内容:" + model.title); //记录日志
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
            return(false);
        }
예제 #6
0
파일: List.aspx.cs 프로젝트: tcld2269/HM_ED
        private void bindParentMenu()
        {
            ddrParent.Items.Clear();
            BLL.menu  deptBll = new BLL.menu();
            DataTable dt      = deptBll.GetList("parentId=0 order by orders asc").Tables[0];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                ddrParent.Items.Add(new ListItem(dt.Rows[i]["menuName"].ToString(), dt.Rows[i]["menuId"].ToString()));
            }
            ddrParent.Items.Insert(0, new ListItem("根菜单", "0"));
        }
예제 #7
0
        private void SiteMapBind()
        {
            if (this.parent_id > 0)
            {
                BLL.menu   bll   = new BLL.menu();
                Model.menu model = bll.GetModel(this.parent_id);

                LabelStatus.Text += "<a href=\"index.aspx\">全部</a><i></i>";

                DataTable dt = bll.GetList(0, "id in(" + model.class_list.Substring(1, (model.class_list).LastIndexOf(",") - 1) + ")", "charindex(','+ltrim(id)+',','" + model.class_list + "')", 0);
                foreach (DataRow dr in dt.Rows)
                {
                    LabelStatus.Text += "<a href=\"index.aspx?parent_id=" + dr["id"].ToString() + "\">" + dr["title"].ToString() + "</a><i></i>";
                }
            }
        }
예제 #8
0
        private void TreeBind()
        {
            BLL.menu  bll = new BLL.menu();
            DataTable dt  = bll.GetList(0, "parent_id=0", "sort_id asc, id desc", 0);

            this.ddlClass.Items.Clear();
            this.ddlClass.Items.Add(new ListItem("所有组", "0"));
            foreach (DataRow dr in dt.Rows)
            {
                string Id         = dr["id"].ToString();
                int    ClassLayer = int.Parse(dr["class_layer"].ToString());
                string Title      = dr["title"].ToString().Trim();

                this.ddlClass.Items.Add(new ListItem(Title, Id));
            }
        }
예제 #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.Params["roleId"] != null && Request.Params["roleId"].Trim() != "")
                {
                    litRoleId.Text = "<input type='hidden' id='roleId' value='" + Request.QueryString["roleId"].ToString() + "' />";
                    BLL.roleMenu rmBll = new BLL.roleMenu();
                    List<Model.roleMenu> list = rmBll.GetModelList("roleId=" + Request.QueryString["roleId"].ToString());
                    if (list.Count > 0)
                    {
                        string idstring = "";
                        foreach (Model.roleMenu menu in list)
                        {
                            idstring += menu.menuId + ",";
                        }
                        string[] ids = idstring.Substring(0, idstring.Length - 1).Split(',');

                        string execString = "";
                        for (int i = 0; i < ids.Length; i++)
                        {
                            execString += "document.getElementById('checkMenu" + ids[i] + "').checked=true;";
                        }
                        this.ClientScript.RegisterStartupScript(this.GetType(), "message", "<script  language='javascript' defer>" + execString + "</script>");
                    }

                }
                StringBuilder sb = new StringBuilder();
                string menuIds = "";
                BLL.menu menuBll = new BLL.menu();
                DataTable dt1 = menuBll.GetList("parentId=0 order by orders").Tables[0];
                for (int i = 0; i < dt1.Rows.Count; i++)
                {
                    sb.Append("<tr style='background-color:#ddd'><td style='background-color:#ddd'><input type='checkbox' id='checkMenu" + dt1.Rows[i]["menuId"].ToString() + "' value='" + dt1.Rows[i]["menuId"].ToString() + "' onclick='checkAll(" + dt1.Rows[i]["menuId"].ToString() + ")'/>" + dt1.Rows[i]["menuname"].ToString() + "</td></tr>");
                    menuIds += dt1.Rows[i]["menuId"].ToString() + ",";
                    DataTable dt2 = menuBll.GetList("parentId=" + dt1.Rows[i]["menuId"].ToString() + " order by orders").Tables[0];
                    for (int j = 0; j < dt2.Rows.Count; j++)
                    {
                        sb.Append("<tr><td><input type='checkbox' id='checkMenu" + dt2.Rows[j]["menuId"].ToString() + "' name='menu" + dt1.Rows[i]["menuId"].ToString() + "' value='" + dt2.Rows[j]["menuId"].ToString() + "' onclick='checkParent(" + dt1.Rows[i]["menuId"].ToString() + ")'/>" + dt2.Rows[j]["menuname"].ToString() + "</td></tr>");
                    }

                }
                litMenu.Text = sb.ToString();
                menuIds = menuIds.Substring(0, menuIds.Length - 1);
                litMenuIds.Text = "<input type='hidden' id='menuIds' value='" + menuIds + "' />";
            }
        }
예제 #10
0
 /// <summary>
 /// 保存排序
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnSave_Click(object sender, EventArgs e)
 {
     ChkAdminLevel("plugin_menu", DTEnums.ActionEnum.Edit.ToString()); //检查权限
     BLL.menu bll = new BLL.menu();
     for (int i = 0; i < rptList.Items.Count; i++)
     {
         int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
         int sortId;
         if (!int.TryParse(((TextBox)rptList.Items[i].FindControl("txtSortId")).Text.Trim(), out sortId))
         {
             sortId = 99;
         }
         bll.UpdateField(id, "sort_id=" + sortId.ToString());
     }
     AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改菜单排序!"); //记录日志
     JscriptMsg("保存排序成功!", Utils.CombUrlTxt("index.aspx", "keywords={0}", this.keywords));
 }
예제 #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.Params["roleId"] != null && Request.Params["roleId"].Trim() != "")
                {
                    litRoleId.Text = "<input type='hidden' id='roleId' value='" + Request.QueryString["roleId"].ToString() + "' />";
                    BLL.roleMenu          rmBll = new BLL.roleMenu();
                    List <Model.roleMenu> list  = rmBll.GetModelList("roleId=" + Request.QueryString["roleId"].ToString());
                    if (list.Count > 0)
                    {
                        string idstring = "";
                        foreach (Model.roleMenu menu in list)
                        {
                            idstring += menu.menuId + ",";
                        }
                        string[] ids = idstring.Substring(0, idstring.Length - 1).Split(',');

                        string execString = "";
                        for (int i = 0; i < ids.Length; i++)
                        {
                            execString += "document.getElementById('checkMenu" + ids[i] + "').checked=true;";
                        }
                        this.ClientScript.RegisterStartupScript(this.GetType(), "message", "<script  language='javascript' defer>" + execString + "</script>");
                    }
                }
                StringBuilder sb      = new StringBuilder();
                string        menuIds = "";
                BLL.menu      menuBll = new BLL.menu();
                DataTable     dt1     = menuBll.GetList("parentId=0 order by orders").Tables[0];
                for (int i = 0; i < dt1.Rows.Count; i++)
                {
                    sb.Append("<tr style='background-color:#ddd'><td style='background-color:#ddd'><input type='checkbox' id='checkMenu" + dt1.Rows[i]["menuId"].ToString() + "' value='" + dt1.Rows[i]["menuId"].ToString() + "' onclick='checkAll(" + dt1.Rows[i]["menuId"].ToString() + ")'/>" + dt1.Rows[i]["menuname"].ToString() + "</td></tr>");
                    menuIds += dt1.Rows[i]["menuId"].ToString() + ",";
                    DataTable dt2 = menuBll.GetList("parentId=" + dt1.Rows[i]["menuId"].ToString() + " order by orders").Tables[0];
                    for (int j = 0; j < dt2.Rows.Count; j++)
                    {
                        sb.Append("<tr><td><input type='checkbox' id='checkMenu" + dt2.Rows[j]["menuId"].ToString() + "' name='menu" + dt1.Rows[i]["menuId"].ToString() + "' value='" + dt2.Rows[j]["menuId"].ToString() + "' onclick='checkParent(" + dt1.Rows[i]["menuId"].ToString() + ")'/>" + dt2.Rows[j]["menuname"].ToString() + "</td></tr>");
                    }
                }
                litMenu.Text    = sb.ToString();
                menuIds         = menuIds.Substring(0, menuIds.Length - 1);
                litMenuIds.Text = "<input type='hidden' id='menuIds' value='" + menuIds + "' />";
            }
        }
예제 #12
0
파일: left.aspx.cs 프로젝트: tcld2269/hmdfs
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                HttpCookie roleId = Request.Cookies["roleId"];
                if (null == roleId)
                {
                    MessageBox.ShowAndRedirects(this, "ss", "../Login.aspx");
                }
                else
                {
                    string isAdmin = Request.Cookies["isAdmin"].Value;
                    StringBuilder sb = new StringBuilder();
                    BLL.menu mBll = new BLL.menu();
                    string sql1 = " parentId=0 ";
                    if (isAdmin != "1")
                    {
                        sql1 += " and menuId in (select menuId from [roleMenu] where roleId=" + roleId.Value + ") ";
                    }
                    sql1 += " order by orders asc";
                    DataTable dt = mBll.GetList(sql1).Tables[0];
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        sb.Append("<h1 class=\"type\"><a href=\"javascript:void(0)\">" + dt.Rows[i]["menuName"].ToString() + "</a></h1>");
                        sb.Append("<div class=\"content\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><img src=\"../images/menu_topline.gif\" width=\"182\" height=\"5\" /></td></tr></table><ul class=\"MM\">");

                        string sql2 = " parentId=" + dt.Rows[i]["menuId"].ToString();
                        if (isAdmin != "1")
                        {
                            sql2 += " and menuId in (select menuId from [roleMenu] where roleId=" + roleId.Value + ") ";
                        }
                        sql2 += " order by orders asc";
                        DataTable dt2 = mBll.GetList(sql2).Tables[0];
                        for (int j = 0; j < dt2.Rows.Count; j++)
                        {
                            sb.Append("<li><a href=\""+ dt2.Rows[j]["url"].ToString() +"\" target=\"main\">" + dt2.Rows[j]["menuName"].ToString() + "</a></li>");
                        }
                        sb.Append("</ul></div>");
                    }
                    menuHtml = sb.ToString();
                }

            }
        }
예제 #13
0
 private void bindMenu()
 {
     string roleId = Common.Cookie.GetValue(StatusHelpercs.Cookie_Admin_RoleId);
     string isAdmin = Common.Cookie.GetValue(StatusHelpercs.Cookie_Admin_IsAdmin);
     StringBuilder sb = new StringBuilder();
     BLL.menu mBll = new BLL.menu();
     string sql1 = " parentId=0 ";
     if (isAdmin != "1")
     {
         sql1 += " and menuId in (select menuId from [roleMenu] where roleId=" + roleId + ") ";
     }
     sql1 += " order by orders asc";
     DataTable dt = mBll.GetList(sql1).Tables[0];
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         string sql2 = " parentId=" + dt.Rows[i]["menuId"].ToString();
         if (isAdmin != "1")
         {
             sql2 += " and menuId in (select menuId from [roleMenu] where roleId=" + roleId + ") ";
         }
         sql2 += " order by orders asc";
         DataTable dt2 = mBll.GetList(sql2).Tables[0];
         //有下级菜单
         if (dt.Rows.Count > 0)
         {
             sb.AppendFormat("<li><a href=\"#\"><i class=\"fa fa-home\"></i><span class=\"nav-label\">{0}</span><span class=\"fa arrow\"></span></a>", dt.Rows[i]["menuName"].ToString());
             sb.Append("<ul class=\"nav nav-second-level\">");
         }
         else
         {
             sb.AppendFormat("<li><a href=\"{0}\"><i class=\"fa fa-home\"></i><span class=\"nav-label\">{1}</span></a>", dt.Rows[i]["url"].ToString(), dt.Rows[i]["menuName"].ToString());
         }
         for (int j = 0; j < dt2.Rows.Count; j++)
         {
             sb.AppendFormat("<li><a class=\"J_menuItem\" href=\"{0}\">{1}</a></li>", dt2.Rows[j]["url"].ToString(), dt2.Rows[j]["menuName"].ToString());
         }
         if (dt.Rows.Count > 0)
         {
             sb.Append("</ul>");
         }
         sb.Append("</li>");
     }
     menuHtml = sb.ToString();
 }
예제 #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BLL.menu bll = new BLL.menu();
            this.id = DTRequest.GetQueryInt("id");

            string _action = DTRequest.GetQueryString("action");

            if (!string.IsNullOrEmpty(_action) && _action == DTEnums.ActionEnum.Edit.ToString())
            {
                this.id     = DTRequest.GetQueryInt("id");
                this.action = DTEnums.ActionEnum.Edit.ToString();//修改类型
                if (id == 0)
                {
                    JscriptMsg("传输参数不正确!", "back");
                    return;
                }
                if (!bll.Exists(this.id))
                {
                    JscriptMsg("记录不存在或已被删除!", "back");
                    return;
                }
            }
            if (!Page.IsPostBack)
            {
                //检查权限
                ChkAdminLevel("plugin_menu", DTEnums.ActionEnum.Show.ToString());

                //上一页地址
                this.backUrl = DTRequest.GetUrlReferrer();

                //绑定类别
                TreeBind();

                if (action == DTEnums.ActionEnum.Edit.ToString()) //修改
                {
                    ShowInfo(this.id);
                }
                else
                {
                    ddlParentId.SelectedValue = this.id.ToString();
                }
            }
        }
예제 #15
0
 private void ShowInfo(int _id)
 {
     BLL.menu   bll   = new BLL.menu();
     Model.menu model = bll.GetModel(_id);
     txtName.Text = model.title;
     txtUrl.Text  = model.link_url;
     ddlParentId.SelectedValue = model.parent_id.ToString();
     txtSort.Text          = model.sort_id.ToString();
     rblHide.SelectedValue = model.is_lock.ToString();
     rblMode.SelectedValue = model.open_mode;
     txtName.Focus(); //设置焦点,防止JS无法提交
     txtCssTxt.Text  = model.css_txt;
     txtIconUrl.Text = model.img_url;
     if (!string.IsNullOrEmpty(model.img_url))
     {
         ImgDiv.Visible   = true;
         IconUrl.ImageUrl = model.img_url;
     }
 }
예제 #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                HttpCookie roleId = Request.Cookies["roleId"];
                if (null == roleId)
                {
                    MessageBox.ShowAndRedirects(this, "ss", "../Login.aspx");
                }
                else
                {
                    string        isAdmin = Request.Cookies["isAdmin"].Value;
                    StringBuilder sb      = new StringBuilder();
                    BLL.menu      mBll    = new BLL.menu();
                    string        sql1    = " parentId=0 ";
                    if (isAdmin != "1")
                    {
                        sql1 += " and menuId in (select menuId from [roleMenu] where roleId=" + roleId.Value + ") ";
                    }
                    sql1 += " order by orders asc";
                    DataTable dt = mBll.GetList(sql1).Tables[0];
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        sb.Append("<h1 class=\"type\"><a href=\"javascript:void(0)\">" + dt.Rows[i]["menuName"].ToString() + "</a></h1>");
                        sb.Append("<div class=\"content\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><img src=\"../images/menu_topline.gif\" width=\"182\" height=\"5\" /></td></tr></table><ul class=\"MM\">");

                        string sql2 = " parentId=" + dt.Rows[i]["menuId"].ToString();
                        if (isAdmin != "1")
                        {
                            sql2 += " and menuId in (select menuId from [roleMenu] where roleId=" + roleId.Value + ") ";
                        }
                        sql2 += " order by orders asc";
                        DataTable dt2 = mBll.GetList(sql2).Tables[0];
                        for (int j = 0; j < dt2.Rows.Count; j++)
                        {
                            sb.Append("<li><a href=\"" + dt2.Rows[j]["url"].ToString() + "\" target=\"main\">" + dt2.Rows[j]["menuName"].ToString() + "</a></li>");
                        }
                        sb.Append("</ul></div>");
                    }
                    menuHtml = sb.ToString();
                }
            }
        }
예제 #17
0
        private bool DoAdd()
        {
            try
            {
                BLL.menu   bll   = new BLL.menu();
                Model.menu model = new Model.menu();
                model.title     = txtName.Text;
                model.link_url  = txtUrl.Text;
                model.parent_id = int.Parse(ddlParentId.SelectedValue);
                model.open_mode = rblMode.SelectedValue;
                model.is_lock   = int.Parse(rblHide.SelectedValue);
                model.sort_id   = Utils.StrToInt(txtSort.Text, 99);
                model.css_txt   = txtCssTxt.Text;
                //判断上传图片
                if (this.imgUpload.HasFile)
                {
                    Model.upLoad upfile = new Web.UI.UpLoad().fileSaveAs(this.imgUpload.PostedFile, 0, false, false);
                    if (upfile.status > 0)
                    {
                        model.img_url = upfile.path;
                    }
                }
                else
                {
                    model.img_url = txtIconUrl.Text.Trim();
                }
                model.add_time = DateTime.Now;

                if (bll.Add(model) > 0)
                {
                    AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "添加菜单内容:" + model.title); //记录日志
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
            return(false);
        }