/// <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));
                }
            }
        }
        /// <summary>
        /// 根据主键删除培训记录
        /// </summary>
        /// <param name="trainingId"></param>
        public static void DeleteTrainDetailByTrainDetail(string trainDetailId)
        {
            Model.SUBHSSEDB db = Funs.DB;
            Model.EduTrain_TrainRecordDetail trainDetails = Funs.DB.EduTrain_TrainRecordDetail.FirstOrDefault(e => e.TrainDetailId == trainDetailId);
            if (trainDetails != null)
            {
                db.EduTrain_TrainRecordDetail.DeleteOnSubmit(trainDetails);
                db.SubmitChanges();

                var rainRecord = EduTrain_TrainRecordService.GetTrainingByTrainingId(trainDetails.TrainingId);
                if (rainRecord != null)
                {
                    rainRecord.TrainPersonNum -= 1;
                    BLL.EduTrain_TrainRecordService.UpdateTraining(rainRecord);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 根据主键删除培训计划信息
        /// </summary>
        /// <param name="TestPlanId"></param>
        public static void DeleteTestPlanById(string TestPlanId)
        {
            var getTestPlan = GetTestPlanById(TestPlanId);

            if (getTestPlan != null)
            {
                var testPlanTrainings = from x in Funs.DB.Training_TestPlanTraining where x.TestPlanId == TestPlanId select x;
                if (testPlanTrainings.Count() > 0)
                {
                    Funs.DB.Training_TestPlanTraining.DeleteAllOnSubmit(testPlanTrainings);
                    Funs.DB.SubmitChanges();
                }
                if (getTestPlan.States == "3") //状态考试结束
                {
                    var updateTrainingPlan = TrainingPlanService.GetPlanById(getTestPlan.PlanId);
                    if (updateTrainingPlan != null)
                    {
                        updateTrainingPlan.States = "2";
                        TrainingPlanService.UpdatePlan(updateTrainingPlan);
                        var getTrainingTasks = from x in Funs.DB.Training_Task
                                               where x.PlanId == updateTrainingPlan.PlanId
                                               select x;
                        foreach (var item in getTrainingTasks)
                        {
                            item.States = "1";
                            TrainingTaskService.UpdateTask(item);
                        }
                        ////删除归档的培训记录
                        var trainRecord = Funs.DB.EduTrain_TrainRecord.FirstOrDefault(x => x.PlanId == getTestPlan.PlanId);
                        if (trainRecord != null)
                        {
                            EduTrain_TrainRecordService.DeleteTrainingByTrainingId(trainRecord.TrainingId);
                        }
                    }
                }

                Funs.DB.Training_TestPlan.DeleteOnSubmit(getTestPlan);
                Funs.DB.SubmitChanges();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 插入培训记录 2
        /// </summary>
        /// <param name="projectId"></param>
        /// <param name="arr"></param>
        public static bool AddTrainRecord(string projectId, JArray arr, Model.Sys_User user)
        {
            Model.SUBHSSEDB db   = Funs.DB;
            bool            isOk = true;

            try
            {
                foreach (var item in arr)
                {
                    string fromRecordId = item["ID"].ToString();
                    string trainTypeId  = null; ////培训类型
                    var    getTrainType = db.Base_TrainType.FirstOrDefault(x => x.TrainTypeName == item["TrainType"].ToString());
                    if (getTrainType != null)
                    {
                        trainTypeId = getTrainType.TrainTypeId;
                    }
                    string unitId = null;
                    if (!string.IsNullOrEmpty(item["TrainDepart"].ToString()))
                    {
                        var lists = Funs.GetStrListByStr(item["TrainDepart"].ToString(), ',');
                        if (lists.Count() > 0)
                        {
                            foreach (var itemList in lists)
                            {
                                var getUnit = db.Base_Unit.FirstOrDefault(x => x.UnitName == itemList);
                                if (getUnit != null)
                                {
                                    if (string.IsNullOrEmpty(unitId))
                                    {
                                        unitId = getUnit.UnitId;
                                    }
                                    else
                                    {
                                        unitId += ("," + getUnit.UnitId);
                                    }
                                }
                            }
                        }
                    }

                    if (!string.IsNullOrEmpty(unitId) && !string.IsNullOrEmpty(fromRecordId))
                    {
                        Model.EduTrain_TrainRecord newTrainRecord = new Model.EduTrain_TrainRecord
                        {
                            FromRecordId = fromRecordId,

                            ProjectId      = projectId,
                            TrainTitle     = item["RecordName"].ToString(),
                            TrainContent   = item["TrainContent"].ToString(),
                            TrainStartDate = Funs.GetNewDateTime(item["TrainStartDate"].ToString()),
                            TrainEndDate   = Funs.GetNewDateTime(item["TrainEndDate"].ToString()),
                            TeachHour      = Funs.GetNewDecimalOrZero(item["TrainPeriod"].ToString()),
                            TeachMan       = item["TrainPrincipal"].ToString(),
                            Remark         = item["TrainDescript"].ToString(),
                            TrainTypeId    = trainTypeId,
                            UnitIds        = unitId,
                            States         = Const.State_0,
                            CompileMan     = item["CreateUser"].ToString(),
                            TrainPersonNum = Funs.GetNewInt(item["PersonCount"].ToString()),
                        };

                        newTrainRecord.TrainingCode = Funs.GetNewFileName(newTrainRecord.TrainStartDate);
                        var getTrainRecord = Funs.DB.EduTrain_TrainRecord.FirstOrDefault(x => x.FromRecordId == fromRecordId);
                        if (getTrainRecord == null)
                        {
                            newTrainRecord.TrainingId = SQLHelper.GetNewID(typeof(Model.EduTrain_TrainRecord));
                            EduTrain_TrainRecordService.AddTraining(newTrainRecord);
                            BLL.LogService.AddSys_Log(user, newTrainRecord.TrainingCode, newTrainRecord.TrainingId, BLL.Const.ProjectTrainRecordMenuId, BLL.Const.BtnAdd);
                        }
                        else
                        {
                            getTrainRecord.TrainingCode   = newTrainRecord.TrainingCode;
                            getTrainRecord.TrainTitle     = newTrainRecord.TrainTitle;
                            getTrainRecord.TrainContent   = newTrainRecord.TrainContent;
                            getTrainRecord.UnitIds        = newTrainRecord.UnitIds;
                            getTrainRecord.TrainStartDate = newTrainRecord.TrainStartDate;
                            if (newTrainRecord.TrainEndDate.HasValue)
                            {
                                getTrainRecord.TrainEndDate = newTrainRecord.TrainEndDate;
                            }
                            else
                            {
                                getTrainRecord.TrainEndDate = newTrainRecord.TrainStartDate;
                            }
                            getTrainRecord.TeachHour    = newTrainRecord.TeachHour;
                            getTrainRecord.TeachMan     = newTrainRecord.TeachMan;
                            getTrainRecord.TeachAddress = newTrainRecord.TeachAddress;

                            getTrainRecord.Remark = newTrainRecord.Remark;
                            EduTrain_TrainRecordService.UpdateTraining(getTrainRecord);
                            BLL.LogService.AddSys_Log(user, getTrainRecord.TrainingCode, getTrainRecord.TrainingId, BLL.Const.ProjectTrainRecordMenuId, BLL.Const.BtnModify);
                        }
                    }
                    else
                    {
                        isOk = false;
                    }
                }
            }
            catch (Exception ex)
            {
                isOk = false;
                ErrLogInfo.WriteLog(string.Empty, ex);
            }
            return(isOk);
        }