예제 #1
0
        public static string page(string PageIndex, string PageSize, string ClassId, string SchId, string Stuname, string GradeId)
        {
            bool islist = false;

            Com.Public.PageModelResp pages = new Com.Public.PageModelResp();
            pages.PageIndex = int.Parse(PageIndex);
            pages.PageSize  = int.Parse(PageSize);
            SchSystem.BLL.SchClassUser  bllclassuser = new SchSystem.BLL.SchClassUser();
            SchSystem.BLL.SchGradeUsers bllgradeuser = new SchSystem.BLL.SchGradeUsers();
            #region 添加按钮和列表显示权限
            pages.isadd = false;
            if (Com.SoureSession.Souresystype == "1")//学校超管
            {
                islist = true;
                if (GradeId == "-1" || ClassId == "-1" || GradeId == "" || ClassId == "") //系统编辑状态为0,或者年级,班级其中一个选择了全部,则不允许出现添加按钮
                {
                    pages.isadd = false;
                }
                else
                {
                    pages.isadd = true;
                }
            }
            else//普通老师账号
            {
                if (bllclassuser.ExistsIsMs(Com.Public.SqlEncStr(ClassId), Com.SoureSession.Soureuserid, Com.SoureSession.Soureschid, 1) == true)//班主任
                {
                    if (Com.Session.appeditstat == "1")
                    {
                        pages.isadd = true;
                    }
                    islist = true;
                }
                else
                {
                    pages.isadd = false;
                    if (bllgradeuser.ExistsGrade(Com.Public.SqlEncStr(GradeId), Com.SoureSession.Soureschid, Com.SoureSession.Soureuserid) == true)//年级主任
                    {
                        islist = true;
                    }
                    if (bllclassuser.ExistsIsMs(Com.Public.SqlEncStr(ClassId), Com.SoureSession.Soureuserid, Com.SoureSession.Soureschid, 0) == true)//任课老师
                    {
                        islist = true;
                    }
                }
                if (Com.Public.IsUserVal(Com.Session.userrolestr, 2))
                {
                    islist = true;
                }
                ;
            }
            #endregion
            if (islist)
            {
                string strWhere = "StuStat=1 ";
                if (!string.IsNullOrEmpty(Stuname))
                {
                    strWhere += " and stuname LIKE '%" + Com.Public.SqlEncStr(Stuname) + "%'";
                }
                if (GradeId == "-1" || GradeId == "")//获取当前用户的所有年级
                {
                    strWhere += " and GradeId in (" + Com.Public.GetIdsAllStu("4", Com.SoureSession.Soureschid) + ")";
                }
                else
                {
                    strWhere += " and GradeId=" + Com.Public.SqlEncStr(GradeId);
                }
                if (ClassId == "-1" || ClassId == "")//获取当前用户的所有班级
                {
                    if (GradeId == "")
                    {
                        GradeId = "-1";
                    }
                    strWhere += " and ClassId in (" + Com.Public.GetIdsAllStu("5", Com.Public.SqlEncStr(GradeId)) + ")";
                }
                else
                {
                    strWhere += " and ClassId=" + Com.Public.SqlEncStr(ClassId);
                }

                int    RowCount = 0; int PageCount = 0;//left('00000000',8-len(StuId))+convert(varchar(10),StuId)
                string cols = "  GradeId,ClassId,GradeName,ClassName,StuId,TestNo,StuName,CardNo,Sex,StuNo,TelNo,StudyType,LoginName,'' GenNameO,'' GenLoginNameO ,'' GenTelO,'' GenNameT,'' GenLoginNameT ,'' GenTelT,'0' isdel,'0' isedit,'0' islook";
                SchSystem.BLL.SchStuInfoV bllstuv = new SchSystem.BLL.SchStuInfoV();
                DataTable dtstuv = bllstuv.GetListCols(cols, strWhere, "StuName", "ASC", pages.PageIndex, pages.PageSize, ref RowCount, ref PageCount).Tables[0];
                pages.PageCount = PageCount;
                pages.RowCount  = RowCount;
                if (dtstuv != null && dtstuv.Rows.Count > 0)
                {
                    SchSystem.BLL.SchStuGenUV bllstugenv = new SchSystem.BLL.SchStuGenUV();
                    for (int i = 0; i < dtstuv.Rows.Count; i++)//将家长添加上,并且把权限加上
                    {
                        //获取家长
                        DataTable dtgenv = bllstugenv.GetList("GenName,LoginName,TelNo,Relation", "Stat=1 and StuId=" + dtstuv.Rows[i]["StuId"].ToString()).Tables[0];
                        if (dtgenv != null && dtgenv.Rows.Count > 0)
                        {
                            dtstuv.Rows[i]["GenNameO"]      = dtgenv.Rows[0]["GenName"].ToString();
                            dtstuv.Rows[i]["GenTelO"]       = dtgenv.Rows[0]["TelNo"].ToString();
                            dtstuv.Rows[i]["GenLoginNameO"] = dtgenv.Rows[0]["LoginName"].ToString();
                            if (dtgenv.Rows.Count > 1)
                            {
                                dtstuv.Rows[i]["GenNameT"]      = dtgenv.Rows[1]["GenName"].ToString();
                                dtstuv.Rows[i]["GenTelT"]       = dtgenv.Rows[1]["TelNo"].ToString();
                                dtstuv.Rows[i]["GenLoginNameT"] = dtgenv.Rows[1]["LoginName"].ToString();
                            }
                        }
                        //权限
                        if (Com.SoureSession.Souresystype == "1") //学校超管,可看
                        {
                            if (Com.Session.appeditstat == "1")   //系统未被屏蔽编辑功能,则可编辑和删除
                            {
                                dtstuv.Rows[i]["isdel"]  = "1";
                                dtstuv.Rows[i]["isedit"] = "1";
                            }
                            dtstuv.Rows[i]["islook"] = "1";
                        }
                        else//普通老师账号
                        {
                            if (bllclassuser.ExistsIsMs(dtstuv.Rows[i]["ClassId"].ToString(), Com.SoureSession.Soureuserid, Com.SoureSession.Soureschid, 1) == true)//班主任可查看
                            {
                                dtstuv.Rows[i]["islook"] = "1";
                                if (Com.Session.appeditstat == "1")
                                {
                                    dtstuv.Rows[i]["isdel"]  = "1";
                                    dtstuv.Rows[i]["isedit"] = "1";
                                }
                            }
                            else
                            {
                                if (bllgradeuser.ExistsGrade(dtstuv.Rows[i]["GradeId"].ToString(), Com.SoureSession.Soureschid, Com.SoureSession.Soureuserid) == true)//年级主任
                                {
                                    islist = true;
                                    dtstuv.Rows[i]["islook"] = "1";
                                }
                            }
                            if (Com.Public.IsUserVal(Com.Session.userrolestr, 2))
                            {
                                dtstuv.Rows[i]["islook"] = "1";
                                islist = true;
                            }
                        }
                    }
                    pages.list = dtstuv;
                }
            }

            return(Newtonsoft.Json.JsonConvert.SerializeObject(pages));
        }
        public static Com.DataPack.DataRsp <string> page(string PageIndex, string PageSize, string txtname, string ustat, string txtcode, string drptype)
        {
            Com.DataPack.DataRsp <string> rsp = new Com.DataPack.DataRsp <string>();
            if (Com.Session.userid == null)
            {
                rsp.code = "expire";
                rsp.msg  = "页面已经过期,请重新登录";
            }
            else
            {
                try
                {
                    //Stat:0废弃,1正常,2被删除,正常界面不显示删除,超管界面可以考虑
                    string strwhere = "Stat<2 and SchId='" + Com.Session.schid + "' ";

                    if (!string.IsNullOrEmpty(txtname))
                    {
                        strwhere += " and Topic like '%" + Com.Public.SqlEncStr(txtname) + "%'";
                    }
                    if (!string.IsNullOrEmpty(ustat))
                    {
                        strwhere += " and Stat='" + Com.Public.SqlEncStr(ustat) + "'";
                    }
                    if (txtcode != "0")
                    {
                        strwhere += " and ChnId='" + Com.Public.SqlEncStr(txtcode) + "'";
                    }
                    if (drptype != "")
                    {
                        strwhere += " and Lv='" + Com.Public.SqlEncStr(drptype) + "'";
                    }
                    Com.Public.PageModelResp pages = new Com.Public.PageModelResp();
                    pages.PageIndex = int.Parse(PageIndex);
                    pages.PageSize  = int.Parse(PageSize);
                    int rowc = 0;
                    int pc   = 0;
                    SchSystem.BLL.WebSchChnNewsV userbll = new SchSystem.BLL.WebSchChnNewsV();
                    string    dbcols = "NewsId,ChnName,ChnId,Topic,RecTime,GradeId,ClassId,Lv,'' GradeName,'' ClassName,'' LvName,'0' isdel,'0' isedit,'1' islook,Stat,IsTop";
                    DataTable dt     = userbll.GetListCols(dbcols, strwhere, "IsTop Desc,RecTime DESC", "", pages.PageIndex, pages.PageSize, ref rowc, ref pc).Tables[0];
                    pages.PageCount = pc;
                    pages.RowCount  = rowc;
                    if (dt.Rows.Count > 0)
                    {
                        SchSystem.BLL.SchClassUser  bllclassuser = new SchSystem.BLL.SchClassUser();
                        SchSystem.BLL.SchGradeUsers bllgradeuser = new SchSystem.BLL.SchGradeUsers();
                        SchSystem.BLL.SchClassInfo  bllclass     = new SchSystem.BLL.SchClassInfo();
                        SchSystem.BLL.SchGradeInfo  bllgrade     = new SchSystem.BLL.SchGradeInfo();
                        //权限
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            if (Com.Session.appeditstat == "1")                                                                                                                                            //允许编辑
                            {
                                if (dt.Rows[i]["Lv"].ToString() == "0")                                                                                                                                    //班级新闻
                                {
                                    if (Com.Public.IsUserVal(Com.Session.userrolestr, 14) || bllclassuser.ExistsIsMs(dt.Rows[i]["ClassId"].ToString(), Com.Session.usertid, Com.Session.schid, 1) == true) //如果有所有班级权限或是班主任
                                    {
                                        dt.Rows[i]["isdel"]  = "1";
                                        dt.Rows[i]["isedit"] = "1";
                                    }
                                    //获取年级,班级,类型
                                    dt.Rows[i]["GradeName"] = bllgrade.GetName(int.Parse(dt.Rows[i]["GradeId"].ToString()));
                                    dt.Rows[i]["ClassName"] = bllclass.GetName(int.Parse(dt.Rows[i]["ClassId"].ToString()));
                                    dt.Rows[i]["LvName"]    = "班级";
                                }
                                else if (dt.Rows[i]["Lv"].ToString() == "1")                                                                                                                             //年级新闻
                                {
                                    if (Com.Public.IsUserVal(Com.Session.userrolestr, 13) || bllgradeuser.ExistsGrade(dt.Rows[i]["GradeId"].ToString(), Com.Session.schid, Com.Session.usertid) == true) //如果有全校权限或是年级组长
                                    {
                                        dt.Rows[i]["isdel"]  = "1";
                                        dt.Rows[i]["isedit"] = "1";
                                    }
                                    //获取年级
                                    dt.Rows[i]["GradeName"] = bllgrade.GetName(int.Parse(dt.Rows[i]["GradeId"].ToString()));
                                    dt.Rows[i]["LvName"]    = "年级";
                                }
                                else if (dt.Rows[i]["Lv"].ToString() == "2")               //学校新闻
                                {
                                    if (Com.Public.IsUserVal(Com.Session.userrolestr, 13)) //如果有全校权限
                                    {
                                        dt.Rows[i]["isdel"]  = "1";
                                        dt.Rows[i]["isedit"] = "1";
                                    }
                                    dt.Rows[i]["LvName"] = "学校";
                                }
                            }
                        }
                        pages.list = dt;
                    }
                    rsp.RspData = Newtonsoft.Json.JsonConvert.SerializeObject(pages).Replace("\n\r", "");
                }
                catch (Exception ex)
                {
                    rsp.code = "error";
                    rsp.msg  = ex.Message;
                }
            }
            return(rsp);
        }