protected void Page_Load(object sender, EventArgs e) { if (Request.Params["schid"] != null && Request.Params["schid"].ToString() != "") { schid = Com.Public.SqlEncStr(Request.Params["schid"].ToString()); //年级 SchSystem.BLL.SchGradeInfo sgiBLL = new SchSystem.BLL.SchGradeInfo(); DataTable dtSchGrade = sgiBLL.GetList(" IsFinish=0 and SchId='" + schid + "' order by GradeCode").Tables[0];//得到年级数据列表,并且是为非毕业的年级 //年级领导 SchSystem.BLL.SchGradeUsers sguBLL = new SchSystem.BLL.SchGradeUsers(); dtSchGrade.Columns.Add("GradeBoss"); if (dtSchGrade.Rows.Count > 0) { for (int i = 0; i < dtSchGrade.Rows.Count; i++) { dtSchGrade.Rows[i]["GradeBoss"] = sguBLL.GetNames("GradeId=" + dtSchGrade.Rows[i]["GradeId"].ToString()); } } grades = Newtonsoft.Json.JsonConvert.SerializeObject(dtSchGrade); //当前学校所开设的科目 SchSystem.BLL.SchSub schsubBll = new SchSystem.BLL.SchSub(); DataSet dsSchSub = schsubBll.GetList("Stat=1 and SchId='" + schid + "'"); subs = Newtonsoft.Json.JsonConvert.SerializeObject(dsSchSub); //获取科目教师 SchSystem.BLL.SchSubLeader scuBll = new SchSystem.BLL.SchSubLeader(); DataSet dssubUser = scuBll.GetListTecSub("*", "schid='" + schid + "' and Stat=1"); subUser = Newtonsoft.Json.JsonConvert.SerializeObject(dssubUser); //subUser //当前学校的教师 SchSystem.BLL.SchUserInfo suiBll = new SchSystem.BLL.SchUserInfo(); DataSet dsSUI = suiBll.GetList("*", "Stat=1 and SchId='" + schid + "'"); tecs = Newtonsoft.Json.JsonConvert.SerializeObject(dsSUI); } }
protected void Page_Load(object sender, EventArgs e) { string jsid = Request.Params["sid"].ToString(); string jstoken = Request.Params["token"].ToString(); Com.SoureSession.jsid = jsid; Com.SoureSession.jstoken = jstoken; Com.DataPack.DataRsp <Com.DataPack.UserInfo> rsp = Com.Public.UserFuncSoure(jsid, jstoken); if (rsp.code == "ERROR_TOKEN") { Response.Write("登录已失效!"); Response.End(); } else if (!IsPostBack) { if (Com.SoureSession.Souresystype == "1" || Com.SoureSession.Souresystype == "2")//超级管理员和学校管理员 { islook = true; if (Com.SoureSession.Souresystype == "1") { isadd = false; isedit = false; isdel = false; } else { isadd = true; isedit = true; isdel = true; } } else//普通老师 { isadd = false; isedit = false; isdel = false; islook = true;//学科/年级/班级任课权限 } //isGradeClassAuth = Com.Public.IsUserVal(Com.Session.userrolestr, 2) ? true : false;//学科/年级/班级任课权限 //不是超管获取本学校的 if (Com.SoureSession.Souresystype != "2") { schid = Com.SoureSession.Soureschid; } else//超管还要加省市区学校下拉,后面需要更改 { //第一次加载,获取省市区,获取第一个省份下的所有学校 StringBuilder sbarea = new StringBuilder(); //获取省份 sbarea.Append("省:<select id=\"aprov\">"); string sareacode = ""; sbarea.Append(Com.Public.GetDrpArea("0", "", ref sareacode, false)); sbarea.Append("</select>"); //获取城市 sbarea.Append("市:<select id=\"acity\">"); string sareacitycode = ""; sbarea.Append(Com.Public.GetDrpArea("1", sareacode, ref sareacitycode, false)); sbarea.Append("</select>"); //获取区县 sbarea.Append("区:<select id=\"acoty\">"); string sareacotycode = ""; sbarea.Append(Com.Public.GetDrpArea("2", sareacitycode, ref sareacotycode, false)); cotycode = sareacotycode; sbarea.Append("</select>"); sbarea.Append("学校:<select id=\"asch\">"); string sareaschid = ""; sbarea.Append(Com.Public.GetDrpArea("3", sareacotycode, ref sareaschid, false)); if (sareaschid != "") { schid = sareaschid; } sbarea.Append("</select>"); areastr = sbarea.ToString(); systype = Com.SoureSession.Souresystype; } //当前学校年级:IsFinish状态,1代表已毕业;0代表未毕业 // SchSystem.BLL.SchGradeInfo sgiBll = new SchSystem.BLL.SchGradeInfo(); //DataSet dsSchGrade = sgiBll.GetList("IsFinish=0 and SchId=" + schid); //年级 SchSystem.BLL.SchGradeInfo sgiBLL = new SchSystem.BLL.SchGradeInfo(); DataTable dtSchGrade = sgiBLL.GetList(" IsFinish=0 and SchId='" + schid + "' order by GradeCode").Tables[0];//得到年级数据列表,并且是为非毕业的年级 //年级领导 SchSystem.BLL.SchGradeUsers sguBLL = new SchSystem.BLL.SchGradeUsers(); dtSchGrade.Columns.Add("GradeBoss"); if (dtSchGrade.Rows.Count > 0) { for (int i = 0; i < dtSchGrade.Rows.Count; i++) { dtSchGrade.Rows[i]["GradeBoss"] = sguBLL.GetNames("GradeId=" + dtSchGrade.Rows[i]["GradeId"].ToString()); } } grades = Newtonsoft.Json.JsonConvert.SerializeObject(dtSchGrade); //当前学校所开设的科目 SchSystem.BLL.SchSub schsubBll = new SchSystem.BLL.SchSub(); DataSet dsSchSub = schsubBll.GetList("Stat=1 and SchId='" + schid + "'"); subs = Newtonsoft.Json.JsonConvert.SerializeObject(dsSchSub); //获取科目教师 SchSystem.BLL.SchSubLeader scuBll = new SchSystem.BLL.SchSubLeader(); DataSet dssubUser = scuBll.GetListTecSub("*", "schid='" + schid + "' and Stat=1"); subUser = Newtonsoft.Json.JsonConvert.SerializeObject(dssubUser); //subUser //当前学校的教师 SchSystem.BLL.SchUserInfo suiBll = new SchSystem.BLL.SchUserInfo(); DataSet dsSUI = suiBll.GetList("*", "Stat=1 and SchId='" + schid + "'"); tecs = Newtonsoft.Json.JsonConvert.SerializeObject(dsSUI); } }
public static string usersave(string dotype, string userid, string usertname, string usertel, string userpst, string usertitle, string usermobile, string username, string userpw, string usersex, string userstat, string userdpts) { //解密 RSA RSACryptoService rsa = new RSACryptoService(PublicProperty.PrivateKey, PublicProperty.PublicKey); if (userpw != "") { userpw = Com.Public.SqlEncStr(rsa.Decrypt(userpw)); } username = Com.Public.SqlEncStr(username); string ret = ""; if (Com.Session.userid == null) { ret = "expire"; } else { try { SchSystem.BLL.SchUserInfo userbll = new SchSystem.BLL.SchUserInfo(); SchSystem.Model.SchUserInfo usermodel = new SchSystem.Model.SchUserInfo(); //判断编号及账号是否有重复,生成密码加密 if (dotype == "e") { if (username != "") { if (userbll.ExistsUserName(int.Parse(userid), username)) { 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]; if (dt.Rows.Count > 0) { DataRow[] dr = dt.Select(); foreach (DataRow item in dr) { sbExists.Append(item["DepartName"].ToString() + "、"); utname = item["UserTname"].ToString(); } } else { sbExists.Append("学校管理员"); SchSystem.BLL.SchUserInfo suiBll = new SchSystem.BLL.SchUserInfo(); DataTable dtuser = suiBll.GetList("UserTname", "UserName='******'").Tables[0]; if (dtuser.Rows.Count > 0) { utname = dtuser.Rows[0]["UserTname"].ToString(); } else { utname = Com.Session.uname.ToString(); } } if (utname == Com.Session.uname.ToString()) { ret += sbExists.ToString(); } else { ret += sbExists.ToString().Substring(0, sbExists.ToString().Length - 1); } ret += "," + utname; } } else if (!userbll.ExistsUserName(0, username)) { userbll.UpdateUserName(username, int.Parse(userid)); } } } if (dotype == "a") { if (username != "") { 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];//使用的的是视图查询,部门和用户连表,查询需要的部门和真实姓名 if (dt.Rows.Count > 0) { DataRow[] dr = dt.Select(); foreach (DataRow item in dr) { sbExists.Append(item["DepartName"].ToString() + "、"); utname = item["UserTname"].ToString(); } } else { sbExists.Append("学校管理员,"); SchSystem.BLL.SchUserInfo suiBll = new SchSystem.BLL.SchUserInfo(); DataTable dtuser = suiBll.GetList("UserTname", "UserName='******'").Tables[0]; if (dtuser.Rows.Count > 0) { utname = dtuser.Rows[0]["UserTname"].ToString(); } else { utname = Com.Session.uname.ToString(); } } //ret += "账号重复!"; if (utname == Com.Session.uname.ToString()) { ret += sbExists.ToString(); } else { 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 = ""; usermodel.SysType = 0; usermodel.Telno = usertel; usermodel.Title = usertitle; usermodel.UserNo = ""; 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(Com.Session.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, Com.Session.schid, userdpts); ret = "success"; } } catch (Exception ex) { ret = ex.Message; } } return(ret); }
//需要根据不同情况建立或修改的不同学校用户和不同类型的用户,本学校用户唯一,不需要全系统唯一 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 } }
//用户登录判断 public static string UserLoginDo(string uname, bool iscookies, string schid) { string str = ""; SchSystem.BLL.SchUserInfo userbll = new SchSystem.BLL.SchUserInfo(); //查询登录用户记录数据 DataTable SchUserInfoDs = userbll.GetList("UserId,UserName,UserTname,SchId,SysType,ImgUrl", "UserName='******' and Stat=1 and AccStat=1 and SchId=" + schid).Tables[0]; if (SchUserInfoDs.Rows.Count > 0) { SchSystem.BLL.SchUserRoleV userroleV = new SchSystem.BLL.SchUserRoleV(); DataTable dtroles = userroleV.GetList("UserName='******' and Stat=1 and AccStat=1 and SchId=" + schid).Tables[0]; //if (dtroles.Rows.Count > 0) //{ //设置Session信息 Com.Session.usertid = SchUserInfoDs.Rows[0]["UserId"].ToString(); Com.Session.userid = SchUserInfoDs.Rows[0]["UserName"].ToString(); Com.Session.uname = SchUserInfoDs.Rows[0]["UserTname"].ToString(); Com.Session.schid = SchUserInfoDs.Rows[0]["SchId"].ToString(); Com.Session.systype = SchUserInfoDs.Rows[0]["SysType"].ToString(); Com.Session.imgurl = SchUserInfoDs.Rows[0]["ImgUrl"].ToString(); //合并普通权限串 Com.Session.userrolestr = Com.Public.UserRoleStr(dtroles); //合并特殊权限串 Com.Session.userrolestrext = Com.Public.UserRoleExtStr(dtroles); Com.Session.ulogintime = DateTime.Now.ToString("yyyyMMddHHmmss"); //设置cookies if (iscookies) { CookieHelper.SetCookie("uname", uname, DateTime.Now.AddDays(7)); } //获取老师身份 if (Com.Session.usertp == "0") { string tectype = "0"; //1年级主任,2科任组长,3班主任,4科任老师 SchSystem.BLL.SchGradeUserV bllgrade = new SchSystem.BLL.SchGradeUserV(); if (bllgrade.Exists(Com.Session.usertid)) { tectype += ",1"; } SchSystem.BLL.SchUserSubV bllsub = new SchSystem.BLL.SchUserSubV(); if (bllsub.Exists(Com.Session.usertid)) { tectype += ",2"; } SchSystem.BLL.SchClassUser bllclasssub = new SchSystem.BLL.SchClassUser(); if (bllclasssub.ExistsV(0, 1, Com.Session.usertid, 1)) { tectype += ",3"; } if (bllclasssub.ExistsV(0, 1, Com.Session.usertid, 0)) { tectype += ",4"; } Com.Session.usertectp = tectype; } //获取该学校的系统编辑状态 SchSystem.BLL.SchInfo schbll = new SchSystem.BLL.SchInfo(); SchSystem.Model.SchInfo schmodel = schbll.GetModel(int.Parse(Com.Session.schid)); Com.Session.appeditstat = schmodel.SonSysStat.ToString(); str = "1"; //} // else // { // str = "该账号没有相应的权限或者对应角色被屏蔽,请联系管理员进行分配处理"; // } } else { str = "该账号被屏蔽或不存在"; } return(str); }