Beispiel #1
0
 //需要根据不同情况建立或修改的不同学校用户和不同类型的用户,本学校用户唯一,不需要全系统唯一
 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.Mobile;
         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);
         uid   = "00000000".Substring(0, 8 - uid.Length) + uid;
     }
 }
Beispiel #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);
                }
            }
        }
Beispiel #3
0
        public static string usersave(string dotype, string schid, string systype, string userid, string usercode, string usertname, string usertel, string userpst, string usertitle, string usermobile, string username, string userpw, string usersex, string userstat, string usersub, string userdpts, string userroles)
        {
            //解密 RSA
            RSACryptoService rsa = new RSACryptoService(PublicProperty.PrivateKey, PublicProperty.PublicKey);

            if (userpw != "")
            {
                userpw = Com.Public.SqlEncStr(rsa.Decrypt(userpw));
            }
            string ret = "";

            if (Com.Session.userid == null)
            {
                ret = "expire";
            }
            else
            {
                try
                {
                    if (string.IsNullOrEmpty(schid) || schid == "0")
                    {
                        ret += "非法的学校!";
                    }
                    SchSystem.BLL.SchUserInfo   userbll   = new SchSystem.BLL.SchUserInfo();
                    SchSystem.Model.SchUserInfo usermodel = new SchSystem.Model.SchUserInfo();
                    if (!Com.Public.isVa(schid, ""))
                    {
                        ret += "无跨界权限;";
                    }
                    //判断编号及账号是否有重复,生成密码加密
                    if (dotype == "e")
                    {
                        //if (userbll.ExistsUserCode(int.Parse(userid), usercode, int.Parse(schid)))
                        //{
                        //    ret += "用户编号重复!";
                        //}
                        if (username != "")
                        {
                            if (userbll.ExistsUserName(int.Parse(userid), username))
                            {
                                ret += "账号重复!";
                            }
                            else if (!userbll.ExistsUserName(0, username))
                            {
                                userbll.UpdateUserName(username, int.Parse(userid));
                            }
                        }
                    }
                    if (dotype == "a")
                    {
                        //if (userbll.ExistsUserCode(0, usercode, int.Parse(schid)))
                        //{
                        //    ret += "用户编号重复!";
                        //}
                        if (username != "")
                        {
                            /*if (userbll.ExistsUserName(0, username, int.Parse(schid)))
                             * {
                             *  ret += "账号重复!";
                             * }*/
                            StringBuilder sbExists = new StringBuilder();
                            string        utname   = "";
                            if (userbll.ExistsUserName(0, username))
                            {
                                SchSystem.BLL.SchUserDeptV bllusdpt = new SchSystem.BLL.SchUserDeptV();
                                DataTable dt = bllusdpt.GetList("DepartName,UserTname", "UserName='******'").Tables[0];
                                DataRow[] dr = dt.Select();
                                foreach (DataRow item in dr)
                                {
                                    sbExists.Append(item["DepartName"].ToString() + "、");
                                    utname = item["UserTname"].ToString();
                                }
                                //ret += "账号重复!";
                                ret += sbExists.ToString().Substring(0, sbExists.ToString().Length - 1);
                                ret += "," + utname;
                            }
                        }
                    }
                    if (ret == "")
                    {
                        usermodel.LastRecTime = DateTime.Now;
                        usermodel.LastRecUser = Com.Session.userid;
                        usermodel.Mobile      = usermobile;
                        usermodel.Postion     = userpst;
                        usermodel.Sex         = int.Parse(usersex);
                        if (!string.IsNullOrEmpty(userstat))
                        {
                            usermodel.AccStat = int.Parse(userstat);
                        }
                        else
                        {
                            usermodel.AccStat = 2;
                        }
                        usermodel.SubCode   = usersub;
                        usermodel.SysType   = int.Parse(systype);
                        usermodel.Telno     = usertel;
                        usermodel.Title     = usertitle;
                        usermodel.UserNo    = usercode;
                        usermodel.UserTname = usertname;
                        if (dotype == "e")
                        {
                            if (!string.IsNullOrEmpty(userpw) && !string.IsNullOrEmpty(username))
                            {
                                userpw = Com.Public.StrToMD5(userpw);
                                if (userpw == Com.Public.StrToMD5("123456"))//如果重置密码时保存
                                {
                                    userbll.UpdatePw(int.Parse(userid), userpw);
                                }
                            }
                            usermodel.UserId = int.Parse(userid);
                            userbll.UpdateUser(usermodel);
                        }
                        if (dotype == "a")
                        {
                            //必须有账号和密码
                            if (!string.IsNullOrEmpty(userpw) && !string.IsNullOrEmpty(username))
                            {
                                usermodel.PassWord = Com.Public.StrToMD5("123456"); //SchManagerInfoSystem.Common.DESEncrypt.Encrypt(userpw) ;添加时均为123456密码
                            }
                            usermodel.RecTime  = DateTime.Now;
                            usermodel.RecUser  = Com.Session.userid;
                            usermodel.SchId    = int.Parse(schid);
                            usermodel.UserName = username;
                            userid             = userbll.Add(usermodel).ToString();
                        }
                        //添加或更新关联部门
                        SchSystem.BLL.SchUserDept userdeptbll = new SchSystem.BLL.SchUserDept();
                        if (userdpts == null)
                        {
                            userdpts = "0";
                        }
                        userdeptbll.DoUserDept(userid, Com.Session.userid, schid, userdpts);
                        //添加或更新关联角色
                        SchSystem.BLL.SchUserRole userrolebll = new SchSystem.BLL.SchUserRole();
                        if (userroles == null)
                        {
                            userroles = "0";
                        }
                        userrolebll.DoUserRole(userid, Com.Session.userid, schid, userroles);
                        ret = "success";
                    }
                }
                catch (Exception ex)
                {
                    ret = ex.Message;
                }
            }
            return(ret);
        }
