//需要根据不同情况建立或修改的不同学校用户和不同类型的用户,本学校用户唯一,不需要全系统唯一 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,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"] = "u_" + 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 } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataTable dt = new DataTable(); dotype = Request.Params["dotype"].ToString(); gradecodestr = Request.Params["gradecode"].ToString(); classidstr = Request.Params["classid"].ToString(); #region 编辑绑定查询 if (dotype == "e") { Stubh = Request.Params["Stubh"].ToString(); stuid = Request.Params["id"].ToString(); string sql = "select * from SchStuInfoV where StuId='" + stuid + "' ";//根据学生ID查询出学校,年级,班级等信息 dt = DbHelperSQL.Query(sql).Tables[0]; //18 //string oldclassname = dt.Rows[0][18].ToString(); DataRow[] dr = dt.Select(); if (classidstr == "") { classidstr = dr[0]["ClassId"].ToString(); } string oldclassname = dr[0]["OldClassId"].ToString(); if (!string.IsNullOrEmpty(oldclassname) || oldclassname != "") { oldClassName = oldclassname; } else { oldClassName = ""; } /*if (!string.IsNullOrEmpty(oldclassid) || oldclassid != "") * { * SchSystem.BLL.SchClassInfo sciBll = new SchSystem.BLL.SchClassInfo(); * oldClassName = sciBll.GetClassNames("ClassId in (" + oldclassid + ")"); * } * else * { * oldClassName = ""; * }*/ if (dt.Rows.Count > 0) { classinfo = Newtonsoft.Json.JsonConvert.SerializeObject(dt); } else { classinfo = "0"; } SchSystem.BLL.SchStuInfo bll_stu = new SchSystem.BLL.SchStuInfo(); string strWhere = " a.StuId=" + stuid; DataSet ds = bll_stu.GetList(strWhere);//修改绑定需要的数据 ds.Tables[0].Columns.Add("ClassId"); ds.Tables[0].Columns.Add("jzGenName2"); ds.Tables[0].Columns.Add("jzLoginName2"); ds.Tables[0].Columns.Add("jzTelNo2"); ds.Tables[0].Columns.Add("jzPwd2"); ds.Tables[0].Columns.Add("jzStat2"); ds.Tables[0].Columns.Add("jzRelation2"); ds.Tables[0].Columns.Add("jzGenId2"); ds.Tables[0].Columns.Add("jzUnId2"); if (ds.Tables[0].Rows.Count != 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { for (int j = i + 1; j < ds.Tables[0].Rows.Count; j++) { if (ds.Tables[0].Rows[i]["StuId"].ToString() == ds.Tables[0].Rows[j]["StuId"].ToString()) { ds.Tables[0].Rows[i]["jzGenName2"] = ds.Tables[0].Rows[j]["jzGenName1"].ToString(); ds.Tables[0].Rows[i]["jzLoginName2"] = ds.Tables[0].Rows[j]["jzLoginName1"].ToString(); ds.Tables[0].Rows[i]["jzTelNo2"] = ds.Tables[0].Rows[j]["jzTelNo1"].ToString(); ds.Tables[0].Rows[i]["jzPwd2"] = ds.Tables[0].Rows[j]["jzPwd1"].ToString(); ds.Tables[0].Rows[i]["jzStat2"] = ds.Tables[0].Rows[j]["jzStat1"].ToString(); ds.Tables[0].Rows[i]["jzRelation2"] = ds.Tables[0].Rows[j]["jzRelation1"].ToString(); ds.Tables[0].Rows[i]["jzGenId2"] = ds.Tables[0].Rows[j]["jzGenId1"].ToString(); ds.Tables[0].Rows[i]["jzUnId2"] = ds.Tables[0].Rows[j]["jzUnId1"].ToString(); ds.Tables[0].Rows.RemoveAt(j); } } } } umodelstr = dttojson.DatSetToJSON2(ds); } #endregion #region 缺省值:年級領導、班主任和任課教師 SchSystem.BLL.SchGradeUsers sgiBll = new SchSystem.BLL.SchGradeUsers(); SchSystem.BLL.SchClassUser scuBll = new SchSystem.BLL.SchClassUser(); DataTable dtgradeuser = sgiBll.GetList("*", "GradeId='" + gradecodestr + "'").Tables[0]; if (dtgradeuser.Rows.Count > 0) { StringBuilder sbgradeuser = new StringBuilder(); foreach (DataRow dr in dtgradeuser.Rows) { sbgradeuser.Append(dr["UserTname"].ToString() + ","); } if (sbgradeuser.ToString().Length > 0) { njld = sbgradeuser.ToString().Substring(0, sbgradeuser.ToString().Length - 1);//年級領導 } } DataTable dtclassuser = scuBll.GetList("*", "ClassId='" + classidstr + "'").Tables[0]; if (dtclassuser.Rows.Count > 0) { StringBuilder sbgradeuser01 = new StringBuilder(); StringBuilder sbgradeuser02 = new StringBuilder(); foreach (DataRow dr in dtclassuser.Rows) { if (dr["IsMs"].ToString() == "1") { sbgradeuser01.Append(dr["UserTname"].ToString() + ","); } else { sbgradeuser02.Append(dr["UserTname"].ToString() + ","); } } if (sbgradeuser01.ToString().Length > 0) { bzr = sbgradeuser01.ToString().Substring(0, sbgradeuser01.ToString().Length - 1);//班主任 } if (sbgradeuser02.ToString().Length > 0) { bjjs = sbgradeuser02.ToString().Substring(0, sbgradeuser02.ToString().Length - 1);//任課教師 } } #endregion StringBuilder sbarea = new StringBuilder(); //普通老师登录 if (Com.SoureSession.Souresystype == "0") { string gradeid = ""; if (dotype == "e" && dt.Rows[0]["AreaNo"].ToString().Length == 6) { gradeid = dt.Rows[0]["GradeId"].ToString(); } else { gradeid = gradecodestr; } sbarea.Append("<br/><label class=\"biaoti\">年级:</label><select id=\"nj\" style=\"width:100px\">"); sbarea.Append(Com.Public.GetGradeSelect("1", int.Parse(classidstr), ref gradeid, Com.SoureSession.Soureschid)); sbarea.Append("</select>"); string classid = ""; if (dotype == "e" && dt.Rows[0]["AreaNo"].ToString().Length == 6) { classid = dt.Rows[0]["ClassId"].ToString(); } sbarea.Append("<span id=\"njld\" style=\"color: #808080 \">年级领导:" + njld + "</span><br/><br/>"); sbarea.Append("<label class=\"biaoti\">班级:</label><select id=\"bj\" style=\"width:100px\" >"); sbarea.Append(Com.Public.GetGradeSelect("2", int.Parse(classidstr), ref classid, gradeid)); sbarea.Append("</select>"); sbarea.Append("<span id=\"bzr\" style=\"color: #808080 \">班主任:"+ bzr + "</span> "); sbarea.Append("<span id=\"bjjs\" style=\"color: #808080 \">任课老师:" + bjjs + "</span><br/><br/>"); areastr = sbarea.ToString(); } else if (Com.SoureSession.Souresystype == "1") { //获取年级 sbarea.Append("<br/> 年级:<select id=\"nj\" style=\"width:100px\">"); string schcode = ""; if (dotype == "e" && dt.Rows[0]["AreaNo"].ToString().Length == 6) { schcode = dt.Rows[0]["GradeId"].ToString(); } sbarea.Append(Com.Public.GetDrpArea("4", Com.SoureSession.Soureschid, ref schcode, false)); sbarea.Append("</select> "); sbarea.Append("<span id=\"njld\" style=\"color: #808080 \">年级领导:" + njld + "</span><br/><br/>"); //获取班级 sbarea.Append(" 班级:<select id=\"bj\" style=\"width:100px\" >"); string Classcode = ""; if (dotype == "e" && dt.Rows[0]["AreaNo"].ToString().Length == 6) { Classcode = dt.Rows[0]["ClassId"].ToString(); } sbarea.Append(Com.Public.GetDrpArea("5", schcode, ref Classcode, false)); sbarea.Append("</select> "); sbarea.Append("<span id=\"bzr\" style=\"color: #808080 \">班主任:"+ bzr + "</span> "); sbarea.Append("<span id=\"bjjs\" style=\"color: #808080 \">任课老师:" + bjjs + "</span><br/><br/>"); string s = getnj("1", schcode, schid, Classcode); areastr = sbarea.ToString(); } else//超管还要加学校下拉,后面需要更改 { //第一次加载,获取省市区,获取第一个省份下的所有学校 //StringBuilder sbarea = new StringBuilder(); //获取省份 sbarea.Append("省:<select id=\"aprov\">"); string sareacode = ""; if (dotype == "e" && dt.Rows[0]["AreaNo"].ToString().Length == 6) { sareacode = dt.Rows[0]["AreaNo"].ToString().Substring(0, 2) + "0000"; } sbarea.Append(Com.Public.GetDrpArea("0", "", ref sareacode, false)); sbarea.Append("</select>"); //获取城市 sbarea.Append("市:<select id=\"acity\">"); string sareacitycode = ""; if (dotype == "e" && dt.Rows[0]["AreaNo"].ToString().Length == 6) { sareacitycode = dt.Rows[0]["AreaNo"].ToString().Substring(0, 4) + "00"; } sbarea.Append(Com.Public.GetDrpArea("1", sareacode, ref sareacitycode, false)); sbarea.Append("</select>"); //获取区县 sbarea.Append("区:<select id=\"acoty\">"); string sareacotycode = ""; if (dotype == "e" && dt.Rows[0]["AreaNo"].ToString().Length == 6) { sareacotycode = dt.Rows[0]["AreaNo"].ToString(); } sbarea.Append(Com.Public.GetDrpArea("2", sareacitycode, ref sareacotycode, false)); sbarea.Append("</select>"); //获取学校 sbarea.Append("学校:<select id=\"asch\">"); string sareaschid = ""; if (dotype == "e" && dt.Rows[0]["AreaNo"].ToString().Length == 6) { sareaschid = dt.Rows[0]["SchId"].ToString(); } sbarea.Append(Com.Public.GetDrpArea("3", sareacotycode, ref sareaschid, false)); sbarea.Append("</select><br/> "); //获取年级 sbarea.Append("<br/> 年级:<select id=\"nj\" style=\"width:100px\">"); string schcode = ""; if (dotype == "e" && dt.Rows[0]["AreaNo"].ToString().Length == 6) { schcode = dt.Rows[0]["GradeId"].ToString(); } sbarea.Append(Com.Public.GetDrpArea("4", sareaschid, ref schcode, false)); sbarea.Append("</select> "); sbarea.Append("<span id=\"njld\" style=\"color:#808080 \">年级领导:"+ njld + "</span><br/><br/>"); //获取班级 sbarea.Append(" 班级:<select id=\"bj\" style=\"width:100px\" >"); string Classcode = ""; if (dotype == "e" && dt.Rows[0]["AreaNo"].ToString().Length == 6) { Classcode = dt.Rows[0]["ClassId"].ToString(); } sbarea.Append(Com.Public.GetDrpArea("5", schcode, ref Classcode, false)); sbarea.Append("</select> "); sbarea.Append("<span id=\"bzr\" style=\"color: #808080 \">班主任:"+ bzr + "</span> "); sbarea.Append("<span id=\"bjjs\" style=\"color:#808080 \">任课老师:" + bjjs + "</span><br/><br/>"); string s = getnj("1", schcode, sareaschid, Classcode); areastr = sbarea.ToString(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataTable dt = new DataTable(); string dotype = Request.Params["dotype"].ToString(); var gradeid = Request.Params["gradecode"].ToString(); var classid = Request.Params["classid"].ToString(); if (dotype == "c") { Stubh = Request.Params["Stubh"].ToString(); string stuid = Request.Params["id"].ToString(); string sql = "select * from SchStuInfoV where StuId='" + stuid + "' ";//根据学生ID查询出学校,年级,班级等信息 dt = DbHelperSQL.Query(sql).Tables[0]; if (gradeid == "") { gradeid = dt.Rows[0]["GradeId"].ToString(); } if (classid == "") { classid = dt.Rows[0]["ClassId"].ToString(); } DataRow[] drr = dt.Select(); string oldclassname = drr[0]["OldClassId"].ToString(); if (!string.IsNullOrEmpty(oldclassname) || oldclassname != "") { oldClassName = oldclassname; } else { oldClassName = ""; } SchSystem.BLL.SchStuInfo bll_stu = new SchSystem.BLL.SchStuInfo(); string strWhere = " a.StuId=" + stuid; DataSet ds = bll_stu.GetList(strWhere);//修改绑定需要的数据 ds.Tables[0].Columns.Add("jzGenName2"); ds.Tables[0].Columns.Add("jzLoginName2"); ds.Tables[0].Columns.Add("jzTelNo2"); ds.Tables[0].Columns.Add("jzPwd2"); ds.Tables[0].Columns.Add("jzStat2"); ds.Tables[0].Columns.Add("jzRelation2"); ds.Tables[0].Columns.Add("jzGenId2"); ds.Tables[0].Columns.Add("jzUnId2"); if (ds.Tables[0].Rows.Count != 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { for (int j = i + 1; j < ds.Tables[0].Rows.Count; j++) { if (ds.Tables[0].Rows[i]["StuId"].ToString() == ds.Tables[0].Rows[j]["StuId"].ToString()) { ds.Tables[0].Rows[i]["jzGenName2"] = ds.Tables[0].Rows[j]["jzGenName1"].ToString(); ds.Tables[0].Rows[i]["jzLoginName2"] = ds.Tables[0].Rows[j]["jzLoginName1"].ToString(); ds.Tables[0].Rows[i]["jzTelNo2"] = ds.Tables[0].Rows[j]["jzTelNo1"].ToString(); ds.Tables[0].Rows[i]["jzPwd2"] = ds.Tables[0].Rows[j]["jzPwd1"].ToString(); ds.Tables[0].Rows[i]["jzStat2"] = ds.Tables[0].Rows[j]["jzStat1"].ToString(); ds.Tables[0].Rows[i]["jzRelation2"] = ds.Tables[0].Rows[j]["jzRelation1"].ToString(); ds.Tables[0].Rows[i]["jzGenId2"] = ds.Tables[0].Rows[j]["jzGenId1"].ToString(); ds.Tables[0].Rows[i]["jzUnId2"] = ds.Tables[0].Rows[j]["jzUnId1"].ToString(); ds.Tables[0].Rows.RemoveAt(j); } } } } #region 缺省值:年級領導、班主任和任課教師 SchSystem.BLL.SchGradeUsers sgiBll = new SchSystem.BLL.SchGradeUsers(); SchSystem.BLL.SchClassUser scuBll = new SchSystem.BLL.SchClassUser(); DataTable dtgradeuser = sgiBll.GetList("*", "GradeId='" + gradeid + "'").Tables[0]; if (dtgradeuser.Rows.Count > 0) { StringBuilder sbgradeuser = new StringBuilder(); foreach (DataRow dr in dtgradeuser.Rows) { sbgradeuser.Append(dr["UserTname"].ToString() + ","); } if (sbgradeuser.ToString().Length > 0) { njld = sbgradeuser.ToString().Substring(0, sbgradeuser.ToString().Length - 1);//年級領導 } } DataTable dtclassuser = scuBll.GetList("*", "ClassId='" + classid + "'").Tables[0]; if (dtclassuser.Rows.Count > 0) { StringBuilder sbgradeuser01 = new StringBuilder(); StringBuilder sbgradeuser02 = new StringBuilder(); foreach (DataRow dr in dtclassuser.Rows) { if (dr["IsMs"].ToString() == "1") { sbgradeuser01.Append(dr["UserTname"].ToString() + ","); } else { sbgradeuser02.Append(dr["UserTname"].ToString() + ","); } } if (sbgradeuser01.ToString().Length > 0) { bzr = sbgradeuser01.ToString().Substring(0, sbgradeuser01.ToString().Length - 1);//班主任 } if (sbgradeuser02.ToString().Length > 0) { bjjs = sbgradeuser02.ToString().Substring(0, sbgradeuser02.ToString().Length - 1);//任課教師 } } #endregion StringBuilder sbarea = new StringBuilder(); //获取年级 sbarea.Append("<br/> 年级:<select id=\"nj\" style=\"width:100px\" disabled=\"disabled\">"); sbarea.Append(Com.Public.GetDrpAreaShow("4", Com.Session.schid, ref gradeid, false)); sbarea.Append("</select> "); //获取年级主任 StudentList.namepack npgrade = (StudentList.namepack)Newtonsoft.Json.JsonConvert.DeserializeObject <StudentList.namepack>(getusers("1", gradeid)); sbarea.Append("<span id=\"njld\" style=\"color: #808080 \">年级领导:" + npgrade.gradeboss + "</span><br/><br/>"); //获取班级 sbarea.Append(" 班级:<select id=\"bj\" style=\"width:100px\" disabled=\"disabled\" >"); sbarea.Append(Com.Public.GetDrpAreaShow("5", gradeid, ref classid, false)); sbarea.Append("</select> "); //获取班主任及任课老师 StudentList.namepack np = (StudentList.namepack)Newtonsoft.Json.JsonConvert.DeserializeObject <StudentList.namepack>(getusers("2", classid)); sbarea.Append("<span id=\"bzr\" style=\"color: #808080 \">班主任:"+ np.classms + "</span> "); sbarea.Append("<span id=\"bjjs\" style=\"color: #808080 \">任课老师:" + np.classtec + "</span><br/><br/>"); areastr = sbarea.ToString(); umodelstr = dttojson.DatSetToJSON2(ds);; } } }