ChengDa_English/SGGL/BLL/HSSE/EduTrain/TrainTestRecordService.cs

80 lines
2.9 KiB
C#
Raw Normal View History

2022-03-15 17:36:38 +08:00
using System;
using System.Linq;
namespace BLL
{
/// <summary>
/// 考试记录
/// </summary>
public static class TrainTestRecordService
{
public static Model.SGGLDB db = Funs.DB;
/// <summary>
/// 根据主键获取考试记录
/// </summary>
/// <param name="testRecordId"></param>
/// <returns></returns>
public static Model.Training_TrainTestRecord GetTrainTestRecordById(string trainingTestRecordId)
{
return Funs.DB.Training_TrainTestRecord.FirstOrDefault(e => e.TrainingTestRecordId == trainingTestRecordId);
}
/// <summary>
/// 新增考生记录信息
/// </summary>
/// <param name="Training"></param>
public static void AddTestRecord(Model.Training_TrainTestRecord testRecord)
{
Model.SGGLDB db = Funs.DB;
Model.Training_TrainTestRecord newTestRecord = new Model.Training_TrainTestRecord
{
TrainingTestRecordId = testRecord.TrainingTestRecordId,
ProjectId = testRecord.ProjectId,
TrainingName = testRecord.TrainingName,
TrainingType = testRecord.TrainingType,
PeopleNum = testRecord.PeopleNum,
UnitId = testRecord.UnitId,
DateA = testRecord.DateA,
DateZ = testRecord.DateZ,
};
db.Training_TrainTestRecord.InsertOnSubmit(newTestRecord);
db.SubmitChanges();
}
/// <summary>
/// 修改考试记录信息
/// </summary>
/// <param name="Training"></param>
public static void UpdateTrainTestRecord(Model.Training_TrainTestRecord testRecord)
{
Model.SGGLDB db = Funs.DB;
Model.Training_TrainTestRecord newTestRecord = db.Training_TrainTestRecord.FirstOrDefault(e => e.TrainingTestRecordId == testRecord.TrainingTestRecordId);
if (newTestRecord != null)
{
newTestRecord.TrainingName = testRecord.TrainingName;
newTestRecord.TrainingType = testRecord.TrainingType;
newTestRecord.PeopleNum = testRecord.PeopleNum;
newTestRecord.UnitId = testRecord.UnitId;
newTestRecord.DateA = testRecord.DateA;
newTestRecord.DateZ = testRecord.DateZ;
db.SubmitChanges();
}
}
/// <summary>
/// 根据计划主键删除考试人员信息
/// </summary>
/// <param name="planId"></param>
public static void DeleteTrainTestRecordById(string TrainingTestRecordId)
{
var deleteRecords = Funs.DB.Training_TrainTestRecord.FirstOrDefault(x=> x.TrainingTestRecordId == TrainingTestRecordId) ;
Funs.DB.Training_TrainTestRecord.DeleteOnSubmit(deleteRecords);
Funs.DB.SubmitChanges();
}
}
}