Exemple #1
0
        public static DataTable MenuData(string thstr)
        {
            DataTable dt = new DataTable();

            //根据登录的用户身份获取菜单,0学校普通用户,1学校管理员,2系统超管
            if (Com.Session.systype == "0")
            {
                //再判断用户类型:0普通登录账号,1家长账号,2学生账号
                if (Com.Session.usertp == "0")//普通老师
                {
                    string sqlstr = " Stat=1 ";
                    //根据不同执教类型并集用户菜单,拼凑用户菜单查询条件

                    //普通账号执教类型:0普通老师,1年级主任,2科任组长,3班主任,4科任老师,多个用逗号隔开,在用户登录时根据用户情况赋值
                    //根据Com.Session.usertectp拆分数组,获取该用户能够获取的菜单 ((FuncLv like or FuncLv like )FuncLv:有逗号做查询最好,因现在暂不会重复,则先不做逗号间隔的查询
                    string funclv = "FuncLv like '%0%'";
                    if (!string.IsNullOrEmpty(Com.Session.usertectp))
                    {
                        string[] tp = Com.Session.usertectp.Split(',');
                        if (tp.Length > 0)
                        {
                            foreach (var item in tp)
                            {
                                funclv += " or FuncLv like '%" + item + "%'";
                            }
                        }
                    }
                    //再根据合并的权限串,根据节点调取菜单组funccode串并组合,OR,并集用户权限 or (FuncCode in )) --如果有
                    string func = "0";
                    //菜单组节点,获取菜单组
                    string sqlfuncg = "0";
                    for (int i = 0; i < 4000; i++)//权限串长度
                    {
                        bool bf = Com.Public.IsOne(Com.Session.userrolestr, i + 1);
                        if (bf)
                        {
                            sqlfuncg += "," + (i + 1);
                        }
                    }
                    if (sqlfuncg.Length > 2)//有相应的菜单组,获取菜单组
                    {
                        //读取菜单组表
                        SchSystem.BLL.SchMenuInfoUserFunc menubll = new SchSystem.BLL.SchMenuInfoUserFunc();
                        func += "," + menubll.GetMenug("FuncCode in (" + sqlfuncg + ")");
                    }

                    sqlstr += " and (" + funclv + " or FuncCode in (" + func + thstr + ")" + ")";
                    //再组装屏蔽菜单权限串SQL查询串,之前的条件均为并集,最后为差集.and (FuncCode not in )
                    string nfunc = "0";
                    for (int i = 0; i < 4000; i++)//权限串长度
                    {
                        bool bf = Com.Public.IsOne(Com.Session.userrolestrext, i + 1);
                        if (bf)
                        {
                            nfunc += "," + (i + 1);
                        }
                    }
                    sqlstr += " and FuncCode not in (" + nfunc + ")";



                    //获取菜单表
                    SchSystem.BLL.SchMenuInfoUser menuuserbll = new SchSystem.BLL.SchMenuInfoUser();
                    dt = menuuserbll.GetList(sqlstr + "order by OrderId").Tables[0];
                }
                else if (Com.Session.usertp == "1")//家长
                {
                }
                else if (Com.Session.usertp == "2")//学生
                {
                }
            }
            else//超管和学校超管共用菜单表,0学校普通用户,1学校管理员,2系统超管
            {
                string sqlstr = " Stat=1 and FuncLv like '%" + Com.Session.systype + "%' ";
                SchSystem.BLL.SchMenuInfoIntegral menuuserbll = new SchSystem.BLL.SchMenuInfoIntegral();
                dt = menuuserbll.GetList(sqlstr + "order by OrderId").Tables[0];
            }

            return(dt);
        }
