From 3351d07c2a64ee9fb5a39957d2630fc52af75a0c Mon Sep 17 00:00:00 2001 From: zhangli <1109134334@qq.com> Date: Tue, 19 Oct 2021 17:18:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=99=E5=AD=A6=E8=AE=A1=E5=88=92=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E6=98=8E=E7=BB=86=E5=92=8C=E6=9F=A5=E7=9C=8B=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/TeachingPlanController.cs | 16 +- .../Views/TeachingPlan/FormManage.js | 55 +++--- .../Views/TeachingPlan/FormManageView.cshtml | 38 ++++ .../Views/TeachingPlan/FormManageView.js | 165 ++++++++++++++++++ .../Views/TeachingPlan/IndexManage.js | 36 ++-- .../Views/TeachingPlanItem/Form.cshtml | 25 +-- .../Views/TeachingPlanItem/Form.js | 67 +++++-- .../Learun.Application.Web.csproj | 2 + .../TeachingPlan/TeachingPlanBLL.cs | 4 +- .../TeachingPlan/TeachingPlanIBLL.cs | 2 +- .../TeachingPlan/TeachingPlanService.cs | 34 ++-- 11 files changed, 355 insertions(+), 89 deletions(-) create mode 100644 Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlan/FormManageView.cshtml create mode 100644 Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlan/FormManageView.js diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/TeachingPlanController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/TeachingPlanController.cs index ce18928b8..2baa81d55 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/TeachingPlanController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/TeachingPlanController.cs @@ -56,7 +56,16 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers { return View(); } - + /// + /// 教学计划和课程设置--查看 + /// + /// + [HttpGet] + public ActionResult FormManageView() + { + return View(); + } + #endregion #region 获取数据 @@ -148,10 +157,11 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers [HttpPost] [ValidateAntiForgeryToken] [AjaxOnly] - public ActionResult SaveForm(string keyValue, string strEntity) + public ActionResult SaveForm(string keyValue, string strEntity,string TeachingPlanItemList) { TeachingPlanEntity entity = strEntity.ToObject(); - teachingPlanIBLL.SaveEntity(keyValue, entity); + List teachingPlanItemList = TeachingPlanItemList.ToObject>(); + teachingPlanIBLL.SaveEntity(keyValue, entity, teachingPlanItemList); if (string.IsNullOrEmpty(keyValue)) { } diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlan/FormManage.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlan/FormManage.js index 8904573d1..4ef2c76d7 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlan/FormManage.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlan/FormManage.js @@ -28,8 +28,8 @@ var bootstrap = function ($, learun) { id: 'form_TeachingPlanItem', title: '编辑明细', url: top.$.rootUrl + '/EducationalAdministration/TeachingPlanItem/Form?keyValue=' + keyValue, - width: 860, - height: 580, + width: 650, + height: 430, callBack: function (id) { return top[id].acceptClick(refreshGirdData); } @@ -48,7 +48,7 @@ var bootstrap = function ($, learun) { maxHeight: 200 }); - $('#Major').lrDataSourceSelect({ code: 'CdMajorInfo', value: 'majorno',text: 'majorname' }); + $('#Major').lrDataSourceSelect({ code: 'CdMajorInfo', value: 'majorno', text: 'majorname' }); $('#Enabled').lrRadioCheckbox({ type: 'radio', code: 'YesOrNoBit', @@ -69,7 +69,7 @@ var bootstrap = function ($, learun) { } }, { - label: '课程学时', name: 'CourseTime', width: 100, align: 'left' + label: '课程学时', name: 'LessonTime', width: 100, align: 'left' }, { label: '执行学期', name: 'Semester', width: 100, align: 'left' @@ -105,9 +105,10 @@ var bootstrap = function ($, learun) { } }; refreshGirdData = function (temprow) { + var ifnewrow = true; $.each(tempdatra, function (key, val) { - if (tempdatra[key].PAIId === temprow.PAIId) { + if (tempdatra[key].Id === temprow.Id) { tempdatra[key] = temprow; ifnewrow = false; } @@ -115,8 +116,8 @@ var bootstrap = function ($, learun) { if (ifnewrow) { tempdatra.push(temprow); } - $('#Ass_PurchaseItemApply').jfGridSet('refreshdata', tempdatra); - + $('#TeachingPlanItem').jfGridSet('refreshdata', tempdatra); + }; // 验证数据是否填写完整 @@ -124,25 +125,39 @@ var bootstrap = function ($, learun) { if (!$('.lr-form-wrap').lrValidform()) { return false; } - var datas = $('#Ass_PurchaseItemApply').jfGridGet('rowdatas'); - if (datas == null || datas.length == 0) { - learun.alert.warning("申请未包含明细!请先新增明细!"); - return false; - } + //var datas = $('#TeachingPlanItem').jfGridGet('rowdatas'); + //if (datas == null || datas.length == 0) { + // learun.alert.warning("申请未包含明细!请先新增明细!"); + // return false; + //} return true; }; + //// 保存数据 + //acceptClick = function (callBack) { + // if (!$('body').lrValidform()) { + // return false; + // } + // var postData = { + // strEntity: JSON.stringify($('body').lrGetFormData()) + // }; + // $.lrSaveForm(top.$.rootUrl + '/EducationalAdministration/TeachingPlan/SaveForm?keyValue=' + keyValue, postData, function (res) { + // // 保存成功后才回调 + // if (!!callBack) { + // callBack(); + // } + // }); + //}; // 保存数据 - acceptClick = function (callBack) { - if (!$('body').lrValidform()) { - return false; - } - var postData = { - strEntity: JSON.stringify($('body').lrGetFormData()) - }; + save = function (callBack, i) { + var postData = {}; + var formData = $('[data-table="TeachingPlan"]').lrGetFormData(); + + postData.strEntity = JSON.stringify(formData); + postData.TeachingPlanItemList = JSON.stringify($('#TeachingPlanItem').jfGridGet('rowdatas')); $.lrSaveForm(top.$.rootUrl + '/EducationalAdministration/TeachingPlan/SaveForm?keyValue=' + keyValue, postData, function (res) { // 保存成功后才回调 if (!!callBack) { - callBack(); + callBack(res, formData, i); } }); }; diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlan/FormManageView.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlan/FormManageView.cshtml new file mode 100644 index 000000000..c6a2c9082 --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlan/FormManageView.cshtml @@ -0,0 +1,38 @@ +@{ + ViewBag.Title = "教学计划"; + Layout = "~/Views/Shared/_Form.cshtml"; +} +
+
+
名称*
+ +
+
+
年级
+
+
+
+
专业
+
+
+
+
学制
+ +
+
+
总学分
+ +
+
+
启用
+
+
+
+
备注
+ +
+
+
+
+
+@Html.AppendJsFile("/Areas/EducationalAdministration/Views/TeachingPlan/FormManageView.js") diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlan/FormManageView.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlan/FormManageView.js new file mode 100644 index 000000000..4ef2c76d7 --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlan/FormManageView.js @@ -0,0 +1,165 @@ +/* * 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架(http://www.learun.cn) + * Copyright (c) 2013-2020 力软信息技术(苏州)有限公司 + * 创建人:超级管理员 + * 日 期:2021-10-14 10:09 + * 描 述:教学计划 + */ +var acceptClick; +var keyValue = request('keyValue'); +// 设置表单数据 +var setFormData; +// 验证数据是否填写完整 +var validForm; +// 保存数据 +var save; +var refreshGirdData; +var selectedRow; +var tempdatra = new Array(); +var bootstrap = function ($, learun) { + "use strict"; + var page = { + init: function () { + $('.lr-form-wrap').lrscroll(); + $("#detailedit").on('click', function () { + var keyValue = $('#TeachingPlanItem').jfGridValue('Id'); + selectedRow = $('#TeachingPlanItem').jfGridGet('rowdata'); + if (learun.checkrow(keyValue)) { + learun.layerForm({ + id: 'form_TeachingPlanItem', + title: '编辑明细', + url: top.$.rootUrl + '/EducationalAdministration/TeachingPlanItem/Form?keyValue=' + keyValue, + width: 650, + height: 430, + callBack: function (id) { + return top[id].acceptClick(refreshGirdData); + } + }); + } + }); + page.bind(); + page.initData(); + }, + bind: function () { + //年级 + $('#Grade').lrselect({ + url: top.$.rootUrl + '/EducationalAdministration/ClassInfo/GenerateNearByYear', + value: 'value', + text: 'text', + maxHeight: 200 + }); + + $('#Major').lrDataSourceSelect({ code: 'CdMajorInfo', value: 'majorno', text: 'majorname' }); + $('#Enabled').lrRadioCheckbox({ + type: 'radio', + code: 'YesOrNoBit', + }); + $('#TeachingPlanItem').jfGrid({ + headData: [ + { + label: '课程名称', name: 'LessonNo', width: 100, align: 'left', + formatterAsync: function (callback, value, row, op, $cell) { + learun.clientdata.getAsync('custmerData', { + url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'LessonInfo', + key: value, + keyId: 'lessonno', + callback: function (_data) { + callback(_data['lessonname']); + } + }); + } + }, + { + label: '课程学时', name: 'LessonTime', width: 100, align: 'left' + }, + { + label: '执行学期', name: 'Semester', width: 100, align: 'left' + }, + { + label: '周节次', name: 'WeeklyFestival', width: 100, align: 'left' + }, + { + label: '开课起始周', name: 'WeeklyStart', width: 150, align: 'left' + }, + { + label: '开课结束周', name: 'WeeklyEnd', width: 150, align: 'left' + }, + ], + height: 270, + mainId: 'Id' + }); + }, + initData: function () { + if (!!keyValue) { + $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/TeachingPlan/GetFormData?keyValue=' + keyValue, function (data) { + for (var id in data) { + if (!!data[id].length && data[id].length > 0) { + $('#' + id).jfGridSet('refreshdata', data[id]); + tempdatra = data[id]; + } + else { + $('[data-table="' + id + '"]').lrSetFormData(data[id]); + } + } + }); + } + } + }; + refreshGirdData = function (temprow) { + + var ifnewrow = true; + $.each(tempdatra, function (key, val) { + if (tempdatra[key].Id === temprow.Id) { + tempdatra[key] = temprow; + ifnewrow = false; + } + }); + if (ifnewrow) { + tempdatra.push(temprow); + } + $('#TeachingPlanItem').jfGridSet('refreshdata', tempdatra); + + }; + + // 验证数据是否填写完整 + validForm = function () { + if (!$('.lr-form-wrap').lrValidform()) { + return false; + } + //var datas = $('#TeachingPlanItem').jfGridGet('rowdatas'); + //if (datas == null || datas.length == 0) { + // learun.alert.warning("申请未包含明细!请先新增明细!"); + // return false; + //} + return true; + }; + //// 保存数据 + //acceptClick = function (callBack) { + // if (!$('body').lrValidform()) { + // return false; + // } + // var postData = { + // strEntity: JSON.stringify($('body').lrGetFormData()) + // }; + // $.lrSaveForm(top.$.rootUrl + '/EducationalAdministration/TeachingPlan/SaveForm?keyValue=' + keyValue, postData, function (res) { + // // 保存成功后才回调 + // if (!!callBack) { + // callBack(); + // } + // }); + //}; + // 保存数据 + save = function (callBack, i) { + var postData = {}; + var formData = $('[data-table="TeachingPlan"]').lrGetFormData(); + + postData.strEntity = JSON.stringify(formData); + postData.TeachingPlanItemList = JSON.stringify($('#TeachingPlanItem').jfGridGet('rowdatas')); + $.lrSaveForm(top.$.rootUrl + '/EducationalAdministration/TeachingPlan/SaveForm?keyValue=' + keyValue, postData, function (res) { + // 保存成功后才回调 + if (!!callBack) { + callBack(res, formData, i); + } + }); + }; + page.init(); +} diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlan/IndexManage.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlan/IndexManage.js index 21b3d5dbd..b18b65fa6 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlan/IndexManage.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlan/IndexManage.js @@ -20,16 +20,17 @@ var bootstrap = function ($, learun) { $('#lr_refresh').on('click', function () { location.reload(); }); - // 新增 - $('#lr_add').on('click', function () { + //查看 + $('#lr_look').on('click', function () { learun.layerForm({ id: 'form', - title: '新增', - url: top.$.rootUrl + '/EducationalAdministration/TeachingPlan/Form', + title: '查看', + url: top.$.rootUrl + '/EducationalAdministration/TeachingPlan/FormManageView', width: 600, height: 400, + btn: null, callBack: function (id) { - return top[id].acceptClick(refreshGirdData); + //return top[id].acceptClick(refreshGirdData); } }); }); @@ -44,20 +45,17 @@ var bootstrap = function ($, learun) { width: 1100, height: 700, callBack: function (id) { - return top[id].acceptClick(refreshGirdData); - } - }); - } - }); - // 删除 - $('#lr_delete').on('click', function () { - var keyValue = $('#gridtable').jfGridValue('Id'); - if (learun.checkrow(keyValue)) { - learun.layerConfirm('是否确认删除该项!', function (res) { - if (res) { - learun.deleteForm(top.$.rootUrl + '/EducationalAdministration/TeachingPlan/DeleteForm', { keyValue: keyValue }, function () { - refreshGirdData(); - }); + var res = false; + // 验证数据 + res = top[id].validForm(); + // 保存数据 + if (res) { + res = top[id].save(function () { + page.search(); + }); + } + return res; + //return top[id].acceptClick(refreshGirdData); } }); } diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlanItem/Form.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlanItem/Form.cshtml index 88228bd3d..328228ab3 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlanItem/Form.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlanItem/Form.cshtml @@ -3,29 +3,30 @@ Layout = "~/Views/Shared/_Form.cshtml"; }
-
+
课程名称
- + +
-
+
课程学时
- +
-
+
执行学期
- +
-
+
周节次
- +
-
+
开课起始周
- +
-
+
开课结束周
- +
@Html.AppendJsFile("/Areas/EducationalAdministration/Views/TeachingPlanItem/Form.js") diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlanItem/Form.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlanItem/Form.js index c18c99b23..9be1356dc 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlanItem/Form.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachingPlanItem/Form.js @@ -17,19 +17,37 @@ var bootstrap = function ($, learun) { page.initData(); }, bind: function () { + $('#LessonNo').hide(); }, initData: function () { + //if (!!keyValue) { + // $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/TeachingPlanItem/GetFormData?keyValue=' + keyValue, function (data) { + // for (var id in data) { + // if (!!data[id].length && data[id].length > 0) { + // $('#' + id ).jfGridSet('refreshdata', data[id]); + // } + // else { + // $('[data-table="' + id + '"]').lrSetFormData(data[id]); + // } + // } + // }); + //} + if (!!keyValue) { - $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/TeachingPlanItem/GetFormData?keyValue=' + keyValue, function (data) { - for (var id in data) { - if (!!data[id].length && data[id].length > 0) { - $('#' + id ).jfGridSet('refreshdata', data[id]); - } - else { - $('[data-table="' + id + '"]').lrSetFormData(data[id]); - } + if (!!selectedRow) { + $('#form').lrSetFormData(selectedRow); + + if (!!selectedRow.LessonNo) { + learun.clientdata.getAsync('custmerData', { + url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'LessonInfo', + key: selectedRow.LessonNo, + keyId: 'lessonno', + callback: function (_data) { + $('#LessonName').val(_data['lessonname']); + } + }); } - }); + } } } }; @@ -38,15 +56,30 @@ var bootstrap = function ($, learun) { if (!$('body').lrValidform()) { return false; } - var postData = { - strEntity: JSON.stringify($('body').lrGetFormData()) - }; - $.lrSaveForm(top.$.rootUrl + '/EducationalAdministration/TeachingPlanItem/SaveForm?keyValue=' + keyValue, postData, function (res) { - // 保存成功后才回调 - if (!!callBack) { - callBack(); + //var postData = { + // strEntity: JSON.stringify($('body').lrGetFormData()) + //}; + //$.lrSaveForm(top.$.rootUrl + '/EducationalAdministration/TeachingPlanItem/SaveForm?keyValue=' + keyValue, postData, function (res) { + // // 保存成功后才回调 + // if (!!callBack) { + // callBack(); + // } + //}); + + + var postData = $('body').lrGetFormData(); + if (!!keyValue) { + if (!!selectedRow) { + postData.Id = selectedRow.Id; } - }); + } else { + postData.Id = learun.newGuid(); + } + if (!!callBack) { + callBack(postData); + return true; + } + }; page.init(); } diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj b/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj index 2188f8117..e8aaa7d52 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj @@ -1058,6 +1058,7 @@ + @@ -7224,6 +7225,7 @@ + diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachingPlan/TeachingPlanBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachingPlan/TeachingPlanBLL.cs index 9fde56cd2..9ba8bf2ae 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachingPlan/TeachingPlanBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachingPlan/TeachingPlanBLL.cs @@ -118,11 +118,11 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration /// 主键 /// 实体 /// - public void SaveEntity(string keyValue, TeachingPlanEntity entity) + public void SaveEntity(string keyValue, TeachingPlanEntity entity, List teachingPlanItemList) { try { - teachingPlanService.SaveEntity(keyValue, entity); + teachingPlanService.SaveEntity(keyValue, entity, teachingPlanItemList); } catch (Exception ex) { diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachingPlan/TeachingPlanIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachingPlan/TeachingPlanIBLL.cs index aaa2516d6..fbc340c4c 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachingPlan/TeachingPlanIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachingPlan/TeachingPlanIBLL.cs @@ -42,7 +42,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration ///
/// 主键 /// 实体 - void SaveEntity(string keyValue, TeachingPlanEntity entity); + void SaveEntity(string keyValue, TeachingPlanEntity entity, List teachingPlanItemList); #endregion } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachingPlan/TeachingPlanService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachingPlan/TeachingPlanService.cs index 191a2ef12..dcdcd343c 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachingPlan/TeachingPlanService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachingPlan/TeachingPlanService.cs @@ -169,7 +169,7 @@ join CdLessonType c on t.LessonTypeId=c.ltid "; ///
/// 主键 /// 实体 - public void SaveEntity(string keyValue, TeachingPlanEntity entity) + public void SaveEntity(string keyValue, TeachingPlanEntity entity, List teachingPlanItemList) { var db = this.BaseRepository("CollegeMIS").BeginTrans(); try @@ -178,25 +178,29 @@ join CdLessonType c on t.LessonTypeId=c.ltid "; { entity.Modify(keyValue); db.Update(entity); + //删除课程子表 + db.Delete(x => x.TeachingPlanId == entity.Id); + foreach (var itemEntity in teachingPlanItemList) + { + itemEntity.TeachingPlanId = entity.Id; + db.Insert(itemEntity); + } } else { entity.Create(); db.Insert(entity); - } - //删除课程子表 - db.Delete(x => x.TeachingPlanId == entity.Id); - - //新增 - var lessonInfoList = db.FindList(x => x.TeachMajorNo == entity.Major); - foreach (var lessonInfo in lessonInfoList) - { - TeachingPlanItemEntity itemEntity = new TeachingPlanItemEntity(); - itemEntity.Create(); - itemEntity.TeachingPlanId = entity.Id; - itemEntity.LessonNo = lessonInfo.LessonNo; - itemEntity.LessonTime = lessonInfo.TotalStudyHour; - db.Insert(itemEntity); + //新增 + var lessonInfoList = db.FindList(x => x.TeachMajorNo == entity.Major); + foreach (var lessonInfo in lessonInfoList) + { + TeachingPlanItemEntity itemEntity = new TeachingPlanItemEntity(); + itemEntity.Create(); + itemEntity.TeachingPlanId = entity.Id; + itemEntity.LessonNo = lessonInfo.LessonNo; + itemEntity.LessonTime = lessonInfo.TotalStudyHour; + db.Insert(itemEntity); + } } db.Commit(); }