@@ -463,7 +463,12 @@ namespace Learun.Application.Web.Areas.LogisticsManagement.Controllers | |||||
public ActionResult SaveRoom(string RoomId, List<Acc_DormitoryBuildEntity> list) | public ActionResult SaveRoom(string RoomId, List<Acc_DormitoryBuildEntity> list) | ||||
{ | { | ||||
//List<Acc_DormitoryBuildEntity> list = strEntity.ToObject<List<Acc_DormitoryBuildEntity>>(); | //List<Acc_DormitoryBuildEntity> list = strEntity.ToObject<List<Acc_DormitoryBuildEntity>>(); | ||||
accommodationIBLL.SaveRoom(RoomId, list); | |||||
string res = accommodationIBLL.SaveRoom(RoomId, list); | |||||
if (!string.IsNullOrEmpty(res)) | |||||
{ | |||||
return Fail(res); | |||||
} | |||||
return Success("保存成功!"); | return Success("保存成功!"); | ||||
} | } | ||||
@@ -18,7 +18,7 @@ var bootstrap = function ($, learun) { | |||||
page.initData(); | page.initData(); | ||||
}, | }, | ||||
bind: function () { | bind: function () { | ||||
}, | }, | ||||
initData: function () { | initData: function () { | ||||
if (!!keyValue) { | if (!!keyValue) { | ||||
@@ -51,16 +51,16 @@ var bootstrap = function ($, learun) { | |||||
value: "stuno", | value: "stuno", | ||||
text: "stuname", | text: "stuname", | ||||
url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable', | url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable', | ||||
param: { code: "StuInfoBasic", strWhere: strWhere }, | |||||
param: { code: "StuInfoBasic", strWhere: strWhere }, | |||||
// 是否允许搜索 | // 是否允许搜索 | ||||
allowSearch: true, | allowSearch: true, | ||||
select: function (item) { | select: function (item) { | ||||
// console.log(item); | |||||
// console.log(item); | |||||
var stuid = ''; | var stuid = ''; | ||||
if (item) { | if (item) { | ||||
stuid = item.stuno; | stuid = item.stuno; | ||||
} | |||||
} | |||||
var id = $(this).attr('id'); | var id = $(this).attr('id'); | ||||
//console.log('id', id); | //console.log('id', id); | ||||
//console.log('item',item); | //console.log('item',item); | ||||
@@ -78,9 +78,9 @@ var bootstrap = function ($, learun) { | |||||
//arr.push({ ID: data[i].ID, StudentID: data[i].StudentID }); | //arr.push({ ID: data[i].ID, StudentID: data[i].StudentID }); | ||||
} | } | ||||
}); | }); | ||||
} | } | ||||
}, | }, | ||||
@@ -93,8 +93,14 @@ var bootstrap = function ($, learun) { | |||||
//var postData = { | //var postData = { | ||||
// strEntity: JSON.stringify($('body').lrGetFormData()) | // 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 = { | var postData = { | ||||
list: arr | list: arr | ||||
}; | }; | ||||
@@ -680,11 +680,11 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement | |||||
} | } | ||||
} | } | ||||
public void SaveRoom(string RoomId, List<Acc_DormitoryBuildEntity> list) | |||||
public string SaveRoom(string RoomId, List<Acc_DormitoryBuildEntity> list) | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
accommodationService.SaveRoom(RoomId, list); | |||||
return accommodationService.SaveRoom(RoomId, list); | |||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
@@ -83,7 +83,7 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement | |||||
void SaveEntity(string keyValue, Acc_DormitoryBuildEntity entity); | void SaveEntity(string keyValue, Acc_DormitoryBuildEntity entity); | ||||
void SaveBedEntity(string keyValue,string ParentID, Acc_DormitoryBuildEntity entity); | void SaveBedEntity(string keyValue,string ParentID, Acc_DormitoryBuildEntity entity); | ||||
void SaveDeptClass(string keyValue, Acc_DormitoryBuildEntity entity,int type); | void SaveDeptClass(string keyValue, Acc_DormitoryBuildEntity entity,int type); | ||||
void SaveRoom(string RoomId, List<Acc_DormitoryBuildEntity> list); | |||||
string SaveRoom(string RoomId, List<Acc_DormitoryBuildEntity> list); | |||||
/// <summary> | /// <summary> | ||||
/// 批量添加单元、楼层、房间、床位 | /// 批量添加单元、楼层、房间、床位 | ||||
@@ -1721,13 +1721,25 @@ where ID='{ParentID}' | |||||
/// </summary> | /// </summary> | ||||
/// <param name="RoomId"></param> | /// <param name="RoomId"></param> | ||||
/// <param name="list"></param> | /// <param name="list"></param> | ||||
public void SaveRoom(string RoomId, List<Acc_DormitoryBuildEntity> list) | |||||
public string SaveRoom(string RoomId, List<Acc_DormitoryBuildEntity> list) | |||||
{ | { | ||||
var db = this.BaseRepository("CollegeMIS").BeginTrans(); | var db = this.BaseRepository("CollegeMIS").BeginTrans(); | ||||
try | try | ||||
{ | { | ||||
foreach (var entity in list) | foreach (var entity in list) | ||||
{ | { | ||||
//判断该学生是否已分配 | |||||
if (!string.IsNullOrEmpty(entity.StudentID)) | |||||
{ | |||||
var count = db.FindList<Acc_DormitoryBuildEntity>().Count(x => x.StudentID == entity.StudentID && x.ID != entity.ID); | |||||
if (count > 0) | |||||
{ | |||||
var stuname = db.FindEntity<StuInfoBasicEntity>(x => x.StuNo == entity.StudentID)?.StuName; | |||||
return "学生" + stuname + "已分配床位,不可重复分配!"; | |||||
} | |||||
} | |||||
//分配床位 | |||||
string sql = $"update Acc_DormitoryBuild set StudentID='{entity.StudentID}' where ID='{entity.ID}'"; | string sql = $"update Acc_DormitoryBuild set StudentID='{entity.StudentID}' where ID='{entity.ID}'"; | ||||
db.ExecuteBySql(sql); | db.ExecuteBySql(sql); | ||||
} | } | ||||
@@ -1737,6 +1749,7 @@ where ID='{ParentID}' | |||||
db.ExecuteBySql(checkInSql); | db.ExecuteBySql(checkInSql); | ||||
db.Commit(); | db.Commit(); | ||||
return ""; | |||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||