Beispiel #4
0
        //需要根据不同情况建立或修改的不同学校用户和不同类型的用户,本学校用户唯一,不需要全系统唯一
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (true)//如果没对应权限,及判断用户类型是否跨界,主要防止非法篡改数据出现
            //{
            //    Response.Write("无对应权限");
            //    Response.End();
            //}
            if (!IsPostBack)
            {
                //不是超管获取本学校的
                if (Com.Session.systype != "2")
                {
                    schid   = Com.Session.schid;
                    systype = "0";
                }
                else
                {
                    schid = Request.Params["schid"].ToString();
                    if (string.IsNullOrEmpty(schid))//如果没有对应参数中任意一个
                    {
                        Response.Write("学校ID为空或者添加的类型为空!");
                        Response.End();
                    }
                }
                SchSystem.BLL.SchSub ssBll = new SchSystem.BLL.SchSub();
                //先得到操作类型
                dotype = Com.Public.SqlEncStr(Request.Params["dotype"].ToString());
                string subid = "0"; //修改时的用户ID
                string uname = "";  //修改时的用户账号
                if (dotype == "e")  //修改,不能修改用户的类型及学校参数
                {
                    btnname = "保存";
                    subid   = Com.Public.SqlEncStr(Request.Params["subid"].ToString());
                    if (string.IsNullOrEmpty(subid))
                    {
                        Response.Write("无对应修改的用户!");
                        Response.End();
                    }
                    //获取修改的对应用户的
                    SchSystem.Model.SchSub ssModel = ssBll.GetModelSub(subid, schid);
                    if (ssModel != null && ssModel.SubId > 0)
                    {
                        umodelstr = Newtonsoft.Json.JsonConvert.SerializeObject(ssModel);
                        schid     = ssModel.SchId.ToString();
                    }
                    else
                    {
                        Response.Write("无该科目!");
                        Response.End();
                    }
                }
                else//不在添加及修改之内,则返回
                {
                    Response.Write("没有可供确认的操作类型!");
                    Response.End();
                }
                //判断跨界操作的可能性
                if (!Com.Public.isVa(schid, systype))
                {
                    Response.Write("出错,用户非法跨界操作!");
                    Response.End();
                }
                #region
                SchSystem.BLL.SchInfo schbll = new SchSystem.BLL.SchInfo();
                schname = schbll.GetSchName(int.Parse(schid));
                SchSystem.BLL.SchDepartInfo sdiBll = new SchSystem.BLL.SchDepartInfo();
                //获取部门列表
                DataTable dtdpt = sdiBll.GetList("Pid pId,convert(varchar(20),DepartId) id,DepartName name,'false' checked,'true' nochecks", "SchId=" + schid + " and Stat=1 Order by OrderId").Tables[0];
                dtdpt.Columns["nochecks"].ColumnName = "nocheck";
                DataTable dtdptuser = dtdpt.Clone();
                if (dtdpt.Rows.Count > 0)
                {
                    //获取该年级组长
                    SchSystem.BLL.SchSubLeader sslBll = new SchSystem.BLL.SchSubLeader();
                    DataTable dtgradeuser             = sslBll.GetList("UserName", "SubCode=" + subid).Tables[0];
                    //获取该学校的所有人员
                    SchSystem.BLL.SchUserDeptV userbll = new SchSystem.BLL.SchUserDeptV();
                    DataTable dtuser = userbll.GetList("DeptId ,UserId,UserTname", "Stat=1 and Ustat=1 and SchId=" + Com.Public.SqlEncStr(schid)).Tables[0];
                    //合并人员到部门表
                    for (int i = 0; i < dtdpt.Rows.Count; i++)
                    {
                        dtdptuser.Rows.Add(dtdpt.Rows[i].ItemArray);
                        //获取该部门下的人员
                        DataRow[] drs = dtuser.Select("DeptId='" + dtdpt.Rows[i]["id"].ToString() + "'");
                        if (drs.Length > 0)
                        {
                            foreach (DataRow item in drs)
                            {
                                //如果是被绑定了,则勾选
                                DataRow[] drsgrade = dtgradeuser.Select("UserName='******'");
                                DataRow   dr       = dtdptuser.NewRow();
                                dr["id"]   = "sub_" + item["UserId"].ToString();
                                dr["name"] = item["UserTname"].ToString();
                                dr["pId"]  = item["DeptId"].ToString();
                                if (drsgrade.Length > 0)
                                {
                                    dr["checked"] = "true";
                                }
                                dtdptuser.Rows.Add(dr);
                            }
                        }
                    }
                }

                depart = Newtonsoft.Json.JsonConvert.SerializeObject(dtdptuser);
                #endregion
            }
        }
