public string publicKey = "";//公钥

        //需要根据不同情况建立或修改的不同学校用户和不同类型的用户,本学校用户唯一,不需要全系统唯一
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //公钥
                publicKey = Model.PublicProperty.PublicKey.Replace("\r\n", ",");
                //权限组的增删改
                isadd  = true;
                isedit = true;
                isdel  = true;
                islook = true;
                //先得到操作类型
                dotype = Request.Params["dotype"].ToString();
                string uid   = "0"; //修改时的用户ID
                string uname = "";  //修改时的用户账号
                if (dotype == "a")  //添加
                {
                    schid   = Request.Params["schid"].ToString();
                    systype = Request.Params["systype"].ToString();
                    if (string.IsNullOrEmpty(schid) || string.IsNullOrEmpty(systype))    //如果没有对应参数中任意一个
                    {
                        Response.Write("学校ID为空或者添加的类型为空!");
                        Response.End();
                    }
                }
                else if (dotype == "e")//修改,不能修改用户的类型及学校参数
                {
                    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)
                    {
                        //给默认的屏蔽密码,管理员不能随便修改,只能重置为123456
                        if (!string.IsNullOrEmpty(usermodel.PassWord))               //密码不为空
                        {
                            if (usermodel.PassWord == Com.Public.StrToMD5("123456")) //初始密码
                            {
                                usermodel.PassWord = "******";
                            }
                            else//非初始密码
                            {
                                usermodel.PassWord = "******";
                            }
                        }
                        else//密码为空
                        {
                            usermodel.PassWord = "";
                        }
                        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();
                }

                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.SchRoleSoure rolebll = new SchSystem.BLL.SchRoleSoure();
                    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];

                    //获取该用户关联的角色
                    SchSystem.BLL.SchUserRoleSoureV urolevbll = new SchSystem.BLL.SchUserRoleSoureV();
                    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.SchMenuInfoUserFuncSoure funcbll = new SchSystem.BLL.SchMenuInfoUserFuncSoure();

                    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();
                    SchSystem.BLL.SchMenuInfoUserFuncSoure smieBll = new SchSystem.BLL.SchMenuInfoUserFuncSoure();
                    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);
                }
            }
        }
        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.SchRoleSoure rolebll = new SchSystem.BLL.SchRoleSoure();
                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];

                //获取该用户关联的角色
                SchSystem.BLL.SchUserRoleSoureV urolevbll = new SchSystem.BLL.SchUserRoleSoureV();
                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.SchMenuInfoUserFuncSoure funcbll = new SchSystem.BLL.SchMenuInfoUserFuncSoure();

                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);
            }
        }
        public static string page(string PageIndex, string PageSize, string txtname, string dptid, string ustat, string schid, string schsubs, string childrenids)
        {
            string ret = "";

            if (Com.Session.userid == null)
            {
                ret = "expire";
            }
            else
            {
                SchSystem.BLL.SchUserInfo userbll = new SchSystem.BLL.SchUserInfo();
                if (schid == "")
                {
                    schid = "0";
                }
                //Stat:0废弃,1正常,2被删除,正常界面不显示删除,超管界面可以考虑
                string strwhere = " Stat=1 and SchId='" + Com.Public.SqlEncStr(schid) + "'";//SysType
                if (!string.IsNullOrEmpty(txtname))
                {
                    strwhere += " and UserTname like '%" + Com.Public.SqlEncStr(txtname) + "%'";
                }
                if (Com.Session.systype != "2")
                {
                    strwhere += " and SysType=0 ";
                }
                if (!string.IsNullOrEmpty(ustat))
                {
                    if (ustat != "3")
                    {
                        strwhere += " and AccStat='" + Com.Public.SqlEncStr(ustat) + "' and len(UserName)>0 ";
                    }
                    else
                    {
                        strwhere += " and (len(UserName)=0 or UserName=NULL) ";
                    }
                }
                if (!string.IsNullOrEmpty(schsubs) && schsubs != "0")
                {
                    strwhere += " and SubCode='" + Com.Public.SqlEncStr(schsubs) + "'";
                }
                if (!string.IsNullOrEmpty(dptid) && dptid != "0")
                {
                    if (!string.IsNullOrEmpty(childrenids))
                    {
                        childrenids = childrenids.Substring(0, childrenids.Length - 1);
                        strwhere   += " and UserId in (select UserName from SchUserDept where DeptId in (" + Com.Public.SqlEncStr(childrenids) + "))";
                    }
                    else
                    {
                        strwhere += " and UserId in (select UserName from SchUserDept where DeptId=" + Com.Public.SqlEncStr(dptid) + ")";
                    }
                }
                Com.Public.PageModelResp pages = new Com.Public.PageModelResp();
                pages.PageIndex = int.Parse(PageIndex);
                pages.PageSize  = int.Parse(PageSize);
                int rowc = 0;
                int pc   = 0;

                DataTable dt = userbll.GetListCols("Mobile,UserId,UserName,UserTname,Postion,Title,Sex,AccStat,SchId", strwhere, "UserTname", "ASC", pages.PageIndex, pages.PageSize, ref rowc, ref pc).Tables[0];
                pages.PageCount = pc;
                pages.RowCount  = rowc;
                if (dt.Rows.Count > 0)
                {
                    dt.Columns.Add("Dpts");
                    //获取关联的部门

                    //性别
                    dt.Columns.Add("Sexn");
                    //获取关联的角色
                    dt.Columns.Add("Roles");

                    //获取关联科目
                    dt.Columns.Add("SubName");
                    //获取关联科目
                    dt.Columns.Add("Ustat");

                    SchSystem.BLL.SchUserRoleSoureV rolevbll = new SchSystem.BLL.SchUserRoleSoureV();
                    SchSystem.BLL.SchUserDeptV      deptvbll = new SchSystem.BLL.SchUserDeptV();

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        dt.Rows[i]["Roles"] = rolevbll.GetNames("UserName='******' and Stat=1 and schid=" + dt.Rows[i]["SchId"]);
                        dt.Rows[i]["Roles"] = rolevbll.GetNames("UserId='" + dt.Rows[i]["UserId"] + "' and Stat=1 and schid=" + dt.Rows[i]["SchId"]);
                        dt.Rows[i]["Dpts"]  = deptvbll.GetNames("UserId='" + dt.Rows[i]["UserId"] + "' and Stat=1 and schid=" + dt.Rows[i]["SchId"]);
                        dt.Rows[i]["Sexn"]  = dt.Rows[i]["Sex"].ToString() == "1" ? "男" : "女";
                        //dt.Rows[i]["Ustat"] = dt.Rows[i]["Stat"].ToString() == "1" ? "正常" : "停用";
                        if (dt.Rows[i]["AccStat"].ToString() == "1")
                        {
                            dt.Rows[i]["Ustat"] = "正常";
                        }
                        else if (dt.Rows[i]["AccStat"].ToString() == "0")
                        {
                            dt.Rows[i]["Ustat"] = "停用";
                        }
                        //if (!string.IsNullOrEmpty(dt.Rows[i]["SubCode"].ToString()))
                        //    dt.Rows[i]["SubName"] = Com.Public.GetSubName(dt.Rows[i]["SubCode"].ToString(), dt.Rows[i]["SchId"].ToString());
                        //else
                        //    dt.Rows[i]["SubName"] = "";
                    }
                    pages.list = dt;
                }
                ret = Newtonsoft.Json.JsonConvert.SerializeObject(pages);
            }
            return(ret);
        }