20220928考试计划试题类型加判断

This commit is contained in:
杨红卫 2022-09-28 17:30:05 +08:00
parent 061826c677
commit 3a62ed2219
2 changed files with 45 additions and 33 deletions

View File

@ -265,18 +265,22 @@ namespace BLL
var trainingType = TestTrainingService.GetTestTrainingById(item.TrainingTypeId); var trainingType = TestTrainingService.GetTestTrainingById(item.TrainingTypeId);
if (trainingType != null) if (trainingType != null)
{ {
Model.Training_TestPlanTraining newPlanItem = new Model.Training_TestPlanTraining var getT = db.Training_TestPlanTraining.FirstOrDefault(x => x.TestPlanId == newTestPlan.TestPlanId && x.TrainingId == item.TrainingTypeId);
if (getT == null)
{ {
TestPlanTrainingId = SQLHelper.GetNewID(), Model.Training_TestPlanTraining newPlanItem = new Model.Training_TestPlanTraining
TestPlanId = newTestPlan.TestPlanId, {
TrainingId = item.TrainingTypeId, TestPlanTrainingId = SQLHelper.GetNewID(),
TestType1Count = item.TestType1Count, TestPlanId = newTestPlan.TestPlanId,
TestType2Count = item.TestType2Count, TrainingId = item.TrainingTypeId,
TestType3Count = item.TestType3Count, TestType1Count = item.TestType1Count,
}; TestType2Count = item.TestType2Count,
TestType3Count = item.TestType3Count,
};
db.Training_TestPlanTraining.InsertOnSubmit(newPlanItem); db.Training_TestPlanTraining.InsertOnSubmit(newPlanItem);
db.SubmitChanges(); db.SubmitChanges();
}
} }
} }
} }
@ -321,18 +325,22 @@ namespace BLL
var trainingType = db.Training_TestTraining.FirstOrDefault(e => e.TrainingId == item.TrainingTypeId); var trainingType = db.Training_TestTraining.FirstOrDefault(e => e.TrainingId == item.TrainingTypeId);
if (trainingType != null) if (trainingType != null)
{ {
Model.Training_TestPlanTraining newPlanItem = new Model.Training_TestPlanTraining var getT = db.Training_TestPlanTraining.FirstOrDefault(x => x.TestPlanId == testPlanId && x.TrainingId == item.TrainingTypeId);
if (getT == null)
{ {
TestPlanTrainingId = SQLHelper.GetNewID(), Model.Training_TestPlanTraining newPlanItem = new Model.Training_TestPlanTraining
TestPlanId = testPlanId, {
TrainingId = item.TrainingTypeId, TestPlanTrainingId = SQLHelper.GetNewID(),
TestType1Count = item.TestType1Count, TestPlanId = testPlanId,
TestType2Count = item.TestType2Count, TrainingId = item.TrainingTypeId,
TestType3Count = item.TestType3Count, TestType1Count = item.TestType1Count,
}; TestType2Count = item.TestType2Count,
TestType3Count = item.TestType3Count,
};
db.Training_TestPlanTraining.InsertOnSubmit(newPlanItem); db.Training_TestPlanTraining.InsertOnSubmit(newPlanItem);
db.SubmitChanges(); db.SubmitChanges();
}
} }
} }
} }
@ -459,18 +467,22 @@ namespace BLL
{ {
foreach (var item in getTrainTypeItems) foreach (var item in getTrainTypeItems)
{ {
/////考试题型类别及数量 var getT = db.Training_TestPlanTraining.FirstOrDefault(x => x.TestPlanId == testPlanId && x.TrainingId == item.TrainingId);
Model.Training_TestPlanTraining newTestPlanTraining = new Model.Training_TestPlanTraining if (getT == null)
{ {
TestPlanTrainingId = SQLHelper.GetNewID(), /////考试题型类别及数量
TestPlanId = testPlanId, Model.Training_TestPlanTraining newTestPlanTraining = new Model.Training_TestPlanTraining
TrainingId = item.TrainingId, {
TestType1Count = item.SCount, TestPlanTrainingId = SQLHelper.GetNewID(),
TestType2Count = item.MCount, TestPlanId = testPlanId,
TestType3Count = item.JCount, TrainingId = item.TrainingId,
}; TestType1Count = item.SCount,
db.Training_TestPlanTraining.InsertOnSubmit(newTestPlanTraining); TestType2Count = item.MCount,
db.SubmitChanges(); TestType3Count = item.JCount,
};
db.Training_TestPlanTraining.InsertOnSubmit(newTestPlanTraining);
db.SubmitChanges();
}
} }
} }
} }

View File

@ -151,9 +151,9 @@ namespace BLL
int sumTestType2Count = 0; int sumTestType2Count = 0;
int sumTestType3Count = 0; int sumTestType3Count = 0;
var testPlanTrainings = from x in db.Training_TestPlanTraining var testPlanTrainings =( from x in db.Training_TestPlanTraining
where x.TestPlanId == getTestPlan.TestPlanId where x.TestPlanId == getTestPlan.TestPlanId
select x; select new { x.TestPlanId,x.TrainingId,x.TestType1Count,x.TestType2Count,x.TestType3Count}).Distinct();
if (testPlanTrainings.Count() > 0) if (testPlanTrainings.Count() > 0)
{ {
//// 计划考试中单选、多选、判断题总数 //// 计划考试中单选、多选、判断题总数