Beispiel #5
0
        public string depts   = "";//相应学校部门及个人部门,json

        //需要根据不同情况建立或修改的不同学校用户和不同类型的用户,本学校用户唯一,不需要全系统唯一
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //公钥
                publicKey = PublicProperty.PublicKey.Replace("\r\n", ",");
                //先得到操作类型
                dotype = Request.Params["dotype"].ToString();
                if (dotype == "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.ToString();
                        ups    = usermodel.Postion;
                        ujb    = usermodel.Title;
                        utl    = usermodel.Mobile.Trim();
                        uname  = usermodel.UserName.Trim();
                        if (usermodel.PassWord == Com.Public.StrToMD5("123456"))
                        {
                            upw     = "123456";
                            upwname = "初始密码:";
                        }
                        else if (usermodel.PassWord == "")
                        {
                            upw     = "";
                            upwname = "初始密码:";
                        }
                        else
                        {
                            upw     = "●●●●●●";
                            upwname = "用户密码:";
                        }
                        ustat = usermodel.AccStat.ToString();
                        uno   = "00000000".Substring(0, 8 - uid.Length) + uid;
                    }
                    else
                    {
                        Response.Write("无该用户!");
                        Response.End();
                    }
                }
                SchSystem.BLL.SchDepartInfo dptbll = new SchSystem.BLL.SchDepartInfo();
                DataTable dtdept = dptbll.GetList("Pid pId,DepartId id,DepartName name,'false' checked", "SchId=" + Com.Session.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=" + Com.Session.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);
            }
        }
        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);
            }
        }
