20220829未做培训计划 新增按钮手动加入培训记录
This commit is contained in:
@@ -184,5 +184,96 @@ namespace BLL
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 将相关未做培训 但考试考生内容 写培训记录归档
|
||||
/// <summary>
|
||||
/// 将相关未做培训 但考试考生内容 写培训记录归档
|
||||
/// </summary>
|
||||
/// <param name="getTestPlan"></param>
|
||||
|
||||
public static void InsertTrainRecordNoTrainingPlan(Model.Training_TestPlan getTestPlan)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
Model.EduTrain_TrainRecord newTrainRecord = new Model.EduTrain_TrainRecord
|
||||
{
|
||||
TrainingId = SQLHelper.GetNewID(),
|
||||
TrainingCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectTrainRecordMenuId, getTestPlan.ProjectId, Const.UnitId_CWCEC),
|
||||
ProjectId = getTestPlan.ProjectId,
|
||||
TrainTitle = getTestPlan.PlanName,
|
||||
TrainContent = getTestPlan.PlanName,
|
||||
TrainStartDate = getTestPlan.TestStartTime,
|
||||
TeachHour = getTestPlan.Duration,
|
||||
TrainEndDate = getTestPlan.TestEndTime,
|
||||
TeachMan = UserService.GetUserNameByUserId(getTestPlan.PlanManId),
|
||||
TeachAddress = getTestPlan.TestPalce,
|
||||
Remark = "来源:考试计划",
|
||||
TrainTypeId = Const.EntryTrainTypeId,
|
||||
UnitIds = getTestPlan.UnitIds,
|
||||
States = Const.State_2,
|
||||
WorkPostIds = getTestPlan.WorkPostIds,
|
||||
PlanId = getTestPlan.TestPlanId,
|
||||
};
|
||||
newTrainRecord.CompileMan = newTrainRecord.TeachMan;
|
||||
///获取培训人员
|
||||
var getTestRecords = from x in db.Training_TestRecord
|
||||
where x.TestPlanId == getTestPlan.TestPlanId
|
||||
select x;
|
||||
newTrainRecord.TrainPersonNum = getTestRecords.Count();
|
||||
///新增培训记录
|
||||
db.EduTrain_TrainRecord.InsertOnSubmit(newTrainRecord);
|
||||
db.SubmitChanges();
|
||||
|
||||
////及格分数
|
||||
int passScore = 80;
|
||||
var testRule = db.Sys_TestRule.FirstOrDefault();
|
||||
if (testRule != null)
|
||||
{
|
||||
passScore = testRule.PassingScore;
|
||||
}
|
||||
|
||||
foreach (var item in getTestRecords)
|
||||
{
|
||||
var getItem = db.EduTrain_TrainRecordDetail.FirstOrDefault(x => x.PersonId == item.TestManId && x.CheckResult);
|
||||
if (getItem == null)
|
||||
{
|
||||
|
||||
decimal gScores = item.TestScores ?? 0;
|
||||
bool result = false;
|
||||
if (gScores >= passScore)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
Model.EduTrain_TrainRecordDetail newDetail = new Model.EduTrain_TrainRecordDetail
|
||||
{
|
||||
TrainDetailId = SQLHelper.GetNewID(),
|
||||
TrainingId = newTrainRecord.TrainingId,
|
||||
PersonId = item.TestManId,
|
||||
CheckScore = gScores,
|
||||
CheckResult = result,
|
||||
};
|
||||
db.EduTrain_TrainRecordDetail.InsertOnSubmit(newDetail);
|
||||
db.SubmitChanges();
|
||||
|
||||
///// 培训考试 通过 更新卡号
|
||||
if (result)
|
||||
{
|
||||
var getPerson = db.SitePerson_Person.FirstOrDefault(e => e.PersonId == newDetail.PersonId);
|
||||
if (getPerson != null && string.IsNullOrEmpty(getPerson.CardNo))
|
||||
{
|
||||
getPerson.CardNo = SQLHelper.RunProcNewId("SpGetNewNumber", "SitePerson_Person", "CardNo", getPerson.ProjectId, UnitService.GetUnitCodeByUnitId(getPerson.UnitId));
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////增加一条编码记录
|
||||
CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.ProjectTrainRecordMenuId, newTrainRecord.ProjectId, null, newTrainRecord.TrainingId, newTrainRecord.TrainStartDate);
|
||||
CommonService.btnSaveData(newTrainRecord.ProjectId, Const.ProjectTrainRecordMenuId, newTrainRecord.TrainingId, getTestPlan.PlanManId, true, newTrainRecord.TrainTitle, "../EduTrain/TrainRecordView.aspx?TrainingId={0}");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user