예제 #1
0
        protected void LinkButton2_Command(object sender, CommandEventArgs e)
        {
            int Id = int.Parse(e.CommandArgument.ToString());

            ljxpower.BLL.tb_navigation   bll   = new ljxpower.BLL.tb_navigation();
            ljxpower.Model.tb_navigation model = bll.GetModel(Id);
            string sql = "update tb_navigation set Sort=Sort-1 where ParentId=" + model.ParentId + " and Sort>" + model.Sort;

            ljxpower.Common.DbHelperMySQL.ExecuteSql(sql);
            if (bll.Delete(Id))
            {
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>msgShow('系统提示', '菜单删除成功!', 'info');window.location.href='NavigationList.aspx';</script>");
            }
            else
            {
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>msgShow('系统提示', '菜单删除失败,请稍后重试!', 'error');</script>");
            }
        }
예제 #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            StringBuilder sb = new StringBuilder();

            if (context.Request.QueryString["type"] == "edit")//获取要修改的菜单
            {
                int Id = int.Parse(context.Request.QueryString["Id"]);
                ljxpower.BLL.tb_navigation   bll   = new ljxpower.BLL.tb_navigation();
                ljxpower.Model.tb_navigation model = bll.GetModel(Id);
                if (model != null)
                {
                    sb.Append(model.MenuName + ",");
                    sb.Append(model.Pagelogo + ",");
                    sb.Append(model.ParentId + ",");
                    sb.Append(model.LinkAddress + ",");
                    sb.Append(model.Icon + ",");
                    List <ljxpower.Model.tb_navigation> list = bll.GetModelList(" ParentId=" + model.ParentId);
                    string str = "";
                    for (int i = 1; i <= list.Count; i++)
                    {
                        if (i == model.Sort)
                        {
                            str += "<option value='" + i + "'  selected='selected'>" + i + "</option>";
                        }
                        else
                        {
                            str += "<option value='" + i + "'>" + i + "</option>";
                        }
                    }
                    sb.Append(str + ",");
                    sb.Append(model.IsShow);
                }
                context.Response.Write(sb.ToString());
            }
            else if (context.Request.QueryString["type"] == "Parent")//获取所有根节点 并生成选项
            {
                ljxpower.BLL.tb_navigation          bll  = new ljxpower.BLL.tb_navigation();
                List <ljxpower.Model.tb_navigation> list = bll.GetModelList(" ParentId=0");
                sb.Append("<option value='0'></option>");
                foreach (ljxpower.Model.tb_navigation model in list)
                {
                    sb.Append("<option value='" + model.Id + "'>" + model.MenuName + "</option>");
                }
                context.Response.Write(sb.ToString());
            }
            else if (context.Request.QueryString["type"] == "child")//获取所有子节点数量并生成排序选项
            {
                int Id = int.Parse(context.Request.QueryString["Id"]);
                ljxpower.BLL.tb_navigation          bll  = new ljxpower.BLL.tb_navigation();
                List <ljxpower.Model.tb_navigation> list = bll.GetModelList(" ParentId=" + Id);
                int i = 1;
                for ( ; i <= list.Count; i++)
                {
                    sb.Append("<option value='" + i + "'>" + i + "</option>");
                }
                sb.Append("<option value='" + i + "' selected='selected'>" + i + "</option>");
                sb.Append(",<option value='" + i + "' selected='selected'>" + i + "</option>");
                context.Response.Write(sb.ToString());
            }
            else if (context.Request.QueryString["type"] == "save")//保存修改的菜单
            {
                int    Id       = int.Parse(context.Request.QueryString["Id"]);
                string MenuName = context.Request.QueryString["Name"];
                string Logo     = context.Request.QueryString["Name"];
                int    Parent   = int.Parse(context.Request.QueryString["Parent"]);
                string Link     = context.Request.QueryString["Link"];
                string icon     = context.Request.QueryString["icon"];
                int    sort     = int.Parse(context.Request.QueryString["sort"]);
                int    Isshow   = int.Parse(context.Request.QueryString["Isshow"]);
                ljxpower.BLL.tb_navigation   bll   = new ljxpower.BLL.tb_navigation();
                ljxpower.Model.tb_navigation model = bll.GetModel(Id);
                model.MenuName = MenuName;
                model.Pagelogo = Logo;
                List <string> listSql = new List <string>();
                if (model.ParentId == Parent)
                {
                    if (model.Sort > sort)
                    {
                        string sql = "update tb_navigation set Sort=Sort+1 where ParentId=" + Parent + " and Sort>=" + sort + " and Sort<" + model.Sort;
                        listSql.Add(sql);
                    }
                    else if (model.Sort < sort)
                    {
                        string sql = "update tb_navigation set Sort=Sort-1 where ParentId=" + Parent + " and Sort<=" + sort + " and Sort>" + model.Sort;
                        listSql.Add(sql);
                    }
                }
                else
                {
                    string sql = "update tb_navigation set Sort=Sort+1 where ParentId=" + Parent + " and Sort>=" + sort;
                    listSql.Add(sql);
                    string sql2 = "update tb_navigation set Sort=Sort-1 where ParentId=" + model.ParentId + " and Sort>" + model.Sort;
                    listSql.Add(sql2);
                }
                if (listSql.Count > 0)
                {
                    ljxpower.Common.DbHelperMySQL.ExecuteSqlTran(listSql);
                }
                if (Parent == 0)
                {
                    model.LinkAddress = null;
                }
                else
                {
                    model.LinkAddress = Link;
                }
                model.ParentId = Parent;
                model.Icon     = icon;
                List <ljxpower.Model.tb_navigation> list = bll.GetModelList(" ParentId=" + Parent);
                if (sort > list.Count + 1)
                {
                    model.Sort = list.Count + 1;
                }
                else
                {
                    model.Sort = sort;
                }
                model.IsShow = Isshow;
                bll.Update1(model);
            }
            else if (context.Request.QueryString["type"] == "add")//添加菜单
            {
                int    n1 = 1, n2 = 1;
                string MenuName = context.Request.QueryString["Name"];
                string Logo     = context.Request.QueryString["Name"];
                int    Parent   = int.Parse(context.Request.QueryString["Parent"]);
                string Link     = context.Request.QueryString["Link"];
                string icon     = context.Request.QueryString["icon"];
                if (context.Request.QueryString["sort"] != null)
                {
                    n1 = int.Parse(context.Request.QueryString["sort"].ToString());
                }
                if (context.Request.QueryString["sort"] != null)
                {
                    n2 = int.Parse(context.Request.QueryString["Isshow"].ToString());
                }

                int sort   = n1;
                int Isshow = n2;
                ljxpower.BLL.tb_navigation   bll   = new ljxpower.BLL.tb_navigation();
                ljxpower.Model.tb_navigation model = new ljxpower.Model.tb_navigation();
                model.MenuName = MenuName;
                model.Pagelogo = Logo;
                string sql = "update tb_navigation set Sort=Sort+1  where ParentId=" + Parent + " and Sort>=" + sort;
                ljxpower.Common.DbHelperMySQL.ExecuteSql(sql);
                if (Parent == 0)
                {
                    model.LinkAddress = null;
                }
                model.LinkAddress = Link;
                model.ParentId    = Parent;
                model.Icon        = icon;
                model.Sort        = sort;
                model.IsShow      = Isshow;
                bll.Add1(model);
            }
            else if (context.Request.QueryString["type"] == "ljxquery")//添加菜单
            {
                //StringBuilder sb = new StringBuilder();
                sb.Clear();
                ljxpower.BLL.tb_navigation          bll  = new ljxpower.BLL.tb_navigation();
                List <ljxpower.Model.tb_navigation> list = new List <ljxpower.Model.tb_navigation>();

                userinfo userobj  = (userinfo)context.Session["userobj"];
                string   strWhere = null;
                if (userobj.logincount == "admin")
                {
                    strWhere = " IsShow=0";
                }
                else
                {
                    strWhere = "Id in(select NavigationId from tb_rolesandnavigation where RolesId in(select RolesId from tb_rolesadduser where UserId='" + userobj.userid + "')) and IsShow=0";
                }
                DataSet ds = bll.GetList(strWhere);
                sb.Append(" {\"menus\":[");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    DataView dv = new DataView(ds.Tables[0]);
                    dv.RowFilter = " ParentId=0";
                    dv.Sort      = "Sort";
                    for (int i = 0; i < dv.Count; i++)
                    {
                        sb.Append("{\"menuid\":\"" + dv[i]["Id"] + "\",\"icon\":\"" + dv[i]["Icon"] + "\",\"menuname\":\"" + dv[i]["Pagelogo"] + "\",");
                        sb.Append("\"menus\":[");
                        //sb.Append("{" + dv[i]["Pagelogo"] + "," + dv[i]["Icon"] + ",");
                        //sb.Append("<ul>");
                        DataView dv2 = new DataView(ds.Tables[0]);
                        dv2.RowFilter = " ParentId=" + dv[i]["Id"];
                        dv2.Sort      = " Sort";
                        for (int j = 0; j < dv2.Count; j++)
                        {
                            sb.Append("{\"menuid\":\"" + dv2[j]["Id"] + "\",\"menuname\":\"" + dv2[j]["Pagelogo"].ToString().Trim() + "\",\"icon\":\"" + dv2[j]["Icon"].ToString().ToString().Trim() + "\",\"url\":\"" + dv2[j]["LinkAddress"].ToString().Trim() + "\"},");
                            //sb.Append("<li><div><a ref=\"" + dv2[j]["Pagelogo"] + "\" href=\"javascript:void(0)\" rel=\"" + dv2[j]["LinkAddress"] + "\" ><span class=\"" + dv2[j]["Icon"].ToString() + "\" >&nbsp;</span><span class=\"nav\">" + dv2[j]["Pagelogo"] + "</span></a></div></li>");
                        }
                        if (dv2.Count > 0)
                        {
                            sb.Remove(sb.Length - 1, 1);
                        }

                        sb.Append("]},");
                        // sb.Append("</ul>}");
                    }
                    //sb.Remove(0, 1);
                    sb.Remove(sb.Length - 1, 1);
                    sb.Append("]}");
                }

                context.Response.Write(sb.ToString());
            }
        }
