using Dapper;
using Learun.DataBase.Repository;
using Learun.Util;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Learun.Application.Base.SystemModule;
using Newtonsoft.Json;
namespace Learun.Application.TwoDevelopment.EducationalAdministration
{
///
/// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2018 北京泉江科技有限公司
/// 创 建:超级管理员
/// 日 期:2019-04-02 16:44
/// 描 述:学生考勤
///
public class StuAttendanceService : RepositoryFactory
{
private DataItemIBLL dataItemIBLL = new DataItemBLL();
private CdMajorIBLL cdMajorIBLL = new CdMajorBLL();
#region 获取数据
///
/// 获取页面显示列表数据
///
/// 查询参数
///
public IEnumerable GetPageList(Pagination pagination, string queryJson)
{
try
{
var strSql = new StringBuilder();
strSql.Append("SELECT t.* ");
strSql.Append(" FROM StuAttendance t ");
strSql.Append(" WHERE 1=1 ");
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["ClassNo"].IsEmpty())
{
dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String);
strSql.Append(" and t.ClassNo = @ClassNo ");
}
if (!queryParam["LessonNo"].IsEmpty())
{
dp.Add("LessonNo", queryParam["LessonNo"].ToString(), DbType.String);
strSql.Append(" and t.LessonNo = @LessonNo ");
}
if (!queryParam["EmpNo"].IsEmpty())
{
dp.Add("EmpNo", queryParam["EmpNo"].ToString(), DbType.String);
strSql.Append(" and t.EmpNo = @EmpNo ");
}
return this.BaseRepository("CollegeMIS").FindList(strSql.ToString(), dp, pagination);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
///
/// 获取页面显示列表数据
///
/// 查询参数
///
public IEnumerable GetPageListOfUnrecord(Pagination pagination, string queryJson)
{
try
{
var strSql = new StringBuilder();
var queryParam = queryJson.ToJObject();
// 虚拟参数
var dp = new DynamicParameters(new { });
strSql.Append(@"(
select distinct t.AcademicYearNo,t.Semester,t.DeptNo,t.MajorNo,t.ClassNo,t.LessonNo,t.LessonName,t.LessonSortNo,t.EmpNo
,a.LessonDate,a.LessonTime
from StuSelectLessonList t
left join ArrangeLessonTerm a on t.AcademicYearNo=a.AcademicYearNo and t.Semester=a.Semester and t.LessonNo=a.LessonNo and t.EmpNo=a.EmpNo
where t.StuNo not in (select sa.StuNo from StuAttendance sa where sa.AcademicYearNo=t.AcademicYearNo and sa.Semester=t.Semester and sa.ClassNo=t.ClassNo and sa.LessonNo=t.LessonNo and sa.EmpNo=t.EmpNo and sa.LessonSortNo=t.LessonSortNo)");
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["ClassNo"].IsEmpty())
{
dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String);
strSql.Append(" and t.ClassNo = @ClassNo ");
}
if (!queryParam["StartTime"].IsEmpty())
{
dp.Add("StartTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
strSql.Append(" and a.LessonDate >= @StartTime ");
}
if (!queryParam["EndTime"].IsEmpty())
{
dp.Add("EndTime", queryParam["EndTime"].ToDate(), DbType.DateTime);
strSql.Append(" and a.LessonDate <= @EndTime ");
}
strSql.Append(") union ( ");
strSql.Append(@"select distinct t.AcademicYearNo,t.Semester,t.DeptNo,t.MajorNo,t.ClassNo,t.LessonNo,t.LessonName,t.LessonSortNo,t.EmpNo
,a.LessonDate,a.LessonSection as LessonTime
from StuSelectLessonListOfElective t
left join ArrangeLessonTermOfElective a on t.AcademicYearNo=a.AcademicYearNo and t.Semester=a.Semester and t.LessonNo=a.LessonNo and t.EmpNo=a.EmpNo and t.ClassRoomNo=a.ClassRoomNo
where t.StuNo not in (select sa.StuNo from StuAttendance sa where sa.AcademicYearNo=t.AcademicYearNo and sa.Semester=t.Semester and sa.ClassNo=t.ClassNo and sa.LessonNo=t.LessonNo and sa.EmpNo=t.EmpNo and sa.LessonSortNo=t.LessonSortNo and sa.ClassRoomNo=t.ClassRoomNo and sa.LessonTime in (t.LessonSection))
and t.Status=2");
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["ClassNo"].IsEmpty())
{
dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String);
strSql.Append(" and t.ClassNo = @ClassNo ");
}
if (!queryParam["StartTime"].IsEmpty())
{
dp.Add("StartTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
strSql.Append(" and a.LessonDate >= @StartTime ");
}
if (!queryParam["EndTime"].IsEmpty())
{
dp.Add("EndTime", queryParam["EndTime"].ToDate(), DbType.DateTime);
strSql.Append(" and a.LessonDate <= @EndTime ");
}
strSql.Append(" )");
return this.BaseRepository("CollegeMIS").FindList(strSql.ToString(), dp, pagination);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
public IEnumerable GetAllList()
{
try
{
return this.BaseRepository("CollegeMIS").FindList();
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
///
/// 获取StuAttendance表实体数据
/// 主键
///
///
public StuAttendanceEntity GetStuAttendanceEntity(string keyValue)
{
try
{
//return this.BaseRepository("CollegeMIS").FindEntity(keyValue);
var keyvalue = Convert.ToInt32(keyValue);
return this.BaseRepository("CollegeMIS").FindEntity(keyvalue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
internal List GetStuInfo(string academicYear, string semester, string lessonNo, string empNo, string classRoomNum, string lessonTime, DateTime lessonDate, string teachClassNo)
{
try
{
return this.BaseRepository("CollegeMIS").FindList(a => a.AcademicYearNo == academicYear && a.Semester == semester && a.LessonNo == lessonNo && a.EmpNo == empNo && a.ClassRoomNo == classRoomNum && a.LessonTime == lessonTime && a.LessonDate == lessonDate && a.TeachClassNo == teachClassNo).ToList();
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
internal List GetStuLessonInfo(string account)
{
try
{
return this.BaseRepository("CollegeMIS").FindList(a => a.StuNo == account).ToList();
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
///
/// 考勤统计
///
/// 查询参数
///
public IEnumerable GetAttendanceStatisticPageList(Pagination pagination, string queryJson)
{
try
{
var queryParam = queryJson.ToJObject();
var dp = new DynamicParameters(new { });
var strSql = new StringBuilder();
strSql.Append("select t.AcademicYearNo,t.Semester,t.StuNo,t.StuName,count(a.ALTId) as totalCourse,");
strSql.Append(" (select count(sa.ID) from StuAttendance sa where sa.AcademicYearNo=t.AcademicYearNo and sa.Semester=t.Semester and sa.StuNo=t.StuNo and sa.AttendOrNo='是') as attendanceCourse ");
strSql.Append(" from StuSelectLessonList t ");
strSql.Append(" left join ArrangeLessonTerm a on t.AcademicYearNo=a.AcademicYearNo and t.Semester=a.Semester and t.LessonNo=a.LessonNo and t.EmpNo=a.EmpNo ");
strSql.Append(" where 1=1 ");
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["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 ");
}
strSql.Append(" group by t.AcademicYearNo,t.Semester,t.StuNo,t.StuName ");
// 虚拟参数
return this.BaseRepository("CollegeMIS").FindList(strSql.ToString(), dp, pagination);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
///
/// 全校学生课程考勤
///
/// 查询参数
///
public IEnumerable GetAttendancePageList(Pagination pagination, string queryJson)
{
try
{
var queryParam = queryJson.ToJObject();
var dp = new DynamicParameters(new { });
var strSql = new StringBuilder();
strSql.Append(@"select s.AcademicYearNo,s.Semester,s.DeptNo,s.MajorNo,s.ClassNo,s.LessonNo,s.EmpNo,s.LessonSortNo,s.StuNo,s.StuName,a.AttendOrNo,a.Sort from StuSelectLessonList s
left join StuAttendance a on s.AcademicYearNo = a.AcademicYearNo and s.Semester = a.Semester and s.DeptNo = a.DeptNo and s.MajorNo = a.MajorNo and s.ClassNo = a.ClassNo and s.LessonNo = a.LessonNo and s.EmpNo = a.EmpNo and s.LessonSortNo = a.LessonSortNo and s.StuNo = a.StuNo
where 1=1 ");
if (!queryParam["AcademicYearNo"].IsEmpty())
{
dp.Add("AcademicYearNo", queryParam["AcademicYearNo"].ToString(), DbType.String);
strSql.Append(" and s.AcademicYearNo=@AcademicYearNo ");
}
if (!queryParam["Semester"].IsEmpty())
{
dp.Add("Semester", queryParam["Semester"].ToString(), DbType.String);
strSql.Append(" and s.Semester=@Semester ");
}
if (!queryParam["DeptNo"].IsEmpty())
{
dp.Add("DeptNo", queryParam["DeptNo"].ToString(), DbType.String);
strSql.Append(" and s.DeptNo=@DeptNo ");
}
if (!queryParam["MajorNo"].IsEmpty())
{
dp.Add("MajorNo", queryParam["MajorNo"].ToString(), DbType.String);
strSql.Append(" and s.MajorNo=@MajorNo ");
}
if (!queryParam["LessonNo"].IsEmpty())
{
dp.Add("LessonNo", queryParam["LessonNo"].ToString(), DbType.String);
strSql.Append(" and s.LessonNo=@LessonNo ");
}
if (!queryParam["EmpNo"].IsEmpty())
{
dp.Add("EmpNo", queryParam["EmpNo"].ToString(), DbType.String);
strSql.Append(" and s.EmpNo=@EmpNo ");
}
if (!queryParam["StuNo"].IsEmpty())
{
dp.Add("StuNo", "%" + queryParam["StuNo"].ToString() + "%", DbType.String);
strSql.Append(" and s.StuNo like @StuNo ");
}
if (!queryParam["StuName"].IsEmpty())
{
dp.Add("StuName", "%" + queryParam["StuName"].ToString() + "%", DbType.String);
strSql.Append(" and s.StuName like @StuName ");
}
strSql.Append(" union ");
strSql.Append(@"select s.AcademicYearNo,s.Semester,s.DeptNo,s.MajorNo,s.ClassNo,s.LessonNo,s.EmpNo,s.LessonSortNo,s.StuNo,s.StuName,a.AttendOrNo,a.Sort from StuSelectLessonListOfElective s
left join StuAttendance a on s.AcademicYearNo=a.AcademicYearNo and s.Semester=a.Semester and s.DeptNo=a.DeptNo and s.MajorNo=a.MajorNo and s.ClassNo=a.ClassNo and s.LessonNo=a.LessonNo and s.EmpNo=a.EmpNo and s.LessonSortNo=a.LessonSortNo and s.ClassRoomNo=a.ClassRoomNo and a.LessonTime in (s.LessonSection) and s.StuNo=a.StuNo and s.Status=2
where 1=1 ");
if (!queryParam["AcademicYearNo"].IsEmpty())
{
dp.Add("AcademicYearNo", queryParam["AcademicYearNo"].ToString(), DbType.String);
strSql.Append(" and s.AcademicYearNo=@AcademicYearNo ");
}
if (!queryParam["Semester"].IsEmpty())
{
dp.Add("Semester", queryParam["Semester"].ToString(), DbType.String);
strSql.Append(" and s.Semester=@Semester ");
}
if (!queryParam["DeptNo"].IsEmpty())
{
dp.Add("DeptNo", queryParam["DeptNo"].ToString(), DbType.String);
strSql.Append(" and s.DeptNo=@DeptNo ");
}
if (!queryParam["MajorNo"].IsEmpty())
{
dp.Add("MajorNo", queryParam["MajorNo"].ToString(), DbType.String);
strSql.Append(" and s.MajorNo=@MajorNo ");
}
if (!queryParam["LessonNo"].IsEmpty())
{
dp.Add("LessonNo", queryParam["LessonNo"].ToString(), DbType.String);
strSql.Append(" and s.LessonNo=@LessonNo ");
}
if (!queryParam["EmpNo"].IsEmpty())
{
dp.Add("EmpNo", queryParam["EmpNo"].ToString(), DbType.String);
strSql.Append(" and s.EmpNo=@EmpNo ");
}
if (!queryParam["StuNo"].IsEmpty())
{
dp.Add("StuNo", "%" + queryParam["StuNo"].ToString() + "%", DbType.String);
strSql.Append(" and s.StuNo like @StuNo ");
}
if (!queryParam["StuName"].IsEmpty())
{
dp.Add("StuName", "%" + queryParam["StuName"].ToString() + "%", DbType.String);
strSql.Append(" and s.StuName like @StuName ");
}
// 虚拟参数
return this.BaseRepository("CollegeMIS").FindList(strSql.ToString(), dp, pagination);
}
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.StuAttendanceNo == keyValue);
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, StuAttendanceEntity 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
///
/// 提交课程考勤
///
///
///
///
///
///
public async Task AttendanceApply(string kqType, string lessonTime, string lessonDate, string classRoomNo, string dataJson, decimal? attenScore, string attenCondition)
{
var kqEntity = dataItemIBLL.GetDetailListByParentId("ktkqlx", "0").Find(a => a.F_ItemValue == kqType);
var data = JsonConvert.DeserializeObject>(dataJson);
if (data.Any())
{
var majorList = BaseRepository("CollegeMIS").FindList().ToList();
var deptList = BaseRepository("CollegeMIS").FindList().ToList();
var classList = BaseRepository("CollegeMIS").FindList().ToList();
var lessonSortList = BaseRepository("CollegeMIS").FindList().ToList();
var classRoomList = BaseRepository("CollegeMIS").FindList().ToList();
var db = this.BaseRepository("CollegeMIS").BeginTrans();
try
{
foreach (var stuSelectLessonListEntity in data)
{
var model = new StuAttendanceEntity();
model.AcademicYearNo = stuSelectLessonListEntity.AcademicYearNo;
model.Semester = stuSelectLessonListEntity.Semester;
model.StuNo = stuSelectLessonListEntity.StuNo;
model.StuName = stuSelectLessonListEntity.StuName;
model.Gender = stuSelectLessonListEntity.GenderNo == "0" ? "女" : "男";
model.Grade = stuSelectLessonListEntity.Grade;
model.DeptNo = stuSelectLessonListEntity.DeptNo;
model.DeptName = deptList.Find(m => m.DeptNo == stuSelectLessonListEntity.DeptNo)?.DeptName;
model.MajorNo = stuSelectLessonListEntity.MajorNo;
model.MajorName = majorList.Find(m => m.MajorNo == stuSelectLessonListEntity.MajorNo)?.MajorName;
model.ClassNo = stuSelectLessonListEntity.ClassNo;
model.ClassName = classList.Find(m => m.ClassNo == stuSelectLessonListEntity.ClassNo)?.ClassName;
model.LessonNo = stuSelectLessonListEntity.LessonNo;
model.LessonName = stuSelectLessonListEntity.LessonName;
model.TeachClassNo = stuSelectLessonListEntity.TeachClassNo;
model.LessonSortNo = stuSelectLessonListEntity.LessonSortNo;
model.LessonSortName = lessonSortList
.Find(m => m.LessonSortNo == stuSelectLessonListEntity.LessonSortNo)?.LessonSortName;
model.LessonDate = DateTime.Parse(lessonDate);
model.LessonTime = stuSelectLessonListEntity.LessonSortNo == "2" ? db.FindEntity(x => x.Id == stuSelectLessonListEntity.StuSelectLessonListOfElectiveId)?.LessonSection : lessonTime;
model.AttendOrNo = kqEntity.F_Description;
model.Sort = kqEntity.F_ItemName;
model.AttenScore = attenScore.HasValue ? attenScore.Value : 0;
model.AttenCondition = attenCondition;
model.EmpNo = stuSelectLessonListEntity.EmpNo;
model.CheckMarkDept = "0";
model.CheckMark = "0";
model.InertDate = DateTime.Now;
model.ClassRoomNo = classRoomNo;
model.ClassRoomName = classRoomList.Find(x => x.ClassroomId.Trim() == classRoomNo.Trim())?.ClassroomName.Trim();
//var ifExistModel = BaseRepository("CollegeMIS").FindEntity(m =>
// m.EmpNo == model.EmpNo && m.AcademicYearNo == model.AcademicYearNo &&
// m.Semester == model.Semester && m.StuNo == model.StuNo &&
// m.TeachClassNo == model.TeachClassNo);
if (!string.IsNullOrEmpty(stuSelectLessonListEntity.StuAttendanceNo))
{
model.Modify(stuSelectLessonListEntity.StuAttendanceNo);
db.Update(model);
}
else
{
model.Create();
db.Insert(model);
}
}
db.Commit();
}
catch (Exception ex)
{
db.Rollback();
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
return true;
}
public async Task AttendanceApply(string lessonTime, string lessonDate, string classRoomNo, string dataJson, decimal? attenScore, string attenCondition)
{
var kqList = dataItemIBLL.GetDetailListByParentId("ktkqlx", "0");
var data = JsonConvert.DeserializeObject>(dataJson);
if (data.Any())
{
var majorList = BaseRepository("CollegeMIS").FindList().ToList();
var deptList = BaseRepository("CollegeMIS").FindList().ToList();
var classList = BaseRepository("CollegeMIS").FindList().ToList();
var lessonSortList = BaseRepository("CollegeMIS").FindList().ToList();
var classRoomList = BaseRepository("CollegeMIS").FindList().ToList();
var db = this.BaseRepository("CollegeMIS").BeginTrans();
try
{
foreach (var stuSelectLessonListEntity in data)
{
var kqEntity = kqList.Find(a => a.F_ItemValue == stuSelectLessonListEntity.kqType);
var model = new StuAttendanceEntity();
model.AcademicYearNo = stuSelectLessonListEntity.AcademicYearNo;
model.Semester = stuSelectLessonListEntity.Semester;
model.StuNo = stuSelectLessonListEntity.StuNo;
model.StuName = stuSelectLessonListEntity.StuName;
model.Gender = stuSelectLessonListEntity.GenderNo == "0" ? "女" : "男";
model.Grade = stuSelectLessonListEntity.Grade;
model.DeptNo = stuSelectLessonListEntity.DeptNo;
model.DeptName = deptList.Find(m => m.DeptNo == stuSelectLessonListEntity.DeptNo)?.DeptName;
model.MajorNo = stuSelectLessonListEntity.MajorNo;
model.MajorName = majorList.Find(m => m.MajorNo == stuSelectLessonListEntity.MajorNo)?.MajorName;
model.ClassNo = stuSelectLessonListEntity.ClassNo;
model.ClassName = classList.Find(m => m.ClassNo == stuSelectLessonListEntity.ClassNo)?.ClassName;
model.LessonNo = stuSelectLessonListEntity.LessonNo;
model.LessonName = stuSelectLessonListEntity.LessonName;
model.TeachClassNo = stuSelectLessonListEntity.TeachClassNo;
model.LessonSortNo = stuSelectLessonListEntity.LessonSortNo;
model.LessonSortName = lessonSortList
.Find(m => m.LessonSortNo == stuSelectLessonListEntity.LessonSortNo)?.LessonSortName;
model.LessonDate = DateTime.Parse(lessonDate);
model.LessonTime = stuSelectLessonListEntity.LessonSortNo == "2" ? db.FindEntity(x => x.Id == stuSelectLessonListEntity.StuSelectLessonListOfElectiveId)?.LessonSection : lessonTime;
model.AttendOrNo = kqEntity.F_Description;
model.Sort = kqEntity.F_ItemName;
model.AttenScore = attenScore.HasValue ? attenScore.Value : 0;
model.AttenCondition = attenCondition;
model.EmpNo = stuSelectLessonListEntity.EmpNo;
model.CheckMarkDept = "0";
model.CheckMark = "0";
model.InertDate = DateTime.Now;
model.ClassRoomNo = classRoomNo;
model.ClassRoomName = classRoomList.Find(x => x.ClassroomId.Trim() == classRoomNo.Trim())?.ClassroomName.Trim();
//var ifExistModel = BaseRepository("CollegeMIS").FindEntity(m =>
// m.EmpNo == model.EmpNo && m.AcademicYearNo == model.AcademicYearNo &&
// m.Semester == model.Semester && m.StuNo == model.StuNo &&
// m.TeachClassNo == model.TeachClassNo);
if (!string.IsNullOrEmpty(stuSelectLessonListEntity.StuAttendanceNo))
{
model.Modify(stuSelectLessonListEntity.StuAttendanceNo);
db.Update(model);
}
else
{
model.Create();
db.Insert(model);
}
}
db.Commit();
}
catch (Exception ex)
{
db.Rollback();
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
return true;
}
}
}