/// <summary>
        /// 增加教育培训明细信息
        /// </summary>
        /// <param name="trainDetail">教育培训明细信息实体</param>
        public static void AddTrainDetail(Model.EduTrain_TrainRecordDetail trainDetail)
        {
            Model.SUBHSSEDB db       = Funs.DB;
            string          newKeyID = SQLHelper.GetNewID(typeof(Model.EduTrain_TrainRecordDetail));

            Model.EduTrain_TrainRecordDetail newTrainDetail = new Model.EduTrain_TrainRecordDetail
            {
                TrainDetailId = newKeyID,
                TrainingId    = trainDetail.TrainingId,
                PersonId      = trainDetail.PersonId,
                CheckScore    = trainDetail.CheckScore,
                CheckResult   = trainDetail.CheckResult
            };

            db.EduTrain_TrainRecordDetail.InsertOnSubmit(newTrainDetail);
            db.SubmitChanges();

            var rainRecord = EduTrain_TrainRecordService.GetTrainingByTrainingId(trainDetail.TrainingId);

            if (rainRecord != null)
            {
                rainRecord.TrainPersonNum += 1;
                EduTrain_TrainRecordService.UpdateTraining(rainRecord);
            }
            ///// 培训考试 通过 更新卡号
            if (newTrainDetail.CheckResult)
            {
                var getPerson = PersonService.GetPersonById(trainDetail.PersonId);
                if (getPerson != null && string.IsNullOrEmpty(getPerson.CardNo))
                {
                    getPerson.CardNo = SQLHelper.RunProcNewId("SpGetNewNumber", "SitePerson_Person", "CardNo", rainRecord.ProjectId, UnitService.GetUnitCodeByUnitId(getPerson.UnitId));
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 根据菜单id、项目id返回编码 (用于页面新增显示)
        /// </summary>
        /// <param name="menuId"></param>
        /// <param name="projectId"></param>
        /// <returns></returns>
        public static string ReturnCodeByMenuIdProjectId(string menuId, string projectId, string unitId)
        {
            string code        = string.Empty;
            string ruleCodes   = string.Empty;
            int    digit       = 4;
            string symbol      = "-"; ///间隔符
            var    codeRecords = (from x in Funs.DB.Sys_CodeRecords where x.MenuId == menuId && x.ProjectId == projectId orderby x.CompileDate descending select x).FirstOrDefault();

            if (codeRecords != null && !string.IsNullOrEmpty(codeRecords.RuleCodes))
            {
                ruleCodes = codeRecords.RuleCodes;
                if (codeRecords.Digit.HasValue)
                {
                    digit = codeRecords.Digit.Value;
                }
            }
            else
            {
                ////项目
                string ruleCode = string.Empty;
                var    project  = ProjectService.GetProjectByProjectId(projectId);
                if (project != null)
                {
                    string projectCode = project.ProjectCode; ///项目编号
                    ////编码规则表
                    var sysCodeTemplateRule = ProjectData_CodeTemplateRuleService.GetProjectData_CodeTemplateRuleByMenuIdProjectId(menuId, project.ProjectId);
                    if (sysCodeTemplateRule != null)
                    {
                        symbol = sysCodeTemplateRule.Symbol;
                        if (sysCodeTemplateRule.Digit.HasValue)
                        {
                            digit = sysCodeTemplateRule.Digit.Value;
                        }
                        if (sysCodeTemplateRule.IsProjectCode == true)
                        {
                            ruleCode = projectCode + symbol;
                        }
                        if (!string.IsNullOrEmpty(sysCodeTemplateRule.Prefix))
                        {
                            ruleCode += sysCodeTemplateRule.Prefix + symbol;
                        }
                        if (sysCodeTemplateRule.IsUnitCode == true)
                        {
                            var unit = UnitService.GetUnitByUnitId(unitId);
                            if (unit != null)
                            {
                                ruleCode += unit.UnitCode + symbol;
                            }
                        }
                        ruleCodes = ruleCode;
                    }
                }
                else
                {
                    var codeTempRule = Funs.DB.Sys_CodeTemplateRule.FirstOrDefault(x => x.MenuId == menuId);
                    if (codeTempRule != null && !string.IsNullOrEmpty(codeTempRule.Prefix))
                    {
                        if (!string.IsNullOrEmpty(codeTempRule.Symbol))
                        {
                            symbol = codeTempRule.Symbol;
                        }
                        ruleCodes = codeTempRule.Prefix + symbol;
                        if (codeTempRule.Digit.HasValue)
                        {
                            digit = codeTempRule.Digit.Value;
                        }
                    }
                }
            }

            ////获取编码记录表最大排列序号
            int maxNewSortIndex = 0;
            var maxSortIndex    = Funs.DB.Sys_CodeRecords.Where(x => (x.ProjectId == projectId || projectId == null) && x.MenuId == menuId).Select(x => x.SortIndex).Max();

            if (maxSortIndex.HasValue)
            {
                maxNewSortIndex = maxSortIndex.Value;
            }
            maxNewSortIndex = maxNewSortIndex + 1;
            code            = (maxNewSortIndex.ToString().PadLeft(digit, '0')); ///字符自动补零
            if (!string.IsNullOrEmpty(ruleCodes))
            {
                code = ruleCodes + code;
            }

            return(code);
        }
예제 #3
0
 /// <summary>
 /// 获取考生信息
 /// </summary>
 /// <param name="testPlanId"></param>
 /// <param name="testManId"></param>
 /// <param name="userType"></param>
 /// <param name="identityCard"></param>
 /// <returns></returns>
 public static Model.TestRecordItem getTestRecordInfo(string testPlanId, string testManId, string userType, string identityCard)
 {
     using (Model.SUBHSSEDB db = new Model.SUBHSSEDB(Funs.ConnString))
     {
         Model.TestRecordItem newTestRecord = new Model.TestRecordItem();
         var getTestPlan = db.Test_TestPlan.FirstOrDefault(x => x.TestPlanId == testPlanId);
         if (getTestPlan != null)
         {
             newTestRecord.TestPlanName      = getTestPlan.PlanName;
             newTestRecord.TestPlanId        = testPlanId;
             newTestRecord.TestPlanStartTime = string.Format("{0:yyyy-MM-dd HH:mm:ss}", getTestPlan.TestStartTime);
             newTestRecord.TestPlanEndTime   = string.Format("{0:yyyy-MM-dd HH:mm:ss}", getTestPlan.TestEndTime);
             newTestRecord.TestManId         = testManId;
             newTestRecord.UserType          = userType;
             var getUpdateTestRecord = db.Test_TestRecord.FirstOrDefault(x => x.TestPlanId == testPlanId && x.IdentityCard == identityCard);
             if (getUpdateTestRecord == null && userType != "2")
             {
                 getUpdateTestRecord = db.Test_TestRecord.FirstOrDefault(x => x.TestPlanId == testPlanId && x.TestManId == testManId);
             }
             if (getUpdateTestRecord != null)
             {
                 newTestRecord.TestRecordId = getUpdateTestRecord.TestRecordId;
                 newTestRecord.DepartId     = getUpdateTestRecord.DepartId;
                 newTestRecord.UnitId       = getUpdateTestRecord.UnitId;
                 newTestRecord.ProjectId    = getUpdateTestRecord.ProjectId;
                 newTestRecord.TestManName  = getUpdateTestRecord.TestManName;
                 newTestRecord.Telephone    = getUpdateTestRecord.Telephone;
                 newTestRecord.IdentityCard = getUpdateTestRecord.IdentityCard;
                 newTestRecord.TestScores   = getUpdateTestRecord.TestScores ?? 0;
             }
             else
             {
                 if (userType == "1")
                 {
                     var getUser = db.Sys_User.FirstOrDefault(x => x.UserId == testManId);
                     if (getUser != null)
                     {
                         newTestRecord.TestManName  = getUser.UserName;
                         newTestRecord.UnitId       = getUser.UnitId;
                         newTestRecord.DepartId     = getUser.DepartId;
                         newTestRecord.IdentityCard = getUser.IdentityCard;
                         newTestRecord.Telephone    = getUser.Telephone;
                     }
                 }
                 else if (userType == "3")
                 {
                     var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.PersonId == testManId);
                     if (getPerson != null)
                     {
                         newTestRecord.TestManName  = getPerson.PersonName;
                         newTestRecord.ProjectId    = getPerson.ProjectId;
                         newTestRecord.UnitId       = getPerson.UnitId;
                         newTestRecord.WorkPostId   = getPerson.WorkPostId;
                         newTestRecord.IdentityCard = getPerson.IdentityCard;
                         newTestRecord.Telephone    = getPerson.Telephone;
                     }
                 }
                 else
                 {
                     newTestRecord.UnitId = newTestRecord.UnitId = CommonService.GetIsThisUnitId();
                 }
             }
             newTestRecord.DepartName  = DepartService.getDepartNameById(newTestRecord.DepartId);
             newTestRecord.UnitName    = UnitService.GetUnitNameByUnitId(newTestRecord.UnitId);
             newTestRecord.ProjectName = ProjectService.GetProjectNameByProjectId(newTestRecord.ProjectId);
             newTestRecord.IsThiUnit   = CommonService.GetIsThisUnit(newTestRecord.UnitId);
         }
         return(newTestRecord);
     }
 }
예제 #4
0
        /// <summary>
        /// 插入信息-单位信息 1
        /// </summary>
        /// <param name="projectId"></param>
        /// <param name="arr"></param>
        public static bool AddUnit(string projectId, JArray arr, Model.Sys_User user)
        {
            Model.SUBHSSEDB db   = Funs.DB;
            bool            isOk = true;

            try
            {
                foreach (var item in arr)
                {
                    string fromUnitId = item["ID"].ToString();
                    string departName = item["DepartName"].ToString(); ///单位名称
                    string departSir  = item["DepartSir"].ToString();  ///单位级别 0:非项目部 1:项目部级 2:项目部下级单位
                    ////单位类型
                    string unitTypeId  = null;
                    var    getUnitType = db.Base_UnitType.FirstOrDefault(x => x.UnitTypeName == item["DepartType"].ToString());
                    if (getUnitType != null)
                    {
                        unitTypeId = getUnitType.UnitTypeId;
                    }

                    if (!string.IsNullOrEmpty(fromUnitId) && !string.IsNullOrEmpty(departName) && departSir != "1")
                    {
                        if (!string.IsNullOrEmpty(projectId))
                        {
                            Model.Base_Unit newUnit = new Model.Base_Unit
                            {
                                FromUnitId  = fromUnitId,
                                UnitCode    = item["DepartCode"].ToString(),
                                UnitName    = departName,
                                UnitTypeId  = unitTypeId,
                                Corporate   = item["Charge"].ToString(),
                                Telephone   = item["Phone"].ToString(),
                                IsHide      = false,
                                DataSources = projectId,
                            };

                            var getUnit = db.Base_Unit.FirstOrDefault(x => x.FromUnitId == fromUnitId);
                            if (getUnit == null)
                            {
                                var getUnitByName = db.Base_Unit.FirstOrDefault(x => x.UnitName == departName);
                                if (getUnitByName != null)
                                {
                                    newUnit.UnitId           = getUnitByName.UnitId;
                                    getUnitByName.FromUnitId = fromUnitId;
                                    db.SubmitChanges();
                                }
                                else
                                {
                                    newUnit.UnitId = SQLHelper.GetNewID(typeof(Model.Base_Unit));
                                    UnitService.AddUnit(newUnit);
                                }
                            }
                            else
                            {
                                newUnit.UnitId = getUnit.UnitId;
                            }

                            var pUnit = db.Project_ProjectUnit.FirstOrDefault(x => x.ProjectId == projectId && x.UnitId == newUnit.UnitId);
                            if (pUnit == null)
                            {
                                Model.Project_ProjectUnit newProjectUnit = new Model.Project_ProjectUnit
                                {
                                    ProjectId = projectId,
                                    UnitId    = newUnit.UnitId,
                                    UnitType  = Const.ProjectUnitType_2,
                                };

                                ProjectUnitService.AddProjectUnit(newProjectUnit);
                                BLL.LogService.AddSys_Log(user, null, newProjectUnit.ProjectUnitId, BLL.Const.ProjectUnitMenuId, BLL.Const.BtnModify);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                isOk = false;
                ErrLogInfo.WriteLog(string.Empty, ex);
            }
            return(isOk);
        }
예제 #5
0
        /// <summary>
        /// 根据培训计划ID生成 考试计划信息
        /// </summary>
        /// <param name="getTestPlan"></param>
        public static string SaveTestPlanByTrainingPlanId(string trainingPlanId, string userId)
        {
            string testPlanId = string.Empty;

            using (Model.SUBHSSEDB db = new Model.SUBHSSEDB(Funs.ConnString))
            {
                ////培训计划
                var getTrainingPlan = db.Training_Plan.FirstOrDefault(x => x.PlanId == trainingPlanId);;
                if (getTrainingPlan != null && getTrainingPlan.States == "1")
                {
                    testPlanId = SQLHelper.GetNewID();
                    Model.Training_TestPlan newTestPlan = new Model.Training_TestPlan
                    {
                        TestPlanId = testPlanId,
                        ProjectId  = getTrainingPlan.ProjectId,
                        //PlanCode = getTrainingPlan.PlanCode,
                        PlanName      = getTrainingPlan.PlanName,
                        PlanManId     = userId,
                        PlanDate      = DateTime.Now,
                        TestStartTime = DateTime.Now,
                        TestPalce     = getTrainingPlan.TeachAddress,
                        UnitIds       = getTrainingPlan.UnitIds,
                        UnitNames     = UnitService.getUnitNamesUnitIds(getTrainingPlan.UnitIds),
                        WorkPostIds   = getTrainingPlan.WorkPostId,
                        WorkPostNames = WorkPostService.getWorkPostNamesWorkPostIds(getTrainingPlan.WorkPostId),
                        PlanId        = getTrainingPlan.PlanId,
                        States        = "0",
                    };

                    string unitId = string.Empty;
                    var    user   = db.Sys_User.FirstOrDefault(e => e.UserId == userId);
                    if (user != null)
                    {
                        unitId = user.UnitId;
                    }
                    newTestPlan.PlanCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectTestPlanMenuId, newTestPlan.ProjectId, unitId);

                    int Duration       = 90;
                    int SValue         = 1;
                    int MValue         = 2;
                    int JValue         = 1;
                    int testType1Count = 40;
                    int testType2Count = 10;
                    int testType3Count = 40;
                    ////获取考试规则设置数据
                    var getTestRule = db.Sys_TestRule.FirstOrDefault(); ////考试数据设置
                    if (getTestRule != null)
                    {
                        Duration       = getTestRule.Duration;
                        SValue         = getTestRule.SValue;
                        MValue         = getTestRule.MValue;
                        JValue         = getTestRule.JValue;
                        testType1Count = getTestRule.SCount;
                        testType2Count = getTestRule.MCount;
                        testType3Count = getTestRule.JCount;
                    }
                    ////按照培训类型获取试题类型及题型数量
                    var getTrainTypeItems = from x in db.Base_TrainTypeItem
                                            where x.TrainTypeId == getTrainingPlan.TrainTypeId
                                            select x;
                    if (getTrainTypeItems.Count() > 0)
                    {
                        testType1Count = getTrainTypeItems.Sum(x => x.SCount);
                        testType2Count = getTrainTypeItems.Sum(x => x.MCount);
                        testType3Count = getTrainTypeItems.Sum(x => x.JCount);
                    }

                    newTestPlan.Duration      = getTestRule.Duration;
                    newTestPlan.SValue        = getTestRule.SValue;
                    newTestPlan.MValue        = getTestRule.MValue;
                    newTestPlan.JValue        = getTestRule.JValue;
                    newTestPlan.TotalScore    = testType1Count * SValue + testType2Count * MValue + testType3Count * JValue;
                    newTestPlan.QuestionCount = testType1Count + testType2Count + testType3Count;
                    newTestPlan.TestEndTime   = newTestPlan.TestStartTime.AddMinutes(newTestPlan.Duration);
                    ////新增考试计划记录
                    var getIsTestPlan = db.Training_TestPlan.FirstOrDefault(x => x.PlanId == newTestPlan.PlanId);
                    if (getIsTestPlan == null)
                    {
                        db.Training_TestPlan.InsertOnSubmit(newTestPlan);
                        db.SubmitChanges();
                        CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.ProjectTestPlanMenuId, newTestPlan.ProjectId, null, testPlanId, newTestPlan.PlanDate);
                        ///培训人员
                        var getTrainingTask = (from x in db.Training_Task where x.PlanId == trainingPlanId select x).ToList();
                        foreach (var itemTask in getTrainingTask)
                        {
                            Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
                            {
                                TestRecordId = SQLHelper.GetNewID(),
                                ProjectId    = getTrainingPlan.ProjectId,
                                TestPlanId   = testPlanId,
                                TestManId    = itemTask.UserId,
                                TestType     = db.Base_TrainType.First(z => z.TrainTypeId == getTrainingPlan.TrainTypeId).TrainTypeName,
                            };

                            db.Training_TestRecord.InsertOnSubmit(newTestRecord);
                            db.SubmitChanges();
                        }
                        if (getTrainTypeItems.Count() == 0)
                        {
                            /////考试题型类别及数量
                            Model.Training_TestPlanTraining newTestPlanTraining = new Model.Training_TestPlanTraining
                            {
                                TestPlanTrainingId = SQLHelper.GetNewID(),
                                TestPlanId         = testPlanId,
                                TestType1Count     = testType1Count,
                                TestType2Count     = testType2Count,
                                TestType3Count     = testType3Count,
                            };

                            db.Training_TestPlanTraining.InsertOnSubmit(newTestPlanTraining);
                            db.SubmitChanges();
                        }
                        else
                        {
                            foreach (var item in getTrainTypeItems)
                            {
                                /////考试题型类别及数量
                                Model.Training_TestPlanTraining newTestPlanTraining = new Model.Training_TestPlanTraining
                                {
                                    TestPlanTrainingId = SQLHelper.GetNewID(),
                                    TestPlanId         = testPlanId,
                                    TrainingId         = item.TrainingId,
                                    TestType1Count     = item.SCount,
                                    TestType2Count     = item.MCount,
                                    TestType3Count     = item.JCount,
                                };
                                db.Training_TestPlanTraining.InsertOnSubmit(newTestPlanTraining);
                                db.SubmitChanges();
                            }
                        }
                    }
                    ////回写培训计划状态
                    getTrainingPlan.States = "2";
                    db.SubmitChanges();
                }
            }
            return(testPlanId);
        }
예제 #6
0
        /// <summary>
        ///  保存专项检查明细项
        /// </summary>
        /// <param name="newDetail"></param>
        public static void SaveCheckSpecialDetail(Model.CheckSpecialDetailItem newDetail)
        {
            if (!string.IsNullOrEmpty(newDetail.CheckSpecialId))
            {
                Model.Check_CheckSpecialDetail newCheckSpecialDetail = new Model.Check_CheckSpecialDetail
                {
                    CheckSpecialId  = newDetail.CheckSpecialId,
                    CheckItem       = newDetail.CheckItemSetId,
                    CheckItemType   = newDetail.CheckItemSetName,
                    Unqualified     = newDetail.Unqualified,
                    UnitId          = newDetail.UnitId,
                    HandleStep      = newDetail.HandleStep,
                    CompleteStatus  = newDetail.CompleteStatus,
                    RectifyNoticeId = newDetail.RectifyNoticeId,
                    LimitedDate     = Funs.GetNewDateTime(newDetail.LimitedDate),
                    CompletedDate   = Funs.GetNewDateTime(newDetail.CompletedDate),
                    Suggestions     = newDetail.Suggestions,
                    WorkArea        = newDetail.WorkArea,
                    CheckArea       = newDetail.WorkAreaId,
                    CheckContent    = newDetail.CheckContent,
                };
                var getUnit = UnitService.GetUnitByUnitId(newDetail.UnitId);
                if (getUnit != null)
                {
                    newCheckSpecialDetail.UnitId = newDetail.UnitId;
                }

                var updateDetail = Funs.DB.Check_CheckSpecialDetail.FirstOrDefault(x => x.CheckSpecialDetailId == newDetail.CheckSpecialDetailId);
                if (updateDetail == null)
                {
                    newCheckSpecialDetail.CheckSpecialDetailId = SQLHelper.GetNewID();
                    Funs.DB.Check_CheckSpecialDetail.InsertOnSubmit(newCheckSpecialDetail);
                    Funs.DB.SubmitChanges();
                }
                else
                {
                    newCheckSpecialDetail.CheckSpecialDetailId = updateDetail.CheckSpecialDetailId;
                    updateDetail.CheckItem       = newCheckSpecialDetail.CheckItem;
                    updateDetail.CheckItemType   = newCheckSpecialDetail.CheckItemType;
                    updateDetail.Unqualified     = newCheckSpecialDetail.Unqualified;
                    updateDetail.UnitId          = newCheckSpecialDetail.UnitId;
                    updateDetail.HandleStep      = newCheckSpecialDetail.HandleStep;
                    updateDetail.CompleteStatus  = newCheckSpecialDetail.CompleteStatus;
                    updateDetail.RectifyNoticeId = newCheckSpecialDetail.RectifyNoticeId;
                    updateDetail.LimitedDate     = newCheckSpecialDetail.LimitedDate;
                    updateDetail.CompletedDate   = newCheckSpecialDetail.CompletedDate;
                    updateDetail.Suggestions     = newCheckSpecialDetail.Suggestions;
                    updateDetail.WorkArea        = newCheckSpecialDetail.WorkArea;
                    updateDetail.CheckContent    = newCheckSpecialDetail.CheckContent;
                    Funs.DB.SubmitChanges();
                }
                ////保存附件
                if (!string.IsNullOrEmpty(newDetail.AttachUrl1))
                {
                    UploadFileService.SaveAttachUrl(UploadFileService.GetSourceByAttachUrl(newDetail.AttachUrl1, 10, null), newDetail.AttachUrl1, Const.ProjectCheckSpecialMenuId, newCheckSpecialDetail.CheckSpecialDetailId);
                }
                else
                {
                    CommonService.DeleteAttachFileById(Const.ProjectCheckSpecialMenuId, newCheckSpecialDetail.CheckSpecialDetailId);
                }
            }
        }
예제 #7
0
        /// <summary>
        /// 根据考生计划结束时 将相关培训考生内容 写培训记录归档
        /// </summary>
        /// <param name="getTestPlan"></param>

        public static void InsertTrainRecord(Model.Training_TestPlan getTestPlan)
        {
            using (Model.SUBHSSEDB db = new Model.SUBHSSEDB(Funs.ConnString))
            {
                ////获取培训计划
                var getTrainingPlan = db.Training_Plan.FirstOrDefault(e => e.PlanId == getTestPlan.PlanId);
                var getTrainRecord  = db.EduTrain_TrainRecord.FirstOrDefault(x => x.PlanId == getTestPlan.PlanId);
                if (getTrainingPlan != null && getTrainRecord == null)
                {
                    getTrainingPlan.States = "3";
                    db.SubmitChanges();

                    Model.EduTrain_TrainRecord newTrainRecord = new Model.EduTrain_TrainRecord
                    {
                        TrainingId     = SQLHelper.GetNewID(),
                        TrainingCode   = getTrainingPlan.PlanCode,
                        ProjectId      = getTrainingPlan.ProjectId,
                        TrainTitle     = getTrainingPlan.PlanName,
                        TrainContent   = getTrainingPlan.TrainContent,
                        TrainStartDate = getTrainingPlan.TrainStartDate,
                        TeachHour      = getTrainingPlan.TeachHour,
                        TrainEndDate   = getTrainingPlan.TrainEndDate,
                        TeachMan       = getTrainingPlan.TeachMan,
                        TeachAddress   = getTrainingPlan.TeachAddress,
                        Remark         = "来源:培训计划",
                        TrainTypeId    = getTrainingPlan.TrainTypeId,
                        TrainLevelId   = getTrainingPlan.TrainLevelId,
                        UnitIds        = getTrainingPlan.UnitIds,
                        States         = Const.State_2,
                        WorkPostIds    = getTrainingPlan.WorkPostId,
                        PlanId         = getTrainingPlan.PlanId,
                    };
                    newTrainRecord.CompileMan = UserService.GetUserNameByUserId(getTrainingPlan.DesignerId);
                    ///获取培训人员
                    var getTrainingTasks = from x in db.Training_Task where x.PlanId == getTrainingPlan.PlanId
                                           select x;
                    newTrainRecord.TrainPersonNum = getTrainingTasks.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 getTrainingTasks)
                    {
                        decimal gScores = 0;
                        bool    result  = false;
                        ////获取 考生试卷
                        var getTestRecord = db.Training_TestRecord.Where(x => x.TestPlanId == getTestPlan.TestPlanId && x.TestManId == item.UserId);
                        foreach (var itemR in getTestRecord)
                        {
                            if (itemR.TestScores > gScores)
                            {
                                gScores = itemR.TestScores ?? 0;
                            }
                        }

                        if (gScores >= passScore)
                        {
                            result = true;
                        }

                        Model.EduTrain_TrainRecordDetail newDetail = new Model.EduTrain_TrainRecordDetail
                        {
                            TrainDetailId = SQLHelper.GetNewID(),
                            TrainingId    = newTrainRecord.TrainingId,
                            PersonId      = item.UserId,
                            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, getTrainingPlan.DesignerId, true, newTrainRecord.TrainTitle, "../EduTrain/TrainRecordView.aspx?TrainingId={0}");
                }
            }
        }