From 4bee105743660a0443afc6bdbc7cd5bc09f6edf3 Mon Sep 17 00:00:00 2001 From: ndbs Date: Mon, 24 Oct 2022 10:00:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=A9=BA=E6=8E=92=E8=AF=BE=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EmptyByConditionForm.cshtml | 4 ++ .../ArrangeLessonTerm/EmptyByConditionForm.js | 6 +++ .../ArrangeLessonTermService.cs | 46 +++++++++++-------- 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ArrangeLessonTerm/EmptyByConditionForm.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ArrangeLessonTerm/EmptyByConditionForm.cshtml index 7b7a69828..d67de2992 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ArrangeLessonTerm/EmptyByConditionForm.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ArrangeLessonTerm/EmptyByConditionForm.cshtml @@ -15,5 +15,9 @@
学期*
+
+
同步内容*
+
+
@Html.AppendJsFile("/Areas/EducationalAdministration/Views/ArrangeLessonTerm/EmptyByConditionForm.js") diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ArrangeLessonTerm/EmptyByConditionForm.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ArrangeLessonTerm/EmptyByConditionForm.js index 68e543073..0986a9145 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ArrangeLessonTerm/EmptyByConditionForm.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ArrangeLessonTerm/EmptyByConditionForm.js @@ -30,6 +30,12 @@ var bootstrap = function ($, learun) { value: 'value', text: 'text' }); + $('#SyncType').lrselect({ + placeholder: "请选择同步内容", + data: [{ text: "课表", value: "1" }, { text: "开课计划", value: "2" }], + value: 'value', + text: 'text' + }); }, initData: function () { //if (!!selectedRow) { diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermService.cs index da0273401..619aebbd3 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermService.cs @@ -1345,34 +1345,42 @@ WHERE (AcademicYearNo = '" + strAcademicYear + "') and semester='" + strSemest public async Task AsyncModifyArrangeLessonDataByCondition(ArrangeLessonTermEntity entity) { bool result = false; + var db = BaseRepository("CollegeMIS"); try { - HttpContent httpContent = new StringContent("{\"school\":\"" + entity.F_SchoolId + "\",\"year\":\"" + entity.AcademicYearNo + "\",\"number\":\"" + entity.Semester + "\"}"); - httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); - string apiData = await Client.PostAsync(Config.GetValue("ModifyArrangeLessonAPI"), httpContent).Result.Content.ReadAsStringAsync(); - - if (!string.IsNullOrEmpty(apiData)) + if (entity.SyncType == "1") { - var data = JsonConvert.DeserializeObject(apiData); - if (data.success) + db.BeginTrans(); + db.ExecuteBySql( + $"delete from ArrangeLessonTerm where F_SchoolId='{entity.F_SchoolId}' and AcademicYearNo='{entity.AcademicYearNo}' and Semester='{entity.Semester}' "); + db.Commit(); + + + HttpContent httpContent = new StringContent("{\"school\":\"" + entity.F_SchoolId + "\",\"year\":\"" + entity.AcademicYearNo + "\",\"number\":\"" + entity.Semester + "\"}"); + httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); + string apiData = await Client.PostAsync(Config.GetValue("ModifyArrangeLessonAPI"), httpContent).Result.Content.ReadAsStringAsync(); + + if (!string.IsNullOrEmpty(apiData)) { - var executeResult = await BaseRepository("CollegeMIS").ExecuteAsyncBySql( - $"delete from ArrangeLessonTerm where F_SchoolId='{entity.F_SchoolId}' and AcademicYearNo='{entity.AcademicYearNo}' and Semester='{entity.Semester}' "); - await BaseRepository("CollegeMIS").ExecuteAsyncBySql( - $"delete from TeachClass where F_SchoolId='{entity.F_SchoolId}' and AcademicYearNo='{entity.AcademicYearNo}' and Semester='{entity.Semester}' "); - await BaseRepository("CollegeMIS").ExecuteAsyncBySql( - $"delete from OpenLessonPlan where F_SchoolId='{entity.F_SchoolId}' and AcademicYearNo='{entity.AcademicYearNo}' and Semester='{entity.Semester}' "); - await BaseRepository("CollegeMIS").ExecuteAsyncBySql( - $"delete from StuSelectLessonList where F_SchoolId='{entity.F_SchoolId}' and AcademicYearNo='{entity.AcademicYearNo}' and Semester='{entity.Semester}' "); - if (executeResult > 0) - { - result = true; - } + result = true; } } + else + { + db.BeginTrans(); + db.ExecuteBySql( + $"delete from TeachClass where F_SchoolId='{entity.F_SchoolId}' and AcademicYearNo='{entity.AcademicYearNo}' and Semester='{entity.Semester}' "); + db.ExecuteBySql( + $"delete from OpenLessonPlan where F_SchoolId='{entity.F_SchoolId}' and AcademicYearNo='{entity.AcademicYearNo}' and Semester='{entity.Semester}' "); + db.ExecuteBySql( + $"delete from StuSelectLessonList where F_SchoolId='{entity.F_SchoolId}' and AcademicYearNo='{entity.AcademicYearNo}' and Semester='{entity.Semester}' "); + db.Commit(); + result = true; + } } catch (Exception ex) { + db.Rollback(); if (ex is ExceptionEx) { throw;