Beispiel #7
0
        //需要根据不同情况建立或修改的不同学校用户和不同类型的用户,本学校用户唯一,不需要全系统唯一
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (true)//如果没对应权限,及判断用户类型是否跨界,主要防止非法篡改数据出现
            //{
            //    Response.Write("无对应权限");
            //    Response.End();
            //}
            if (!IsPostBack)
            {
                //先得到操作类型
                dotype    = Com.Public.SqlEncStr(Request.Params["dotype"].ToString());
                schid     = Com.Public.SqlEncStr(Request.Params["schid"].ToString());
                gradecode = Com.Public.SqlEncStr(Request.Params["gradecode"].ToString());
                if (string.IsNullOrEmpty(schid) || string.IsNullOrEmpty(gradecode))//如果没有对应参数中任意一个
                {
                    Response.Write("参数错误!");
                    Response.End();
                }
                if (dotype == "a")
                {
                }
                else if (dotype == "e")//修改,不能修改用户的类型及学校参数
                {
                    btnname = "保存";
                    classid = Com.Public.SqlEncStr(Request.Params["classid"].ToString());
                    if (string.IsNullOrEmpty(classid))
                    {
                        Response.Write("无对应修改的记录!");
                        Response.End();
                    }
                    //获取修改的对应用户的
                    SchSystem.BLL.SchClassInfo   sgibll   = new SchSystem.BLL.SchClassInfo();
                    SchSystem.Model.SchClassInfo sgimodel = sgibll.GetModel(int.Parse(classid));
                    if (sgimodel != null && sgimodel.ClassId > 0)
                    {
                        umodelstr = Newtonsoft.Json.JsonConvert.SerializeObject(sgimodel);
                    }
                    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));
                #region 获取当前学校的老师
                //当前班级任课老师及班主任
                SchSystem.BLL.SchClassUser userclassbll = new SchSystem.BLL.SchClassUser();
                DataTable dtclassuser = userclassbll.GetList("UserName id,SubCode subcode,UserTname name,IsMs isms", "ClassId=" + Com.Public.SqlEncStr(classid)).Tables[0];

                //当前学校老师
                SchSystem.BLL.SchUserDeptV userbll = new SchSystem.BLL.SchUserDeptV();
                DataTable dtuser = userbll.GetList("DeptId,DepartName,UserId,UserTname", "Stat=1 and Ustat=1 and SchId=" + Com.Public.SqlEncStr(schid)).Tables[0];
                //DataRow[] dtRow = dtuser.Select();
                StringBuilder sb = new StringBuilder();
                //DataView dv = dtuser.DefaultView;
                //DataTable datadpt = dv.ToTable(true, "Pid,DeptId,DepartName");
                SchSystem.BLL.SchDepartInfo dptbll = new SchSystem.BLL.SchDepartInfo();
                DataTable dt        = dptbll.GetList(" 'd_'+convert(varchar(20),Pid) pId,'d_'+convert(varchar(20),DepartId) id,DepartName name,'0' isms,'' subcode,'false' checked,'true' nochecks", "SchId=" + schid + " and Stat=1 Order by OrderId,DepartName").Tables[0];
                DataTable dtdptuser = dt.Clone();
                dtdptuser.Columns["nochecks"].ColumnName = "nocheck";
                if (dt.Rows.Count > 0)
                {
                    //合并人员到部门表
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        dtdptuser.Rows.Add(dt.Rows[i].ItemArray);
                        //获取该部门下的人员
                        DataRow[] drss = dtuser.Select("DeptId='" + dt.Rows[i]["id"].ToString().Replace("d_", "") + "'");
                        if (drss.Length > 0)
                        {
                            foreach (DataRow item in drss)
                            {
                                DataRow dr = dtdptuser.NewRow();
                                dr["id"]   = item["UserId"].ToString();
                                dr["name"] = item["UserTname"].ToString();
                                dr["pId"]  = "d_" + item["DeptId"].ToString();
                                dtdptuser.Rows.Add(dr);
                            }
                        }
                    }
                    deptusers = Newtonsoft.Json.JsonConvert.SerializeObject(dtdptuser);
                    //DataRow[] drs = dt.Select("Pid=0");
                    //foreach (DataRow dr in drs)
                    //{
                    //    string nodeID = dr["ID"].ToString();
                    //    string nodeText = dr["Name"].ToString();


                    //    nodeText = "├" + nodeText;
                    //    string blank = "&nbsp;&nbsp;&nbsp;&nbsp;";
                    //    sb.Append("<option value=\"p_" + nodeID + "\">" + nodeText + "</option>");
                    //    DataRow[] drusers = dtuser.Select("DeptId='" + nodeID + "'");
                    //    if (drusers != null && drusers.Length > 0)
                    //    {
                    //        foreach (DataRow druser in drusers)
                    //        {
                    //            sb.Append("<option style=\"color:blue\" value=\"u_" + druser["UserId"].ToString() + "\">" + blank + "&nbsp;&nbsp;&nbsp;&nbsp;" + druser["UserTname"].ToString() + "</option>");
                    //        }
                    //    }
                    //    BindSon(sb, nodeID, dt, blank, dtuser);
                    //}
                }
                //depts = sb.ToString();
                deptss  = Newtonsoft.Json.JsonConvert.SerializeObject(dtclassuser);
                subsdrp = Com.Public.GetDrp("sub", schid, "1", false, "", "");
                #endregion

                #region 获取年级领导
                SchSystem.BLL.SchGradeUsers usergradebll = new SchSystem.BLL.SchGradeUsers();
                gradeboss = usergradebll.GetNames("GradeId='" + Com.Public.SqlEncStr(gradecode) + "'");
                gradesdrp = Com.Public.GetDrp("grade", schid, "0", false, "", "");
                #endregion
            }
        }
        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.SchUserRoleV rolevbll = new SchSystem.BLL.SchUserRoleV();
                    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);
        }
        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);
                }
            }
        }
        //需要根据不同情况建立或修改的不同学校用户和不同类型的用户,本学校用户唯一,不需要全系统唯一
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (true)//如果没对应权限,及判断用户类型是否跨界,主要防止非法篡改数据出现
            //{
            //    Response.Write("无对应权限");
            //    Response.End();
            //}
            if (!IsPostBack)
            {
                //先得到操作类型
                dotype    = Com.Public.SqlEncStr(Request.Params["dotype"].ToString());
                schid     = Com.Public.SqlEncStr(Request.Params["schid"].ToString());
                gradecode = Com.Public.SqlEncStr(Request.Params["gradecode"].ToString());
                if (string.IsNullOrEmpty(schid) || string.IsNullOrEmpty(gradecode))//如果没有对应参数中任意一个
                {
                    Response.Write("参数错误!");
                    Response.End();
                }
                if (dotype == "a")
                {
                }
                else if (dotype == "e")//修改,不能修改用户的类型及学校参数
                {
                    btnname = "修改";
                    classid = Com.Public.SqlEncStr(Request.Params["classid"].ToString());
                    if (string.IsNullOrEmpty(classid))
                    {
                        Response.Write("无对应修改的记录!");
                        Response.End();
                    }
                    //获取修改的对应用户的
                    SchSystem.BLL.SchClassInfo   sgibll   = new SchSystem.BLL.SchClassInfo();
                    SchSystem.Model.SchClassInfo sgimodel = sgibll.GetModel(int.Parse(classid));
                    if (sgimodel != null && sgimodel.ClassId > 0)
                    {
                        umodelstr = Newtonsoft.Json.JsonConvert.SerializeObject(sgimodel);
                    }
                    else
                    {
                        Response.Write("无该记录!");
                        Response.End();
                    }
                }
                else//不在添加及修改之内,则返回
                {
                    Response.Write("没有可供确认的操作类型!");
                    Response.End();
                }

                /*//判断跨界操作的可能性
                 * if (!Com.Public.isVa(schid, systype))
                 * {
                 *  Response.Write("出错,用户非法跨界操作!");
                 *  Response.End();
                 * }*/
                #region 获取部门人员列表
                SchSystem.BLL.SchInfo schbll = new SchSystem.BLL.SchInfo();
                schname = schbll.GetSchName(int.Parse(schid));
                //获取年级领导
                SchSystem.BLL.SchGradeUsers usergradebll = new SchSystem.BLL.SchGradeUsers();
                gradeboss = usergradebll.GetNames("GradeId in ( select GradeId from SchGradeInfo where GradeCode=" + Com.Public.SqlEncStr(gradecode) + " and schid=" + schid + ")");
                gradesdrp = Com.Public.GetDrp("grade", schid, "0", false, "", "");
                SchSystem.BLL.SchDepartInfo sdiBll = new SchSystem.BLL.SchDepartInfo();
                //获取部门列表
                DataTable dtdpt = sdiBll.GetList("Pid pId,convert(varchar(20),DepartId) id,DepartName name,'false' checked,'true' nochecks,'0' isms,'' subcode", "SchId=" + Com.Public.SqlEncStr(schid) + " and Stat=1 Order by OrderId").Tables[0];
                dtdpt.Columns["nochecks"].ColumnName = "nocheck";
                DataTable     dtdptuser = dtdpt.Clone();
                StringBuilder sb        = new StringBuilder();
                if (dtdpt.Rows.Count > 0)
                {
                    SchSystem.BLL.SchClassUser userclassbll = new SchSystem.BLL.SchClassUser();
                    DataTable dtclassuser = userclassbll.GetList("UserName,SubCode,IsMs", "ClassId=" + Com.Public.SqlEncStr(classid)).Tables[0];
                    //获取该学校的所有人员
                    SchSystem.BLL.SchUserDeptV userbll = new SchSystem.BLL.SchUserDeptV();
                    DataTable dtuser = userbll.GetList("DeptId ,UserName,UserTname", "Stat=1 and Ustat=1 and SchId=" + Com.Public.SqlEncStr(schid)).Tables[0];
                    //合并人员到部门表
                    for (int i = 0; i < dtdpt.Rows.Count; i++)
                    {
                        dtdptuser.Rows.Add(dtdpt.Rows[i].ItemArray);
                        //获取该部门下的人员
                        DataRow[] drs = dtuser.Select("DeptId='" + dtdpt.Rows[i]["id"].ToString() + "'");
                        if (drs.Length > 0)
                        {
                            foreach (DataRow item in drs)
                            {
                                DataRow dr = dtdptuser.NewRow();
                                dr["id"]   = "u_" + item["UserName"].ToString();
                                dr["name"] = item["UserTname"].ToString();
                                dr["pId"]  = item["DeptId"].ToString();
                                //如果是被绑定了,则勾选
                                DataRow[] drsclassuser = dtclassuser.Select("UserName='******'");
                                if (drsclassuser.Length > 0)
                                {
                                    dr["isms"]    = drsclassuser[0]["IsMs"].ToString();
                                    dr["subcode"] = drsclassuser[0]["SubCode"].ToString();
                                    dr["checked"] = "true";
                                }
                                dtdptuser.Rows.Add(dr);
                            }
                        }
                    }
                }
                SchSystem.BLL.SchUserInfo sui = new SchSystem.BLL.SchUserInfo();
                DataTable dtsui = sui.GetList("*", "Stat=1 and SchId=" + Com.Public.SqlEncStr(schid)).Tables[0];
                DataRow[] drsui = dtsui.Select();

                foreach (DataRow item in drsui)
                {
                    sb.Append("<option value=\"u_" + item["UserName"].ToString() + "\">" + item["UserTname"].ToString() + "</option>");
                }
                tec     = sb.ToString();
                depts   = Newtonsoft.Json.JsonConvert.SerializeObject(dtdptuser);
                subsdrp = Com.Public.GetDrp("sub", schid, "1", false, "", "");
                #endregion
                #region 获取部门人员列表

                /*SchSystem.BLL.SchInfo schbll = new SchSystem.BLL.SchInfo();
                 * schname = schbll.GetSchName(int.Parse(schid));
                 * //获取年级领导
                 * SchSystem.BLL.SchGradeUsers usergradebll = new SchSystem.BLL.SchGradeUsers();
                 * gradeboss = usergradebll.GetNames("GradeId in ( select GradeId from SchGradeInfo where GradeCode=" + Com.Public.SqlEncStr(gradecode) + " and schid=" + schid + ")");
                 * gradesdrp = Com.Public.GetDrp("grade", schid, "0", false, "", "");
                 * SchSystem.BLL.SchDepartInfo sdiBll = new SchSystem.BLL.SchDepartInfo();
                 * //获取部门列表
                 * DataTable dtdpt = sdiBll.GetList("Pid pId,convert(varchar(20),DepartId) id,DepartName name,'false' checked,'false' checked,'true' nochecks,'0' isms,'' subcode", "SchId=" + Com.Public.SqlEncStr(schid) + " and Stat=1 Order by OrderId").Tables[0];
                 * dtdpt.Columns["nochecks"].ColumnName = "nocheck";
                 * DataTable dtdptuser = dtdpt.Clone();
                 * StringBuilder sb = new StringBuilder();
                 * if (dtdpt.Rows.Count > 0)
                 * {
                 *  SchSystem.BLL.SchClassUser userclassbll = new SchSystem.BLL.SchClassUser();
                 *  DataTable dtclassuser = userclassbll.GetList("UserName,SubCode,IsMs", "ClassId=" + Com.Public.SqlEncStr(classid)).Tables[0];
                 *  //获取该学校的所有人员
                 *  SchSystem.BLL.SchUserDeptV userbll = new SchSystem.BLL.SchUserDeptV();
                 *  DataTable dtuser = userbll.GetList("DeptId ,UserName,UserTname", "Stat=1 and Ustat=1 and SchId=" + Com.Public.SqlEncStr(schid)).Tables[0];
                 *  //合并人员到部门表
                 *  int z = 0;
                 *  for (int i = 0; i < dtdpt.Rows.Count; i++)
                 *  {
                 *
                 *      dtdptuser.Rows.Add(dtdpt.Rows[i].ItemArray);
                 *      //获取该部门下的人员
                 *      DataRow[] drs = dtuser.Select("DeptId='" + dtdpt.Rows[i]["id"].ToString() + "'");
                 *      if (drs.Length > 0)
                 *      {
                 *          foreach (DataRow item in drs)
                 *          {
                 *              sb.Append("<option value=\"u_"+z+"_" + item["UserName"].ToString() + "\">" + item["UserTname"].ToString() + "</option>");
                 *              DataRow dr = dtdptuser.NewRow();
                 *              dr["id"] = "u_" + z + "_" + item["UserName"].ToString();
                 *              dr["name"] = item["UserTname"].ToString();
                 *              dr["pId"] = item["DeptId"].ToString();
                 *              //如果是被绑定了,则勾选
                 *              DataRow[] drsclassuser = dtclassuser.Select("UserName='******'");
                 *              if (drsclassuser.Length > 0)
                 *              {
                 *                  dr["isms"] = drsclassuser[0]["IsMs"].ToString();
                 *                  dr["subcode"] = drsclassuser[0]["SubCode"].ToString();
                 *                  dr["checked"] = "true";
                 *              }z++;
                 *              dtdptuser.Rows.Add(dr);
                 *
                 *          }
                 *      }
                 *  }
                 *
                 * }
                 * tec = sb.ToString();
                 * depts = Newtonsoft.Json.JsonConvert.SerializeObject(dtdptuser);
                 * subsdrp = Com.Public.GetDrp("sub", schid, "1", false, "", "");*/
                #endregion
            }
        }
        //需要根据不同情况建立或修改的不同学校用户和不同类型的用户,本学校用户唯一,不需要全系统唯一
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (true)//如果没对应权限,及判断用户类型是否跨界,主要防止非法篡改数据出现
            //{
            //    Response.Write("无对应权限");
            //    Response.End();
            //}
            if (!IsPostBack)
            {
                //先得到操作类型
                dotype = Com.Public.SqlEncStr(Request.Params["dotype"].ToString());
                string gradeid = "0"; //修改时的用户ID
                string uname   = "";  //修改时的用户账号
                if (dotype == "e")    //修改,不能修改用户的类型及学校参数
                {
                    btnname = "保存";
                    gradeid = Com.Public.SqlEncStr(Request.Params["gradeid"].ToString());
                    if (string.IsNullOrEmpty(gradeid))
                    {
                        Response.Write("无对应修改的用户!");
                        Response.End();
                    }
                    //获取修改的对应用户的
                    SchSystem.BLL.SchGradeInfo   sgibll   = new SchSystem.BLL.SchGradeInfo();
                    SchSystem.Model.SchGradeInfo sgimodel = sgibll.GetModel(int.Parse(gradeid));
                    if (sgimodel != null && sgimodel.GradeId > 0)
                    {
                        umodelstr = Newtonsoft.Json.JsonConvert.SerializeObject(sgimodel);
                        schid     = sgimodel.SchId.ToString();
                    }
                    else
                    {
                        Response.Write("无该用户!");
                        Response.End();
                    }
                }
                else//不在添加及修改之内,则返回
                {
                    Response.Write("没有可供确认的操作类型!");
                    Response.End();
                }
                //判断跨界操作的可能性
                if (!Com.Public.isVa(schid, systype))
                {
                    Response.Write("出错,用户非法跨界操作!");
                    Response.End();
                }
                #region
                SchSystem.BLL.SchInfo schbll = new SchSystem.BLL.SchInfo();
                schname = schbll.GetSchName(int.Parse(schid));
                SchSystem.BLL.SchDepartInfo sdiBll = new SchSystem.BLL.SchDepartInfo();
                //获取部门列表
                DataTable dtdpt = sdiBll.GetList("Pid pId,convert(varchar(20),DepartId) id,DepartName name,'false' checked,'true' nochecks", "SchId=" + schid + " and Stat=1 Order by OrderId").Tables[0];
                dtdpt.Columns["nochecks"].ColumnName = "nocheck";
                DataTable dtdptuser = dtdpt.Clone();
                if (dtdpt.Rows.Count > 0)
                {
                    //获取该年级下关联的领导
                    SchSystem.BLL.SchGradeUsers usergradebll = new SchSystem.BLL.SchGradeUsers();
                    DataTable dtgradeuser = usergradebll.GetList("UserName", "GradeId=" + gradeid).Tables[0];
                    //获取该学校的所有人员
                    SchSystem.BLL.SchUserDeptV userbll = new SchSystem.BLL.SchUserDeptV();
                    DataTable dtuser = userbll.GetList("DeptId ,UserId id,UserTname name,'false' checked,'true' nochecks", "Stat=1 and Ustat=1 and SchId=" + Com.Public.SqlEncStr(schid)).Tables[0];

                    foreach (DataRow item in dtuser.Select())
                    {
                        DataRow[] drsgrade = dtgradeuser.Select("UserName='******'");

                        if (drsgrade.Length > 0)
                        {
                            item["checked"] = "true";
                        }
                    }
                    schuser = Newtonsoft.Json.JsonConvert.SerializeObject(dtuser);
                }

                depart = Newtonsoft.Json.JsonConvert.SerializeObject(dtdpt);
                #endregion
            }
        }
