using Dapper; using Learun.DataBase.Repository; using Learun.Util; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; namespace Learun.Application.TwoDevelopment.EducationalAdministration { /// /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园 /// Copyright (c) 2013-2018 北京泉江科技有限公司 /// 创 建:超级管理员 /// 日 期:2020-01-03 10:10 /// 描 述:取消考试资格 /// public class StuCancelExamService : RepositoryFactory { #region 获取数据 /// /// 获取页面显示列表数据 /// /// 查询参数 /// public IEnumerable GetPageList(Pagination pagination, string queryJson) { try { var strSql = new StringBuilder(); strSql.Append("SELECT t.* "); strSql.Append(" FROM StuCancelExam t "); strSql.Append(" WHERE 1=1 "); var queryParam = queryJson.ToJObject(); // 虚拟参数 var dp = new DynamicParameters(new { }); if (!queryParam["StuNo"].IsEmpty()) { dp.Add("StuNo", "%" + queryParam["StuNo"].ToString() + "%", DbType.String); strSql.Append(" AND t.StuNo Like @StuNo "); } if (!queryParam["StuName"].IsEmpty()) { dp.Add("StuName", "%" + queryParam["StuName"].ToString() + "%", DbType.String); strSql.Append(" AND t.StuName Like @StuName "); } if (!queryParam["LessonNo"].IsEmpty()) { dp.Add("LessonNo", "%" + queryParam["LessonNo"].ToString() + "%", DbType.String); strSql.Append(" AND t.LessonNo Like @LessonNo "); } if (!queryParam["LessonName"].IsEmpty()) { dp.Add("LessonName", "%" + queryParam["LessonName"].ToString() + "%", DbType.String); strSql.Append(" AND t.LessonName Like @LessonName "); } return this.BaseRepository("CollegeMIS").FindList(strSql.ToString(), dp, pagination); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } /// /// 获取页面显示列表数据 /// /// 查询参数 /// public IEnumerable GetStudentPageList(Pagination pagination, string queryJson) { try { var strSql = new StringBuilder(); strSql.Append("select t.SelectId,t.StuNo,t.StuName,t.ClassNo,t.EmpNo from StuSelectLessonList t "); strSql.Append(" WHERE 1=1 and t.SelectId not in (select c.StuSelectLessonListId from StuCancelExam c ) "); var queryParam = queryJson.ToJObject(); // 虚拟参数 var dp = new DynamicParameters(new { }); if (!queryParam["AcademicYearNo"].IsEmpty()) { dp.Add("AcademicYearNo", queryParam["AcademicYearNo"].ToString(), DbType.String); strSql.Append(" AND t.AcademicYearNo = @AcademicYearNo "); } if (!queryParam["Semester"].IsEmpty()) { dp.Add("Semester", queryParam["Semester"].ToString(), DbType.String); strSql.Append(" AND t.Semester = @Semester "); } if (!queryParam["LessonNo"].IsEmpty()) { dp.Add("LessonNo", queryParam["LessonNo"].ToString(), DbType.String); strSql.Append(" AND t.LessonNo = @LessonNo "); } return this.BaseRepository("CollegeMIS").FindList(strSql.ToString(), dp, pagination); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } /// /// 获取StuCancelExam表实体数据 /// 主键 /// /// public StuCancelExamEntity GetStuCancelExamEntity(string keyValue) { try { return this.BaseRepository("CollegeMIS").FindEntity(keyValue); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } #endregion #region 提交数据 /// /// 删除实体数据 /// 主键 /// /// public void DeleteEntity(string keyValue) { try { this.BaseRepository("CollegeMIS").Delete(t => t.Id == keyValue); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } /// /// 保存实体数据(新增、修改) /// 主键 /// /// public void SaveEntity(string keyValue, StuCancelExamEntity entity) { try { if (!string.IsNullOrEmpty(keyValue)) { entity.Modify(keyValue); this.BaseRepository("CollegeMIS").Update(entity); } else { entity.Create(); this.BaseRepository("CollegeMIS").Insert(entity); } } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } /// /// 确认上报 /// /// /// public void SaveApply(string dataJson) { var loginInfo = LoginUserInfo.Get(); var data = JsonConvert.DeserializeObject>(dataJson); if (data.Any()) { var db = this.BaseRepository("CollegeMIS").BeginTrans(); try { foreach (var item in data) { var stuSelectLessonListEntity = db.FindEntity(x => x.SelectId == item.SelectId); if (stuSelectLessonListEntity != null) { var model = new StuCancelExamEntity(); model.StuSelectLessonListId = stuSelectLessonListEntity.SelectId; model.AcademicYearNo = stuSelectLessonListEntity.AcademicYearNo; model.Semester = stuSelectLessonListEntity.Semester; model.StuNo = stuSelectLessonListEntity.StuNo; model.DeptNo = stuSelectLessonListEntity.DeptNo; model.MajorNo = stuSelectLessonListEntity.MajorNo; model.ClassNo = stuSelectLessonListEntity.ClassNo; model.StuName = stuSelectLessonListEntity.StuName; model.LessonNo = stuSelectLessonListEntity.LessonNo; model.LessonName = stuSelectLessonListEntity.LessonName; model.EmpNo = stuSelectLessonListEntity.EmpNo; model.CheckMark = "0"; model.CreateTime = DateTime.Now; model.CreateUserId = loginInfo.userId; model.CreateUserName = loginInfo.realName; model.Create(); db.Insert(model); } } db.Commit(); } catch (Exception ex) { db.Rollback(); if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } } #endregion } }