diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/ClassPlanTeachController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/ClassPlanTeachController.cs index 764dccd58..75946a8fb 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/ClassPlanTeachController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/ClassPlanTeachController.cs @@ -146,7 +146,7 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers for (int i = 0; i < entityList.Count; i++) { var stuDataList = stuInfoBasicIBLL.GetAllList().Where(s => - s.MajorNo == entityList[i].MajorNo + s.MajorNo == entityList[i].MajorNo && s.F_SchoolId == entityList[i].F_SchoolId && s.ClassNo == entityList[i].TeachClassNo ).ToList(); @@ -207,7 +207,7 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers for (int i = 0; i < entityList.Count; i++) { List ssList = StuSelectLesson.GetAllList().Where( - y => y.MajorNo == entityList[i].MajorNo + y => y.MajorNo == entityList[i].MajorNo && y.F_SchoolId == entityList[i].F_SchoolId && y.ClassNo == entityList[i].TeachClassNo && y.LessonNo == entityList[i].LessonNo @@ -223,8 +223,8 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers List TeachList = new List(); for (int i = 0; i < entityList.Count; i++) { - var stuDataList = stuInfoBasicIBLL.GetAllList().Where(s => - s.MajorNo == entityList[i].MajorNo + var stuDataList = stuInfoBasicIBLL.GetAllList().Where(s => + s.MajorNo == entityList[i].MajorNo && s.F_SchoolId == entityList[i].F_SchoolId && s.ClassNo == entityList[i].TeachClassNo ).ToList(); @@ -275,6 +275,39 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers return Success("设置成功!"); } + + [HttpPost] + [AjaxOnly] + public ActionResult UpTeach(string keyValue, string EmpNo) + { + var entityList = teachClassIBLL.GetTeachListById(keyValue); + if (entityList != null) + { + var res = teachClassIBLL.UpSetTeach(keyValue, EmpNo); //更改当前教师 + if (!string.IsNullOrEmpty(res)) + { + return Fail(res); + } + } + else + { + return Fail("设置失败"); + } + + return Success("设置成功!"); + } + + [HttpPost] + [AjaxOnly] + public ActionResult QzUpTeach(string keyValue, string EmpNo) + { + var entityList = teachClassIBLL.GetTeachListById(keyValue); + if (entityList != null) + { + teachClassIBLL.UpQzSetTeach(keyValue, EmpNo); //更改当前教师 + } + return Success("设置成功!"); + } #endregion } } diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ClassPlanTeach/TeachForm.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ClassPlanTeach/TeachForm.js index db907b115..ad2b865a4 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ClassPlanTeach/TeachForm.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ClassPlanTeach/TeachForm.js @@ -24,8 +24,7 @@ var bootstrap = function ($, learun) { } var postData = $('#form').lrGetFormData(); var EmpNo = postData.EmpNo; - console.log(EmpNo); - learun.postForm(top.$.rootUrl + '/EducationalAdministration/ClassPlanTeach/SetTeach', { keyValue: keyValue, EmpNo: EmpNo}, function () { + learun.postForm(top.$.rootUrl + '/EducationalAdministration/ClassPlanTeach/UpTeach', { keyValue: keyValue, EmpNo: EmpNo}, function () { }); }; page.init(); diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ClassPlanTeach/TeachFormQZ.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ClassPlanTeach/TeachFormQZ.js index 02ee00152..69c0a9533 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ClassPlanTeach/TeachFormQZ.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ClassPlanTeach/TeachFormQZ.js @@ -24,8 +24,7 @@ var bootstrap = function ($, learun) { } var postData = $('#form').lrGetFormData(); var EmpNo = postData.EmpNo; - console.log(EmpNo); - learun.postForm(top.$.rootUrl + '/EducationalAdministration/ClassPlanTeach/QZSetTeach', { keyValue: keyValue, EmpNo: EmpNo}, function () { + learun.postForm(top.$.rootUrl + '/EducationalAdministration/ClassPlanTeach/QzUpTeach', { keyValue: keyValue, EmpNo: EmpNo}, function () { }); }; page.init(); diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachClass/TeachClassBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachClass/TeachClassBLL.cs index 8e07b0437..ef86f5a28 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachClass/TeachClassBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachClass/TeachClassBLL.cs @@ -227,6 +227,53 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } + /// + /// 保存实体数据(新增、修改) + /// 主键 + /// + /// + public string UpSetTeach(string keyValue, string EmpNo) + { + try + { + return teachClassEntity.UpSetTeach(keyValue, EmpNo); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } + + /// + /// 保存实体数据(新增、修改) + /// 主键 + /// + /// + public string UpQzSetTeach(string keyValue, string EmpNo) + { + try + { + return teachClassEntity.UpQzSetTeach(keyValue, EmpNo); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } #endregion } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachClass/TeachClassIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachClass/TeachClassIBLL.cs index 27aeb4551..e57f079fc 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachClass/TeachClassIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachClass/TeachClassIBLL.cs @@ -71,6 +71,8 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration /// /// void UpEmpNo(string keyvalue, string EmpNo); + string UpSetTeach(string keyvalue, string EmpNo); + string UpQzSetTeach(string keyvalue, string EmpNo); #endregion } } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachClass/TeachClassService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachClass/TeachClassService.cs index 6798daddd..7a74b8abf 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachClass/TeachClassService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachClass/TeachClassService.cs @@ -1,4 +1,5 @@ using Dapper; +using Learun.Application.Organization; using Learun.DataBase.Repository; using Learun.Util; using System; @@ -326,6 +327,348 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } } + /// + /// 修改教师和成绩 + /// + /// + /// + public string UpSetTeach(string keyValue, string EmpNo) + { + string Result = ""; + var db = BaseRepository("CollegeMIS").BeginTrans(); + try + { + #region 获取班级开课计划的数据 + var IdList = keyValue.Split(','); + var TeachClassList = BaseRepository("CollegeMIS").FindList(x => IdList.Contains(x.ID.ToString())).ToList(); + foreach (var item in IdList)//修改TeachClass表 + { + var entityList = GetTeachClassEntity(item); + entityList.EmpNo = EmpNo; + db.Update(entityList); + } + #endregion + + List stuLessonList = new List(); + for (int i = 0; i < TeachClassList.Count; i++) + { + var LessonData = db.FindList().Where(x => x.LessonNo == TeachClassList[i].LessonNo).FirstOrDefault(); + + var stuDataList = db.FindList().Where(s => + s.DeptNo == TeachClassList[i].DeptNo && s.MajorNo == TeachClassList[i].MajorNo && + s.F_SchoolId == TeachClassList[i].F_SchoolId && + s.ClassNo == TeachClassList[i].TeachClassNo && s.CheckMark == "1"); + var DeleteStuSelectLesson = db.FindList().Where( + x => x.AcademicYearNo == TeachClassList[i].AcademicYearNo && + x.LessonNo == TeachClassList[i].LessonNo && + x.Semester == TeachClassList[i].Semester && + x.F_SchoolId == TeachClassList[i].F_SchoolId && + x.DeptNo == TeachClassList[i].DeptNo && + x.MajorNo == TeachClassList[i].MajorNo && + x.ClassNo == TeachClassList[i].TeachClassNo && + x.Grade == TeachClassList[i].Grade && + x.OpenLessonDeptNo == TeachClassList[i].DeptNo && + x.OpenLessonMajorNo == TeachClassList[i].MajorNo && + x.LessonSortNo == "1").ToList(); + if (DeleteStuSelectLesson.Count > 0) + { + db.Delete(DeleteStuSelectLesson); + } + if (stuDataList != null) + { + #region 修改StuSelectLessonList表 + + foreach (var item in stuDataList) + { + var StuSelectLessonEntity = new StuSelectLessonListEntity + { + StuNo = item.StuNo, + DeptNo = TeachClassList[i].DeptNo, + MajorNo = TeachClassList[i].MajorNo, + ClassNo = item.ClassNo, + GenderNo = item.GenderNo == true ? "0" : "1", + MajorDetailNo = TeachClassList[i].MajorDetailNo, + MajorDetailName = TeachClassList[i].MajorDetailName, + StuName = item.StuName, + AcademicYearNo = TeachClassList[i].AcademicYearNo, + Semester = TeachClassList[i].Semester, + OpenLessonDeptNo = TeachClassList[i].DeptNo, + OpenLessonMajorNo = TeachClassList[i].MajorNo, + LessonNo = TeachClassList[i].LessonNo, + LessonName = LessonData.LessonName, + PartCode = TeachClassList[i].PartCode, + OrdinaryScoreScale = 0, + TermInScoreScale = 0, + TermEndScoreScale = 0, + OtherScoreScale = 0, + TeachClassNo = TeachClassList[i].TeachClassNo, + LessonSortNo = TeachClassList[i].LessonSortNo, + StuSortNo = TeachClassList[i].LessonSortNo, + Grade = item.Grade, + StudyScore = 2, + TotalStudyHour = 2, + IsInEffect = "1", + IsPitchOn = "1", + F_SchoolId = TeachClassList[i].F_SchoolId, + CheckMark = "1", + InsertTime = DateTime.Now + }; + stuLessonList.Add(StuSelectLessonEntity); + db.Insert(StuSelectLessonEntity); + } + #endregion + var ScoreList = db.FindList().Where(x => x.AcademicYearNo == TeachClassList[i].AcademicYearNo && x.Semester == TeachClassList[i].Semester && x.DeptNo == TeachClassList[i].DeptNo && x.MajorNo == TeachClassList[i].MajorNo && x.ClassNo == TeachClassList[i].TeachClassNo && x.LessonSortNo == TeachClassList[i].LessonSortNo && x.LessonNo == TeachClassList[i].LessonNo); + var DeleteStuScore = db.FindList().Where( + x => x.AcademicYearNo == TeachClassList[i].AcademicYearNo && + x.LessonNo == TeachClassList[i].LessonNo && + x.Semester == TeachClassList[i].Semester && + x.F_SchoolId == TeachClassList[i].F_SchoolId && + x.DeptNo == TeachClassList[i].DeptNo && + x.MajorNo == TeachClassList[i].MajorNo && + x.ClassNo == TeachClassList[i].TeachClassNo && + x.Grade == TeachClassList[i].Grade && + x.OpenLessonDeptNo == TeachClassList[i].DeptNo && + x.OpenLessonMajorNo == TeachClassList[i].MajorNo && + x.LessonSortNo == "1" && x.CheckMark == "1").ToList(); + if (DeleteStuScore.Count > 0) + { + return Result = "成绩已审核不可设置教师"; + } + db.Delete(DeleteStuScore); + + + if (ScoreList != null) + { + #region 添加StuScore表 + foreach (var item in stuDataList) + { + var stuScoreEntity = new StuScoreEntity + { + StuNo = item.StuNo, + DeptNo = item.DeptNo, + MajorNo = item.MajorNo, + ClassNo = item.ClassNo, + StuName = item.StuName, + EmpNo = EmpNo, + GenderNo = item.GenderNo == true ? "0" : "1", + AcademicYearNo = TeachClassList[i].AcademicYearNo, + Semester = TeachClassList[i].Semester, + OpenLessonDeptNo = TeachClassList[i].DeptNo, + OpenLessonMajorNo = TeachClassList[i].MajorNo, + LessonNo = TeachClassList[i].LessonNo, + LessonName = LessonData.LessonName, + PartCode = TeachClassList[i].PartCode, + StuSortNo = item.TestStuSortNo, + TeachClassNo = TeachClassList[i].TeachClassNo, + LessonSortNo = TeachClassList[i].LessonSortNo, + Grade = TeachClassList[i].Grade, + StudyScore = 2, + TotalStudyHour = 2, + IsInEffect = "1", + IsPitchOn = "1", + F_SchoolId = TeachClassList[i].F_SchoolId, + CheckMark = "0", + TestKindNo = "1", + IsEditable = "1", + OrdinaryScore = 0, + TermInScore = 0, + TermEndScore = 0, + OtherScore = 0 + + }; + db.Insert(stuScoreEntity); + } + #endregion + } + } + + } + db.Commit(); + return Result = "设置教师成功"; + } + catch (Exception ex) + { + db.Rollback(); + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } + /// + /// 强制修改教师 + /// + /// + /// + public string UpQzSetTeach(string keyValue, string EmpNo) + { + string Result = ""; + var db = BaseRepository("CollegeMIS").BeginTrans(); + try + { + #region 获取班级开课计划的数据 + var IdList = keyValue.Split(','); + var TeachClassList = BaseRepository("CollegeMIS").FindList(x => IdList.Contains(x.ID.ToString())).ToList(); + foreach (var item in IdList)//修改TeachClass表 + { + var entityList = GetTeachClassEntity(item); + entityList.EmpNo = EmpNo; + db.Update(entityList); + } + #endregion + + List stuLessonList = new List(); + for (int i = 0; i < TeachClassList.Count; i++) + { + var LessonData = db.FindList().Where(x => x.LessonNo == TeachClassList[i].LessonNo).FirstOrDefault(); + + var stuDataList = db.FindList().Where(s => + s.DeptNo == TeachClassList[i].DeptNo && s.MajorNo == TeachClassList[i].MajorNo && + s.F_SchoolId == TeachClassList[i].F_SchoolId && + s.ClassNo == TeachClassList[i].TeachClassNo && s.CheckMark == "1"); + var DeleteStuSelectLesson = db.FindList().Where( + x => x.AcademicYearNo == TeachClassList[i].AcademicYearNo && + x.LessonNo == TeachClassList[i].LessonNo && + x.Semester == TeachClassList[i].Semester && + x.F_SchoolId == TeachClassList[i].F_SchoolId && + x.DeptNo == TeachClassList[i].DeptNo && + x.MajorNo == TeachClassList[i].MajorNo && + x.ClassNo == TeachClassList[i].TeachClassNo && + x.Grade == TeachClassList[i].Grade && + x.OpenLessonDeptNo == TeachClassList[i].DeptNo && + x.OpenLessonMajorNo == TeachClassList[i].MajorNo && + x.LessonSortNo == "1").ToList(); + if (DeleteStuSelectLesson.Count > 0) + { + db.Delete(DeleteStuSelectLesson); + } + if (stuDataList != null) + { + #region 修改StuSelectLessonList表 + + foreach (var item in stuDataList) + { + var StuSelectLessonEntity = new StuSelectLessonListEntity + { + StuNo = item.StuNo, + DeptNo = TeachClassList[i].DeptNo, + MajorNo = TeachClassList[i].MajorNo, + ClassNo = item.ClassNo, + GenderNo = item.GenderNo == true ? "0" : "1", + MajorDetailNo = TeachClassList[i].MajorDetailNo, + MajorDetailName = TeachClassList[i].MajorDetailName, + StuName = item.StuName, + AcademicYearNo = TeachClassList[i].AcademicYearNo, + Semester = TeachClassList[i].Semester, + OpenLessonDeptNo = TeachClassList[i].DeptNo, + OpenLessonMajorNo = TeachClassList[i].MajorNo, + LessonNo = TeachClassList[i].LessonNo, + LessonName = LessonData.LessonName, + PartCode = TeachClassList[i].PartCode, + OrdinaryScoreScale = 0, + TermInScoreScale = 0, + TermEndScoreScale = 0, + OtherScoreScale = 0, + TeachClassNo = TeachClassList[i].TeachClassNo, + LessonSortNo = TeachClassList[i].LessonSortNo, + StuSortNo = TeachClassList[i].LessonSortNo, + Grade = item.Grade, + StudyScore = 2, + TotalStudyHour = 2, + IsInEffect = "1", + IsPitchOn = "1", + F_SchoolId = TeachClassList[i].F_SchoolId, + CheckMark = "1", + InsertTime = DateTime.Now + }; + stuLessonList.Add(StuSelectLessonEntity); + db.Insert(StuSelectLessonEntity); + } + #endregion + var ScoreList = db.FindList().Where(x => x.AcademicYearNo == TeachClassList[i].AcademicYearNo && x.Semester == TeachClassList[i].Semester && x.DeptNo == TeachClassList[i].DeptNo && x.MajorNo == TeachClassList[i].MajorNo && x.ClassNo == TeachClassList[i].TeachClassNo && x.LessonSortNo == TeachClassList[i].LessonSortNo && x.LessonNo == TeachClassList[i].LessonNo); + var DeleteStuScore = db.FindList().Where( + x => x.AcademicYearNo == TeachClassList[i].AcademicYearNo && + x.LessonNo == TeachClassList[i].LessonNo && + x.Semester == TeachClassList[i].Semester && + x.F_SchoolId == TeachClassList[i].F_SchoolId && + x.DeptNo == TeachClassList[i].DeptNo && + x.MajorNo == TeachClassList[i].MajorNo && + x.ClassNo == TeachClassList[i].TeachClassNo && + x.Grade == TeachClassList[i].Grade && + x.OpenLessonDeptNo == TeachClassList[i].DeptNo && + x.OpenLessonMajorNo == TeachClassList[i].MajorNo && + x.LessonSortNo == "1" && x.CheckMark == "0").ToList(); + if (DeleteStuScore.Count > 0) + { + db.Delete(DeleteStuScore); + + } + if (ScoreList != null) + { + #region 添加StuScore表 + foreach (var item in stuDataList) + { + var stuScoreEntity = new StuScoreEntity + { + StuNo = item.StuNo, + DeptNo = item.DeptNo, + MajorNo = item.MajorNo, + ClassNo = item.ClassNo, + StuName = item.StuName, + EmpNo = EmpNo, + GenderNo = item.GenderNo == true ? "0" : "1", + AcademicYearNo = TeachClassList[i].AcademicYearNo, + Semester = TeachClassList[i].Semester, + OpenLessonDeptNo = TeachClassList[i].DeptNo, + OpenLessonMajorNo = TeachClassList[i].MajorNo, + LessonNo = TeachClassList[i].LessonNo, + LessonName = LessonData.LessonName, + PartCode = TeachClassList[i].PartCode, + StuSortNo = item.TestStuSortNo, + TeachClassNo = TeachClassList[i].TeachClassNo, + LessonSortNo = TeachClassList[i].LessonSortNo, + Grade = TeachClassList[i].Grade, + StudyScore = 2, + TotalStudyHour = 2, + IsInEffect = "1", + IsPitchOn = "1", + F_SchoolId = TeachClassList[i].F_SchoolId, + CheckMark = "0", + TestKindNo = "1", + IsEditable = "1", + OrdinaryScore = 0, + TermInScore = 0, + TermEndScore = 0, + OtherScore = 0 + + }; + db.Insert(stuScoreEntity); + } + #endregion + } + } + + } + db.Commit(); + return Result = "设置教师成功"; + } + catch (Exception ex) + { + db.Rollback(); + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } #endregion } }