Beispiel #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                usertname = Com.Session.uname;

                //先得到操作类型
                SchSystem.BLL.SchInfo   schbll    = new SchSystem.BLL.SchInfo();
                SchSystem.Model.SchInfo usermodel = new SchSystem.Model.SchInfo();

                SchSystem.BLL.SysSub syssubbll = new SchSystem.BLL.SysSub();
                DataTable            dtsub     = syssubbll.GetList("'0' pId,SubCode id,SubName name,'false' checked", "Stat=1 Order by SubCode").Tables[0];//Stat=1
                DataTable            dtsubmat  = dtsub.Copy();
                //获取学校的sub
                SchSystem.BLL.SchSub schsubbll = new SchSystem.BLL.SchSub();
                DataTable            dtschsub  = schsubbll.GetList("'0' pId,SubCode id,SubName name,'false' checked", "Stat=1 and SchId='" + schid + "' Order by SubCode").Tables[0];
                subs    = Newtonsoft.Json.JsonConvert.SerializeObject(dtsub);
                subsmat = Newtonsoft.Json.JsonConvert.SerializeObject(dtsubmat);

                treeNodekinderstr = Newtonsoft.Json.JsonConvert.SerializeObject(dtschsub);
                //获取子系统:AutoId,AppCode,AppName,Stat,RecTime,RecUser,LastRecTime,LastRecUser
                SchSystem.BLL.SchApp schappBll = new SchSystem.BLL.SchApp();
                DataTable            dtschapp  = schappBll.GetList("'0' pId,AppCode id,AppName name,'false' checked,AppCode", "Stat=1 and AppCode not in (1,2)").Tables[0];
                sonsys = Newtonsoft.Json.JsonConvert.SerializeObject(dtschapp);

                //获取整个系统的年级
                SchSystem.BLL.SysGrade sysgradebll = new SchSystem.BLL.SysGrade();
                DataTable dtgrade = sysgradebll.GetList("GradeType pId,GradeCode id,GradeName name,'false' checked,'false' nochecks,'0' IsFinish", " GradeCode<>'3004' and GradeCode<>'4004' Order by GradeType,GradeLv").Tables[0];
                //获取学校类型
                SchSystem.BLL.SysPer sysperbll = new SchSystem.BLL.SysPer();
                DataTable            dtper     = sysperbll.GetList("PerName Name,PerCode ID", " Stat=1 Order by convert(int,PerCode)").Tables[0];
                if (dtper.Rows.Count > 0)
                {
                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < dtper.Rows.Count; i++)
                    {
                        if (dtper.Rows[i]["ID"].ToString() == percode)
                        {
                            sb.Append("<option value=\"" + dtper.Rows[i]["ID"].ToString() + "\" selected=\"selected\">" + dtper.Rows[i]["Name"].ToString() + "</option>");
                        }
                        else
                        {
                            sb.Append("<option value=\"" + dtper.Rows[i]["ID"].ToString() + "\">" + dtper.Rows[i]["Name"].ToString() + "</option>");
                        }
                        //}
                    }
                    percodes = sb.ToString();
                }


                dtgrade.Columns["nochecks"].ColumnName = "nocheck";
                DataRow dry = dtgrade.NewRow();
                dry["pId"]      = "0";
                dry["id"]       = "1";
                dry["name"]     = "幼儿园";
                dry["nocheck"]  = "false";
                dry["IsFinish"] = "0";

                dtgrade.Rows.Add(dry);
                dry             = dtgrade.NewRow();
                dry["pId"]      = "0";
                dry["id"]       = "2";
                dry["name"]     = "小学";
                dry["nocheck"]  = "false";
                dry["IsFinish"] = "0";

                dtgrade.Rows.Add(dry);
                dry             = dtgrade.NewRow();
                dry["pId"]      = "0";
                dry["id"]       = "3";
                dry["name"]     = "初中";
                dry["nocheck"]  = "false";
                dry["IsFinish"] = "0";

                dtgrade.Rows.Add(dry);
                dry             = dtgrade.NewRow();
                dry["pId"]      = "0";
                dry["id"]       = "4";
                dry["name"]     = "高中";
                dry["nocheck"]  = "false";
                dry["IsFinish"] = "0";

                dtgrade.Rows.Add(dry);

                //if (dtgrade != null && dtschgrade != null && dtgrade.Rows.Count > 0 && dtschgrade.Rows.Count > 0)//系统年级和学校年级不等于null
                //{
                //    for (int i = 0; i < dtgrade.Rows.Count; i++)//遍历实体年级行数
                //    {
                //        DataRow[] drs = dtschgrade.Select("id='" + dtgrade.Rows[i]["id"].ToString() + "'");//根据系统年级id查询学校年级
                //        if (drs.Length > 0)
                //        {
                //            //string ss = drs[0]["id"].ToString();
                //            //dtgrade.Rows[i]["checked"] = "true";
                //            //DataRow[] drss = dtgrade.Select("id='"+ss+"'");
                //            //int ss = int.Parse(drss["pId"].ToString());
                //        }
                //    }
                //}

                grades = Newtonsoft.Json.JsonConvert.SerializeObject(dtgrade);

                //获取资源平台服务资源:AutoId,AppCode,AppName,Stat,RecTime,RecUser,LastRecTime,LastRecUser
                SchSystem.BLL.SchAppSoure schappsoureBll = new SchSystem.BLL.SchAppSoure();
                DataTable dtschappsoure = schappsoureBll.GetList("'0' pId,AppCode id,AppName name,'false' checked,AppCode", "Stat=1").Tables[0];
                if (dtschappsoure.Rows.Count > 0)
                {
                    for (int i = 0; i < dtschappsoure.Rows.Count; i++)
                    {
                        dtschappsoure.Rows[i]["name"] = dtschappsoure.Rows[i]["name"] + "【不共享】";
                    }
                }
                souretree = Newtonsoft.Json.JsonConvert.SerializeObject(dtschappsoure);

                //获取教版
                SchSystem.BLL.SysMater smaterBll = new SchSystem.BLL.SysMater();
                DataTable dtsmater = smaterBll.GetList("'0' pId,AutoId id,MaterName name,'false' checked,MaterCode", "Stat=1").Tables[0];
                sysmatertree = Newtonsoft.Json.JsonConvert.SerializeObject(dtsmater);

                //获取家校互通服务资源:AutoId,AppCode,AppName,Stat,RecTime,RecUser,LastRecTime,LastRecUser
                SchSystem.BLL.SchAppXXT schappxxtBll = new SchSystem.BLL.SchAppXXT();
                DataTable dtschappxxt = schappxxtBll.GetList("'0' pId,AppCode id,AppName name,'false' checked,AppCode", "Stat=1").Tables[0];
                //if (dtschappsoure.Rows.Count > 0)
                //{
                //    for (int i = 0; i < dtschappsoure.Rows.Count; i++)
                //    {
                //        dtschappsoure.Rows[i]["name"] = dtschappsoure.Rows[i]["name"] + "【不共享】";
                //    }
                //}
                homeschtree = Newtonsoft.Json.JsonConvert.SerializeObject(dtschappxxt);

                //获取下拉列表
                StringBuilder sbarea = new StringBuilder();
                //获取省份
                sbarea.Append("<select id=\"aprov\">");
                string sareacode = "";
                if (usermodel != null && usermodel.SchId > 0 && usermodel.AreaNo.Length == 6)
                {
                    sareacode = usermodel.AreaNo.Substring(0, 2) + "0000";
                }
                sbarea.Append(SchWebAdmin.Com.Public.GetDrpArea("0", "", ref sareacode, false));
                sbarea.Append("</select>");
                //获取城市
                sbarea.Append("<select id=\"acity\">");
                string sareacitycode = "";
                if (usermodel != null && usermodel.SchId > 0 && usermodel.AreaNo.Length == 6)
                {
                    sareacitycode = usermodel.AreaNo.Substring(0, 4) + "00";
                }
                sbarea.Append(SchWebAdmin.Com.Public.GetDrpArea("1", sareacode, ref sareacitycode, false));
                sbarea.Append("</select>");
                //获取区县
                sbarea.Append("<select id=\"acoty\">");
                string sareacotycode = "";
                if (usermodel != null && usermodel.SchId > 0 && usermodel.AreaNo.Length == 6)
                {
                    sareacotycode = usermodel.AreaNo;
                }
                sbarea.Append(SchWebAdmin.Com.Public.GetDrpArea("2", sareacitycode, ref sareacotycode, false));
                sbarea.Append("</select>");
                areastr = sbarea.ToString();

                //根据部门分类查询人员信息
                //当前学校老师
                SchSystem.BLL.SchUserDeptV userbll = new SchSystem.BLL.SchUserDeptV();
                DataTable dtuser = userbll.GetList("DeptId,DepartName,UserId,UserTname", "Stat=1 and Ustat=1 and SchId=" + Com.Public.SqlEncStr(schid)).Tables[0];
                SchSystem.BLL.SchDepartInfo dptbll = new SchSystem.BLL.SchDepartInfo();
                DataTable dt        = dptbll.GetList("Pid pId,convert(varchar(20),DepartId) id,DepartName name,'0' isms,'' subcode,'false' checked,'true' nochecks", "SchId=" + schid + " and Stat=1 Order by OrderId,DepartName").Tables[0];
                DataTable dtdptuser = dt.Clone();
                dtdptuser.Columns["nochecks"].ColumnName = "nocheck";
                if (dt.Rows.Count > 0)
                {
                    //合并人员到部门表
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        dtdptuser.Rows.Add(dt.Rows[i].ItemArray);
                        //获取该部门下的人员
                        DataRow[] drss = dtuser.Select("DeptId='" + dt.Rows[i]["id"].ToString() + "'");
                        if (drss.Length > 0)
                        {
                            foreach (DataRow item in drss)
                            {
                                DataRow dr = dtdptuser.NewRow();

                                dr["id"]   = item["UserId"].ToString();
                                dr["name"] = item["UserTname"].ToString();
                                dr["pId"]  = item["DeptId"].ToString();
                                if (dr["name"].ToString() == usermodel.Artisan.ToString())
                                {
                                    dr["checked"] = true;
                                }
                                dtdptuser.Rows.Add(dr);
                            }
                        }
                    }
                }

                deptsuser = Newtonsoft.Json.JsonConvert.SerializeObject(dtdptuser);
            }
        }