|
- using Dapper;
- using Learun.DataBase.Repository;
- using Learun.Util;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
-
- namespace Learun.Application.TwoDevelopment.EducationalAdministration
- {
- /// <summary>
- /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
- /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
- /// 创 建:超级管理员
- /// 日 期:2021-09-17 11:30
- /// 描 述:学生学期注册
- /// </summary>
- public class StuInfoSemsterService : RepositoryFactory
- {
- #region 构造函数和属性
-
- private string fieldSql;
- /// <summary>
- /// 构造方法
- /// </summary>
- public StuInfoSemsterService()
- {
- fieldSql = @"
- t.StuId,
- t.StuNo,
- t.StuName,
- t.MajorNo,
- t.ClassNo,
- t.AcademicYearNo,
- t.Semester,
- t.Status,
- t.TIME
- ";
- }
- #endregion
-
- #region 获取数据
-
- /// <summary>
- /// 获取列表数据
- /// </summary>
- /// <param name="queryJson">条件参数</param>
- /// <returns></returns>
- public IEnumerable<StuInfoSemsterEntity> GetList(string queryJson)
- {
- try
- {
- //参考写法
- //var queryParam = queryJson.ToJObject();
- // 虚拟参数
- //var dp = new DynamicParameters(new { });
- //dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
- var strSql = new StringBuilder();
- strSql.Append("SELECT ");
- strSql.Append(fieldSql);
- strSql.Append(" FROM StuInfoSemster t ");
- return this.BaseRepository("CollegeMIS").FindList<StuInfoSemsterEntity>(strSql.ToString());
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取列表分页数据
- /// </summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="queryJson">条件参数</param>
- /// <returns></returns>
- public IEnumerable<StuInfoSemsterEntity> GetPageList(Pagination pagination, string queryJson)
- {
- try
- {
- var strSql = new StringBuilder();
- strSql.Append("SELECT ");
- strSql.Append(fieldSql);
- strSql.Append(" FROM StuInfoSemster t ");
- return this.BaseRepository("CollegeMIS").FindList<StuInfoSemsterEntity>(strSql.ToString(), pagination);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取实体数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- public StuInfoSemsterEntity GetEntity(string keyValue)
- {
- try
- {
- return this.BaseRepository("CollegeMIS").FindEntity<StuInfoSemsterEntity>(keyValue);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- #endregion
-
- #region 提交数据
-
- /// <summary>
- /// 删除实体数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- public void DeleteEntity(string keyValue)
- {
- try
- {
- this.BaseRepository("CollegeMIS").Delete<StuInfoSemsterEntity>(t => t.StuId == keyValue);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// <param name="keyValue">主键</param>
- /// <param name="entity">实体</param>
- /// </summary>
- public void SaveEntity(string keyValue, StuInfoSemsterEntity 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);
- }
- }
- }
-
- #endregion
-
-
- #region 扩展数据
- /// 注册
- /// </summary>
- /// <param name="keyValue">主键</param>
- public void ZhuCe(string keyValue, string status)
- {
- var db = BaseRepository("CollegeMIS").BeginTrans();
- try
- {
- List<string> Ids = keyValue.Split(',').ToList();
- List<StuInfoSemsterEntity> StuInfoEntity = new List<StuInfoSemsterEntity>();
- if (status == "1")
- {
- foreach (var item in Ids)
- {
- var list = this.BaseRepository("CollegeMIS").FindEntity<StuInfoSemsterEntity>(x => x.StuId == item);
- if (list != null)
- {
- list.Status = "1";
- list.TIME = DateTime.Now;
- StuInfoEntity.Add(list);
- }
- }
- }
- else
- {
- foreach (var item in Ids)
- {
- var list = this.BaseRepository("CollegeMIS").FindEntity<StuInfoSemsterEntity>(x => x.StuId == item);
- if (list != null)
- {
- list.Status = "0";
- list.TIME = null;
- StuInfoEntity.Add(list);
- }
- }
- }
- db.Update(StuInfoEntity);
- db.Commit();
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
- #endregion
- }
- }
|