protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { usertname = Com.Session.uname; //权限组的增删改 if (Com.Session.systype == "1") //超级管理员和学校管理员 { if (Com.Session.appeditstat == "0") // && Com.Session.systype == "1" { isadd = false; } else { isadd = true; } } SchSystem.BLL.SchClassUser bllclassuser = new SchSystem.BLL.SchClassUser(); if (bllclassuser.ExistsIsMs(Com.Session.usertid, Com.Session.schid, 1) == true)//班主任 { if (Com.Session.appeditstat == "1") { isaddlist = true; } } #region 普通人员 if (Com.Session.systype == "0") { schid = Com.Session.schid; StringBuilder sbarea = new StringBuilder(); //获取年级 sbarea.Append("年级:<select id=\"nj\" style=\"width:100px\">"); string schcode = ""; sbarea.Append(Com.Public.GetDrpAreaStu("4", Com.Session.schid, ref schcode, true)); sbarea.Append("</select> "); sbarea.Append("<span id=\"njld\" style=\"color: #808080 \">年级领导:</span><br/>"); sbarea.Append("<div class=\"space-4\"></div>"); //获取班级 sbarea.Append("班级:<select id=\"bj\" style=\"width:100px\" >"); string Classcode = ""; sbarea.Append(Com.Public.GetDrpAreaStu("5", "", ref Classcode, true)); sbarea.Append("</select> "); sbarea.Append("<span id=\"bzr\" style=\"color: #808080 \">班主任:</span> "); sbarea.Append("<span id=\"bjjs\" style=\"color: #808080 \">任课老师:</span>"); areastr = sbarea.ToString(); } #endregion } }
public static string schsave(string Genid1, string Genid2, string Unid1, string Unid2, string Stuid, string dotype, string schid, string ClassId, string TestNo, string StuName, string Sex, string CardNo, string StudyType, string TelNo, string LoginName, string Pwd, string Addr, string Stat, string jzGenName1, string jzTelNo1, string jzLoginName1, string jzPwd1, string jzStat1, string jzGenName2, string jzTelNo2, string jzLoginName2, string jzPwd2, string jzStat2, string Relation1, string Relation2, string OldClassName, string OldGradeId, string OldGradeName, string GradeId, string OldClassId, string CurrentTestNo) { string result = ""; //事物返回结果 SchSystem.BLL.SchClassUser bllclassuser = new SchSystem.BLL.SchClassUser(); Com.DataPack.DataRsp <Com.DataPack.UserInfo> rsp = Com.Public.UserFuncSoure(Com.SoureSession.jsid, Com.SoureSession.jstoken); if (rsp.code == "ERROR_TOKEN") { result = "expire"; } else { List <string> LstError = new List <string>(); try { //if (!Com.Public.isVa(schid, "")) //{ // LstError.Add("无跨界权限!" + Environment.NewLine); //} SchSystem.Model.SchStuInfo model_stu = new SchSystem.Model.SchStuInfo(); SchSystem.BLL.SchStuInfo bll_stu = new SchSystem.BLL.SchStuInfo(); #region 收集学生信息 if (Com.SoureSession.Souresystype != "2") { model_stu.SchId = Convert.ToInt32(Com.SoureSession.Soureschid); } else { model_stu.SchId = Convert.ToInt32(schid); } StringBuilder sb = new StringBuilder(); if (GradeId != OldGradeId) { sb.Append(OldGradeName); } if (ClassId != OldClassId) { sb.Append(OldClassName); } string sbstr = sb.ToString(); if (sbstr != "") { model_stu.OldClassId = sbstr; } else { model_stu.OldClassId = ""; } model_stu.ClassId = Convert.ToInt32(ClassId); /* * if (ClassId != OldClassIdstr)//如果班级ID有变化说明是在调班 * { * if (OldClassIdSavestr == "")//如果是第一次调班 * { * model_stu.OldClassId = OldClassIdstr; * } * else//曾经调过班 * { * StringBuilder sb = new StringBuilder(); * sb.Append(OldClassIdSavestr + "," + OldClassIdstr);//班级ID以英文半角的逗号隔开 * model_stu.OldClassId = sb.ToString() ; * } * model_stu.ClassId = Convert.ToInt32(ClassId); * } * else//否则,没有调班 * { * model_stu.ClassId = Convert.ToInt32(ClassId); * } */ model_stu.TestNo = Com.Public.SqlEncStr(TestNo); model_stu.StuName = Com.Public.SqlEncStr(StuName); model_stu.Sex = Convert.ToInt32(Sex); model_stu.Dutie = ""; model_stu.StudyType = Convert.ToInt32(StudyType); model_stu.TelNo = Com.Public.SqlEncStr(TelNo); model_stu.LoginName = Com.Public.SqlEncStr(LoginName); if (Pwd != "") { model_stu.Pwd = Com.Public.StrToMD5(Com.Public.SqlEncStr(Pwd)); } else { model_stu.Pwd = ""; } model_stu.Addr = Com.Public.SqlEncStr(Addr); model_stu.Stat = Convert.ToInt32(Stat); model_stu.Birth = Convert.ToDateTime(DateTime.Now.ToLocalTime().ToString()); model_stu.RecUser = Com.SoureSession.Soureuserid; model_stu.RecTime = Convert.ToDateTime(DateTime.Now.ToLocalTime().ToString()); model_stu.LastRecUser = Com.SoureSession.Soureuserid; model_stu.LastRecTime = Convert.ToDateTime(DateTime.Now.ToLocalTime().ToString()); model_stu.StuNo = Com.Public.SqlEncStr(TestNo); model_stu.CardNo = ""; //(Test)卡地址在前台读取, model_stu.ImgUrl = "00"; //(Test)学生默认头像 if (dotype == "e") { model_stu.StuId = Convert.ToInt32(Stuid); } #endregion #region 收集家长信息 List <SchSystem.Model.SchGenInfo> list_model_gen = new List <SchSystem.Model.SchGenInfo>(); SchSystem.Model.SchGenInfo model_gen = new SchSystem.Model.SchGenInfo(); //if (Convert.ToString(jzGenName1) != "" && Convert.ToString(jzTelNo1) != "") //{ model_gen.GenName = Com.Public.SqlEncStr(jzGenName1); model_gen.TelNo = Com.Public.SqlEncStr(jzTelNo1); model_gen.LoginName = ""; if (Pwd != "") { model_gen.Pwd = Com.Public.StrToMD5(Com.Public.SqlEncStr(jzPwd1)); } else { model_gen.Pwd = ""; } model_gen.Stat = Convert.ToInt32(jzStat1); model_gen.RecUser = Com.SoureSession.Soureuserid; model_gen.RecTime = Convert.ToDateTime(DateTime.Now.ToLocalTime().ToString()); model_gen.LastRecUser = Com.SoureSession.Soureuserid; model_gen.LastRecTime = Convert.ToDateTime(DateTime.Now.ToLocalTime().ToString()); model_gen.ImgUrl = "00";//(Test)学生默认头像 model_gen.Sex = 1; if (Genid1 != "") { if (dotype == "e") { model_gen.GenId = Convert.ToInt32(Genid1); } } list_model_gen.Add(model_gen); //} SchSystem.Model.SchGenInfo model_gen2 = new SchSystem.Model.SchGenInfo(); //if (Convert.ToString(jzGenName2) != "" && Convert.ToString(jzTelNo2) != "") //{ model_gen2.GenName = Com.Public.SqlEncStr(jzGenName2); model_gen2.TelNo = Com.Public.SqlEncStr(jzTelNo2); model_gen2.LoginName = ""; if (Pwd != "") { model_gen2.Pwd = Com.Public.StrToMD5(Convert.ToString(jzPwd2)); } else { model_gen2.Pwd = ""; } model_gen2.Stat = Convert.ToInt32(jzStat2); model_gen2.RecUser = Com.SoureSession.Soureuserid; model_gen2.RecTime = Convert.ToDateTime(DateTime.Now.ToLocalTime().ToString()); model_gen2.LastRecUser = Com.SoureSession.Soureuserid; model_gen2.LastRecTime = Convert.ToDateTime(DateTime.Now.ToLocalTime().ToString()); model_gen2.ImgUrl = "00";//(Test)学生默认头像 model_gen2.Sex = 1; if (dotype == "e") { if (Genid2 == "")//编辑时,如果家长ID为空,则添加 { model_gen2.GenId = 0; } else { model_gen2.GenId = Convert.ToInt32(Genid2); } } list_model_gen.Add(model_gen2); //} #endregion #region 收集学生家长关系信息 List <SchSystem.Model.SchStuGenUn> list_model_stu_gen = new List <SchSystem.Model.SchStuGenUn>(); SchSystem.Model.SchStuGenUn model_stu_gen = new SchSystem.Model.SchStuGenUn(); model_stu_gen.Relation = Com.Public.SqlEncStr(Relation1); model_stu_gen.GenName = Com.Public.SqlEncStr(jzGenName1); if (dotype == "e") { if (Unid1 != "") { model_stu_gen.UnId = Convert.ToInt32(Unid1); } else { model_stu_gen.UnId = 0; } model_stu_gen.StuId = model_stu.StuId; model_stu_gen.GenId = model_gen.GenId; } list_model_stu_gen.Add(model_stu_gen); SchSystem.Model.SchStuGenUn model_stu_gen2 = new SchSystem.Model.SchStuGenUn(); if (Convert.ToString(Relation2) != "") { model_stu_gen2.Relation = Com.Public.SqlEncStr(Relation2); model_stu_gen2.GenName = Com.Public.SqlEncStr(jzGenName2); if (dotype == "e") { if (model_gen2.GenId != 0) { model_stu_gen2.UnId = Convert.ToInt32(Unid2); model_stu_gen2.StuId = model_stu.StuId; model_stu_gen2.GenId = model_gen2.GenId; } else { model_stu_gen2.UnId = 0; } } list_model_stu_gen.Add(model_stu_gen2); } #endregion if (dotype == "a")//操作类型为添加 { if (bll_stu.ExistsStuCode(0, model_stu.TestNo.ToString(), Convert.ToInt32(model_stu.SchId))) { /* * LstError.Add("学(考)号重复 !" + Environment.NewLine);//学(考)号重复 * result = "KHCF";*/ StringBuilder sbExists = new StringBuilder(); string utname = ""; SchSystem.BLL.SchStuInfo ssiBll = new SchSystem.BLL.SchStuInfo(); if (schid == "0") { schid = model_stu.SchId.ToString(); } DataTable dt = ssiBll.ExistsStuNo(TestNo, int.Parse(schid)).Tables[0]; if (dt.Rows.Count > 0) { DataRow[] dr = dt.Select(); foreach (DataRow item in dr) { sbExists.Append(item["StuName"].ToString() + "[" + item["GradeName"].ToString()); sbExists.Append("(" + item["ClassName"].ToString() + ")]"); } //ret += "账号重复!"; return(result = sbExists.ToString()); } } if (LoginName != "") { if (bll_stu.ExistsStuUsername(0, model_stu.LoginName.ToString(), Convert.ToInt32(model_stu.SchId))) { LstError.Add("账号重复 !" + Environment.NewLine);//账号重复 result = "ZHCF"; } } if (LstError.Count == 0) { if (Com.SoureSession.Souresystype == "1" || Com.SoureSession.Souresystype == "2")//超管和学校超管 { result = bll_stu.Add(model_stu, list_model_gen, list_model_stu_gen); } else { //if (ClassId == classidstr) //{ if (bllclassuser.ExistsIsMs(Com.Public.SqlEncStr(ClassId), Com.SoureSession.Soureusertid, Com.SoureSession.Soureschid, 1) == true)//班主任 { result = bll_stu.Add(model_stu, list_model_gen, list_model_stu_gen); } else { result = "BBBZR"; } //} //else if (GradeId == gradecodestr) //{ // if (bll_stu.ExistsGrade(Com.Public.SqlEncStr(GradeId), Com.Session.schid, Com.Session.usertid) == true)//年级主任 // { // result = bll_stu.Add(model_stu, list_model_gen, list_model_stu_gen); // } // else // { // result = "BNJZR"; // } //} } //result = bll_stu.Add(model_stu, list_model_gen, list_model_stu_gen); } } else if (dotype == "e")//操作类型为编辑 { StringBuilder sbExists = new StringBuilder(); string utname = ""; SchSystem.BLL.SchStuInfo ssiBll = new SchSystem.BLL.SchStuInfo(); if (schid == "0") { schid = model_stu.SchId.ToString(); } DataTable dt = ssiBll.ExistsStuNoUpdate(TestNo, int.Parse(schid), CurrentTestNo).Tables[0]; if (dt.Rows.Count > 0) { DataRow[] dr = dt.Select(); foreach (DataRow item in dr) { sbExists.Append(item["StuName"].ToString() + "[" + item["GradeName"].ToString()); sbExists.Append("(" + item["ClassName"].ToString() + ")]"); } //ret += "账号重复!"; return(result = sbExists.ToString()); } //if (bll_stu.ExistsStuCode(0, model_stu.TestNo.ToString(), Convert.ToInt32(model_stu.SchId))) //{ // LstError.Add("学(考)号重复 !" + Environment.NewLine);//学(考)号重复 // result = "KHCF"; //} if (LstError.Count == 0) { result = bll_stu.Update(model_stu, list_model_gen, list_model_stu_gen); } } } catch (Exception) { throw; } } return(result); }
public static string page(string PageIndex, string PageSize, string ClassId, string SchId, string Stuname, string GradeId) { bool islist = false; Com.Public.PageModelResp pages = new Com.Public.PageModelResp(); pages.PageIndex = int.Parse(PageIndex); pages.PageSize = int.Parse(PageSize); SchSystem.BLL.SchClassUser bllclassuser = new SchSystem.BLL.SchClassUser(); SchSystem.BLL.SchGradeUsers bllgradeuser = new SchSystem.BLL.SchGradeUsers(); #region 添加按钮和列表显示权限 pages.isadd = false; if (Com.SoureSession.Souresystype == "1")//学校超管 { islist = true; if (GradeId == "-1" || ClassId == "-1" || GradeId == "" || ClassId == "") //系统编辑状态为0,或者年级,班级其中一个选择了全部,则不允许出现添加按钮 { pages.isadd = false; } else { pages.isadd = true; } } else//普通老师账号 { if (bllclassuser.ExistsIsMs(Com.Public.SqlEncStr(ClassId), Com.SoureSession.Soureuserid, Com.SoureSession.Soureschid, 1) == true)//班主任 { if (Com.Session.appeditstat == "1") { pages.isadd = true; } islist = true; } else { pages.isadd = false; if (bllgradeuser.ExistsGrade(Com.Public.SqlEncStr(GradeId), Com.SoureSession.Soureschid, Com.SoureSession.Soureuserid) == true)//年级主任 { islist = true; } if (bllclassuser.ExistsIsMs(Com.Public.SqlEncStr(ClassId), Com.SoureSession.Soureuserid, Com.SoureSession.Soureschid, 0) == true)//任课老师 { islist = true; } } if (Com.Public.IsUserVal(Com.Session.userrolestr, 2)) { islist = true; } ; } #endregion if (islist) { string strWhere = "StuStat=1 "; if (!string.IsNullOrEmpty(Stuname)) { strWhere += " and stuname LIKE '%" + Com.Public.SqlEncStr(Stuname) + "%'"; } if (GradeId == "-1" || GradeId == "")//获取当前用户的所有年级 { strWhere += " and GradeId in (" + Com.Public.GetIdsAllStu("4", Com.SoureSession.Soureschid) + ")"; } else { strWhere += " and GradeId=" + Com.Public.SqlEncStr(GradeId); } if (ClassId == "-1" || ClassId == "")//获取当前用户的所有班级 { if (GradeId == "") { GradeId = "-1"; } strWhere += " and ClassId in (" + Com.Public.GetIdsAllStu("5", Com.Public.SqlEncStr(GradeId)) + ")"; } else { strWhere += " and ClassId=" + Com.Public.SqlEncStr(ClassId); } int RowCount = 0; int PageCount = 0;//left('00000000',8-len(StuId))+convert(varchar(10),StuId) string cols = " GradeId,ClassId,GradeName,ClassName,StuId,TestNo,StuName,CardNo,Sex,StuNo,TelNo,StudyType,LoginName,'' GenNameO,'' GenLoginNameO ,'' GenTelO,'' GenNameT,'' GenLoginNameT ,'' GenTelT,'0' isdel,'0' isedit,'0' islook"; SchSystem.BLL.SchStuInfoV bllstuv = new SchSystem.BLL.SchStuInfoV(); DataTable dtstuv = bllstuv.GetListCols(cols, strWhere, "StuName", "ASC", pages.PageIndex, pages.PageSize, ref RowCount, ref PageCount).Tables[0]; pages.PageCount = PageCount; pages.RowCount = RowCount; if (dtstuv != null && dtstuv.Rows.Count > 0) { SchSystem.BLL.SchStuGenUV bllstugenv = new SchSystem.BLL.SchStuGenUV(); for (int i = 0; i < dtstuv.Rows.Count; i++)//将家长添加上,并且把权限加上 { //获取家长 DataTable dtgenv = bllstugenv.GetList("GenName,LoginName,TelNo,Relation", "Stat=1 and StuId=" + dtstuv.Rows[i]["StuId"].ToString()).Tables[0]; if (dtgenv != null && dtgenv.Rows.Count > 0) { dtstuv.Rows[i]["GenNameO"] = dtgenv.Rows[0]["GenName"].ToString(); dtstuv.Rows[i]["GenTelO"] = dtgenv.Rows[0]["TelNo"].ToString(); dtstuv.Rows[i]["GenLoginNameO"] = dtgenv.Rows[0]["LoginName"].ToString(); if (dtgenv.Rows.Count > 1) { dtstuv.Rows[i]["GenNameT"] = dtgenv.Rows[1]["GenName"].ToString(); dtstuv.Rows[i]["GenTelT"] = dtgenv.Rows[1]["TelNo"].ToString(); dtstuv.Rows[i]["GenLoginNameT"] = dtgenv.Rows[1]["LoginName"].ToString(); } } //权限 if (Com.SoureSession.Souresystype == "1") //学校超管,可看 { if (Com.Session.appeditstat == "1") //系统未被屏蔽编辑功能,则可编辑和删除 { dtstuv.Rows[i]["isdel"] = "1"; dtstuv.Rows[i]["isedit"] = "1"; } dtstuv.Rows[i]["islook"] = "1"; } else//普通老师账号 { if (bllclassuser.ExistsIsMs(dtstuv.Rows[i]["ClassId"].ToString(), Com.SoureSession.Soureuserid, Com.SoureSession.Soureschid, 1) == true)//班主任可查看 { dtstuv.Rows[i]["islook"] = "1"; if (Com.Session.appeditstat == "1") { dtstuv.Rows[i]["isdel"] = "1"; dtstuv.Rows[i]["isedit"] = "1"; } } else { if (bllgradeuser.ExistsGrade(dtstuv.Rows[i]["GradeId"].ToString(), Com.SoureSession.Soureschid, Com.SoureSession.Soureuserid) == true)//年级主任 { islist = true; dtstuv.Rows[i]["islook"] = "1"; } } if (Com.Public.IsUserVal(Com.Session.userrolestr, 2)) { dtstuv.Rows[i]["islook"] = "1"; islist = true; } } } pages.list = dtstuv; } } return(Newtonsoft.Json.JsonConvert.SerializeObject(pages)); }
public static Com.DataPack.DataRsp <string> page(string PageIndex, string PageSize, string txtname, string ustat, string txtcode, string drptype) { Com.DataPack.DataRsp <string> rsp = new Com.DataPack.DataRsp <string>(); if (Com.Session.userid == null) { rsp.code = "expire"; rsp.msg = "页面已经过期,请重新登录"; } else { try { //Stat:0废弃,1正常,2被删除,正常界面不显示删除,超管界面可以考虑 string strwhere = "Stat<2 and SchId='" + Com.Session.schid + "' "; if (!string.IsNullOrEmpty(txtname)) { strwhere += " and Topic like '%" + Com.Public.SqlEncStr(txtname) + "%'"; } if (!string.IsNullOrEmpty(ustat)) { strwhere += " and Stat='" + Com.Public.SqlEncStr(ustat) + "'"; } if (txtcode != "0") { strwhere += " and ChnId='" + Com.Public.SqlEncStr(txtcode) + "'"; } if (drptype != "") { strwhere += " and Lv='" + Com.Public.SqlEncStr(drptype) + "'"; } Com.Public.PageModelResp pages = new Com.Public.PageModelResp(); pages.PageIndex = int.Parse(PageIndex); pages.PageSize = int.Parse(PageSize); int rowc = 0; int pc = 0; SchSystem.BLL.WebSchChnNewsV userbll = new SchSystem.BLL.WebSchChnNewsV(); string dbcols = "NewsId,ChnName,ChnId,Topic,RecTime,GradeId,ClassId,Lv,'' GradeName,'' ClassName,'' LvName,'0' isdel,'0' isedit,'1' islook,Stat,IsTop"; DataTable dt = userbll.GetListCols(dbcols, strwhere, "IsTop Desc,RecTime DESC", "", pages.PageIndex, pages.PageSize, ref rowc, ref pc).Tables[0]; pages.PageCount = pc; pages.RowCount = rowc; if (dt.Rows.Count > 0) { SchSystem.BLL.SchClassUser bllclassuser = new SchSystem.BLL.SchClassUser(); SchSystem.BLL.SchGradeUsers bllgradeuser = new SchSystem.BLL.SchGradeUsers(); SchSystem.BLL.SchClassInfo bllclass = new SchSystem.BLL.SchClassInfo(); SchSystem.BLL.SchGradeInfo bllgrade = new SchSystem.BLL.SchGradeInfo(); //权限 for (int i = 0; i < dt.Rows.Count; i++) { if (Com.Session.appeditstat == "1") //允许编辑 { if (dt.Rows[i]["Lv"].ToString() == "0") //班级新闻 { if (Com.Public.IsUserVal(Com.Session.userrolestr, 14) || bllclassuser.ExistsIsMs(dt.Rows[i]["ClassId"].ToString(), Com.Session.usertid, Com.Session.schid, 1) == true) //如果有所有班级权限或是班主任 { dt.Rows[i]["isdel"] = "1"; dt.Rows[i]["isedit"] = "1"; } //获取年级,班级,类型 dt.Rows[i]["GradeName"] = bllgrade.GetName(int.Parse(dt.Rows[i]["GradeId"].ToString())); dt.Rows[i]["ClassName"] = bllclass.GetName(int.Parse(dt.Rows[i]["ClassId"].ToString())); dt.Rows[i]["LvName"] = "班级"; } else if (dt.Rows[i]["Lv"].ToString() == "1") //年级新闻 { if (Com.Public.IsUserVal(Com.Session.userrolestr, 13) || bllgradeuser.ExistsGrade(dt.Rows[i]["GradeId"].ToString(), Com.Session.schid, Com.Session.usertid) == true) //如果有全校权限或是年级组长 { dt.Rows[i]["isdel"] = "1"; dt.Rows[i]["isedit"] = "1"; } //获取年级 dt.Rows[i]["GradeName"] = bllgrade.GetName(int.Parse(dt.Rows[i]["GradeId"].ToString())); dt.Rows[i]["LvName"] = "年级"; } else if (dt.Rows[i]["Lv"].ToString() == "2") //学校新闻 { if (Com.Public.IsUserVal(Com.Session.userrolestr, 13)) //如果有全校权限 { dt.Rows[i]["isdel"] = "1"; dt.Rows[i]["isedit"] = "1"; } dt.Rows[i]["LvName"] = "学校"; } } } pages.list = dt; } rsp.RspData = Newtonsoft.Json.JsonConvert.SerializeObject(pages).Replace("\n\r", ""); } catch (Exception ex) { rsp.code = "error"; rsp.msg = ex.Message; } } return(rsp); }
public static Com.DataPack.DataRsp <string> schsave(string Stuid, string dotype, string schid, string ClassId, string TestNo, string StuName, string Sex, string CardNo, string StudyType, string TelNo, string Addr, string jzGenName1, string jzTelNo1, string jzGenName2, string jzTelNo2, string Relation1, string Relation2, string OldClassName, string OldGradeId, string OldGradeName, string GradeId, string OldClassId, string CurrentTestNo) { Com.DataPack.DataRsp <string> rsp = new Com.DataPack.DataRsp <string>(); SchSystem.BLL.SchClassUser bllclassuser = new SchSystem.BLL.SchClassUser(); if (Com.Session.userid == null) { rsp.code = "expire"; rsp.msg = "页面已经过期,请重新登录"; } else { try { SchSystem.Model.SchStuInfo model_stu = new SchSystem.Model.SchStuInfo(); SchSystem.BLL.SchStuInfo bll_stu = new SchSystem.BLL.SchStuInfo(); if (Com.Session.systype != "2") { model_stu.SchId = Convert.ToInt32(Com.Session.schid); } else { model_stu.SchId = Convert.ToInt32(schid); } StringBuilder sb = new StringBuilder(); if (ClassId != OldClassId) { sb.Append(OldGradeName + "(" + OldClassName + ")"); } string sbstr = sb.ToString(); if (sbstr != "") { model_stu.OldClassId = sbstr; } else { model_stu.OldClassId = ""; } model_stu.ClassId = Convert.ToInt32(ClassId); model_stu.TestNo = Com.Public.SqlEncStr(TestNo); model_stu.StuName = Com.Public.SqlEncStr(StuName); model_stu.Sex = Convert.ToInt32(Sex); model_stu.StudyType = Convert.ToInt32(StudyType); model_stu.TelNo = Com.Public.SqlEncStr(TelNo); model_stu.Addr = Com.Public.SqlEncStr(Addr); model_stu.RecUser = Com.Session.userid; model_stu.RecTime = Convert.ToDateTime(DateTime.Now.ToLocalTime().ToString()); model_stu.LastRecUser = Com.Session.userid; model_stu.LastRecTime = Convert.ToDateTime(DateTime.Now.ToLocalTime().ToString()); model_stu.StuNo = Com.Public.SqlEncStr(TestNo); model_stu.CardNo = "";//(Test)卡地址在前台读取, string errorstr = ""; //获取有考号的学生列表,进行添加或者修改判断 int stuids = 0; if (dotype == "e")//根据是否有判断 { model_stu.StuId = Convert.ToInt32(Stuid); stuids = model_stu.StuId; } //判断是否有该学号的学生 StringBuilder sbExists = new StringBuilder(); SchSystem.BLL.SchStuInfo ssiBll = new SchSystem.BLL.SchStuInfo(); //看是否考号被占用 DataTable dt = ssiBll.GetStuNoList(TestNo, model_stu.SchId, stuids).Tables[0]; if (dt.Rows.Count > 0) { DataRow[] dr = dt.Select(); foreach (DataRow item in dr) { sbExists.Append("[" + item["GradeName"].ToString() + item["ClassName"].ToString() + "]" + item["StuName"].ToString() + ";"); } errorstr += "考号被:" + sbExists.ToString() + "占用;"; } if (Com.Session.systype == "0" && !bllclassuser.ExistsIsMs(Com.Public.SqlEncStr(ClassId), Com.Session.usertid, Com.Session.schid, 1) == true)//班主任 { errorstr += "非班主任不能添加学生!"; } if (errorstr == "") { if (dotype == "e") { //更新学生 bll_stu.UpdateStu(model_stu); } else { stuids = bll_stu.AddStu(model_stu); } if (stuids > 0) { //添加家长 //先删除关联表数据 SchSystem.BLL.SchStuGenUn genunBll = new SchSystem.BLL.SchStuGenUn(); genunBll.DeleteStuUn(stuids); SchSystem.BLL.SchGenInfo genBll = new SchSystem.BLL.SchGenInfo(); //对第一个家长资料进行处理 if (Convert.ToString(jzGenName1) != "" && Convert.ToString(jzTelNo1) != "") { int genid = genBll.GetMbId(jzTelNo1); if (genid == 0)//无号码存在,则插数据 { SchSystem.Model.SchGenInfo genmodel = new SchSystem.Model.SchGenInfo(); genmodel.TelNo = jzTelNo1; genmodel.RecUser = Com.Session.userid; genmodel.RecTime = DateTime.Now; genmodel.LastRecUser = Com.Session.userid; genmodel.LastRecTime = DateTime.Now; genid = genBll.Add(genmodel); } if (genid > 0)//插成功或者获取成功,则往关联表插数据 { SchSystem.Model.SchStuGenUn genunmodel = new SchSystem.Model.SchStuGenUn(); genunmodel.StuId = stuids; genunmodel.GenId = genid; genunmodel.GenName = jzGenName1; genunmodel.Relation = Relation1 == "" ? "其他" : Relation1; genunBll.Add(genunmodel); } } //对第二个家长进行处理 if (Convert.ToString(jzGenName2) != "" && Convert.ToString(jzTelNo2) != "") { int genid = genBll.GetMbId(jzTelNo2); if (genid == 0)//无号码存在,则插数据 { SchSystem.Model.SchGenInfo genmodel = new SchSystem.Model.SchGenInfo(); genmodel.TelNo = jzTelNo2; genmodel.RecUser = Com.Session.userid; genmodel.RecTime = DateTime.Now; genmodel.LastRecUser = Com.Session.userid; genmodel.LastRecTime = DateTime.Now; genid = genBll.Add(genmodel); } if (genid > 0)//插成功或者获取成功,则往关联表插数据 { SchSystem.Model.SchStuGenUn genunmodel = new SchSystem.Model.SchStuGenUn(); genunmodel.StuId = stuids; genunmodel.GenId = genid; genunmodel.GenName = jzGenName2; genunmodel.Relation = Relation2 == "" ? "其他" : Relation2; genunBll.Add(genunmodel); } } } rsp.code = "success"; rsp.msg = "保存成功"; } else { rsp.code = "error"; rsp.msg = errorstr; } } catch (Exception ex) { rsp.code = "error"; rsp.msg = ex.Message; } } return(rsp); }