Exemplo n.º 1
0
        //获取学校系统管理或者普通应用菜单列表
        public static DataTable SchMenuData(string cols, string thstr, string schid, string systype)
        {
            if (schid == "")
            {
                schid = Com.Session.schid;
            }
            //查询学校的子系统、资源服务模块状态
            SchSystem.BLL.SchInfo siBll     = new SchSystem.BLL.SchInfo();
            DataTable             dtschinfo = siBll.GetList("SonSysStat,SourceSerStat,HomeschServStat", "SchId='" + schid + "'").Tables[0];
            string SonSysStat    = dtschinfo.Rows[0]["SonSysStat"].ToString();
            string SourceSerStat = dtschinfo.Rows[0]["SourceSerStat"].ToString();
            string SourceXXTStat = dtschinfo.Rows[0]["HomeschServStat"].ToString();

            DataTable dt = new DataTable();

            SchSystem.BLL.SchAppRole schapprolebll = new SchSystem.BLL.SchAppRole();
            string appstr = schapprolebll.GetAppStr(int.Parse(schid));

            if (appstr != "")
            {
                appstr = "  AppCode in (" + appstr + ")";
            }

            //0普通前台通用菜单,1学校管理后台菜单
            if (systype == "0")
            {
                string sqlstr = "";
                //获取正常的
                if (appstr == "")
                {
                    sqlstr = " Stat=1 and (AppCode=1 or AppCode=2  " + thstr + ")";
                }
                else
                {
                    sqlstr = " Stat=1 and (AppCode=1 or AppCode=2 or " + appstr + " " + thstr + ")";
                }

                //获取菜单表
                SchSystem.BLL.SchMenuInfoUser menuuserbll = new SchSystem.BLL.SchMenuInfoUser();
                dt = menuuserbll.GetList(cols, sqlstr + " order by OrderId ").Tables[0];
                if (dt.Rows.Count > 0)
                {
                    DataRow row = dt.NewRow();
                    row["id"]   = 1;
                    row["pId"]  = 0;
                    row["name"] = "首页";
                    dt.Rows.InsertAt(row, 0);
                }
            }
            else if (systype == "1")
            {
                string sqlstr = "";
                //获取正常的
                if (appstr == "")
                {
                    sqlstr = " Stat=1 and (AppCode=0 or AppCode=1 or AppCode=2 " + thstr + ") ";
                }
                else
                {
                    sqlstr = " Stat=1 and (AppCode=0 or AppCode=1 or AppCode=2 or " + appstr + "" + thstr + ") ";
                }

                if (SonSysStat == "0" || SonSysStat == "")                                                            //子系统状态为0时,不显示管理平台菜单
                {
                    sqlstr += " and FuncCode<>22 and Pid<> (select MenuId from SchMenuInfoAdmin where FuncCode=22) "; //id是MenuId的别名
                }
                if (SourceSerStat == "0" || SourceSerStat == "")                                                      //资源服务状态为0时,不显示资源平台菜单
                {
                    sqlstr += " and FuncCode<>23 and Pid<> (select MenuId from SchMenuInfoAdmin where FuncCode=23) ";
                }
                if (SourceXXTStat == "0" || SourceXXTStat == "")//家校互通服务状态为0时,不显示资源平台菜单
                {
                    sqlstr += " and FuncCode<>29 and Pid<> (select MenuId from SchMenuInfoAdmin where FuncCode=29) ";
                }

                SchSystem.BLL.SchMenuInfoAdmin menuuserbll = new SchSystem.BLL.SchMenuInfoAdmin();
                dt = menuuserbll.GetList(cols, sqlstr + " order by OrderId").Tables[0];
                //if (SonSysStat == "0" || SonSysStat == "")//子系统状态为0时,不显示管理平台菜单
                //{
                //    DataRow[] dr = dt.Select("FuncCode=22");//通过FuncCode查找管理平台MenuId
                //    int Manageid = int.Parse(dr[0]["id"].ToString());//id是MenuId的别称
                //    dt = DataRowToDataTable(dt, "FuncCode<>22 and pId<>" + Manageid);//查找出不属于管理平台的菜单项,并转换为DataTable

                //}
                //if (SourceSerStat == "0" || SourceSerStat == "")//资源服务状态为0时,不显示资源平台菜单
                //{
                //    DataRow[] dr = dt.Select("FuncCode=23");//通过FuncCode查找资源平台MenuId
                //    int Sourceid = int.Parse(dr[0]["id"].ToString());//id是MenuId的别称
                //    dt = DataRowToDataTable(dt, "FuncCode<>23 and pId<>" + Sourceid);//查找出不属于资源平台的菜单项,并转换为DataTable
                //}
                //if (SourceXXTStat == "0" || SourceXXTStat == "")//家校互通服务状态为0时,不显示资源平台菜单
                //{
                //    DataRow[] dr = dt.Select("FuncCode=29");//通过FuncCode查找家校互通平台MenuId
                //    int XXTid = int.Parse(dr[0]["id"].ToString());//id是MenuId的别称
                //    dt = DataRowToDataTable(dt, "FuncCode<>29 and pId<>" + XXTid);//查找出不属于家校互通平台的菜单项,并转换为DataTable
                //}
            }
            else
            {
                //获取子系统
                if (appstr != "")
                {
                    string sqlstr = "Stat=1 and (" + appstr + ")";
                    SchSystem.BLL.SchApp schappbll = new SchSystem.BLL.SchApp();
                    dt = schappbll.GetList(cols, sqlstr).Tables[0];
                }
            }

            return(dt);
        }
Exemplo n.º 2
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.SchMenuInfoAdmin menuuserbll = new SchSystem.BLL.SchMenuInfoAdmin();
                dt = menuuserbll.GetList(sqlstr + "order by OrderId").Tables[0];
            }

            return(dt);
        }