diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/ElectiveMajorController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/ElectiveMajorController.cs index cc91e6b22..5053d733e 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/ElectiveMajorController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/ElectiveMajorController.cs @@ -89,9 +89,9 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers /// [HttpPost] [AjaxOnly] - public ActionResult DeleteForm(string keyValue) + public ActionResult DeleteForm(string keyValue, string OLPOEId) { - electiveMajorIBLL.DeleteEntity(keyValue); + electiveMajorIBLL.BatchDeleteEntity(keyValue, OLPOEId); return Success("删除成功!"); } /// diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/OpenLessonPlanOfElectiveController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/OpenLessonPlanOfElectiveController.cs index 03e98533b..fc3cf5d91 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/OpenLessonPlanOfElectiveController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/OpenLessonPlanOfElectiveController.cs @@ -405,6 +405,20 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers return Success("保存成功!"); } + + /// + /// 选修课课程--判断是否可以批量管理专业 + /// + /// + [HttpPost] + public ActionResult IsBatchEditMajor(string data) + { + List list = data.ToObject>(); + var res = openLessonPlanOfElectiveIBLL.IsBatchEditMajor(list); + + return Success(res.flag); + } + #endregion #region 扩展数据 diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ElectiveMajor/Index.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ElectiveMajor/Index.js index 6839e2da6..082fc3948 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ElectiveMajor/Index.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ElectiveMajor/Index.js @@ -45,10 +45,11 @@ var bootstrap = function ($, learun) { // 删除 $('#lr_delete').on('click', function () { var keyValue = $('#gridtablemanagemajor').jfGridValue('ElectiveMajorId'); + //console.log(OLPOEId); if (learun.checkrow(keyValue)) { learun.layerConfirm('是否确认删除该项!', function (res) { if (res) { - learun.deleteForm(top.$.rootUrl + '/EducationalAdministration/ElectiveMajor/DeleteForm', { keyValue: keyValue }, function () { + learun.deleteForm(top.$.rootUrl + '/EducationalAdministration/ElectiveMajor/DeleteForm', { keyValue: keyValue, OLPOEId: OLPOEId }, function () { refreshGirdData(); }); } diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/OpenLessonPlanOfElective/MergeIndex.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/OpenLessonPlanOfElective/MergeIndex.js index 7bc826a3b..cbbbfd8e5 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/OpenLessonPlanOfElective/MergeIndex.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/OpenLessonPlanOfElective/MergeIndex.js @@ -50,17 +50,41 @@ var bootstrap = function ($, learun) { $('#lr_editMajor').on('click', function () { var keyValue = $('#gridtable').jfGridValue('Id'); if (learun.checkrow(keyValue)) { - learun.layerForm({ - id: 'formmajor', - title: '管理选课专业', - url: top.$.rootUrl + '/EducationalAdministration/ElectiveMajor/Index?OLPOEId=' + keyValue, - width: 1000, - height: 700, - //btn: null - callBack: function (id) { - return top[id].acceptClick(refreshGirdData); + var rowdata = $('#gridtable').jfGridGet('rowdata'); + //判断选中记录是否可以批量管理专业 + $.ajax({ + url: top.$.rootUrl + '/EducationalAdministration/OpenLessonPlanOfElective/IsBatchEditMajor', + data: { data: JSON.stringify(rowdata) }, + type: "post", + dataType: "json", + async: false, + cache: false, + success: function (data) { + if (data.data == true) { + learun.layerForm({ + id: 'formmajor', + title: '管理选课专业', + url: top.$.rootUrl + '/EducationalAdministration/ElectiveMajor/Index?OLPOEId=' + keyValue, + width: 1000, + height: 700, + //btn: null + callBack: function (id) { + return top[id].acceptClick(refreshGirdData); + } + }); + } else { + return learun.alert.warning('只有同学期同课程支持批量管理专业!'); + } + }, + error: function (XMLHttpRequest, textStatus, errorThrown) { + learun.httpErrorLog(textStatus); + }, + beforeSend: function () { + }, + complete: function () { } }); + } }); @@ -76,7 +100,7 @@ var bootstrap = function ($, learun) { return top[id].acceptClick(refreshGirdData); } }); - + }); //设置人数 @@ -187,7 +211,7 @@ var bootstrap = function ($, learun) { }); } }); - + //初始化学生选课记录 $('#lr_initStuSelectLesson').on('click', function () { var keyValue = $('#gridtable').jfGridValue('Id'); @@ -301,6 +325,7 @@ var bootstrap = function ($, learun) { ], mainId: 'Id', isPage: true, + isMultiselect: true, sidx: 'AcademicYearNo DESC, Semester DESC, LessonName ASC', sord: 'desc' }); diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ElectiveMajor/ElectiveMajorBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ElectiveMajor/ElectiveMajorBLL.cs index f1500704b..45fbd175d 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ElectiveMajor/ElectiveMajorBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ElectiveMajor/ElectiveMajorBLL.cs @@ -117,6 +117,25 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } + public void BatchDeleteEntity(string keyValue, string OLPOEId) + { + try + { + electiveMajorService.BatchDeleteEntity(keyValue, OLPOEId); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } + /// /// 保存实体数据(新增、修改) /// 主键 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ElectiveMajor/ElectiveMajorIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ElectiveMajor/ElectiveMajorIBLL.cs index 071f83bca..6cbe846fd 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ElectiveMajor/ElectiveMajorIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ElectiveMajor/ElectiveMajorIBLL.cs @@ -44,6 +44,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration /// /// void DeleteEntity(string keyValue); + void BatchDeleteEntity(string keyValue, string OLPOEId); /// /// 保存实体数据(新增、修改) /// 主键 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ElectiveMajor/ElectiveMajorService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ElectiveMajor/ElectiveMajorService.cs index 06ac6763b..aaaf96a99 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ElectiveMajor/ElectiveMajorService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ElectiveMajor/ElectiveMajorService.cs @@ -37,8 +37,45 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration var dp = new DynamicParameters(new { }); if (!queryParam["OLPOEId"].IsEmpty()) { - dp.Add("OLPOEId", queryParam["OLPOEId"].ToString(), DbType.String); - strSql.Append(" AND a.OLPOEId = @OLPOEId "); + if (queryParam["OLPOEId"].ToString().Contains(",")) + { + //判断批量管理专业时 原先的专业是否一致。如果一致,显示列表,如果不一致,不显示 + var OLPOEId_arr = queryParam["OLPOEId"].ToString().Split(','); + var OLPOEIdfirst = OLPOEId_arr[0]; + var listfirst = this.BaseRepository("CollegeMIS") + .FindList($@"SELECT t.MajorNo+a.Grade as Id,t.MajorNo,a.Grade FROM ElectiveMajor a left join CdMajor t on a.majorid=t.id + WHERE 1=1 and t.checkmark=1 AND a.OLPOEId ='{OLPOEIdfirst}'").ToList(); + bool flag = true; + foreach (var OLPOEId in OLPOEId_arr) + { + if (OLPOEId != OLPOEIdfirst) + { + var list = this.BaseRepository("CollegeMIS") + .FindList($@"SELECT t.MajorNo+a.Grade as Id,t.MajorNo,a.Grade FROM ElectiveMajor a left join CdMajor t on a.majorid=t.id + WHERE 1=1 and t.checkmark=1 AND a.OLPOEId ='{OLPOEId}'").ToList(); + var Except1 = listfirst.Except(list, new ItemComparer()); + var Except2 = list.Except(listfirst, new ItemComparer()); + if (Except1.Count() > 0 || Except2.Count() > 0) + { + strSql.Append(" AND a.OLPOEId = '' "); + flag = false; + break; + } + } + + } + + if (flag) + { + strSql.Append($" AND a.OLPOEId = '{OLPOEIdfirst}' "); + } + } + else + { + dp.Add("OLPOEId", queryParam["OLPOEId"].ToString(), DbType.String); + strSql.Append(" AND a.OLPOEId = @OLPOEId "); + } + } if (!queryParam["MajorNo"].IsEmpty()) { @@ -172,6 +209,61 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } + /// + /// 批量删除 + /// + /// + /// + public void BatchDeleteEntity(string keyValue, string OLPOEId) + { + var db = this.BaseRepository("CollegeMIS"); + try + { + db.BeginTrans(); + if (OLPOEId.IndexOf(",") == -1) + { + if (keyValue.IndexOf(",") == -1) + { + db.Delete(x => x.Id == keyValue); + } + else + { + //多个删除 + var keyValueArr = keyValue.Split(','); + foreach (var item in keyValueArr) + { + db.Delete(t => t.Id == item); + } + } + } + else + { + var OLPOEIds = string.Join("','", OLPOEId.Split(',')); + var keyValueArr = keyValue.Split(','); + foreach (var item in keyValueArr) + { + var entity = db.FindEntity(item); + db.ExecuteBySql($"delete from ElectiveMajor where MajorId='{entity.MajorId}' and Grade='{entity.Grade}' and OLPOEId in ('{OLPOEIds}')"); + } + } + + + db.Commit(); + } + catch (Exception ex) + { + db.Rollback(); + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } + /// /// 保存实体数据(新增、修改) /// 主键 @@ -262,22 +354,28 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration { var now = DateTime.Now; var loginInfo = LoginUserInfo.Get(); - var list = db.FindList(x => x.OLPOEId == olpoeId); + + var OLPOEId_arr = olpoeId.Split(','); //添加 foreach (var item in dataList) { - //判断是否已选 - if (list.Where(x => x.MajorId == item.ID && x.Grade == item.Grade).Count() <= 0) + for (int i = 0; i < OLPOEId_arr.Length; i++) { - var entity = new ElectiveMajorEntity(); - entity.Create(); - entity.OLPOEId = olpoeId; - entity.MajorId = item.ID; - entity.Grade = item.Grade; - entity.CreateUserId = loginInfo.userId; - entity.CreateUserName = loginInfo.realName; - entity.CreateDate = now; - db.Insert(entity); + var OLPOEId = OLPOEId_arr[i]; + var list = db.FindList(x => x.OLPOEId == OLPOEId); + //判断是否已选 + if (list.Where(x => x.MajorId == item.ID && x.Grade == item.Grade).Count() <= 0) + { + var entity = new ElectiveMajorEntity(); + entity.Create(); + entity.OLPOEId = OLPOEId;//olpoeId; + entity.MajorId = item.ID; + entity.Grade = item.Grade; + entity.CreateUserId = loginInfo.userId; + entity.CreateUserName = loginInfo.realName; + entity.CreateDate = now; + db.Insert(entity); + } } } db.Commit(); @@ -298,5 +396,26 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration #endregion + public class ElecticeMajorEntity + { + public string Id { get; set; } + public string MajorNo { get; set; } + public string Grade { get; set; } + } + public class ItemComparer : IEqualityComparer + { + public bool Equals(ElecticeMajorEntity x, ElecticeMajorEntity y) + { + if (x.Id == y.Id) + return true; + + return false; + } + + public int GetHashCode(ElecticeMajorEntity obj) + { + return obj.Id.GetHashCode(); + } + } } } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/OpenLessonPlanOfElective/OpenLessonPlanOfElectiveBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/OpenLessonPlanOfElective/OpenLessonPlanOfElectiveBLL.cs index 0b6632323..406368783 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/OpenLessonPlanOfElective/OpenLessonPlanOfElectiveBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/OpenLessonPlanOfElective/OpenLessonPlanOfElectiveBLL.cs @@ -253,6 +253,25 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } } + + public (bool flag, string str) IsBatchEditMajor(List list) + { + try + { + return openLessonPlanOfElectiveService.IsBatchEditMajor(list); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } #endregion #region 扩展数据 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/OpenLessonPlanOfElective/OpenLessonPlanOfElectiveIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/OpenLessonPlanOfElective/OpenLessonPlanOfElectiveIBLL.cs index 28607fca3..9748d12a2 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/OpenLessonPlanOfElective/OpenLessonPlanOfElectiveIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/OpenLessonPlanOfElective/OpenLessonPlanOfElectiveIBLL.cs @@ -72,6 +72,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration void AddForm(string keyValue, OpenLessonPlanOfElectiveEntity entity); void SaveFormOfElective(string keyValue, OpenLessonPlanOfElectiveEntity entity); + (bool flag,string str) IsBatchEditMajor(List list); #endregion diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/OpenLessonPlanOfElective/OpenLessonPlanOfElectiveService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/OpenLessonPlanOfElective/OpenLessonPlanOfElectiveService.cs index 091e191f3..493cddb47 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/OpenLessonPlanOfElective/OpenLessonPlanOfElectiveService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/OpenLessonPlanOfElective/OpenLessonPlanOfElectiveService.cs @@ -312,16 +312,16 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration var AcademicYearNo = queryParam["AcademicYearNo"].ToString(); var Semester = queryParam["Semester"].ToString(); var LessonNo = queryParam["LessonNo"].ToString(); - var LessonSection =queryParam["LessonSection"].ToString(); + var LessonSection = queryParam["LessonSection"].ToString(); var ClassRoomNo = queryParam["ClassRoomNo"].ToString(); - + var classInfoEntity = this.BaseRepository("CollegeMIS").FindEntity(x => x.ClassroomNo == ClassRoomNo); if (classInfoEntity == null) { return new OpenLessonPlanOfElectiveEntity(); } - return this.BaseRepository("CollegeMIS").FindEntity(x => x.F_SchoolId == F_SchoolId && x.AcademicYearNo == AcademicYearNo && x.Semester == Semester && x.ClassRoomNo == classInfoEntity.ClassroomNo && x.LessonSection == LessonSection && x.LessonNo == LessonNo && x.LessonSortNo == "2"); + return this.BaseRepository("CollegeMIS").FindEntity(x => x.F_SchoolId == F_SchoolId && x.AcademicYearNo == AcademicYearNo && x.Semester == Semester && x.ClassRoomNo == classInfoEntity.ClassroomNo && x.LessonSection == LessonSection && x.LessonNo == LessonNo && x.LessonSortNo == "2"); } catch (Exception ex) { @@ -359,7 +359,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration return new StuSelectLessonListOfElectiveEntity(); } - return this.BaseRepository("CollegeMIS").FindEntity(x => x.F_SchoolId == F_SchoolId && x.AcademicYearNo == AcademicYearNo && x.Semester == Semester && x.LessonNo == LessonNo && x.LessonSortNo == "2" && x.ClassRoomNo == ClassRoomNo && x.LessonSection == LessonSection); + return this.BaseRepository("CollegeMIS").FindEntity(x => x.F_SchoolId == F_SchoolId && x.AcademicYearNo == AcademicYearNo && x.Semester == Semester && x.LessonNo == LessonNo && x.LessonSortNo == "2" && x.ClassRoomNo == ClassRoomNo && x.LessonSection == LessonSection); } catch (Exception ex) { @@ -562,6 +562,39 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } } + + /// + /// 选修课课程--判断是否可以批量管理专业 + /// + /// + /// + public (bool flag, string str) IsBatchEditMajor(List list) + { + try + { + if (list.Select(x => x.AcademicYearNo).Distinct().Count() == 1 && list.Select(x => x.Semester).Distinct().Count() == 1 && + list.Select(x => x.LessonNo).Distinct().Count() == 1) + { + return (true, ""); + } + else + { + return (false, ""); + } + + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } #endregion #region 扩展数据 @@ -804,7 +837,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration db.ExecuteBySql("update OpenLessonPlanOfElective set OrdinaryScoreScale=" + entity.OrdinaryScoreScale + ",TermInScoreScale=" + entity.TermInScoreScale + ",TermEndScoreScale=" + entity.TermEndScoreScale + ",OtherScoreScale=" + entity.OtherScoreScale + " where F_SchoolId='" + F_SchoolId + "' and AcademicYearNo='" + AcademicYearNo + "' and Semester='" + Semester + "' and LessonSection='" + LessonSection + "' and ClassroomNo='" + classInfoEntity.ClassroomNo + "' and LessonNo='" + LessonNo + "' and LessonSortNo='2' "); //修改StuScore中的成绩 - var beforeList = db.FindList(x => x.F_SchoolId == F_SchoolId && x.AcademicYearNo == AcademicYearNo && x.Semester == Semester && x.ClassRoomNo == classInfoEntity.ClassroomNo && x.LessonNo == LessonNo && x.LessonSortNo == "2" && x.LessonSection == LessonSection); + var beforeList = db.FindList(x => x.F_SchoolId == F_SchoolId && x.AcademicYearNo == AcademicYearNo && x.Semester == Semester && x.ClassRoomNo == classInfoEntity.ClassroomNo && x.LessonNo == LessonNo && x.LessonSortNo == "2" && x.LessonSection == LessonSection); if (beforeList.Any()) { foreach (var stuScoreItem in beforeList)