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.
 
 
 
 
 
 

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