예제 #3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string RoleId = "0";

            if (context.Request.QueryString["type"] == "edit")//获取角色信息
            {
                int Id = int.Parse(context.Request.QueryString["Id"]);
                ljxpower.BLL.tb_roles   bll   = new ljxpower.BLL.tb_roles();
                ljxpower.Model.tb_roles model = bll.GetModel(Id);
                StringBuilder           sb    = new StringBuilder();
                sb.Append(model.RolesName + ",");
                sb.Append(model.Remark + ",");
                ljxpower.BLL.com_user          ubll = new ljxpower.BLL.com_user();
                List <ljxpower.Model.com_user> list = ubll.GetModelList(" Userid in(select UserId from tb_rolesadduser where RolesId=" + Id + ")");
                foreach (ljxpower.Model.com_user item in list)
                {
                    sb.Append("<div onclick='ss(" + item.userid + ")' height='23px'><input type='hidden' value='" + item.userid + "' />" + item.password + "|" + item.username + "</div>");
                }
                context.Response.Write(sb.ToString());
            }
            else if (context.Request.QueryString["type"] == "getUser")//获取未绑定到当前角色的用户
            {
                StringBuilder                  sb   = new StringBuilder();
                ljxpower.BLL.com_user          ubll = new ljxpower.BLL.com_user();
                List <ljxpower.Model.com_user> list = new List <ljxpower.Model.com_user>();
                //if (context.Request.QueryString["Id"] != null && context.Request.QueryString["Id"] != "")
                //{
                //    int Id = int.Parse(context.Request.QueryString["Id"]);
                //    list = ubll.GetModelList(" Userid not in(select UserId from tb_rolesadduser where RolesId=" + Id + ")");
                //}
                //else
                //{
                list = ubll.GetModelList("");
                // }
                foreach (ljxpower.Model.com_user item in list)
                {
                    sb.Append("<div><input name=\"chkItem\" value=\"<div onclick='ss(" + item.userid + ")' height='23px'><input type='hidden' value='" + item.userid + "'  />" + item.password + "|" + item.username + "</div>\" type=\"checkbox\" /> ");
                    sb.Append(item.password + "|" + item.username + "</div>");
                }
                context.Response.Write(sb.ToString());
            }
            else if (context.Request.QueryString["type"] == "save")//保存角色信息
            {
                string name   = context.Request.QueryString["name"];
                string remark = context.Request.QueryString["remark"];
                int    Id     = int.Parse(context.Request.QueryString["Id"]);
                ljxpower.BLL.tb_roles   bll   = new ljxpower.BLL.tb_roles();
                ljxpower.Model.tb_roles model = bll.GetModel(Id);
                model.Remark    = remark;
                model.RolesName = name;
                context.Response.Write(bll.Update1(model));
            }
            else if (context.Request.QueryString["type"] == "add")//添加
            {
                string name   = context.Request.QueryString["name"];
                string remark = context.Request.QueryString["remark"];
                ljxpower.Model.tb_roles model = new ljxpower.Model.tb_roles();
                ljxpower.BLL.tb_roles   bll   = new ljxpower.BLL.tb_roles();
                model.Remark    = remark;
                model.RolesName = name;
                if (bll.Add1(model) > 0)
                {
                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }
            }
            else if (context.Request.QueryString["type"] == "delRole")//删除角色
            {
                int Id = int.Parse(context.Request.QueryString["Id"]);
                ljxpower.BLL.tb_roles bll = new ljxpower.BLL.tb_roles();

                ljxpower.BLL.tb_rolesadduser rbll = new ljxpower.BLL.tb_rolesadduser();
                rbll.Delete(Id);
                context.Response.Write(bll.Delete(Id));
            }
            else if (context.Request.QueryString["type"] == "Distri")//获取已分配的权限
            {
                int Id = int.Parse(context.Request.QueryString["Id"]);
                ljxpower.BLL.tb_rolesandnavigation          bll  = new ljxpower.BLL.tb_rolesandnavigation();
                List <ljxpower.Model.tb_rolesandnavigation> list = new List <ljxpower.Model.tb_rolesandnavigation>();
                list = bll.GetModelList(" RolesId=" + Id);
                StringBuilder sb = new StringBuilder();
                foreach (ljxpower.Model.tb_rolesandnavigation model in list)
                {
                    sb.Append(model.NavigationId + ",");
                }
                if (sb.Length > 0)
                {
                    sb.Remove(sb.Length - 1, 1);
                }
                context.Response.Write(sb.ToString());
            }
            else if (context.Request.QueryString["type"] == "saveDistri")
            {
                int           Id   = int.Parse(context.Request.QueryString["Id"]);
                string        nav  = context.Request.QueryString["nav"];
                string[]      str  = nav.Split(',');
                List <string> list = new List <string>();
                string        sql  = "delete tb_rolesandnavigation where RolesId=" + Id;
                foreach (string ss in str)
                {
                    ljxpower.BLL.tb_navigation   bll   = new ljxpower.BLL.tb_navigation();
                    ljxpower.Model.tb_navigation model = bll.GetModel(int.Parse(ss));
                    if (model.ParentId != 0)
                    {
                        string sql3 = "delete tb_rolesandnavigation where RolesId=" + Id + " and NavigationId=" + model.ParentId;
                        string sql1 = "insert into tb_rolesandnavigation (RolesId,NavigationId) values(" + Id + "," + model.ParentId + ")";
                        list.Add(sql3);
                        list.Add(sql1);
                    }
                    string sql2 = "insert into tb_rolesandnavigation (RolesId,NavigationId) values(" + Id + "," + ss + ")";
                    list.Add(sql2);
                }
                ljxpower.Common.DbHelperMySQL.ExecuteSqlTran(list);
            }
            else if (context.Request.QueryString["type"] == "savenav")
            {
                RoleId = context.Request["RoleId"].ToString();
                string        NavId = context.Request["NavId"].ToString();
                List <string> list  = new List <string>();
                list.Add("delete from tb_rolesandnavigation where RolesId=" + RoleId);
                string[] str = NavId.Split('|');
                for (int i = 0; i < str.Length - 1; i++)
                {
                    string[] str2 = str[i].Split(',');
                    if (str2.Length == 2)
                    {
                        list.Add(" insert into tb_rolesandnavigation(RolesId,NavigationId,ButtonId) values(" + RoleId + "," + str2[0] + ",0)");
                    }
                    else
                    {
                        for (int j = 1; j < str2.Length - 1; j++)
                        {
                            list.Add(" insert into tb_rolesandnavigation(RolesId,NavigationId,ButtonId) values(" + RoleId + "," + str2[0] + "," + str2[j] + ")");
                        }
                    }
                }
                ljxpower.Common.DbHelperMySQL.ExecuteSqlTran(list);
                context.Response.Write("Hello World");
            }
            else if (context.Request.QueryString["type"] == "query")
            {
                ljxpower.BLL.tb_roles          bll  = new ljxpower.BLL.tb_roles();
                List <ljxpower.Model.tb_roles> list = bll.GetModelList("");
                StringBuilder sb = new StringBuilder();
                sb.Append("[");
                foreach (ljxpower.Model.tb_roles item in list)
                {
                    sb.Append("{\"Id\":" + item.Id + ",");
                    sb.Append("\"Name\":\"" + item.RolesName + "\",");
                    sb.Append("\"Remark\":\"" + item.Remark + "\"},");
                }
                if (sb.Length > 1)
                {
                    sb.Remove(sb.Length - 1, 1);
                }
                sb.Append("]");
                context.Response.Write(sb.ToString());
            }

            /////////////////////////////////////

            else if (context.Request["type"].ToString() == "ljxquery")
            {
                RoleId = context.Request["RoleId"].ToString();
                getdata(RoleId, context);
            }
            else if (context.Request["type"] == "pageload")
            {
                //设置内容权限,读取内容权限,保留在本页中。
                string str1 = context.Request.UrlReferrer.LocalPath;
                if (str1.Length > 3)
                {
                    str1 = str1.Substring(1);
                }
                string pageljxfun = getstrif(str1, context);
                context.Response.Write(pageljxfun);
                //context.Response.Write("OK");
                //return;
            }
            else if (context.Request["type"] == "ljxsave")
            {
                //设置内容权限,读取内容权限,保留在本页中。
                RoleId = context.Request["RoleId"].ToString();
                string        NavId = context.Request["NavId"].ToString();
                List <string> list  = new List <string>();
                list.Add("delete from tb_rolesandnavigation where RolesId=" + RoleId);
                string[] str = NavId.Split('|');
                for (int i = 0; i < str.Length - 1; i++)
                {
                    string[] str2 = str[i].Split(',');
                    if (str2.Length == 2)
                    {
                        list.Add(" insert into tb_rolesandnavigation(RolesId,NavigationId,ButtonId) values(" + RoleId + "," + str2[0] + ",0)");
                    }
                    else
                    {
                        for (int j = 1; j < str2.Length - 1; j++)
                        {
                            list.Add(" insert into tb_rolesandnavigation(RolesId,NavigationId,ButtonId) values(" + RoleId + "," + str2[0] + "," + str2[j] + ")");
                        }
                    }
                }
                ljxpower.Common.DbHelperMySQL.ExecuteSqlTran(list);
                context.Response.Write("OK");
                //return;
            }
        }