diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Controllers/AccommodationController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Controllers/AccommodationController.cs index 5dd7d85e7..24e3ad8cf 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Controllers/AccommodationController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Controllers/AccommodationController.cs @@ -463,7 +463,12 @@ namespace Learun.Application.Web.Areas.LogisticsManagement.Controllers public ActionResult SaveRoom(string RoomId, List list) { //List list = strEntity.ToObject>(); - accommodationIBLL.SaveRoom(RoomId, list); + string res = accommodationIBLL.SaveRoom(RoomId, list); + if (!string.IsNullOrEmpty(res)) + { + return Fail(res); + } + return Success("保存成功!"); } diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/FormRoom.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/FormRoom.js index edc8a2238..be042398a 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/FormRoom.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/FormRoom.js @@ -18,7 +18,7 @@ var bootstrap = function ($, learun) { page.initData(); }, bind: function () { - + }, initData: function () { if (!!keyValue) { @@ -51,16 +51,16 @@ var bootstrap = function ($, learun) { value: "stuno", text: "stuname", url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable', - param: { code: "StuInfoBasic", strWhere: strWhere }, + param: { code: "StuInfoBasic", strWhere: strWhere }, // 是否允许搜索 allowSearch: true, select: function (item) { - // console.log(item); + // console.log(item); var stuid = ''; if (item) { stuid = item.stuno; - } + } var id = $(this).attr('id'); //console.log('id', id); //console.log('item',item); @@ -78,9 +78,9 @@ var bootstrap = function ($, learun) { //arr.push({ ID: data[i].ID, StudentID: data[i].StudentID }); } - - - + + + }); } }, @@ -93,8 +93,14 @@ var bootstrap = function ($, learun) { //var postData = { // strEntity: JSON.stringify($('body').lrGetFormData()) //}; - //console.log('arr',arr); - + //console.log('arr', arr); + for (var i = 0; i < arr.length - 1; i++) { + for (var j = i + 1; j < arr.length; j++) { + if (!!arr[i].StudentID && arr[i].StudentID === arr[j].StudentID) { + return learun.alert.warning('学生不可重复!'); + } + } + } var postData = { list: arr }; diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationBLL.cs index d63fd9665..dcba8bb27 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationBLL.cs @@ -681,11 +681,11 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement } } - public void SaveRoom(string RoomId, List list) + public string SaveRoom(string RoomId, List list) { try { - accommodationService.SaveRoom(RoomId, list); + return accommodationService.SaveRoom(RoomId, list); } catch (Exception ex) { diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationIBLL.cs index 0f72b5a99..09ccf1e2c 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationIBLL.cs @@ -83,7 +83,7 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement void SaveEntity(string keyValue, Acc_DormitoryBuildEntity entity); void SaveBedEntity(string keyValue,string ParentID, Acc_DormitoryBuildEntity entity); void SaveDeptClass(string keyValue, Acc_DormitoryBuildEntity entity,int type); - void SaveRoom(string RoomId, List list); + string SaveRoom(string RoomId, List list); /// /// 批量添加单元、楼层、房间、床位 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationService.cs index b2508a78b..b184d56f2 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationService.cs @@ -1721,13 +1721,25 @@ where ID='{ParentID}' /// /// /// - public void SaveRoom(string RoomId, List list) + public string SaveRoom(string RoomId, List list) { var db = this.BaseRepository("CollegeMIS").BeginTrans(); try { foreach (var entity in list) { + //判断该学生是否已分配 + if (!string.IsNullOrEmpty(entity.StudentID)) + { + var count = db.FindList().Count(x => x.StudentID == entity.StudentID && x.ID != entity.ID); + if (count > 0) + { + var stuname = db.FindEntity(x => x.StuNo == entity.StudentID)?.StuName; + return "学生" + stuname + "已分配床位,不可重复分配!"; + } + } + + //分配床位 string sql = $"update Acc_DormitoryBuild set StudentID='{entity.StudentID}' where ID='{entity.ID}'"; db.ExecuteBySql(sql); } @@ -1737,6 +1749,7 @@ where ID='{ParentID}' db.ExecuteBySql(checkInSql); db.Commit(); + return ""; } catch (Exception ex) {