Exemple #2
0
        public string subs      = "";  //相应学校科目表及个人科目,json
        //需要根据不同情况建立或修改的不同学校用户和不同类型的用户,本学校用户唯一,不需要全系统唯一
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (true)//如果没对应权限,及判断用户类型是否跨界,主要防止非法篡改数据出现
            //{
            //    Response.Write("无对应权限");
            //    Response.End();
            //}
            if (!IsPostBack)
            {
                //先得到操作类型
                dotype = Request.Params["dotype"].ToString();
                string uid   = "0"; //修改时的用户ID
                string uname = "";  //修改时的用户账号
                if (dotype == "a")  //添加
                {
                    //根据登录人员的身份,需要得到不同的参数
                    if (Com.SoureSession.Souresystype == "2")//超管,两个关键参数均需要确认
                    {
                        schid   = Request.Params["schid"].ToString();
                        systype = Request.Params["systype"].ToString();
                        if (string.IsNullOrEmpty(schid) || string.IsNullOrEmpty(systype))//如果没有对应参数中任意一个
                        {
                            Response.Write("学校ID为空或者添加的类型为空!");
                            Response.End();
                        }
                    }
                    else//本学校超管或本学校有权限的用户,只能操作普通用户
                    {
                        schid   = Com.SoureSession.Soureschid;
                        systype = "0";
                    }
                }
                else if (dotype == "e" || dotype == "s")//修改或查看,不能修改用户的类型及学校参数
                {
                    btnname = "修改";
                    uid     = Request.Params["uid"].ToString();
                    if (string.IsNullOrEmpty(uid))
                    {
                        Response.Write("无对应修改的用户!");
                        Response.End();
                    }
                    //获取修改的对应用户的
                    SchSystem.BLL.SchUserInfo   userbll   = new SchSystem.BLL.SchUserInfo();
                    SchSystem.Model.SchUserInfo usermodel = userbll.GetModel(int.Parse(uid));
                    if (usermodel != null && usermodel.UserId > 0)
                    {
                        umodelstr = Newtonsoft.Json.JsonConvert.SerializeObject(usermodel);
                        schid     = usermodel.SchId.ToString();
                        systype   = usermodel.SysType.ToString();
                        uname     = usermodel.UserName;
                    }
                    else
                    {
                        Response.Write("无该用户!");
                        Response.End();
                    }
                }
                else//不在添加及修改之内,则返回
                {
                    Response.Write("没有可供确认的操作类型!");
                    Response.End();
                }
                //判断跨界操作的可能性
                if (!Com.Public.isVa(schid, systype))
                {
                    Response.Write("出错,用户非法跨界操作!");
                    Response.End();
                }
                SchSystem.BLL.SchInfo schbll = new SchSystem.BLL.SchInfo();
                schname = schbll.GetSchName(int.Parse(schid));
                if (!string.IsNullOrEmpty(schid) && !string.IsNullOrEmpty(systype))
                {
                    //获取整个学校的科目
                    subs = Com.Public.GetDrp("sub", schid, "1", false, "", "");

                    //获取整个学校的部门
                    SchSystem.BLL.SchDepartInfo dptbll = new SchSystem.BLL.SchDepartInfo();
                    DataTable dtdept = dptbll.GetList("Pid pId,DepartId id,DepartName name,'false' checked", "SchId=" + schid + " and Stat=1 Order by OrderId").Tables[0];
                    //获取该用户的关联部门
                    SchSystem.BLL.SchUserDeptV udeptvbll = new SchSystem.BLL.SchUserDeptV();
                    string udeptids = udeptvbll.GetIds(" UserId='" + uid + "' and stat=1 and schid=" + schid);
                    if (!string.IsNullOrEmpty(udeptids) && dtdept != null)
                    {
                        string[] ids = udeptids.Split(',');
                        for (int i = 0; i < dtdept.Rows.Count; i++)
                        {
                            string id = dtdept.Rows[i]["id"].ToString();
                            if (ids.Contains(id))
                            {
                                dtdept.Rows[i]["checked"] = "true";
                            }
                        }
                    }

                    depts = Newtonsoft.Json.JsonConvert.SerializeObject(dtdept);
                    //获取角色菜单
                    SchSystem.BLL.SchRole rolebll = new SchSystem.BLL.SchRole();
                    DataTable             dtrole  = rolebll.GetList("RoleId id,null pId,RoleName name,'false' checked", "Stat=1 and SchId=" + schid + " and SysType='" + systype + "'  Order by RoleName").Tables[0];
                    if (dtrole.Rows.Count == 0)
                    {
                        //给个默认根节点
                        DataRow dr = dtrole.NewRow();
                        dr["id"]      = "0";
                        dr["pId"]     = DBNull.Value;
                        dr["name"]    = "权限组";
                        dr["checked"] = "false";
                        dtrole.Rows.Add(dr);
                    }
                    //获取该用户关联的角色
                    SchSystem.BLL.SchUserRoleV urolevbll = new SchSystem.BLL.SchUserRoleV();
                    string uroleids = urolevbll.GetIds(" UserId='" + uid + "' and stat=1 and schid=" + schid);
                    if (!string.IsNullOrEmpty(uroleids) && dtrole != null)
                    {
                        string[] ids = uroleids.Split(',');
                        for (int i = 0; i < dtrole.Rows.Count; i++)
                        {
                            string id = dtrole.Rows[i]["id"].ToString();
                            if (ids.Contains(id))
                            {
                                dtrole.Rows[i]["checked"] = "true";
                            }
                        }
                    }
                    roles = Newtonsoft.Json.JsonConvert.SerializeObject(dtrole);
                    //获取功能树,查询条件需要根据用户种类和状态等,后面需要改
                    //根据学校拥有的子系统
                    SchSystem.BLL.SchAppRole schapprolebll = new SchSystem.BLL.SchAppRole();
                    string appstr = schapprolebll.GetAppStr(int.Parse(schid));
                    if (appstr != "")
                    {
                        appstr = " and (AppCode=1 or AppCode=2 or AppCode in (" + appstr + ")) ";
                    }
                    SchSystem.BLL.SchMenuInfoUserFunc funcbll = new SchSystem.BLL.SchMenuInfoUserFunc();

                    DataTable dtfunc = funcbll.GetList("MenuId id,Pid pId,TextName name,FuncCode funcode,'false' checked", " Stat=1 " + appstr + " Order by OrderId").Tables[0];
                    funcstr = Newtonsoft.Json.JsonConvert.SerializeObject(dtfunc);
                }
            }
        }
