using FineUIPro;
using System;
using System.Collections;
using System.Linq;
namespace BLL
{
///
/// 人员培训考试记录。
/// 该服务只保留人员档案和现场人员接口仍使用的查询能力。
///
public static class Person_TrainingTestRecordService
{
///
/// 查询结果总数。
///
public static int count
{
get;
set;
}
///
/// 获取人员培训考试记录分页数据。
///
public static IEnumerable getListData(string personId, Grid grid)
{
var db = Funs.DB;
IQueryable records = from x in db.Training_TestRecord
where x.TestStartTime.HasValue
&& x.TestManId == personId
select x;
count = records.Count();
if (count == 0)
{
return null;
}
records = SortConditionHelper.SortingAndPaging(records, grid.SortField, grid.SortDirection, grid.PageIndex, grid.PageSize);
return from x in records
join y in db.Training_TestPlan on x.TestPlanId equals y.TestPlanId
join z in db.Training_Plan on y.PlanId equals z.PlanId into planGroup
from z in planGroup.DefaultIfEmpty()
select new
{
x.TestRecordId,
x.TestPlanId,
x.ProjectId,
db.Base_Project.First(p => p.ProjectId == x.ProjectId).ProjectName,
y.PlanName,
y.PlanCode,
y.TestPalce,
y.PlanDate,
x.TestStartTime,
x.TestEndTime,
x.TestScores,
z.TrainTypeId,
db.Base_TrainType.First(u => u.TrainTypeId == z.TrainTypeId).TrainTypeName,
z.TrainStartDate,
};
}
///
/// 根据主键获取人员培训考试记录。
///
public static Model.Training_TestRecord GetTestRecordById(string testRecordId)
{
return Funs.DB.Training_TestRecord.FirstOrDefault(e => e.TestRecordId == testRecordId);
}
///
/// 根据人员和入场时间获取入场教育合格记录。
///
public static Model.Training_TestRecord GetOKTestRecordByPersonIdAndDate(string testManId, DateTime? date)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
return (from x in db.Training_TestRecord
join y in db.Training_TestPlan on x.TestPlanId equals y.TestPlanId
join z in db.Training_Plan on y.PlanId equals z.PlanId
where x.TestManId == testManId
&& x.TestStartTime >= date
&& x.TestScores >= 60
&& z.TrainTypeId == Const.EntryEducationTrainTypeId
select x).FirstOrDefault();
}
}
}
}