You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

713 lines
31 KiB

  1. using Dapper;
  2. using Learun.Application.Organization;
  3. using Learun.DataBase.Repository;
  4. using Learun.Util;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Linq;
  9. using System.Text;
  10. namespace Learun.Application.TwoDevelopment.EducationalAdministration
  11. {
  12. /// <summary>
  13. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  14. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  15. /// 创 建:超级管理员
  16. /// 日 期:2019-01-29 11:08
  17. /// 描 述:班级信息管理
  18. /// </summary>
  19. public class TeachClassService : RepositoryFactory
  20. {
  21. #region 获取数据
  22. /// <summary>
  23. /// 获取页面显示列表数据
  24. /// <summary>
  25. /// <param name="queryJson">查询参数</param>
  26. /// <returns></returns>
  27. public IEnumerable<TeachClassEntity> GetPageList(Pagination pagination, string queryJson)
  28. {
  29. try
  30. {
  31. var strSql = new StringBuilder();
  32. strSql.Append("SELECT ");
  33. strSql.Append(@" * ");
  34. strSql.Append(" FROM TeachClass t ");
  35. strSql.Append(" WHERE 1=1 ");
  36. var queryParam = queryJson.ToJObject();
  37. // 虚拟参数
  38. var dp = new DynamicParameters(new { });
  39. if (!queryParam["F_SchoolId"].IsEmpty())
  40. {
  41. dp.Add("F_SchoolId", queryParam["F_SchoolId"].ToString(), DbType.String);
  42. strSql.Append(" AND t.F_SchoolId = @F_SchoolId ");
  43. }
  44. if (!queryParam["AcademicYearNo"].IsEmpty())
  45. {
  46. dp.Add("AcademicYearNo", queryParam["AcademicYearNo"].ToString(), DbType.String);
  47. strSql.Append(" AND t.AcademicYearNo = @AcademicYearNo ");
  48. }
  49. if (!queryParam["Semester"].IsEmpty())
  50. {
  51. dp.Add("Semester", queryParam["Semester"].ToString(), DbType.String);
  52. strSql.Append(" AND t.Semester = @Semester ");
  53. }
  54. if (!queryParam["DeptNo"].IsEmpty())
  55. {
  56. dp.Add("DeptNo", queryParam["DeptNo"].ToString(), DbType.String);
  57. strSql.Append(" AND t.DeptNo = @DeptNo ");
  58. }
  59. if (!queryParam["MajorNo"].IsEmpty())
  60. {
  61. dp.Add("MajorNo", queryParam["MajorNo"].ToString(), DbType.String);
  62. strSql.Append(" AND t.MajorNo = @MajorNo ");
  63. }
  64. if (!queryParam["Grade"].IsEmpty())
  65. {
  66. dp.Add("Grade", "%" + queryParam["Grade"].ToString() + "%", DbType.String);
  67. strSql.Append(" AND t.Grade Like @Grade ");
  68. }
  69. if (!queryParam["LessonNo"].IsEmpty())
  70. {
  71. dp.Add("LessonNo", queryParam["LessonNo"].ToString(), DbType.String);
  72. strSql.Append(" AND t.LessonNo = @LessonNo ");
  73. }
  74. return this.BaseRepository("CollegeMIS").FindList<TeachClassEntity>(strSql.ToString(), dp, pagination);
  75. }
  76. catch (Exception ex)
  77. {
  78. if (ex is ExceptionEx)
  79. {
  80. throw;
  81. }
  82. else
  83. {
  84. throw ExceptionEx.ThrowServiceException(ex);
  85. }
  86. }
  87. }
  88. internal bool GetAny()
  89. {
  90. try
  91. {
  92. return this.BaseRepository("CollegeMIS").FindList<TeachClassEntity>().ToList().Count > 0 ? true : false;
  93. }
  94. catch (Exception ex)
  95. {
  96. if (ex is ExceptionEx)
  97. {
  98. throw;
  99. }
  100. else
  101. {
  102. throw ExceptionEx.ThrowServiceException(ex);
  103. }
  104. }
  105. }
  106. /// <summary>
  107. /// 获取ClassInfo表实体数据
  108. /// <param name="keyValue">主键</param>
  109. /// <summary>
  110. /// <returns></returns>
  111. public TeachClassEntity GetTeachClassEntity(string keyValue)
  112. {
  113. try
  114. {
  115. int ID = Convert.ToInt32(keyValue);
  116. return this.BaseRepository("CollegeMIS").FindEntity<TeachClassEntity>(ID);
  117. }
  118. catch (Exception ex)
  119. {
  120. if (ex is ExceptionEx)
  121. {
  122. throw;
  123. }
  124. else
  125. {
  126. throw ExceptionEx.ThrowServiceException(ex);
  127. }
  128. }
  129. }
  130. #endregion
  131. #region 提交数据
  132. /// <summary>
  133. /// 删除实体数据
  134. /// <param name="keyValue">主键</param>
  135. /// <summary>
  136. /// <returns></returns>
  137. public void DeleteEntity(string keyValue)
  138. {
  139. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  140. try
  141. {
  142. //修改
  143. var keyValueArr = keyValue.Split(',');
  144. foreach (var item in keyValueArr)
  145. {
  146. var entity = this.BaseRepository("CollegeMIS").FindEntity<TeachClassEntity>(x => x.ID == Convert.ToInt32(item));
  147. if (entity != null)
  148. {
  149. entity.EmpNo = "";
  150. db.Update(entity);
  151. }
  152. }
  153. db.Commit();
  154. }
  155. catch (Exception ex)
  156. {
  157. db.Rollback();
  158. if (ex is ExceptionEx)
  159. {
  160. throw;
  161. }
  162. else
  163. {
  164. throw ExceptionEx.ThrowServiceException(ex);
  165. }
  166. }
  167. }
  168. /// <summary>
  169. /// 保存实体数据(新增、修改)
  170. /// <param name="keyValue">主键</param>
  171. /// <summary>
  172. /// <returns></returns>
  173. public void SaveEntity(string keyValue, TeachClassEntity entity)
  174. {
  175. try
  176. {
  177. var keyvalue = Convert.ToInt32(keyValue);
  178. if (!string.IsNullOrEmpty(keyValue))
  179. {
  180. entity.Modify(keyvalue);
  181. this.BaseRepository("CollegeMIS").Update(entity);
  182. }
  183. else
  184. {
  185. entity.Create();
  186. this.BaseRepository("CollegeMIS").Insert(entity);
  187. }
  188. }
  189. catch (Exception ex)
  190. {
  191. if (ex is ExceptionEx)
  192. {
  193. throw;
  194. }
  195. else
  196. {
  197. throw ExceptionEx.ThrowServiceException(ex);
  198. }
  199. }
  200. }
  201. #endregion
  202. #region 扩展数据
  203. public IEnumerable<TeachClassEntity> GetAllClass()
  204. {
  205. try
  206. {
  207. return this.BaseRepository("CollegeMIS").FindList<TeachClassEntity>();
  208. }
  209. catch (Exception ex)
  210. {
  211. if (ex is ExceptionEx)
  212. {
  213. throw;
  214. }
  215. else
  216. {
  217. throw ExceptionEx.ThrowServiceException(ex);
  218. }
  219. }
  220. }
  221. /// <summary>
  222. /// 获取ClassInfo表实体数据
  223. /// <param name="keyValue">主键</param>
  224. /// <summary>
  225. /// <returns></returns>
  226. public List<TeachClassEntity> GetTeachListById(string keyValue)
  227. {
  228. try
  229. {
  230. var id = keyValue.Split(',');
  231. return this.BaseRepository("CollegeMIS")
  232. .FindList<TeachClassEntity>(x => id.Contains(x.ID.ToString())).ToList();
  233. }
  234. catch (Exception ex)
  235. {
  236. if (ex is ExceptionEx)
  237. {
  238. throw;
  239. }
  240. else
  241. {
  242. throw ExceptionEx.ThrowServiceException(ex);
  243. }
  244. }
  245. }
  246. /// <summary>
  247. /// 保存数据
  248. /// </summary>
  249. /// <param name="keyValue">主键</param>
  250. /// <param name="entity"></param>
  251. public void SaveEntityList(List<TeachClassEntity> List)
  252. {
  253. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  254. try
  255. {
  256. foreach (var item in List)
  257. {
  258. TeachClassEntity Teach = new TeachClassEntity
  259. {
  260. TeachClassNo = item.TeachClassNo,
  261. AcademicYearNo = item.AcademicYearNo,
  262. DeptNo = item.DeptNo,
  263. MajorNo = item.MajorNo,
  264. Grade = item.Grade,
  265. EmpNo = item.EmpNo,
  266. Semester = item.Semester,
  267. LessonNo = item.LessonNo,
  268. StuNum = item.StuNum,
  269. LessonSortNo = item.LessonSortNo,
  270. F_SchoolId = item.F_SchoolId
  271. };
  272. if (db.FindEntity<TeachClassEntity>(
  273. x => x.F_SchoolId == Teach.F_SchoolId && x.AcademicYearNo == Teach.AcademicYearNo
  274. && x.Semester == Teach.Semester && x.DeptNo == Teach.DeptNo
  275. && x.MajorNo == Teach.MajorNo && x.TeachClassNo == Teach.TeachClassNo
  276. && x.Grade == Teach.Grade && x.LessonNo == Teach.LessonNo) == null)
  277. {
  278. db.Insert(Teach);
  279. }
  280. }
  281. db.Commit();
  282. }
  283. catch (Exception ex)
  284. {
  285. db.Rollback();
  286. if (ex is ExceptionEx)
  287. {
  288. throw;
  289. }
  290. else
  291. {
  292. throw ExceptionEx.ThrowServiceException(ex);
  293. }
  294. }
  295. }
  296. /// <summary>
  297. /// 保存或修改教师
  298. /// </summary>
  299. /// <param name="keyValue"></param>
  300. /// <param name="EmpNo"></param>
  301. public void UpEmpNo(string keyValue, string EmpNo)
  302. {
  303. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  304. try
  305. {
  306. var keyarray = keyValue.Split(',');
  307. foreach (var item in keyarray)
  308. {
  309. var entityList = this.GetTeachClassEntity(item);
  310. entityList.EmpNo = EmpNo;
  311. db.Update(entityList);
  312. }
  313. db.Commit();
  314. }
  315. catch (Exception ex)
  316. {
  317. db.Rollback();
  318. if (ex is ExceptionEx)
  319. {
  320. throw;
  321. }
  322. else
  323. {
  324. throw ExceptionEx.ThrowServiceException(ex);
  325. }
  326. }
  327. }
  328. /// <summary>
  329. /// 修改教师和成绩
  330. /// </summary>
  331. /// <param name="keyValue"></param>
  332. /// <param name="EmpNo"></param>
  333. public string UpSetTeach(string keyValue, string EmpNo)
  334. {
  335. string Result = "";
  336. var db = BaseRepository("CollegeMIS").BeginTrans();
  337. try
  338. {
  339. #region 获取班级开课计划的数据
  340. var IdList = keyValue.Split(',');
  341. var TeachClassList = BaseRepository("CollegeMIS").FindList<TeachClassEntity>(x => IdList.Contains(x.ID.ToString())).ToList();
  342. foreach (var item in IdList)//修改TeachClass表
  343. {
  344. var entityList = GetTeachClassEntity(item);
  345. entityList.EmpNo = EmpNo;
  346. db.Update(entityList);
  347. }
  348. #endregion
  349. List<StuSelectLessonListEntity> stuLessonList = new List<StuSelectLessonListEntity>();
  350. for (int i = 0; i < TeachClassList.Count; i++)
  351. {
  352. var LessonData = db.FindList<LessonInfoEntity>().Where(x => x.LessonNo == TeachClassList[i].LessonNo).FirstOrDefault();
  353. var stuDataList = db.FindList<StuInfoBasicEntity>().Where(s =>
  354. s.DeptNo == TeachClassList[i].DeptNo && s.MajorNo == TeachClassList[i].MajorNo &&
  355. s.F_SchoolId == TeachClassList[i].F_SchoolId &&
  356. s.ClassNo == TeachClassList[i].TeachClassNo && s.CheckMark == "1");
  357. var DeleteStuSelectLesson = db.FindList<StuSelectLessonListEntity>().Where(
  358. x => x.AcademicYearNo == TeachClassList[i].AcademicYearNo &&
  359. x.LessonNo == TeachClassList[i].LessonNo &&
  360. x.Semester == TeachClassList[i].Semester &&
  361. x.F_SchoolId == TeachClassList[i].F_SchoolId &&
  362. x.DeptNo == TeachClassList[i].DeptNo &&
  363. x.MajorNo == TeachClassList[i].MajorNo &&
  364. x.ClassNo == TeachClassList[i].TeachClassNo &&
  365. x.Grade == TeachClassList[i].Grade &&
  366. x.OpenLessonDeptNo == TeachClassList[i].DeptNo &&
  367. x.OpenLessonMajorNo == TeachClassList[i].MajorNo &&
  368. x.LessonSortNo == "1").ToList();
  369. if (DeleteStuSelectLesson.Count > 0)
  370. {
  371. db.Delete(DeleteStuSelectLesson);
  372. }
  373. if (stuDataList != null)
  374. {
  375. #region 修改StuSelectLessonList表
  376. foreach (var item in stuDataList)
  377. {
  378. var StuSelectLessonEntity = new StuSelectLessonListEntity
  379. {
  380. StuNo = item.StuNo,
  381. DeptNo = TeachClassList[i].DeptNo,
  382. MajorNo = TeachClassList[i].MajorNo,
  383. ClassNo = item.ClassNo,
  384. GenderNo = item.GenderNo == true ? "0" : "1",
  385. MajorDetailNo = TeachClassList[i].MajorDetailNo,
  386. MajorDetailName = TeachClassList[i].MajorDetailName,
  387. StuName = item.StuName,
  388. AcademicYearNo = TeachClassList[i].AcademicYearNo,
  389. Semester = TeachClassList[i].Semester,
  390. OpenLessonDeptNo = TeachClassList[i].DeptNo,
  391. OpenLessonMajorNo = TeachClassList[i].MajorNo,
  392. LessonNo = TeachClassList[i].LessonNo,
  393. LessonName = LessonData.LessonName,
  394. PartCode = TeachClassList[i].PartCode,
  395. OrdinaryScoreScale = 0,
  396. TermInScoreScale = 0,
  397. TermEndScoreScale = 0,
  398. OtherScoreScale = 0,
  399. TeachClassNo = TeachClassList[i].TeachClassNo,
  400. LessonSortNo = TeachClassList[i].LessonSortNo,
  401. StuSortNo = TeachClassList[i].LessonSortNo,
  402. Grade = item.Grade,
  403. StudyScore = 2,
  404. TotalStudyHour = 2,
  405. IsInEffect = "1",
  406. IsPitchOn = "1",
  407. F_SchoolId = TeachClassList[i].F_SchoolId,
  408. CheckMark = "1",
  409. InsertTime = DateTime.Now
  410. };
  411. stuLessonList.Add(StuSelectLessonEntity);
  412. db.Insert(StuSelectLessonEntity);
  413. }
  414. #endregion
  415. var ScoreList = db.FindList<StuScoreEntity>().Where(x => x.AcademicYearNo == TeachClassList[i].AcademicYearNo && x.Semester == TeachClassList[i].Semester && x.DeptNo == TeachClassList[i].DeptNo && x.MajorNo == TeachClassList[i].MajorNo && x.ClassNo == TeachClassList[i].TeachClassNo && x.LessonSortNo == TeachClassList[i].LessonSortNo && x.LessonNo == TeachClassList[i].LessonNo);
  416. var DeleteStuScore = db.FindList<StuScoreEntity>().Where(
  417. x => x.AcademicYearNo == TeachClassList[i].AcademicYearNo &&
  418. x.LessonNo == TeachClassList[i].LessonNo &&
  419. x.Semester == TeachClassList[i].Semester &&
  420. x.F_SchoolId == TeachClassList[i].F_SchoolId &&
  421. x.DeptNo == TeachClassList[i].DeptNo &&
  422. x.MajorNo == TeachClassList[i].MajorNo &&
  423. x.ClassNo == TeachClassList[i].TeachClassNo &&
  424. x.Grade == TeachClassList[i].Grade &&
  425. x.OpenLessonDeptNo == TeachClassList[i].DeptNo &&
  426. x.OpenLessonMajorNo == TeachClassList[i].MajorNo &&
  427. x.LessonSortNo == "1" && x.CheckMark == "1").ToList();
  428. if (DeleteStuScore.Count > 0)
  429. {
  430. return Result = "成绩已审核不可设置教师";
  431. }
  432. db.Delete(DeleteStuScore);
  433. if (ScoreList != null)
  434. {
  435. #region 添加StuScore表
  436. foreach (var item in stuDataList)
  437. {
  438. var stuScoreEntity = new StuScoreEntity
  439. {
  440. StuNo = item.StuNo,
  441. DeptNo = item.DeptNo,
  442. MajorNo = item.MajorNo,
  443. ClassNo = item.ClassNo,
  444. StuName = item.StuName,
  445. EmpNo = EmpNo,
  446. GenderNo = item.GenderNo == true ? "0" : "1",
  447. AcademicYearNo = TeachClassList[i].AcademicYearNo,
  448. Semester = TeachClassList[i].Semester,
  449. OpenLessonDeptNo = TeachClassList[i].DeptNo,
  450. OpenLessonMajorNo = TeachClassList[i].MajorNo,
  451. LessonNo = TeachClassList[i].LessonNo,
  452. LessonName = LessonData.LessonName,
  453. PartCode = TeachClassList[i].PartCode,
  454. StuSortNo = item.TestStuSortNo,
  455. TeachClassNo = TeachClassList[i].TeachClassNo,
  456. LessonSortNo = TeachClassList[i].LessonSortNo,
  457. Grade = TeachClassList[i].Grade,
  458. StudyScore = 2,
  459. TotalStudyHour = 2,
  460. IsInEffect = "1",
  461. IsPitchOn = "1",
  462. F_SchoolId = TeachClassList[i].F_SchoolId,
  463. CheckMark = "0",
  464. TestKindNo = "1",
  465. IsEditable = "1",
  466. OrdinaryScore = 0,
  467. TermInScore = 0,
  468. TermEndScore = 0,
  469. OtherScore = 0
  470. };
  471. db.Insert(stuScoreEntity);
  472. }
  473. #endregion
  474. }
  475. }
  476. }
  477. db.Commit();
  478. return Result = "设置教师成功";
  479. }
  480. catch (Exception ex)
  481. {
  482. db.Rollback();
  483. if (ex is ExceptionEx)
  484. {
  485. throw;
  486. }
  487. else
  488. {
  489. throw ExceptionEx.ThrowServiceException(ex);
  490. }
  491. }
  492. }
  493. /// <summary>
  494. /// 强制修改教师
  495. /// </summary>
  496. /// <param name="keyValue"></param>
  497. /// <param name="EmpNo"></param>
  498. public string UpQzSetTeach(string keyValue, string EmpNo)
  499. {
  500. string Result = "";
  501. var db = BaseRepository("CollegeMIS").BeginTrans();
  502. try
  503. {
  504. #region 获取班级开课计划的数据
  505. var IdList = keyValue.Split(',');
  506. var TeachClassList = BaseRepository("CollegeMIS").FindList<TeachClassEntity>(x => IdList.Contains(x.ID.ToString())).ToList();
  507. foreach (var item in IdList)//修改TeachClass表
  508. {
  509. var entityList = GetTeachClassEntity(item);
  510. entityList.EmpNo = EmpNo;
  511. db.Update(entityList);
  512. }
  513. #endregion
  514. List<StuSelectLessonListEntity> stuLessonList = new List<StuSelectLessonListEntity>();
  515. for (int i = 0; i < TeachClassList.Count; i++)
  516. {
  517. var LessonData = db.FindList<LessonInfoEntity>().Where(x => x.LessonNo == TeachClassList[i].LessonNo).FirstOrDefault();
  518. var stuDataList = db.FindList<StuInfoBasicEntity>().Where(s =>
  519. s.DeptNo == TeachClassList[i].DeptNo && s.MajorNo == TeachClassList[i].MajorNo &&
  520. s.F_SchoolId == TeachClassList[i].F_SchoolId &&
  521. s.ClassNo == TeachClassList[i].TeachClassNo && s.CheckMark == "1");
  522. var DeleteStuSelectLesson = db.FindList<StuSelectLessonListEntity>().Where(
  523. x => x.AcademicYearNo == TeachClassList[i].AcademicYearNo &&
  524. x.LessonNo == TeachClassList[i].LessonNo &&
  525. x.Semester == TeachClassList[i].Semester &&
  526. x.F_SchoolId == TeachClassList[i].F_SchoolId &&
  527. x.DeptNo == TeachClassList[i].DeptNo &&
  528. x.MajorNo == TeachClassList[i].MajorNo &&
  529. x.ClassNo == TeachClassList[i].TeachClassNo &&
  530. x.Grade == TeachClassList[i].Grade &&
  531. x.OpenLessonDeptNo == TeachClassList[i].DeptNo &&
  532. x.OpenLessonMajorNo == TeachClassList[i].MajorNo &&
  533. x.LessonSortNo == "1").ToList();
  534. if (DeleteStuSelectLesson.Count > 0)
  535. {
  536. db.Delete(DeleteStuSelectLesson);
  537. }
  538. if (stuDataList != null)
  539. {
  540. #region 修改StuSelectLessonList表
  541. foreach (var item in stuDataList)
  542. {
  543. var StuSelectLessonEntity = new StuSelectLessonListEntity
  544. {
  545. StuNo = item.StuNo,
  546. DeptNo = TeachClassList[i].DeptNo,
  547. MajorNo = TeachClassList[i].MajorNo,
  548. ClassNo = item.ClassNo,
  549. GenderNo = item.GenderNo == true ? "0" : "1",
  550. MajorDetailNo = TeachClassList[i].MajorDetailNo,
  551. MajorDetailName = TeachClassList[i].MajorDetailName,
  552. StuName = item.StuName,
  553. AcademicYearNo = TeachClassList[i].AcademicYearNo,
  554. Semester = TeachClassList[i].Semester,
  555. OpenLessonDeptNo = TeachClassList[i].DeptNo,
  556. OpenLessonMajorNo = TeachClassList[i].MajorNo,
  557. LessonNo = TeachClassList[i].LessonNo,
  558. LessonName = LessonData.LessonName,
  559. PartCode = TeachClassList[i].PartCode,
  560. OrdinaryScoreScale = 0,
  561. TermInScoreScale = 0,
  562. TermEndScoreScale = 0,
  563. OtherScoreScale = 0,
  564. TeachClassNo = TeachClassList[i].TeachClassNo,
  565. LessonSortNo = TeachClassList[i].LessonSortNo,
  566. StuSortNo = TeachClassList[i].LessonSortNo,
  567. Grade = item.Grade,
  568. StudyScore = 2,
  569. TotalStudyHour = 2,
  570. IsInEffect = "1",
  571. IsPitchOn = "1",
  572. F_SchoolId = TeachClassList[i].F_SchoolId,
  573. CheckMark = "1",
  574. InsertTime = DateTime.Now
  575. };
  576. stuLessonList.Add(StuSelectLessonEntity);
  577. db.Insert(StuSelectLessonEntity);
  578. }
  579. #endregion
  580. var ScoreList = db.FindList<StuScoreEntity>().Where(x => x.AcademicYearNo == TeachClassList[i].AcademicYearNo && x.Semester == TeachClassList[i].Semester && x.DeptNo == TeachClassList[i].DeptNo && x.MajorNo == TeachClassList[i].MajorNo && x.ClassNo == TeachClassList[i].TeachClassNo && x.LessonSortNo == TeachClassList[i].LessonSortNo && x.LessonNo == TeachClassList[i].LessonNo);
  581. var DeleteStuScore = db.FindList<StuScoreEntity>().Where(
  582. x => x.AcademicYearNo == TeachClassList[i].AcademicYearNo &&
  583. x.LessonNo == TeachClassList[i].LessonNo &&
  584. x.Semester == TeachClassList[i].Semester &&
  585. x.F_SchoolId == TeachClassList[i].F_SchoolId &&
  586. x.DeptNo == TeachClassList[i].DeptNo &&
  587. x.MajorNo == TeachClassList[i].MajorNo &&
  588. x.ClassNo == TeachClassList[i].TeachClassNo &&
  589. x.Grade == TeachClassList[i].Grade &&
  590. x.OpenLessonDeptNo == TeachClassList[i].DeptNo &&
  591. x.OpenLessonMajorNo == TeachClassList[i].MajorNo &&
  592. x.LessonSortNo == "1" && x.CheckMark == "0").ToList();
  593. if (DeleteStuScore.Count > 0)
  594. {
  595. db.Delete(DeleteStuScore);
  596. }
  597. if (ScoreList != null)
  598. {
  599. #region 添加StuScore表
  600. foreach (var item in stuDataList)
  601. {
  602. var stuScoreEntity = new StuScoreEntity
  603. {
  604. StuNo = item.StuNo,
  605. DeptNo = item.DeptNo,
  606. MajorNo = item.MajorNo,
  607. ClassNo = item.ClassNo,
  608. StuName = item.StuName,
  609. EmpNo = EmpNo,
  610. GenderNo = item.GenderNo == true ? "0" : "1",
  611. AcademicYearNo = TeachClassList[i].AcademicYearNo,
  612. Semester = TeachClassList[i].Semester,
  613. OpenLessonDeptNo = TeachClassList[i].DeptNo,
  614. OpenLessonMajorNo = TeachClassList[i].MajorNo,
  615. LessonNo = TeachClassList[i].LessonNo,
  616. LessonName = LessonData.LessonName,
  617. PartCode = TeachClassList[i].PartCode,
  618. StuSortNo = item.TestStuSortNo,
  619. TeachClassNo = TeachClassList[i].TeachClassNo,
  620. LessonSortNo = TeachClassList[i].LessonSortNo,
  621. Grade = TeachClassList[i].Grade,
  622. StudyScore = 2,
  623. TotalStudyHour = 2,
  624. IsInEffect = "1",
  625. IsPitchOn = "1",
  626. F_SchoolId = TeachClassList[i].F_SchoolId,
  627. CheckMark = "0",
  628. TestKindNo = "1",
  629. IsEditable = "1",
  630. OrdinaryScore = 0,
  631. TermInScore = 0,
  632. TermEndScore = 0,
  633. OtherScore = 0
  634. };
  635. db.Insert(stuScoreEntity);
  636. }
  637. #endregion
  638. }
  639. }
  640. }
  641. db.Commit();
  642. return Result = "设置教师成功";
  643. }
  644. catch (Exception ex)
  645. {
  646. db.Rollback();
  647. if (ex is ExceptionEx)
  648. {
  649. throw;
  650. }
  651. else
  652. {
  653. throw ExceptionEx.ThrowServiceException(ex);
  654. }
  655. }
  656. }
  657. /// <summary>
  658. /// 保存实体数据(新增、修改)
  659. /// <param name="keyValue">主键</param>
  660. /// <summary>
  661. /// <returns></returns>
  662. public void UpEmpNos(string xn, string xq, string classNo, string LessonNo, string EmpNo, string hisempno, string Grade)
  663. {
  664. try
  665. {
  666. StringBuilder sb = new StringBuilder();
  667. sb.Append(" update StuSelectLessonList set EmpNo ='" + EmpNo + "' where classno = '" + classNo + "' and Semester ='" + xq + "' and AcademicYearNo ='" + xn + "' and LessonNo ='" + LessonNo + "' and empno = '" + hisempno + "' and Grade = '" + Grade + "'");
  668. this.BaseRepository("CollegeMIS").ExecuteBySql(sb.ToString());
  669. }
  670. catch (Exception ex)
  671. {
  672. if (ex is ExceptionEx)
  673. {
  674. throw;
  675. }
  676. else
  677. {
  678. throw ExceptionEx.ThrowServiceException(ex);
  679. }
  680. }
  681. }
  682. #endregion
  683. }
  684. }