예제 #1
0
 /// <summary>
 /// 修改考试记录信息
 /// </summary>
 /// <param name="Training"></param>
 public static void UpdateTestRecord(Model.Test_TestRecord testRecord)
 {
     Model.SUBHSSEDB       db            = Funs.DB;
     Model.Test_TestRecord newTestRecord = db.Test_TestRecord.FirstOrDefault(e => e.TestRecordId == testRecord.TestRecordId);
     if (newTestRecord != null)
     {
         newTestRecord.TestScores  = testRecord.TestScores;
         newTestRecord.TestEndTime = testRecord.TestEndTime;
         db.SubmitChanges();
     }
 }
예제 #2
0
        /// <summary>
        /// 新增考生记录信息
        /// </summary>
        /// <param name="Training"></param>
        public static void AddTestRecord(Model.Test_TestRecord testRecord)
        {
            Model.SUBHSSEDB       db            = Funs.DB;
            Model.Test_TestRecord newTestRecord = new Model.Test_TestRecord
            {
                TestRecordId = testRecord.TestRecordId,
                ProjectId    = testRecord.ProjectId,
                TestPlanId   = testRecord.TestPlanId,
                TestManId    = testRecord.TestManId,
            };

            db.Test_TestRecord.InsertOnSubmit(newTestRecord);
            db.SubmitChanges();
        }
예제 #3
0
        /// <summary>
        /// 保存考生信息
        /// </summary>
        /// <param name="testRecord">考试计划记录</param>
        public static Model.TestRecordItem SaveTestRecord(Model.TestRecordItem testRecord)
        {
            using (Model.SUBHSSEDB db = new Model.SUBHSSEDB(Funs.ConnString))
            {
                var getTestPlan = db.Test_TestPlan.FirstOrDefault(x => x.TestPlanId == testRecord.TestPlanId);
                if (getTestPlan != null)
                {
                    testRecord.TestPlanName      = getTestPlan.PlanName;
                    testRecord.TestPlanStartTime = string.Format("{0:yyyy-MM-dd HH:mm:ss}", getTestPlan.TestStartTime);
                    testRecord.TestPlanEndTime   = string.Format("{0:yyyy-MM-dd HH:mm:ss}", getTestPlan.TestEndTime);
                    Model.Test_TestRecord newTestRecord = new Model.Test_TestRecord
                    {
                        TestPlanId   = testRecord.TestPlanId,
                        TestManId    = testRecord.TestManId,
                        TestManName  = testRecord.TestManName,
                        IdentityCard = testRecord.IdentityCard,
                        Telephone    = testRecord.Telephone,
                        ManType      = testRecord.UserType,
                        Duration     = getTestPlan.Duration,
                    };
                    if (!string.IsNullOrEmpty(testRecord.UnitId))
                    {
                        newTestRecord.UnitId = testRecord.UnitId;
                    }
                    if (!string.IsNullOrEmpty(testRecord.DepartId))
                    {
                        newTestRecord.DepartId = testRecord.DepartId;
                    }
                    if (!string.IsNullOrEmpty(testRecord.WorkPostId))
                    {
                        newTestRecord.WorkPostId = testRecord.WorkPostId;
                    }
                    if (!string.IsNullOrEmpty(testRecord.ProjectId))
                    {
                        newTestRecord.ProjectId = testRecord.ProjectId;
                    }

                    if (string.IsNullOrEmpty(newTestRecord.ManType))
                    {
                        if (testRecord.TestManId == Const.sedinId)
                        {
                            newTestRecord.ManType = "2";
                        }
                        else if (UserService.GetUserByUserId(testRecord.TestManId) != null)
                        {
                            newTestRecord.ManType = "1";
                        }
                        else
                        {
                            newTestRecord.ManType = "3";
                        }
                    }

                    Model.Test_TestRecord getUpdateTestRecord = new Model.Test_TestRecord();
                    ;                   getUpdateTestRecord = db.Test_TestRecord.FirstOrDefault(x => x.TestRecordId == testRecord.TestRecordId);
                    if (getUpdateTestRecord == null)
                    {
                        getUpdateTestRecord = db.Test_TestRecord.FirstOrDefault(x => x.TestPlanId == testRecord.TestPlanId && x.IdentityCard == testRecord.IdentityCard);
                    }
                    if (getUpdateTestRecord != null)
                    {
                        testRecord.TestRecordId  = getUpdateTestRecord.TestRecordId;
                        testRecord.TestEndTime   = string.Format("{0:yyyy-MM:dd HH:mm:ss}", getUpdateTestRecord.TestEndTime);
                        testRecord.TestStartTime = string.Format("{0:yyyy-MM:dd HH:mm:ss}", getUpdateTestRecord.TestStartTime);
                        testRecord.TestScores    = getUpdateTestRecord.TestScores ?? 0;

                        if (string.IsNullOrEmpty(getUpdateTestRecord.ManType))
                        {
                            getUpdateTestRecord.ManType = newTestRecord.ManType;
                        }
                        if (!getUpdateTestRecord.TestEndTime.HasValue && getTestPlan.TestEndTime < DateTime.Now)
                        {
                            getUpdateTestRecord.DepartId     = newTestRecord.DepartId;
                            getUpdateTestRecord.TestManName  = newTestRecord.TestManName;
                            getUpdateTestRecord.IdentityCard = newTestRecord.IdentityCard;
                            getUpdateTestRecord.Telephone    = newTestRecord.Telephone;
                            db.SubmitChanges();
                        }
                    }
                    else
                    {
                        if (getTestPlan.TestEndTime > DateTime.Now)
                        {
                            var getTestPlanTraining = db.Test_TestPlanTraining.Where(x => x.TestPlanId == getTestPlan.TestPlanId && x.UserType == testRecord.UserType);
                            if (getTestPlanTraining.Count() > 0)
                            {
                                int cout1 = getTestPlanTraining.Sum(x => x.TestType1Count ?? 0);
                                int cout2 = getTestPlanTraining.Sum(x => x.TestType2Count ?? 0);
                                int cout3 = getTestPlanTraining.Sum(x => x.TestType3Count ?? 0);
                                newTestRecord.QuestionCount = cout1 + cout2 + cout3;
                                newTestRecord.TotalScore    = (getTestPlan.SValue ?? 0) * cout1 + (getTestPlan.MValue ?? 0) * cout2 + (getTestPlan.JValue ?? 0) * cout3;
                            }

                            testRecord.TestRecordId = newTestRecord.TestRecordId = SQLHelper.GetNewID();
                            db.Test_TestRecord.InsertOnSubmit(newTestRecord);
                            db.SubmitChanges();
                        }
                    }

                    if (!string.IsNullOrEmpty(testRecord.TestEndTime))
                    {
                        testRecord.TestStates = "3";
                    }
                    else if (getTestPlan.States == Const.State_2 && getTestPlan.TestEndTime >= DateTime.Now)
                    {
                        testRecord.TestStates = "2";
                    }
                    else if (getTestPlan.States != Const.State_2 || getTestPlan.TestStartTime < DateTime.Now)
                    {
                        testRecord.TestStates = "1";
                    }
                    else if (getTestPlan.TestEndTime < DateTime.Now)
                    {
                        testRecord.TestStates = "0";
                    }
                }
            }
            return(testRecord);
        }