Exemple #3
0
        public string MenuInfoExt = ""; //特殊权限功能数据,json

        //需要根据不同情况建立或修改的不同学校用户和不同类型的用户,本学校用户唯一,不需要全系统唯一
        protected void Page_Load(object sender, EventArgs e)
        {
            uid = Request.Params["uid"].ToString();
            SchSystem.BLL.SchUserInfo   userbll   = new SchSystem.BLL.SchUserInfo();
            SchSystem.Model.SchUserInfo usermodel = userbll.GetModel(int.Parse(uid));
            if (usermodel != null && usermodel.UserId > 0)
            {
                utname = usermodel.UserTname;
                usex   = usermodel.Sex == 0 ? "女" : "男";
                ups    = usermodel.Postion;
                ujb    = usermodel.Title;
                utl    = usermodel.Telno;
                uname  = usermodel.UserName;
                if (usermodel.PassWord == Com.Public.StrToMD5("123456"))
                {
                    upw     = "123456";
                    upwname = "初始密码";
                }
                else if (usermodel.PassWord == "")
                {
                    upw     = "";
                    upwname = "初始密码";
                }
                else
                {
                    upw     = "●●●●●●";
                    upwname = "用户密码";
                }
                ustat = usermodel.AccStat == 0 ? "禁用" : "正常";
                SchSystem.BLL.SchUserDeptV dpvbll = new SchSystem.BLL.SchUserDeptV();
                udpts = dpvbll.GetNames("UserId=" + uid);
                uno   = "00000000".Substring(0, 8 - uid.Length) + uid;
                schid = usermodel.SchId.ToString();
                SchSystem.BLL.SchRole rolebll = new SchSystem.BLL.SchRole();
                DataTable             dtrole  = rolebll.GetList("RoleId id,null pId,RoleName name,'false' checked", "Stat=1 and SchId=" + schid + " and SysType='0'  Order by RoleName").Tables[0];
                if (dtrole.Rows.Count == 0)
                {
                    //给个默认根节点
                    //DataRow dr = dtrole.NewRow();
                    //dr["id"] = "0";
                    //dr["pId"] = DBNull.Value;
                    //dr["name"] = "权限组";
                    //dr["checked"] = "false";
                    //dtrole.Rows.Add(dr);
                }
                //获取该用户关联的角色

                SchSystem.BLL.SchUserRoleV urolevbll = new SchSystem.BLL.SchUserRoleV();
                string uroleids = urolevbll.GetIds(" UserId='" + uid + "' and stat=1 and schid=" + usermodel.SchId);
                if (!string.IsNullOrEmpty(uroleids) && dtrole != null)
                {
                    string[] ids = uroleids.Split(',');
                    for (int i = 0; i < dtrole.Rows.Count; i++)
                    {
                        string id = dtrole.Rows[i]["id"].ToString();
                        if (ids.Contains(id))
                        {
                            dtrole.Rows[i]["checked"] = "true";
                        }
                    }
                }
                roles = Newtonsoft.Json.JsonConvert.SerializeObject(dtrole);
                //获取功能树,查询条件需要根据用户种类和状态等,后面需要改
                //根据学校拥有的子系统
                SchSystem.BLL.SchAppRole schapprolebll = new SchSystem.BLL.SchAppRole();
                string appstr = schapprolebll.GetAppStr(usermodel.SchId);
                if (appstr != "")
                {
                    appstr = " and (AppCode=1 or AppCode=2 or AppCode in (" + appstr + ")) ";
                }
                SchSystem.BLL.SchMenuInfoUserFunc funcbll = new SchSystem.BLL.SchMenuInfoUserFunc();

                DataTable dtfunc = funcbll.GetList("MenuId id,Pid pId,TextName name,FuncCode funcode,'false' checked", " Stat=1 " + appstr + " Order by OrderId").Tables[0];
                funcstr = Newtonsoft.Json.JsonConvert.SerializeObject(dtfunc);
                //获取特殊权限功能树
                SchSystem.BLL.SchMenuInfoUser smieBll = new SchSystem.BLL.SchMenuInfoUser();
                DataTable dtsmie = smieBll.GetList("MenuId id,Pid pId,TextName name,FuncCode funcode,'false' checked", " Stat=1 " + appstr + "  Order by OrderId").Tables[0];
                MenuInfoExt = Newtonsoft.Json.JsonConvert.SerializeObject(dtsmie);
            }
        }