예제 #1
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);
        }
예제 #2
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
            }
        }
예제 #3
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
            }
        }
        //需要根据不同情况建立或修改的不同学校用户和不同类型的用户,本学校用户唯一,不需要全系统唯一
        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
            }
        }
예제 #6
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);
            }
        }