@@ -89,9 +89,9 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers | |||||
/// <returns></returns> | /// <returns></returns> | ||||
[HttpPost] | [HttpPost] | ||||
[AjaxOnly] | [AjaxOnly] | ||||
public ActionResult DeleteForm(string keyValue) | |||||
public ActionResult DeleteForm(string keyValue, string OLPOEId) | |||||
{ | { | ||||
electiveMajorIBLL.DeleteEntity(keyValue); | |||||
electiveMajorIBLL.BatchDeleteEntity(keyValue, OLPOEId); | |||||
return Success("删除成功!"); | return Success("删除成功!"); | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -405,6 +405,20 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers | |||||
return Success("保存成功!"); | return Success("保存成功!"); | ||||
} | } | ||||
/// <summary> | |||||
/// 选修课课程--判断是否可以批量管理专业 | |||||
/// <summary> | |||||
/// <returns></returns> | |||||
[HttpPost] | |||||
public ActionResult IsBatchEditMajor(string data) | |||||
{ | |||||
List<OpenLessonPlanOfElectiveEntity> list = data.ToObject<List<OpenLessonPlanOfElectiveEntity>>(); | |||||
var res = openLessonPlanOfElectiveIBLL.IsBatchEditMajor(list); | |||||
return Success(res.flag); | |||||
} | |||||
#endregion | #endregion | ||||
#region 扩展数据 | #region 扩展数据 | ||||
@@ -45,10 +45,11 @@ var bootstrap = function ($, learun) { | |||||
// 删除 | // 删除 | ||||
$('#lr_delete').on('click', function () { | $('#lr_delete').on('click', function () { | ||||
var keyValue = $('#gridtablemanagemajor').jfGridValue('ElectiveMajorId'); | var keyValue = $('#gridtablemanagemajor').jfGridValue('ElectiveMajorId'); | ||||
//console.log(OLPOEId); | |||||
if (learun.checkrow(keyValue)) { | if (learun.checkrow(keyValue)) { | ||||
learun.layerConfirm('是否确认删除该项!', function (res) { | learun.layerConfirm('是否确认删除该项!', function (res) { | ||||
if (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(); | refreshGirdData(); | ||||
}); | }); | ||||
} | } | ||||
@@ -50,17 +50,41 @@ var bootstrap = function ($, learun) { | |||||
$('#lr_editMajor').on('click', function () { | $('#lr_editMajor').on('click', function () { | ||||
var keyValue = $('#gridtable').jfGridValue('Id'); | var keyValue = $('#gridtable').jfGridValue('Id'); | ||||
if (learun.checkrow(keyValue)) { | 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); | return top[id].acceptClick(refreshGirdData); | ||||
} | } | ||||
}); | }); | ||||
}); | }); | ||||
//设置人数 | //设置人数 | ||||
@@ -187,7 +211,7 @@ var bootstrap = function ($, learun) { | |||||
}); | }); | ||||
} | } | ||||
}); | }); | ||||
//初始化学生选课记录 | //初始化学生选课记录 | ||||
$('#lr_initStuSelectLesson').on('click', function () { | $('#lr_initStuSelectLesson').on('click', function () { | ||||
var keyValue = $('#gridtable').jfGridValue('Id'); | var keyValue = $('#gridtable').jfGridValue('Id'); | ||||
@@ -301,6 +325,7 @@ var bootstrap = function ($, learun) { | |||||
], | ], | ||||
mainId: 'Id', | mainId: 'Id', | ||||
isPage: true, | isPage: true, | ||||
isMultiselect: true, | |||||
sidx: 'AcademicYearNo DESC, Semester DESC, LessonName ASC', | sidx: 'AcademicYearNo DESC, Semester DESC, LessonName ASC', | ||||
sord: 'desc' | sord: 'desc' | ||||
}); | }); | ||||
@@ -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); | |||||
} | |||||
} | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// 保存实体数据(新增、修改) | /// 保存实体数据(新增、修改) | ||||
/// <param name="keyValue">主键</param> | /// <param name="keyValue">主键</param> | ||||
@@ -44,6 +44,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
/// <summary> | /// <summary> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
void DeleteEntity(string keyValue); | void DeleteEntity(string keyValue); | ||||
void BatchDeleteEntity(string keyValue, string OLPOEId); | |||||
/// <summary> | /// <summary> | ||||
/// 保存实体数据(新增、修改) | /// 保存实体数据(新增、修改) | ||||
/// <param name="keyValue">主键</param> | /// <param name="keyValue">主键</param> | ||||
@@ -37,8 +37,45 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
var dp = new DynamicParameters(new { }); | var dp = new DynamicParameters(new { }); | ||||
if (!queryParam["OLPOEId"].IsEmpty()) | 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<ElecticeMajorEntity>($@"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<ElecticeMajorEntity>($@"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()) | if (!queryParam["MajorNo"].IsEmpty()) | ||||
{ | { | ||||
@@ -172,6 +209,61 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
} | } | ||||
} | } | ||||
/// <summary> | |||||
/// 批量删除 | |||||
/// </summary> | |||||
/// <param name="keyValue"></param> | |||||
/// <param name="OLPOEId"></param> | |||||
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<ElectiveMajorEntity>(x => x.Id == keyValue); | |||||
} | |||||
else | |||||
{ | |||||
//多个删除 | |||||
var keyValueArr = keyValue.Split(','); | |||||
foreach (var item in keyValueArr) | |||||
{ | |||||
db.Delete<ElectiveMajorEntity>(t => t.Id == item); | |||||
} | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
var OLPOEIds = string.Join("','", OLPOEId.Split(',')); | |||||
var keyValueArr = keyValue.Split(','); | |||||
foreach (var item in keyValueArr) | |||||
{ | |||||
var entity = db.FindEntity<ElectiveMajorEntity>(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); | |||||
} | |||||
} | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// 保存实体数据(新增、修改) | /// 保存实体数据(新增、修改) | ||||
/// <param name="keyValue">主键</param> | /// <param name="keyValue">主键</param> | ||||
@@ -262,22 +354,28 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
{ | { | ||||
var now = DateTime.Now; | var now = DateTime.Now; | ||||
var loginInfo = LoginUserInfo.Get(); | var loginInfo = LoginUserInfo.Get(); | ||||
var list = db.FindList<ElectiveMajorEntity>(x => x.OLPOEId == olpoeId); | |||||
var OLPOEId_arr = olpoeId.Split(','); | |||||
//添加 | //添加 | ||||
foreach (var item in dataList) | 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<ElectiveMajorEntity>(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(); | db.Commit(); | ||||
@@ -298,5 +396,26 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
#endregion | #endregion | ||||
public class ElecticeMajorEntity | |||||
{ | |||||
public string Id { get; set; } | |||||
public string MajorNo { get; set; } | |||||
public string Grade { get; set; } | |||||
} | |||||
public class ItemComparer : IEqualityComparer<ElecticeMajorEntity> | |||||
{ | |||||
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(); | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -253,6 +253,25 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
} | } | ||||
} | } | ||||
} | } | ||||
public (bool flag, string str) IsBatchEditMajor(List<OpenLessonPlanOfElectiveEntity> list) | |||||
{ | |||||
try | |||||
{ | |||||
return openLessonPlanOfElectiveService.IsBatchEditMajor(list); | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
if (ex is ExceptionEx) | |||||
{ | |||||
throw; | |||||
} | |||||
else | |||||
{ | |||||
throw ExceptionEx.ThrowBusinessException(ex); | |||||
} | |||||
} | |||||
} | |||||
#endregion | #endregion | ||||
#region 扩展数据 | #region 扩展数据 | ||||
@@ -72,6 +72,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
void AddForm(string keyValue, OpenLessonPlanOfElectiveEntity entity); | void AddForm(string keyValue, OpenLessonPlanOfElectiveEntity entity); | ||||
void SaveFormOfElective(string keyValue, OpenLessonPlanOfElectiveEntity entity); | void SaveFormOfElective(string keyValue, OpenLessonPlanOfElectiveEntity entity); | ||||
(bool flag,string str) IsBatchEditMajor(List<OpenLessonPlanOfElectiveEntity> list); | |||||
#endregion | #endregion | ||||
@@ -312,16 +312,16 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
var AcademicYearNo = queryParam["AcademicYearNo"].ToString(); | var AcademicYearNo = queryParam["AcademicYearNo"].ToString(); | ||||
var Semester = queryParam["Semester"].ToString(); | var Semester = queryParam["Semester"].ToString(); | ||||
var LessonNo = queryParam["LessonNo"].ToString(); | var LessonNo = queryParam["LessonNo"].ToString(); | ||||
var LessonSection =queryParam["LessonSection"].ToString(); | |||||
var LessonSection = queryParam["LessonSection"].ToString(); | |||||
var ClassRoomNo = queryParam["ClassRoomNo"].ToString(); | var ClassRoomNo = queryParam["ClassRoomNo"].ToString(); | ||||
var classInfoEntity = this.BaseRepository("CollegeMIS").FindEntity<ClassroomInfoEntity>(x => x.ClassroomNo == ClassRoomNo); | var classInfoEntity = this.BaseRepository("CollegeMIS").FindEntity<ClassroomInfoEntity>(x => x.ClassroomNo == ClassRoomNo); | ||||
if (classInfoEntity == null) | if (classInfoEntity == null) | ||||
{ | { | ||||
return new OpenLessonPlanOfElectiveEntity(); | return new OpenLessonPlanOfElectiveEntity(); | ||||
} | } | ||||
return this.BaseRepository("CollegeMIS").FindEntity<OpenLessonPlanOfElectiveEntity>(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<OpenLessonPlanOfElectiveEntity>(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) | catch (Exception ex) | ||||
{ | { | ||||
@@ -359,7 +359,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
return new StuSelectLessonListOfElectiveEntity(); | return new StuSelectLessonListOfElectiveEntity(); | ||||
} | } | ||||
return this.BaseRepository("CollegeMIS").FindEntity<StuSelectLessonListOfElectiveEntity>(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<StuSelectLessonListOfElectiveEntity>(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) | catch (Exception ex) | ||||
{ | { | ||||
@@ -562,6 +562,39 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
} | } | ||||
} | } | ||||
} | } | ||||
/// <summary> | |||||
/// 选修课课程--判断是否可以批量管理专业 | |||||
/// </summary> | |||||
/// <param name="list"></param> | |||||
/// <returns></returns> | |||||
public (bool flag, string str) IsBatchEditMajor(List<OpenLessonPlanOfElectiveEntity> 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 | #endregion | ||||
#region 扩展数据 | #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' "); | 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中的成绩 | //修改StuScore中的成绩 | ||||
var beforeList = db.FindList<StuScoreEntity>(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<StuScoreEntity>(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()) | if (beforeList.Any()) | ||||
{ | { | ||||
foreach (var stuScoreItem in beforeList) | foreach (var stuScoreItem in beforeList) | ||||