/// <summary>
        /// 检测是否能报名
        /// </summary>
        /// <param name="ClassId"></param>
        /// <returns></returns>
        public static bool CheckCanEnroll(int ClassId)
        {
            Class_Detail class_Detail = new Class_Detail();
            Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL();
            Member_ClassRegister member_ClassRegister = new Member_ClassRegister();
            member_ClassRegister.ClassId = ClassId;
            member_ClassRegister.PlanId = Code.SiteCache.Instance.PlanId;
            Class_DetailBLL class_DetailBLL = new Class_DetailBLL();
            member_ClassRegister.TrainingId = class_DetailBLL.GetModel(ClassId).TraningId;
            member_ClassRegister.AccountId = Code.SiteCache.Instance.LoginInfo.UserId;
            member_ClassRegister.Status = 1;
            member_ClassRegister.ManagerId = Code.SiteCache.Instance.LoginInfo.UserId;
            member_ClassRegister.Delflag = false;
            member_ClassRegister.CreateDate = DateTime.Now;
            Course_UnitDetailBLL course_UnitDetailBLL = new Course_UnitDetailBLL();
            member_ClassRegister.TotalSchedule = course_UnitDetailBLL.GetList(" TrainingId='" + class_DetailBLL.GetModel(ClassId).TraningId + "' and ParentId=0 and Display=1 and Delflag='false'", "").Count;

            List<Member_ClassRegister> listno = member_ClassRegisterBLL.GetList(" ClassId='" + ClassId + "' and AccountId='" + Code.SiteCache.Instance.LoginInfo.UserId + "' and delflag='false' and Status in (1,2,4)", "");
            if (listno.Count > 0)
            {
                return false;
            }

            //List<Member_ClassRegister> listpass = member_ClassRegisterBLL.GetList(" TrainingId='" + member_ClassRegister.TrainingId + "' and AccountId='" + Code.SiteCache.Instance.LoginInfo.UserId + "' and delflag='false' and (Result=1 or (Result is NULL and Status=4))", "");
            //if (listpass.Count > 0)
            //{
            //    return false;
            //}

            return true;
        }
Example #2
0
        /// <summary>
        /// 重新打分
        /// </summary>
        /// <param name="classId"></param>
        /// <param name="planId"></param>
        /// <param name="accountId"></param>
        public static void resetScore(int classId, int planId)
        {
            var member_classBll = new Member_ClassRegisterBLL();

            var classDetail = new Class_DetailBLL().GetModel(classId);

            var traningBll = new Traning_DetailBLL();
            var traning_detail = traningBll.GetModel(classDetail.TraningId, "");
            if (traning_detail == null) return;

            var courseBll = new Course_DetailBLL();
            var cousre_detail = courseBll.GetList(" TrainingId=" + traning_detail.Id, "");
            if (cousre_detail == null || cousre_detail.Count == 0) return;

            var unitContentBll = new Course_UnitContentBLL();
            var memberList = member_classBll.GetList("Delflag=0 and ClassId=" + classId + " and PlanId=" + planId, "");
            foreach (var memberModel in memberList)
            {
                var accountId = memberModel.AccountId;
                int total = 1;

                IList<Course_UnitContent> contentList = new List<Course_UnitContent>();

                #region
                //重新计算阅读分数

                total = unitContentBll.GetUnitCountByClassAndUnitType(classId, "1,2");
                contentList = DataTableToListHelper<Course_UnitContent>.ConvertToModel(unitContentBll.GetUnitByClassAndUnitType(classId, "1,2"));
                if (contentList != null)
                {
                    var scheduleBll = new Member_ClassUnitContentScheduleBLL();
                    int scoreCount = 0;
                    foreach (var item in contentList)
                    {
                        var scheduleModel = scheduleBll.GetList("Delflag=0 and ClassId=" + classId + " and AccountId=" + accountId + " and UnitContent=" + item.Id, "");
                        if (scheduleModel != null && scheduleModel.Count > 0)
                        {
                            if (scheduleModel.First().score.HasValue)//如果有值说明打过分
                            {
                                scoreCount++;
                            }
                        }
                    }
                    if (scoreCount == total)//全部阅读过,给满分
                    {
                        memberModel.ReadingScore = cousre_detail[0].ReadingRate;
                    }
                    else
                    {
                        memberModel.ReadingScore = cousre_detail[0].ReadingRate * scoreCount / total;//阅读数与总数折算
                    }
                }

                //重新计算讨论分数

                total = unitContentBll.GetUnitCountByClassAndUnitType(classId, "3");
                contentList = DataTableToListHelper<Course_UnitContent>.ConvertToModel(unitContentBll.GetUnitByClassAndUnitType(classId, "3"));
                if (contentList != null)
                {
                    var scheduleBll = new Member_ClassUnitContentScheduleBLL();
                    int scoreCount = 0;
                    foreach (var item in contentList)
                    {
                        var scheduleModel = scheduleBll.GetList("Delflag=0 and ClassId=" + classId + " and AccountId=" + accountId + " and UnitContent=" + item.Id, "");
                        if (scheduleModel != null && scheduleModel.Count > 0)
                        {
                            if (scheduleModel.First().score.HasValue)//如果有值说明打过分
                            {
                                scoreCount++;
                            }
                        }
                    }
                    if (scoreCount == total)//全部讨论过,给满分
                    {
                        memberModel.DiscussScore = cousre_detail[0].DisscusRate;
                    }
                    else
                    {
                        memberModel.DiscussScore = cousre_detail[0].DisscusRate * scoreCount / total;//讨论数与总数折算
                    }
                }

                //如有分值,重新计算作业分数

                total = unitContentBll.GetUnitCountByClassAndUnitType(classId, "4");
                contentList = DataTableToListHelper<Course_UnitContent>.ConvertToModel(unitContentBll.GetUnitByClassAndUnitType(classId, "4"));
                if (contentList != null)
                {
                    var homeworkBll = new Course_UnitHomeWorkBLL();
                    double homeworkscore = 0;
                    foreach (var item in contentList)
                    {
                        var scheduleModel = homeworkBll.GetList("Delflag=0 and ClassId=" + classId + " and AccountId=" + accountId + " and UnitContent=" + item.Id, "");
                        if (scheduleModel != null && scheduleModel.Count > 0)
                        {
                            if (scheduleModel.First().Score.HasValue)//如果有值说明打过分
                            {
                                homeworkscore += (scheduleModel.First().Score.Value * (cousre_detail[0].HomeWorkRate) / (total * 100)).ToDouble();//已打分数与总数折算
                            }
                        }
                    }

                    memberModel.HomeWorkScore = homeworkscore;
                }

                //重新计算测试分数

                total = unitContentBll.GetUnitCountByClassAndUnitType(classId, "5");
                contentList = DataTableToListHelper<Course_UnitContent>.ConvertToModel(unitContentBll.GetUnitByClassAndUnitType(classId, "5"));
                if (contentList != null)
                {
                    var scheduleBll = new Member_ClassUnitContentScheduleBLL();
                    double testscore = 0;
                    foreach (var item in contentList)
                    {
                        var scheduleModel = scheduleBll.GetList("Delflag=0 and ClassId=" + classId + " and AccountId=" + accountId + " and UnitContent=" + item.Id, "");
                        if (scheduleModel != null && scheduleModel.Count > 0)
                        {
                            if (scheduleModel.First().score.HasValue)
                            {
                                testscore += (scheduleModel.First().score.Value * (cousre_detail[0].QuestionRate) / (total * 100)).ToDouble();
                            }
                        }
                    }
                    memberModel.TestingScore = testscore;
                }

                //重新计算考试分数

                total = unitContentBll.GetUnitCountByClassAndUnitType(classId, "6");
                contentList = DataTableToListHelper<Course_UnitContent>.ConvertToModel(unitContentBll.GetUnitByClassAndUnitType(classId, "6"));
                if (contentList != null)
                {
                    var scheduleBll = new Member_ClassUnitContentScheduleBLL();
                    double examcore = 0;
                    foreach (var item in contentList)
                    {
                        var scheduleModel = scheduleBll.GetList("Delflag=0 and ClassId=" + classId + " and AccountId=" + accountId + " and UnitContent=" + item.Id, "");
                        if (scheduleModel != null && scheduleModel.Count > 0)
                        {
                            if (scheduleModel.First().score.HasValue)
                            {
                                examcore += (scheduleModel.First().score.Value * (cousre_detail[0].TestingRate) / (total * 100)).ToDouble();
                            }
                        }
                    }
                    memberModel.ExaminationScore = examcore;
                }
                #endregion

                member_classBll.Update(memberModel);
            }
        }
Example #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="objectId">单元ID</param>
        /// <param name="objectType">单元类型</param>
        /// <param name="classId">班级ID</param>
        /// <param name="planId">计划ID</param>
        /// <param name="accountId">成员ID</param>
        /// <param name="score">分值</param>
        public static void ScoreSet(int? objectId, int objectType, int classId, int planId, int accountId, double score, bool add = true)
        {
            dynamic objectBll;
            dynamic model;
            Member_ClassRegister memberModel;
            int total = 1;
            var member_classBll = new Member_ClassRegisterBLL();
            var member_class = member_classBll.GetList(" Delflag=0 and ClassId=" + classId + " and PlanId=" + planId + " and AccountId=" + accountId, "");
            if (member_class == null || member_class.Count == 0) return;
            memberModel = member_class.FirstOrDefault();

            var traningBll = new Traning_DetailBLL();
            var traning_detail = traningBll.GetModel(memberModel.TrainingId.Value, "");
            if (traning_detail == null) return;

            var courseBll = new Course_DetailBLL();
            var cousre_detail = courseBll.GetList(" Delflag=0 and TrainingId=" + traning_detail.Id, "");
            if (cousre_detail == null || cousre_detail.Count == 0) return;

            var unitContentBll = new Course_UnitContentBLL();
            var oldScore = 0.0;
            switch (objectType)
            {
                case 1://read

                    objectBll = new Member_ClassUnitContentScheduleBLL();
                    model = objectBll.GetList("Delflag=0 and ClassId=" + classId + " and AccountId=" + accountId + " and UnitContent=" + objectId, "");
                    if (model.Count > 0)
                    {
                        if (add)
                            model[0].score = 1;
                        else
                            model[0].score = 0;
                        objectBll.Update(model[0]);//
                    }
                    total = unitContentBll.GetUnitCountByClassAndUnitType(classId, "1,2");//阅读视频类的单元活动数
                    if (total > 1)
                    {
                        if (add)
                            memberModel.ReadingScore = (memberModel.ReadingScore.HasValue ? memberModel.ReadingScore.Value : 0)
                                + (cousre_detail[0].ReadingRate / (total)).ToDouble();
                        else
                        {
                            if (memberModel.ReadingScore.HasValue && memberModel.ReadingScore.Value.ToInt() > 0)
                                memberModel.ReadingScore = memberModel.ReadingScore.Value
                                    - (cousre_detail[0].ReadingRate / (total)).ToDouble();
                        }
                    }
                    else
                    {
                        if (add)
                            memberModel.ReadingScore = cousre_detail[0].ReadingRate;
                        else
                            memberModel.ReadingScore = 0.0;
                    }

                    if (memberModel.ReadingScore > cousre_detail[0].ReadingRate)
                    {
                        memberModel.ReadingScore = cousre_detail[0].ReadingRate;
                    }
                    if (memberModel.ReadingScore < 0)
                    {
                        memberModel.ReadingScore = 0;
                    }
                    member_classBll.Update(memberModel);//更新班级成员考试分数总值
                    break;
                case 2://discuss
                    objectBll = new Member_ClassUnitContentScheduleBLL();
                    model = objectBll.GetList("Delflag=0 and ClassId=" + classId + " and AccountId=" + accountId + " and UnitContent=" + objectId, "");
                    if (model.Count > 0)
                    {
                        if (add)
                            model[0].score = 1;
                        else
                            model[0].score = 0;
                        objectBll.Update(model[0]);//
                    }
                    total = unitContentBll.GetUnitCountByClassAndUnitType(classId, "3");//讨论类的单元活动数
                    if (total > 1)
                    {
                        if (add)
                            memberModel.DiscussScore = (memberModel.DiscussScore.HasValue ? memberModel.DiscussScore.Value : 0)
                                + (cousre_detail[0].DisscusRate / (total)).ToDouble();
                        else
                        {
                            if (memberModel.ReadingScore.HasValue && memberModel.ReadingScore.Value.ToInt() > 0)
                                memberModel.DiscussScore = memberModel.DiscussScore.Value
                                    - (cousre_detail[0].DisscusRate / (total)).ToDouble();
                        }
                    }
                    else
                    {
                        if (add)
                            memberModel.DiscussScore = cousre_detail[0].DisscusRate;
                        else
                            memberModel.DiscussScore = 0.0;
                    }

                    if (memberModel.DiscussScore > cousre_detail[0].DisscusRate)
                    {
                        memberModel.DiscussScore = cousre_detail[0].DisscusRate;
                    }
                    if (memberModel.DiscussScore < 0)
                    {
                        memberModel.DiscussScore = 0;
                    }
                    member_classBll.Update(memberModel);//更新班级成员考试分数总值
                    break;
                case 3://homework
                    #region

                    objectBll = new Course_UnitHomeWorkBLL();
                    model = objectBll.GetModel(objectId.Value, "");
                    model.Score = score;
                    model.ScoreCreater = SiteCache.Instance.ManagerId;
                    objectBll.Update(model);//更新结果表
                    total = unitContentBll.GetUnitCountByClassAndUnitType(classId, "4");//作业类的单元活动数
                    if (total > 1)
                    {
                        memberModel.HomeWorkScore = (memberModel.HomeWorkScore.HasValue ? memberModel.HomeWorkScore.Value : 0)
                           + (score * (cousre_detail[0].HomeWorkRate) / (total * 100)).ToDouble();
                    }
                    else
                    {
                        memberModel.HomeWorkScore = (score * (cousre_detail[0].HomeWorkRate) / (100)).ToDouble();
                    }

                    if (memberModel.HomeWorkScore > cousre_detail[0].HomeWorkRate)
                    {
                        memberModel.HomeWorkScore = cousre_detail[0].HomeWorkRate;
                    }
                    member_classBll.Update(memberModel);//更新班级成员作业分数总值
                    #endregion
                    break;
                case 4://question
                    #region

                    objectBll = new Member_ClassUnitContentScheduleBLL();
                    model = objectBll.GetModel(objectId.Value, "");
                    oldScore = model.score == null ? 0 : model.score;
                    model.score = score;
                    objectBll.Update(model);//更新班级成员测试分数总值
                    total = unitContentBll.GetUnitCountByClassAndUnitType(classId, "5");//测试类的单元活动数
                    if (add)//第一次打分
                    {
                        if (total > 1)
                        {
                            memberModel.TestingScore = (memberModel.TestingScore.HasValue ? memberModel.TestingScore.Value : 0)
                               + (score * (cousre_detail[0].QuestionRate) / (total * 100)).ToDouble();
                        }
                        else
                        {
                            memberModel.TestingScore = (score * (cousre_detail[0].QuestionRate) / (100)).ToDouble();
                        }
                    }
                    else//多次打分,重新计算
                    {
                        var contentList = DataTableToListHelper<Course_UnitContent>.ConvertToModel(unitContentBll.GetUnitByClassAndUnitType(classId, "5"));
                        if (contentList != null)
                        {
                            var scheduleBll = new Member_ClassUnitContentScheduleBLL();
                            double testscore = 0;
                            foreach (var item in contentList)
                            {
                                var scheduleModel = scheduleBll.GetList("Delflag=0 and ClassId=" + classId + " and AccountId=" + accountId + " AND UnitContent=" + item.Id, "");
                                if (scheduleModel != null && scheduleModel.Count > 0)
                                {
                                    if (scheduleModel.First().score.HasValue)
                                    {
                                        testscore += (scheduleModel.First().score.Value * (cousre_detail[0].QuestionRate) / (total * 100)).ToDouble();
                                    }
                                }
                            }
                            memberModel.TestingScore = testscore;
                        }
                    }
                    if (memberModel.TestingScore > cousre_detail[0].QuestionRate)
                    {
                        memberModel.TestingScore = cousre_detail[0].QuestionRate;
                    }
                    member_classBll.Update(memberModel);//更新班级成员测试分数总值
                    #endregion
                    break;
                case 5://examnation
                    #region

                    objectBll = new Member_ClassUnitContentScheduleBLL();
                    model = objectBll.GetModel(objectId.Value, "");
                    oldScore = model.score == null ? 0 : model.score;
                    model.score = score;
                    if (score >= 60)//考试大于等于60分算通过
                        memberModel.IsPass = true;
                    objectBll.Update(model);//更新班级成员考试分数总值
                    total = unitContentBll.GetUnitCountByClassAndUnitType(classId, "6");//考试类的单元活动数
                    if (total > 1)
                    {
                        memberModel.ExaminationScore = (memberModel.ExaminationScore.HasValue ? memberModel.ExaminationScore.Value : 0)
                            + (score * (cousre_detail[0].TestingRate) / (total * 100)).ToDouble();
                    }
                    else
                    {
                        memberModel.ExaminationScore = (score * (cousre_detail[0].TestingRate) / (100)).ToDouble();
                    }

                    if (memberModel.ExaminationScore > cousre_detail[0].TestingRate)
                    {
                        memberModel.ExaminationScore = cousre_detail[0].TestingRate;
                    }
                    member_classBll.Update(memberModel);//更新班级成员考试分数总值
                    #endregion
                    break;
                case 6://comment
                    #region
                    objectBll = new Member_ClassRegisterBLL();
                    model = objectBll.GetList(" Delflag=0 and ClassId=" + classId + " and PlanId=" + planId + " and AccountId=" + accountId, "")[0];
                    model.CommentScore = (score * (cousre_detail[0].CommentRate) / (total * 100)).ToDouble();
                    objectBll.Update(model);//更新班级成员评价分数总值
                    #endregion
                    break;
                default: break;
            }
        }
        public ActionResult addRecordInfo(string userId, string classId, int scoType, string recordData, string timestamp)
        {
            int result;
            string msg;

            #region 验证参数
            string teacherNo = ApiTools.Decrypt(HttpUtility.UrlDecode(userId), aesKey, aesIV).Replace("\0", "");
            //userId = Dianda.Common.StringSecurity.DES.Decrypt(HttpUtility.UrlDecode(userId));
            if (string.IsNullOrEmpty(teacherNo))
            {
                result = 0;
                msg = "参数:userId的加密格式错误";
                return Json(new { Result = result, Msg = msg });
            }

            classId = ApiTools.Decrypt(HttpUtility.UrlDecode(classId), aesKey, aesIV);
            //classId = Dianda.Common.StringSecurity.DES.Decrypt(HttpUtility.UrlDecode(classId));
            if (string.IsNullOrEmpty(classId))
            {
                result = 0;
                msg = "参数:classId的加密格式错误";
                return Json(new { Result = result, Msg = msg });
            }
            int trainingId;
            if (!int.TryParse(classId.Replace("\0", ""), out trainingId))
            {
                result = 0;
                msg = "参数:classId不是合法的整数类型";
                return Json(new { Result = result, Msg = msg });
            }

            if (scoType < 1 || scoType > 7)
            {
                result = 0;
                msg = "参数:scoType不合法";
                return Json(new { Result = result, Msg = msg });
            }

            recordData = ApiTools.Decrypt(HttpUtility.UrlDecode(recordData), aesKey, aesIV);
            //recordData = Dianda.Common.StringSecurity.DES.Decrypt(HttpUtility.UrlDecode(recordData));
            if (string.IsNullOrEmpty(recordData))
            {
                result = 0;
                msg = "参数:recordData的加密格式错误";
                return Json(new { Result = result, Msg = msg });
            }
            JavaScriptSerializer jss = new JavaScriptSerializer();
            OutCourse outcourse;
            try
            {
                outcourse = jss.Deserialize<OutCourse>(recordData.Replace("\0", ""));
            }
            catch (Exception)
            {
                result = 0;
                msg = "参数:recordData不是合法的Json格式";
                return Json(new { Result = result, Msg = msg });
            }

            if (!Dianda.Common.StringSecurity.MD5Lib.Encrypt(
                DateTime.Now.ToString("yyyyMMddHH") + teacherNo + trainingId).Equals(timestamp, StringComparison.CurrentCultureIgnoreCase))
            {
                result = 0;
                msg = "参数:timestamp验证不通过";
                return Json(new { Result = result, Msg = msg });
            }
            #endregion

            Member_ClassRegisterBLL mcBLL = new Member_ClassRegisterBLL();
            Member_ClassRegister mcModel = mcBLL.GetModel("Delflag=0 and TrainingId=" + this.ConvertTrainingId(trainingId)
                + " and AccountId=(select top 1.AccountId from Member_BaseInfo where Delflag=0 and TeacherNo='" + teacherNo + "') and PlanId=" + Code.SiteCache.Instance.PlanId);
            if (mcModel == null)
            {
                result = 0;
                msg = "学员班级信息不存在";
                return Json(new { Result = result, Msg = msg });
            }

            switch (scoType)
            {
                case 1:
                    if (mcModel.ReadingScore == null)
                        mcModel.ReadingScore = 1;
                    else
                        mcModel.ReadingScore += 1;
                    break;

                case 2:
                    if (mcModel.ReadingScore == null)
                        mcModel.ReadingScore = 1;
                    else
                        mcModel.ReadingScore += 1;
                    break;

                case 3:
                    if (mcModel.TestingScore == null)
                        mcModel.TestingScore = 1;
                    else
                        mcModel.TestingScore += 1;
                    break;

                case 4:
                    if (mcModel.DiscussScore == null)
                        mcModel.DiscussScore = 1;
                    else
                        mcModel.DiscussScore += 1;
                    break;

                case 5:
                    if (mcModel.HomeWorkScore == null)
                        mcModel.HomeWorkScore = 1;
                    else
                        mcModel.HomeWorkScore += 1;
                    break;

                case 6:
                    if (mcModel.ExaminationScore == null)
                        mcModel.ExaminationScore = 1;
                    else
                        mcModel.ExaminationScore += 1;
                    break;

                case 7:
                    if (mcModel.OtherScore == null)
                        mcModel.OtherScore = 1;
                    else
                        mcModel.OtherScore += 1;
                    break;
            }

            Course_OutCourseRecordBLL bll = new Course_OutCourseRecordBLL();
            Course_OutCourseRecord model = new Course_OutCourseRecord();
            model.ClassId = mcModel.ClassId;
            model.TrainingId = mcModel.TrainingId;
            model.AccountId = mcModel.AccountId;
            model.DataType = scoType;
            model.Status = true;
            model.Delflag = false;
            ConvertModel(outcourse, model);

            try
            {
                using (TransactionScope trans = new TransactionScope())
                {
                    bll.Add(model);
                    mcBLL.Update(mcModel);
                    trans.Complete();
                    result = 1;
                    msg = "新增学习记录成功";
                    ApiTools.WriteLog(TraceEventType.Information, 1, "新增学习活动记录");
                    return Json(new { Result = result, Msg = msg });
                }
            }
            catch (Exception e)
            {
                ApiTools.WriteLog(TraceEventType.Error, 0, e.ToString());
                result = 0;
                msg = "新增学习记录失败";
                return Json(new { Result = result, Msg = msg });
            }
        }
        public ActionResult setEvaluation(string userId, string classId, int isPassed, string assessmentName, string remark, string timestamp)
        {
            int result;
            string msg;

            #region 验证参数
            string teacherNo = ApiTools.Decrypt(HttpUtility.UrlDecode(userId), aesKey, aesIV).Replace("\0", "");
            //userId = Dianda.Common.StringSecurity.DES.Decrypt(HttpUtility.UrlDecode(userId));
            if (string.IsNullOrEmpty(userId))
            {
                result = 0;
                msg = "参数:userId的加密格式错误";
                return Json(new { Result = result, Msg = msg });
            }

            classId = ApiTools.Decrypt(HttpUtility.UrlDecode(classId), aesKey, aesIV);
            //classId = Dianda.Common.StringSecurity.DES.Decrypt(HttpUtility.UrlDecode(classId));
            if (string.IsNullOrEmpty(classId))
            {
                result = 0;
                msg = "参数:classId的加密格式错误";
                return Json(new { Result = result, Msg = msg });
            }
            int trainingId;
            if (!int.TryParse(classId.Replace("\0", ""), out trainingId))
            {
                result = 0;
                msg = "参数:classId不是合法的整数类型";
                return Json(new { Result = result, Msg = msg });
            }

            if (!Dianda.Common.StringSecurity.MD5Lib.Encrypt(
                DateTime.Now.ToString("yyyyMMddHH") + teacherNo + trainingId).Equals(timestamp, StringComparison.CurrentCultureIgnoreCase))
            {
                result = 0;
                msg = "参数:timestamp验证不通过";
                return Json(new { Result = result, Msg = msg });
            }
            #endregion

            Member_ClassRegisterBLL mcBLL = new Member_ClassRegisterBLL();
            Member_ClassRegister mcModel = mcBLL.GetModel("Delflag=0 and TrainingId=" + this.ConvertTrainingId(trainingId)
                + " and AccountId=(select top 1.AccountId from Member_BaseInfo where Delflag=0 and TeacherNo='" + teacherNo + "') and PlanId=" + Code.SiteCache.Instance.PlanId);
            if (mcModel == null)
            {
                result = 0;
                msg = "学员班级信息不存在";
                return Json(new { Result = result, Msg = msg });
            }

            if (isPassed == 1)
                mcModel.Result = 1;
            else
                mcModel.Result = 0;

            Course_OutCourseRecordBLL bll = new Course_OutCourseRecordBLL();
            Course_OutCourseRecord model = new Course_OutCourseRecord();
            model.AssessmentName = assessmentName;
            model.ClassId = mcModel.ClassId;
            model.TrainingId = mcModel.TrainingId;
            model.AccountId = mcModel.AccountId;
            model.DataType = 0;
            if (isPassed == 1)
                model.IsPassed = true;
            else
                model.IsPassed = false;
            model.Remark = remark;
            model.Status = true;
            model.Delflag = false;
            model.CreateDate = DateTime.Now;

            try
            {
                using (TransactionScope trans = new TransactionScope())
                {
                    bll.Add(model);
                    mcBLL.Update(mcModel);
                    trans.Complete();
                    result = 1;
                    msg = "结业评定操作成功";
                    ApiTools.WriteLog(TraceEventType.Information, 1, "结业评定");
                    return Json(new { Result = result, Msg = msg });
                }
            }
            catch (Exception e)
            {
                ApiTools.WriteLog(TraceEventType.Error, 0, e.ToString());
                result = 0;
                msg = "结业评定操作失败";
                return Json(new { Result = result, Msg = msg });
            }
        }
        public JsonResult ClassRegister(int ClassId)
        {
            Class_Detail class_Detail = new Class_Detail();
            Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL();
            Member_ClassRegister member_ClassRegister = new Member_ClassRegister();
            member_ClassRegister.ClassId = ClassId;
            member_ClassRegister.PlanId = Code.SiteCache.Instance.PlanId;
            Class_DetailBLL class_DetailBLL = new Class_DetailBLL();
            member_ClassRegister.TrainingId = class_DetailBLL.GetModel(ClassId).TraningId;
            member_ClassRegister.AccountId = Code.SiteCache.Instance.LoginInfo.UserId;
            member_ClassRegister.Status = 1;
            member_ClassRegister.ManagerId = Code.SiteCache.Instance.LoginInfo.UserId;
            member_ClassRegister.Delflag = false;
            member_ClassRegister.CreateDate = DateTime.Now;
            Course_UnitDetailBLL course_UnitDetailBLL = new Course_UnitDetailBLL();
            member_ClassRegister.TotalSchedule = course_UnitDetailBLL.GetList(" TrainingId='" + class_DetailBLL.GetModel(ClassId).TraningId + "' and ParentId=0 and Display=1 and Delflag='false'", "").Count;

            //if (!IsCanRegister(ClassId, true, Code.SiteCache.Instance.LoginInfo.UserId))
            string checkmessage = IsCanRegisterAll(ClassId, true, Code.SiteCache.Instance.LoginInfo.UserId);
            if (checkmessage != "")
            {
                return Json(new { Code = -1, Msg = checkmessage }, JsonRequestBehavior.AllowGet);
            }

            List<Member_ClassRegister> listno = member_ClassRegisterBLL.GetList(" ClassId='" + ClassId + "' and AccountId='" + Code.SiteCache.Instance.LoginInfo.UserId + "' and delflag='false' and Status in (1,2,4)", "");
            if (listno.Count > 0)
            {
                return Json(new { Code = -1, Msg = "您已经提交了报名申请" }, JsonRequestBehavior.AllowGet);
            }

            List<Member_ClassRegister> listpass = member_ClassRegisterBLL.GetList(" TrainingId='" + member_ClassRegister.TrainingId + "' and AccountId='" + Code.SiteCache.Instance.LoginInfo.UserId + "' and delflag='false' and (Result=1 or (Result is NULL and Status in(1,2,4)))", "");
            if (listpass.Count > 0)
            {
                return Json(new { Code = -1, Msg = "您已经学过该课程或已报名该课程下的其他班级" }, JsonRequestBehavior.AllowGet);
            }

            List<Member_ClassRegister> listup = member_ClassRegisterBLL.GetList(" ClassId='" + ClassId + "' and AccountId='" + Code.SiteCache.Instance.LoginInfo.UserId + "' and delflag='false' and Status in (3,5)", "");
            if (listup.Count > 0)
            {
                member_ClassRegister.Id = listup[0].Id;
                member_ClassRegister.Status = 1;
                member_ClassRegisterBLL.Update(member_ClassRegister);

                if (member_ClassRegister.Id > 0)
                {
                    class_Detail = class_DetailBLL.GetModel(member_ClassRegister.ClassId);
                    class_Detail.People += 1;
                    class_DetailBLL.Update(class_Detail);

                    Member_ClassRegisterApplicationBLL member_ClassRegisterApplicationBLL = new Member_ClassRegisterApplicationBLL();
                    Member_ClassRegisterApplication member_ClassRegisterApplication = new Member_ClassRegisterApplication();
                    member_ClassRegisterApplication.ClassRegisterId = member_ClassRegister.Id;
                    member_ClassRegisterApplication.Status = 1;
                    member_ClassRegisterApplication.Creater = Code.SiteCache.Instance.LoginInfo.UserId;
                    member_ClassRegisterApplication.CreateDate = DateTime.Now;
                    member_ClassRegisterApplication.Delflag = false;
                    member_ClassRegisterApplicationBLL.Add(member_ClassRegisterApplication);
                    return Json(new { Code = 0, Msg = "提交成功" }, JsonRequestBehavior.AllowGet);
                }
                else { return Json(new { Code = -1, Msg = "提交失败" }, JsonRequestBehavior.AllowGet); }
            }
            else
            {
                int RegisterId = member_ClassRegisterBLL.Add(member_ClassRegister);
                class_Detail = class_DetailBLL.GetModel(member_ClassRegister.ClassId);
                class_Detail.People += 1;
                class_DetailBLL.Update(class_Detail);
                if (RegisterId > 0)
                {
                    Member_ClassRegisterApplicationBLL member_ClassRegisterApplicationBLL = new Member_ClassRegisterApplicationBLL();
                    Member_ClassRegisterApplication member_ClassRegisterApplication = new Member_ClassRegisterApplication();
                    member_ClassRegisterApplication.ClassRegisterId = RegisterId;
                    member_ClassRegisterApplication.Status = 1;
                    member_ClassRegisterApplication.Creater = Code.SiteCache.Instance.LoginInfo.UserId;
                    member_ClassRegisterApplication.CreateDate = DateTime.Now;
                    member_ClassRegisterApplication.Delflag = false;
                    member_ClassRegisterApplicationBLL.Add(member_ClassRegisterApplication);
                    return Json(new { Code = 0, Msg = "提交成功" }, JsonRequestBehavior.AllowGet);
                }
                else { return Json(new { Code = -1, Msg = "提交失败" }, JsonRequestBehavior.AllowGet); }
            }
        }
        public ActionResult BatchAuditGraduate(int classId, string Ids, string Remark)
        {
            try
            {
                var bll = new Member_ClassRegisterBLL();
                var ids = Ids.Split(',');
                var classDetail = new Dianda.AP.BLL.Class_DetailBLL().GetModel(classId);
                var tranFieldModel = new Traning_DetailBLL().GetModel(classDetail.TraningId, "");

                foreach (var id in ids)
                {
                    if (!string.IsNullOrEmpty(id))
                    {
                        var Val = id.Split('|')[1].ToInt();
                        if (Val == 0) continue;//不操作

                        var model = bll.GetList("Delflag=0 and ClassId=" + classId + " and AccountId=" + id.Split('|')[0].ToInt(), "").First();

                        model.Result = Val;

                        var totalScore = (model.ReadingScore.HasValue ? model.ReadingScore.Value : 0)
                            + (model.DiscussScore.HasValue ? model.DiscussScore.Value : 0)
                            + (model.HomeWorkScore.HasValue ? model.HomeWorkScore.Value : 0)
                            + (model.TestingScore.HasValue ? model.TestingScore.Value : 0)
                            + (model.ExaminationScore.HasValue ? model.ExaminationScore.Value : 0)
                            + (model.CommentScore.HasValue ? model.CommentScore.Value : 0);

                        if (Math.Ceiling(totalScore) < 60 && Val == 1 && tranFieldModel.OutSideType == -1)//分数小于60,不操作
                            continue;

                        model.ApplyRemark = Remark;
                        model.ResultCreater = SiteCache.Instance.LoginInfo.UserId;
                        model.TotalScore = totalScore;
                        bll.Update(model);

                        var comment = new Dianda.AP.BLL.Class_TraningCommentResultBLL().GetListModel(" ClassId=" + classId + " and AccountId=" + id.Split('|')[0].ToInt() + " and Delflag=0");
                        if (Val == 1 && comment != null && comment.Count>0)//如果结论是合格,,并且评论过课程,则要更新用户学分
                        {
                            var tranEditModel = new Member_TrainingReditBLL().GetList("Delflag=0 and TrainingField=" + tranFieldModel.TraingField
                                + " and PlanId=" + model.PlanId + " and AccountId=" + model.AccountId, "");
                            Member_TrainingRedit tranEdit = null;
                            if (tranEditModel == null || tranEditModel.Count == 0)//创建
                            {
                                tranEdit = new Member_TrainingRedit();
                                tranEdit.AccountId = model.AccountId;
                                tranEdit.CreateDate = DateTime.Now;
                                tranEdit.Credits = tranFieldModel.TotalTime.Value;
                                tranEdit.Delflag = false;
                                tranEdit.PlanId = model.PlanId;
                                tranEdit.TrainingField = tranFieldModel.TraingField;
                                new Member_TrainingReditBLL().Add(tranEdit);
                            }
                            else//更新
                            {
                                tranEdit = tranEditModel.First();
                                tranEdit.Credits += tranFieldModel.TotalTime.Value;
                                new Member_TrainingReditBLL().Update(tranEdit);
                            }
                            var traningCredit = DataTableToListHelper<Training_Credits>.ConvertToModel(
                                new Training_CreditsBLL().GetList(" and PlanId=" + model.PlanId + " and OrganId=" + classDetail.OrganId, "")
                                );//查找学时学分
                            if (traningCredit != null && traningCredit.Count > 0) //轮循所有大类
                            {
                                bool graduateFlag = true;
                                var member_traningBll = new Member_TrainingReditBLL();
                                foreach (var item in traningCredit)
                                {
                                    var traning_credit = member_traningBll.GetList
                                        (" Delflag=0 and PlanId=" + model.PlanId + " and AccountId=" + model.AccountId + " and TrainingField=" + item.TraningField
                                        , "");
                                    if (traningCredit != null && traningCredit.Count > 0)
                                    {
                                        if (traningCredit.First().MinValue > tranEdit.Credits)
                                        {
                                            graduateFlag = false;
                                            break;
                                        }
                                    }
                                }
                                if (graduateFlag)//所有大类学分均合格,更新Member_PlanOverall表的用户合格状态。
                                {
                                    var Member_PlanOverallBll = new Member_PlanOverallBLL();
                                    var Member_PlanOverall = Member_PlanOverallBll.GetListModel(" Delflag=0 and  PlanId=" + model.PlanId + " and AccountId=" + model.AccountId);
                                    if (Member_PlanOverall != null && Member_PlanOverall.Count > 0)
                                    {
                                        var item = Member_PlanOverall.First();
                                        item.Result = 1;
                                        Member_PlanOverallBll.Update(item);
                                    }
                                    else
                                    {
                                        var item = new Member_PlanOverall();
                                        item.Result = 1;
                                        item.PlanId = model.PlanId;

                                        item.AccountId = model.AccountId;
                                        item.CreateDate = DateTime.Now;
                                        item.Delflag = false;

                                        Member_PlanOverallBll.Add(item);
                                    }
                                }
                            }

                        }
                    }
                }

                return Json(new { Code = 0, Msg = "提交成功" }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                return Json(new { Code = -1, Msg = ex.Message + ex.StackTrace }, JsonRequestBehavior.AllowGet);
            }
        }
        /// <summary>
        /// 课程是否已结束
        /// </summary>
        /// <param name="iClassId"></param>
        /// <param name="iTrainingId"></param>
        /// <param name="iAccountId"></param>
        /// <returns></returns>
        private bool GetCourseIsOver(int iClassId, int iTrainingId, int iAccountId)
        {
            var classBll = new Class_DetailBLL();
            var registerBll = new Member_ClassRegisterBLL();
            var Model_Member_ClassRegister = new Member_ClassRegister();
            int iPlanId = Code.SiteCache.Instance.PlanId;
            var iResult = 0;

            ///***************************************************************1. 判断当前班级的课程有没有结束  开始***************************************************************/
            //var Model_Class_Detail = classBll.GetModel(iClassId);
            //if (Model_Class_Detail.Status == 6 || Model_Class_Detail.OpenClassTo > DateTime.Now)//班级的课程已结束
            //{
            //    return true;
            //}
            ///***************************************************************判断当前班级的课程有没有结束  结束***************************************************************/

            /***************************************************************2. 判断当前用户的课程有没有结束  开始***************************************************************/
            string strWhere = string.Format(@" AccountId = {0} AND ClassId = {1} AND PlanId = {2} and TrainingId = {3} and Delflag = 0 AND Status = 4",
                    iAccountId, iClassId, iPlanId, iTrainingId);

            var List_Member_ClassRegister = registerBll.GetList(strWhere, "CreateDate");
            if (List_Member_ClassRegister != null && List_Member_ClassRegister.Count == 1)
            {
                Model_Member_ClassRegister = List_Member_ClassRegister[0];
                iResult = Model_Member_ClassRegister.Result == null ? 0 : Convert.ToInt32(Model_Member_ClassRegister.Result.Value);
            }
            /***************************************************************判断当前用户的课程有没有结束  结束***************************************************************/

            return iResult == 1;
        }
        public ActionResult MyVerify(int Status, int mpId, string content)
        {
            try
            {
                Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL();
                Member_ClassRegister member_ClassRegister = member_ClassRegisterBLL.GetModel(mpId, "");
                member_ClassRegister = member_ClassRegisterBLL.GetModel(mpId, "");
                if ((Status == 3 && member_ClassRegister.Status != 3) || (Status == 5 && member_ClassRegister.Status != 5))
                {
                    Class_DetailBLL class_DetailBLL = new Class_DetailBLL();
                    Class_Detail class_Detail = new Class_Detail();
                    class_Detail = class_DetailBLL.GetModel(member_ClassRegister.ClassId);
                    class_Detail.People -= 1;
                    class_DetailBLL.Update(class_Detail);
                }
                else if ((Status == 2 && member_ClassRegister.Status == 3) || (Status == 4 && member_ClassRegister.Status == 5) || (Status == 2 && member_ClassRegister.Status == 5))
                {
                    Class_DetailBLL class_DetailBLL = new Class_DetailBLL();
                    Class_Detail class_Detail = new Class_Detail();
                    class_Detail = class_DetailBLL.GetModel(member_ClassRegister.ClassId);
                    class_Detail.People += 1;
                    if (class_Detail.LimitPeopleCnt != -1)
                    {
                        if (class_Detail.LimitPeopleCnt < class_Detail.People)
                        {
                            TempData["Msg"] = "超过报名限制!";
                            return RedirectToAction("../../Market/Coursemarket/CoursemarketVerify");
                        }
                    }
                    class_DetailBLL.Update(class_Detail);
                }
                member_ClassRegister.Status = Status;
                member_ClassRegister.ApplyRemark = content;
                member_ClassRegisterBLL.Update(member_ClassRegister);

                Member_ClassRegisterApplicationBLL member_ClassRegisterApplicationBLL = new Member_ClassRegisterApplicationBLL();
                Member_ClassRegisterApplication member_ClassRegisterApplication = new Member_ClassRegisterApplication();
                member_ClassRegisterApplication.ClassRegisterId = mpId;
                member_ClassRegisterApplication.Status = Status;
                member_ClassRegisterApplication.Remark = content;
                member_ClassRegisterApplication.Creater = Code.SiteCache.Instance.LoginInfo.UserId;
                member_ClassRegisterApplication.Delflag = false;
                member_ClassRegisterApplication.CreateDate = DateTime.Now;
                member_ClassRegisterApplicationBLL.Add(member_ClassRegisterApplication);
                TempData["Msg"] = "提交成功!";
                return RedirectToAction("../../Market/Coursemarket/CoursemarketVerify");
            }
            catch (Exception)
            {
                TempData["Msg"] = "提交失败!";
                return RedirectToAction("../../Market/Coursemarket/CoursemarketVerify");
            }
        }
        public ActionResult DetailInformation(int Id)
        {
            ViewBag.Title = "报名详细信息";
            Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL();
            Member_ClassRegister member_ClassRegister = new Member_ClassRegister();
            member_ClassRegister = member_ClassRegisterBLL.GetModel(Id, "");

            Class_DetailBLL class_DetailBLL = new Class_DetailBLL();
            Class_Detail class_Detail = new Class_Detail();
            class_Detail = class_DetailBLL.GetModel(member_ClassRegister.ClassId);

            Member_AccountBLL member_AccountBLL = new Member_AccountBLL();
            ViewBag.AcountInfo = member_AccountBLL.GetModel(member_ClassRegister.AccountId, "");

            Member_BaseInfoBLL member_BaseInfoBLL = new Member_BaseInfoBLL();
            ViewBag.BaseInfo = member_BaseInfoBLL.GetModelByAccountId(member_ClassRegister.AccountId);

            Member_ClassRegisterApplicationBLL member_ClassRegisterApplicationBLL = new Member_ClassRegisterApplicationBLL();
            ViewBag.CApplicationList = member_ClassRegisterApplicationBLL.GetList(" Delflag='false' and ClassRegisterId='" + member_ClassRegister.Id + "'", "CreateDate");
            return View(class_Detail);
        }
        public ActionResult CoursemarketVerifyPage(int Id)
        {
            int groupId = Code.SiteCache.Instance.GroupId;//4,学校管理7,普通教师
            ViewData["groupId"] = groupId;
            ViewData["mId"] = Id;
            ViewBag.Title = "报名审核";
            Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL();
            Member_ClassRegister member_ClassRegister = new Member_ClassRegister();
            member_ClassRegister = member_ClassRegisterBLL.GetModel(Id, "");

            Class_DetailBLL class_DetailBLL = new Class_DetailBLL();
            Class_Detail class_Detail = new Class_Detail();
            class_Detail = class_DetailBLL.GetModel(member_ClassRegister.ClassId);

            Member_AccountBLL member_AccountBLL = new Member_AccountBLL();
            ViewBag.AcountInfo = member_AccountBLL.GetModel(member_ClassRegister.AccountId, "");

            Member_BaseInfoBLL member_BaseInfoBLL = new Member_BaseInfoBLL();
            ViewBag.BaseInfo = member_BaseInfoBLL.GetModelByAccountId(member_ClassRegister.AccountId);

            Member_ClassRegisterApplicationBLL member_ClassRegisterApplicationBLL = new Member_ClassRegisterApplicationBLL();
            ViewBag.CApplicationList = member_ClassRegisterApplicationBLL.GetList(" Delflag='false' and ClassRegisterId='" + member_ClassRegister.Id + "'", "CreateDate");
            return View(class_Detail);
        }
        /// <summary>
        /// 学校--审核列表
        /// </summary>
        /// <returns></returns>
        public ActionResult CoursemarketVerify(int? pageIndex, int? planId, int? status, int? trainingId, int? myclassId, string searchTitle)
        {
            ViewBag.Title = "教师报名管理";
            int i = TypeConverter.ObjectToInt(pageIndex, 1);
            int groupId = Code.SiteCache.Instance.GroupId;//4,学校管理7,普通教师
            //int groupId = 4;
            Organ_DetailBLL organ_DetailBLL = new Organ_DetailBLL();
            int OrganId = 0;
            string where = "";
            if (groupId == 4)
            {
                OrganId = (int)organ_DetailBLL.GetModel(Code.SiteCache.Instance.ManageOrganId).ParentId;
                ViewBag.Yes = 2;
                ViewBag.No = 3;
                where += " and ma.OrganId='" + Code.SiteCache.Instance.ManageOrganId + "'";
                //where += " and mcr.Status<=3";
            }
            else if (groupId == 2)
            {
                OrganId = Code.SiteCache.Instance.ManageOrganId;
                ViewBag.Yes = 4;
                ViewBag.No = 5;
                where += " and cd.OrganId='" + Code.SiteCache.Instance.ManageOrganId + "'";
                where += " and mcr.Status in(2,4,5)";
            }
            else if (groupId == 3)
            {
                OrganId = Code.SiteCache.Instance.ManageOrganId;
                ViewBag.Yes = 4;
                ViewBag.No = 5;
                where += " and cd.OrganId='" + Code.SiteCache.Instance.ManageOrganId + "'";
                where += " and mcr.Status in(2,4,5)";
            }
            else
            {
                where += " and 1=2";
            }
            if (planId != null && planId > 0)
            {
                where += " and mcr.PlanId='" + planId + "' ";
            }
            else { planId = -1; }
            if (status != null && status > 0)
            {
                where += " and mcr.Status='" + status + "' ";
            }
            else { status = -1; }
            if (trainingId != null && trainingId > 0)
            {
                where += " and mcr.TrainingId='" + trainingId + "' ";
            }
            else { trainingId = -1; }
            if (myclassId != null && myclassId > 0)
            {
                where += " and mcr.ClassId='" + myclassId + "' ";
            }
            else { myclassId = -1; }

            if (!string.IsNullOrEmpty(searchTitle))
            { where += " and (mbi.RealName like'%" + searchTitle.Replace("'", "''") + "%' or ma.Nickname like '%" + searchTitle.Replace("'", "''") + "%' or ma.UserName like '%" + searchTitle.Replace("'", "''") + "%' or mbi.TeacherNo like '%" + searchTitle.Replace("'", "''") + "%' or mbi.CredentialsNumber like '%" + searchTitle.Replace("'", "''") + "%' or td.Title like '%" + searchTitle.Replace("'", "''") + "%' or cd.Title like '%" + searchTitle.Replace("'", "''") + "%')"; }

            int total = 0;
            Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL();
            List<ClassRegisterManage> tdlist = member_ClassRegisterBLL.GetListManage(10, i, where, "CreateDate desc", out total);

            ViewData["searchTitle"] = string.IsNullOrEmpty(searchTitle) ? "" : searchTitle;
            ViewData["planId"] = planId;
            ViewData["status"] = status;
            ViewData["trainingId"] = trainingId;
            ViewData["myclassId"] = myclassId;
            ViewData["groupId"] = groupId;
            ViewBag.pageIndex = i;
            ViewBag.totalPage = total;

            Training_PlanBLL training_PlanBLL = new Training_PlanBLL();
            ViewBag.PlanList = training_PlanBLL.GetListModel(" Display=1 and Delflag='false'");

            Traning_FieldBLL traning_FieldBLL = new Traning_FieldBLL();
            ViewBag.FieldList = traning_FieldBLL.GetList(" Display=1 and Delflag='false' and IsSpec=0", " Sort");

            Traning_DetailBLL traning_DetailBLL = new Traning_DetailBLL();
            ViewBag.TraningList = traning_DetailBLL.GetList(" Display=1 and Delflag='false' and PartitionId='" + Code.SiteCache.Instance.LoginInfo.PartitionId + "' and Status=5 and (OrganId='" + OrganId + "' or Range=2)", " Id");

            Class_DetailBLL class_DetailBLL = new Class_DetailBLL();
            ViewBag.ClassList = class_DetailBLL.GetListModel(" Display=1 and Delflag='false' ");

            return View(tdlist);
        }
        public JsonResult ClassRegisterAll(int ClassId, string Members, string MembersNames)
        {
            Class_DetailBLL class_DetailBLL = new Class_DetailBLL();
            string[] members = Members.Trim().Substring(1, Members.Length - 2).Split(',');
            string[] membersNames = MembersNames.Trim().Substring(1, MembersNames.Length - 2).Split(',');
            string names = "";
            string namespass = "";
            string namescannotmessage = "";
            string message = "";

            for (int i = 0; i < members.Length; i++)
            {
                Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL();
                Member_ClassRegister member_ClassRegister = new Member_ClassRegister();

                List<Member_ClassRegister> listno = member_ClassRegisterBLL.GetList(" ClassId='" + ClassId + "' and AccountId='" + members[i] + "' and delflag='false' and Status in (1,2,4)", "");
                if (listno.Count > 0)
                {
                    names += membersNames[i] + ",";
                }

                List<Member_ClassRegister> listpass = member_ClassRegisterBLL.GetList(" TrainingId='" + member_ClassRegister.TrainingId + "' and AccountId='" + members[i] + "' and delflag='false' and (Result=1 or (Result is NULL and Status in(1,2,4)))", "");
                if (listpass.Count > 0)
                {
                    namespass += membersNames[i] + ",";
                }
                string checkmessage = IsCanRegisterAll(ClassId, false, Convert.ToInt32(members[i]));
                if (checkmessage != "")
                {
                    namescannotmessage += membersNames[i] + checkmessage;
                }
            }

            if (names != "")
            {
                message += names.Trim(',') + "已报名该课程;";
            }
            if (namespass != "")
            {
                message += namespass.Trim(',') + "已学过该课程;";
            }
            if (namescannotmessage != "")
            {
                message += namescannotmessage;
            }
            if (message != "")
            {
                return Json(new { Code = -1, Msg = message }, JsonRequestBehavior.AllowGet);
            }
            else
            {
                Class_Detail class_Detail = new Class_Detail();
                class_Detail = class_DetailBLL.GetModel(ClassId);
                class_Detail.People += members.Length;
                class_DetailBLL.Update(class_Detail);
                for (int i = 0; i < members.Length; i++)
                {
                    Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL();
                    Member_ClassRegister member_ClassRegister = new Member_ClassRegister();

                    member_ClassRegister.ClassId = ClassId;
                    member_ClassRegister.PlanId = Code.SiteCache.Instance.PlanId;
                    member_ClassRegister.TrainingId = class_DetailBLL.GetModel(ClassId).TraningId;
                    member_ClassRegister.AccountId = Convert.ToInt32(members[i]);
                    member_ClassRegister.Status = 2;
                    member_ClassRegister.BatchCode = Guid.NewGuid();
                    member_ClassRegister.ManagerId = Code.SiteCache.Instance.LoginInfo.UserId;
                    member_ClassRegister.Delflag = false;
                    member_ClassRegister.CreateDate = DateTime.Now;
                    Course_UnitDetailBLL course_UnitDetailBLL = new Course_UnitDetailBLL();
                    member_ClassRegister.TotalSchedule = course_UnitDetailBLL.GetList(" TrainingId='" + class_DetailBLL.GetModel(ClassId).TraningId + "' and ParentId=0 and Display=1 and Delflag='false'", "").Count;

                    List<Member_ClassRegister> listup = member_ClassRegisterBLL.GetList(" ClassId='" + ClassId + "' and AccountId='" + members[i] + "' and delflag='false' and Status in (3,5)", "");
                    if (listup.Count > 0)
                    {
                        member_ClassRegister.Id = listup[0].Id;
                        member_ClassRegister.Status = 2;
                        member_ClassRegisterBLL.Update(member_ClassRegister);
                        if (member_ClassRegister.Id > 0)
                        {
                            Member_ClassRegisterApplicationBLL member_ClassRegisterApplicationBLL = new Member_ClassRegisterApplicationBLL();
                            Member_ClassRegisterApplication member_ClassRegisterApplication = new Member_ClassRegisterApplication();
                            member_ClassRegisterApplication.ClassRegisterId = member_ClassRegister.Id;
                            member_ClassRegisterApplication.Status = 2;
                            member_ClassRegisterApplication.Creater = Code.SiteCache.Instance.LoginInfo.UserId;
                            member_ClassRegisterApplication.CreateDate = DateTime.Now;
                            member_ClassRegisterApplication.Delflag = false;
                            member_ClassRegisterApplicationBLL.Add(member_ClassRegisterApplication);
                        }
                        else { return Json(new { Code = -1, Msg = "提交失败" }, JsonRequestBehavior.AllowGet); }
                    }
                    else
                    {
                        int RegisterId = member_ClassRegisterBLL.Add(member_ClassRegister);
                        if (RegisterId > 0)
                        {
                            Member_ClassRegisterApplicationBLL member_ClassRegisterApplicationBLL = new Member_ClassRegisterApplicationBLL();
                            Member_ClassRegisterApplication member_ClassRegisterApplication = new Member_ClassRegisterApplication();
                            member_ClassRegisterApplication.ClassRegisterId = RegisterId;
                            member_ClassRegisterApplication.Status = 2;
                            member_ClassRegisterApplication.Creater = Code.SiteCache.Instance.LoginInfo.UserId;
                            member_ClassRegisterApplication.CreateDate = DateTime.Now;
                            member_ClassRegisterApplication.Delflag = false;
                            member_ClassRegisterApplicationBLL.Add(member_ClassRegisterApplication);
                        }
                        else { return Json(new { Code = -1, Msg = "提交失败" }, JsonRequestBehavior.AllowGet); }
                    }
                }
            }
            return Json(new { Code = 0, Msg = "提交成功" }, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 当前[我的进度]
        /// </summary>
        /// <param name="TrainingId"></param>
        public void MyProgress(int TrainingId)
        {
            int iAccountId = 0, iClassId = 0,iPlanId=0;

            iAccountId = Code.SiteCache.Instance.LoginInfo.UserId;
            int.TryParse(Convert.ToString(Request["ClassId"]) == "" ? "0" : QueryString.Decrypt(Request["ClassId"]), out iClassId);//获取 ClassId
            iPlanId = Code.SiteCache.Instance.PlanId;

            Member_ClassRegister Model_Member_ClassRegister = new Member_ClassRegister();

            var bll = new Member_ClassRegisterBLL();
            string strWhere = string.Format(@"AccountId = {0} AND ClassId = {1} AND PlanId = {2} and TrainingId = {3} and Delflag = 0 AND Status = 4 ",
                iAccountId, iClassId, iPlanId, TrainingId);
            var List_Member_ClassRegister = bll.GetList(strWhere, "CreateDate");

            if (List_Member_ClassRegister != null && List_Member_ClassRegister.Count == 1)
            {
                Model_Member_ClassRegister = List_Member_ClassRegister[0];
            }

            ViewBag.Model_Member_ClassRegister = Model_Member_ClassRegister;
        }
        public JsonResult MyVerifyAll(int Status, string Ids)
        {
            try
            {
                string[] myIds = Ids.Trim(',').Split(',');
                foreach (string Id in myIds)
                {
                    Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL();
                    Member_ClassRegister member_ClassRegister = new Member_ClassRegister();
                    member_ClassRegister = member_ClassRegisterBLL.GetModel(Convert.ToInt32(Id), "");

                    if ((Status == 3 && member_ClassRegister.Status != 3) || (Status == 5 && member_ClassRegister.Status != 5))
                    {
                        Class_DetailBLL class_DetailBLL = new Class_DetailBLL();
                        Class_Detail class_Detail = new Class_Detail();
                        class_Detail = class_DetailBLL.GetModel(member_ClassRegister.ClassId);
                        class_Detail.People -= 1;
                        class_DetailBLL.Update(class_Detail);
                    }
                    else if ((Status == 2 && member_ClassRegister.Status == 3) || (Status == 4 && member_ClassRegister.Status == 5) || (Status == 2 && member_ClassRegister.Status == 5))
                    {
                        Class_DetailBLL class_DetailBLL = new Class_DetailBLL();
                        Class_Detail class_Detail = new Class_Detail();
                        class_Detail = class_DetailBLL.GetModel(member_ClassRegister.ClassId);
                        class_Detail.People += 1;
                        class_DetailBLL.Update(class_Detail);
                    }
                    member_ClassRegister.Status = Status;
                    member_ClassRegisterBLL.Update(member_ClassRegister);

                    Member_ClassRegisterApplicationBLL member_ClassRegisterApplicationBLL = new Member_ClassRegisterApplicationBLL();
                    Member_ClassRegisterApplication member_ClassRegisterApplication = new Member_ClassRegisterApplication();
                    member_ClassRegisterApplication.ClassRegisterId = Convert.ToInt32(Id);
                    member_ClassRegisterApplication.Status = Status;
                    member_ClassRegisterApplication.Creater = Code.SiteCache.Instance.LoginInfo.UserId;
                    member_ClassRegisterApplication.Delflag = false;
                    member_ClassRegisterApplication.CreateDate = DateTime.Now;
                    member_ClassRegisterApplicationBLL.Add(member_ClassRegisterApplication);
                }
                return Json(new { Code = 0, Msg = "提交成功" }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                return Json(new { Code = -1, Msg = ex.Message }, JsonRequestBehavior.AllowGet);
            }
        }
        public ActionResult CourseLearn(int TrainingId,int ClassId)
        {
            //ViewBag.Title = "课程预览";

            Course_DetailBLL bll = new Course_DetailBLL();
            Code.SiteCache cache = Code.SiteCache.Instance;

            //指定课程的课程ID
            ViewBag.TrainingId = TrainingId;
            //获取指定课程ID对应的课程单元信息
            ViewBag.TrainingInfo = bll.GetTrainingInfoById(TrainingId);
            //获取班级ID
            ViewBag.ClassId = ClassId;

            Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL();
            ViewBag.Score = member_ClassRegisterBLL.GetList("ClassId='" + ClassId + "' and Status=4 and Delflag='false' and PlanId='" + Code.SiteCache.Instance.PlanId + "' and AccountId='" + Code.SiteCache.Instance.LoginInfo.UserId + "'", "")[0].ExaminationScore;

            cache.TrainingId = TrainingId;
            cache.UnitId = TrainingId;
            cache.ClassId = ClassId;
            ViewBag.ExamQuesCnt = cache.ExamQuesInfo.Count;
            ViewBag.ExamInfo = cache.ActivityLearn;

            this.MyProgress(TrainingId);

            return View();
        }
        public JsonResult EditClass(string id, string Title, string TraningId, string PlanId, string SignUpStartTime, string SignUpEndTime
            , string OpenClassFrom, string OpenClassTo, string ClassForm, string LimitPeopleCnt, string Address
            , string Content, string Subject, string StudyLevel, string TeachGrade, string TeachRank, string OrganRange
            , string Status)
        {
            try
            {
                var bll = new Class_DetailBLL();
                var model = bll.GetModel(id.ToInt());
                model.Title = Title;
                model.TraningId = TraningId.ToInt();
                model.PlanId = PlanId.ToInt();
                model.SignUpStartTime = SignUpStartTime.ToDateTime();
                model.SignUpEndTime = SignUpEndTime.ToDateTime();
                model.OpenClassFrom = OpenClassFrom.ToDateTime();
                model.OpenClassTo = OpenClassTo.ToDateTime();
                model.ClassForm = ClassForm.ToInt();
                model.People = 0;
                model.LimitPeopleCnt = LimitPeopleCnt.ToInt();
                model.Address = Address;
                model.Content = Content;
                model.Subject = Subject.Contains("all") ? true : false;
                model.StudyLevel = StudyLevel.Contains("all") ? true : false; ;
                model.TeachGrade = TeachGrade.Contains("all") ? true : false; ;
                model.TeachRank = TeachRank.Contains("all") ? true : false;
                model.OrganRange = OrganRange.Contains("all") ? "0" : OrganRange; ;
                model.ManagerId = SiteCache.Instance.ManagerId;
                model.Status = Status.ToInt();
                model.CreateDate = DateTime.Now;

                bll.Update(model);

                Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL();
                List<Member_ClassRegister> member_ClassRegisterList = member_ClassRegisterBLL.GetList("ClassId='" + id + "'", "");
                if (member_ClassRegisterList != null && member_ClassRegisterList.Count > 0)
                {
                    foreach (Member_ClassRegister m in member_ClassRegisterList)
                    {
                        m.Delflag = true;
                        member_ClassRegisterBLL.Update(m);
                    }
                }

                if (!model.StudyLevel)//不是全部则建立关联数据
                {

                    var arr = StudyLevel.Split(',');
                    var section = new Class_StudySectionBLL();

                    var oldSection = section.GetList(" Delflag=0 and ClassId=" + model.Id, "");
                    foreach (var old in oldSection)
                    {
                        var oldId = old.StudySection.ToString();
                        var exists = arr.Where(s => s == oldId);
                        if (exists == null || exists.Count() == 0)//旧的在新的里面不存,则删除
                        {
                            old.Delflag = true;
                            section.Update(old);
                        }
                    }
                    foreach (var item in arr)//新的在旧的里面不存在,则新加
                    {
                        var newid = item.ToInt();
                        var exists = oldSection.Where(s => s.StudySection == newid && s.Delflag == false);
                        if (exists == null || exists.Count() == 0)//
                        {
                            var classSection = new Dianda.AP.Model.Class_StudySection();
                            classSection.ClassId = model.Id;
                            classSection.CreateDate = DateTime.Now;
                            classSection.Delflag = false;
                            classSection.StudySection = item.ToInt();
                            section.Add(classSection);
                        }

                    }
                }
                if (!model.Subject)//不是全部则建立关联数据
                {
                    var arr = Subject.Split(',');
                    var section = new Class_TeachSubjectBLL();
                    var oldSection = section.GetList(" Delflag=0 and ClassId=" + model.Id, "");
                    foreach (var old in oldSection)
                    {
                        var oldId = old.TeachSubject.ToString();
                        var exists = arr.Where(s => s == oldId);
                        if (exists == null || exists.Count() == 0)//旧的在新的里面不存,则删除
                        {
                            old.Delflag = true;
                            section.Update(old);
                        }
                    }
                    foreach (var item in arr)
                    {
                        var newid = item.ToInt();
                        var exists = oldSection.Where(s => s.TeachSubject == newid && s.Delflag == false);
                        if (exists == null || exists.Count() == 0)//
                        {
                            var teachSubject = new Dianda.AP.Model.Class_TeachSubject();
                            teachSubject.ClassId = model.Id;
                            teachSubject.CreateDate = DateTime.Now;
                            teachSubject.Delflag = false;
                            teachSubject.TeachSubject = item.ToInt();
                            section.Add(teachSubject);
                        }
                    }
                }
                if (!model.TeachGrade)//不是全部则建立关联数据
                {
                    var arr = TeachGrade.Split(',');
                    var section = new Class_TeachGradeBLL();
                    var oldSection = section.GetList(" Delflag=0 and ClassId=" + model.Id, "");
                    foreach (var old in oldSection)
                    {
                        var oldId = old.TeachGrade.ToString();
                        var exists = arr.Where(s => s == oldId);
                        if (exists == null || exists.Count() == 0)//旧的在新的里面不存,则删除
                        {
                            old.Delflag = true;
                            section.Update(old);
                        }
                    }
                    foreach (var item in arr)
                    {
                        var newid = item.ToInt();
                        var exists = oldSection.Where(s => s.TeachGrade == newid && s.Delflag == false);
                        if (exists == null || exists.Count() == 0)//
                        {
                            var classSection = new Dianda.AP.Model.Class_TeachGrade();
                            classSection.ClassId = model.Id;
                            classSection.CreateDate = DateTime.Now;
                            classSection.Delflag = false;
                            classSection.TeachGrade = item.ToInt();
                            section.Add(classSection);
                        }
                    }
                }

                if (!model.TeachRank)//不是全部则建立关联数据
                {
                    var arr = TeachRank.Split(',');
                    var section = new Class_TeachRankBLL();
                    var oldSection = section.GetList(" Delflag=0 and ClassId=" + model.Id, "");
                    foreach (var old in oldSection)
                    {
                        var oldId = old.TeachRank.ToString();
                        var exists = arr.Where(s => s == oldId);
                        if (exists == null || exists.Count() == 0)//旧的在新的里面不存,则删除
                        {
                            old.Delflag = true;
                            section.Update(old);
                        }
                    }
                    foreach (var item in arr)
                    {
                        var newid = item.ToInt();
                        var exists = oldSection.Where(s => s.TeachRank == newid && s.Delflag == false);
                        if (exists == null || exists.Count() == 0)//
                        {
                            var classSection = new Dianda.AP.Model.Class_TeachRank();
                            classSection.ClassId = model.Id;
                            classSection.CreateDate = DateTime.Now;
                            classSection.Delflag = false;
                            classSection.TeachRank = item.ToInt();
                            section.Add(classSection);
                        }
                    }
                }

                if (Status == "2")//为提交状态时,新建审核记录
                {
                    var apply = new Dianda.AP.Model.Class_ApplyApplication();
                    apply.ClassId = id.ToInt();
                    apply.AccountId = SiteCache.Instance.LoginInfo.UserId;
                    apply.Remark = "提交审核";
                    apply.CreateDate = DateTime.Now;
                    var applyBll = new Class_ApplyApplicationBLL();
                    applyBll.Add(apply);
                }
                return Json(new { Code = 0, Msg = "提交成功" }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                return Json(new { Code = -1, Msg = ex.Message }, JsonRequestBehavior.AllowGet);
            }
        }
        /*
         * 进度汇总逻辑:
         *
         * 1.用户每次学习课程时需要往 Member_ClassUnitContentSchedule 中插入数据,作为当前的章节小进度.
         * 2.当当前章节所有的课程学习结束,需要判断当前在章节是否学习结束;
         * 3.在修改章节进度和总进度时,需要重新验证所有的章节进度是否已完成(可能存在章节追加的情况).
         * 4.若当前章节全部学习结束,需要在总进度表中 Member_ClassRegister 更改CurrentSchedule(当前章节进度),TotalSchedule(总课程进度).
         *
         * 所用表:
            select * from Member_ClassRegister
            select * from Course_UnitContent  --1文本,2影音教材,3讨论,4作业 5测试,6结业考试
            select * from Member_ClassUnitContentSchedule
            select * from Course_Detail
            select * from Course_UnitDetail
         *
         * [课程]下 分 [章]下 分 [节]下 分 [活动]
         * 同时也可以在[章]下面没有节,只有[活动],所以需要获取章下面所有的活动
         */
        /// <summary>
        /// 更新总体进度
        /// </summary>
        /// <param name="iUnitId">当前[活动]所在[节]的ID</param>
        /// <param name="iClassId"></param>
        /// <param name="iTrainingId"></param>
        /// <param name="iAccountId"></param>
        /// <param name="iUnitContent"></param>
        private void UpdateOverallProgress(int iUnitId, int iClassId, int iTrainingId, int iAccountId, int iUnitContent)
        {
            var unitBll = new Course_UnitContentBLL();
            var detailBll = new Class_DetailBLL();
            var UnitDetailBll = new Course_UnitDetailBLL();
            var ClassRegisterBll = new Member_ClassRegisterBLL();
            var Member_ClassUnitContentSchedulebll = new Member_ClassUnitContentScheduleBLL();
            int iOverChapterCount = 0, iChapterTotalCount = 0;//完成的[章]的数量,当前课程需要学习的[章]总数,该[章]已完成的[节]的数量(该章的进度)

            //用户的在线学习模块都要插入一条数据到Member_ClassUnitContentSchedule,作为当前小章节的学习进度
            if (this.InsertMember_ClassUnitContentSchedule(iClassId, iTrainingId, iAccountId, iUnitContent))
            {
                var List_Course_UnitDetail = UnitDetailBll.GetList(" ParentId = 0 AND Display = 1 AND Delflag = 0 AND TrainingId = " + iTrainingId, string.Empty);
                iChapterTotalCount = List_Course_UnitDetail.Count;//当前课程学员需要完成学习的总章数

                foreach (var ChapterItem in List_Course_UnitDetail)
                {
                    bool bolResult = this.GetChapterProgress(ChapterItem.Id, iClassId, ChapterItem.TrainingId.Value, iAccountId);
                    if (bolResult)//当前[章]的进度
                    {
                        iOverChapterCount++;
                    }
                }
                //[Status] 1等待学校审核 2学校审核通过 3学校审核不通过 4开班机构审核通过 5开班机构审核不通过
                int iPlanId = Code.SiteCache.Instance.PlanId;
                string strWhere = string.Format(@" AccountId = {0} AND ClassId = {1} AND PlanId = {2} and TrainingId = {3} and Delflag = 0 AND Status = 4",
                    iAccountId, iClassId, iPlanId, iTrainingId);

                var List_Member_ClassRegister = ClassRegisterBll.GetList(strWhere, "CreateDate");
                if (List_Member_ClassRegister != null && List_Member_ClassRegister.Count == 1)
                {
                    var Model_Member_ClassRegister = List_Member_ClassRegister[0];

                    Model_Member_ClassRegister.CurrentSchedule = iOverChapterCount;//[章,节]完成数
                    Model_Member_ClassRegister.TotalSchedule = iChapterTotalCount;//课程总章,节数
                    Model_Member_ClassRegister.CreateDate = DateTime.Now;

                    bool bolResult = ClassRegisterBll.Update(Model_Member_ClassRegister);
                }
            }
        }
Example #19
0
        /// <summary>
        /// 课程评价,如果已合格,加上学时
        /// </summary>
        public static void commentTraningOper(int classId,int accountId)
        {
            var classDetail = new Dianda.AP.BLL.Class_DetailBLL().GetModel(classId);
            var tranFieldModel = new Traning_DetailBLL().GetModel(classDetail.TraningId, "");

            var model = new Dianda.AP.BLL.Member_ClassRegisterBLL().GetList("Delflag=0 and ClassId=" + classId + " and AccountId=" + accountId, "").First();

            var comment = new Dianda.AP.BLL.Class_TraningCommentResultBLL().GetListModel(" ClassId=" + classId + " and AccountId=" + accountId + " and Delflag=0");
            if (model.Result == 1 && comment != null && comment.Count > 0)//如果结论是合格,,并且评论过课程,则要更新用户学分
            {
                var tranEditModel = new Member_TrainingReditBLL().GetList("Delflag=0 and TrainingField=" + tranFieldModel.TraingField
                    + " and PlanId=" + model.PlanId + " and AccountId=" + model.AccountId, "");
                Member_TrainingRedit tranEdit = null;
                if (tranEditModel == null || tranEditModel.Count == 0)//创建
                {
                    tranEdit = new Member_TrainingRedit();
                    tranEdit.AccountId = model.AccountId;
                    tranEdit.CreateDate = DateTime.Now;
                    tranEdit.Credits = tranFieldModel.TotalTime.Value;
                    tranEdit.Delflag = false;
                    tranEdit.PlanId = model.PlanId;
                    tranEdit.TrainingField = tranFieldModel.TraingField;
                    new Member_TrainingReditBLL().Add(tranEdit);
                }
                else//更新
                {
                    tranEdit = tranEditModel.First();
                    tranEdit.Credits += tranFieldModel.TotalTime.Value;
                    new Member_TrainingReditBLL().Update(tranEdit);
                }
                var traningCredit = DataTableToListHelper<Training_Credits>.ConvertToModel(
                    new Training_CreditsBLL().GetList(" and PlanId=" + model.PlanId + " and OrganId=" + classDetail.OrganId, "")
                    );//查找学时学分
                if (traningCredit != null && traningCredit.Count > 0) //轮循所有大类
                {
                    bool graduateFlag = true;
                    var member_traningBll = new Member_TrainingReditBLL();
                    foreach (var item in traningCredit)
                    {
                        var traning_credit = member_traningBll.GetList
                            (" Delflag=0 and PlanId=" + model.PlanId + " and AccountId=" + model.AccountId + " and TrainingField=" + item.TraningField
                            , "");
                        if (traningCredit != null && traningCredit.Count > 0)
                        {
                            if (traningCredit.First().MinValue > tranEdit.Credits)
                            {
                                graduateFlag = false;
                                break;
                            }
                        }
                    }
                    if (graduateFlag)//所有大类学分均合格,更新Member_PlanOverall表的用户合格状态。
                    {
                        var Member_PlanOverallBll = new Member_PlanOverallBLL();
                        var Member_PlanOverall = Member_PlanOverallBll.GetListModel(" Delflag=0 and  PlanId=" + model.PlanId + " and AccountId=" + model.AccountId);
                        if (Member_PlanOverall != null && Member_PlanOverall.Count > 0)
                        {
                            var item = Member_PlanOverall.First();
                            item.Result = 1;
                            Member_PlanOverallBll.Update(item);
                        }
                        else
                        {
                            var item = new Member_PlanOverall();
                            item.Result = 1;
                            item.PlanId = model.PlanId;

                            item.AccountId = model.AccountId;
                            item.CreateDate = DateTime.Now;
                            item.Delflag = false;

                            Member_PlanOverallBll.Add(item);
                        }
                    }
                }

            }
        }
        //小组讨论
        public ActionResult ClassDiscuss(string classId, int? groupId, int unitId = 0, int pageIndex = 1, int pageIndex2 = 1)
        {
            var param_classId = Dianda.Common.QueryString.Decrypt(classId).ToInt();
            int totalPage = 0;
            int totalPage2 = 0;
            var classDetail = new Class_DetailBLL().GetModel(param_classId);

            var topicList = DataTableToListHelper<Dianda.AP.Model.Course_UnitContent>
               .ConvertToModel(PagingQueryBll.GetPagingDataTable(@"  Course_UnitContent
                INNER JOIN Course_UnitDetail ON Course_UnitContent.UnitId = Course_UnitDetail.Id"
               , @" Course_UnitDetail.Display = 1
                                                AND Course_UnitDetail.Delflag = 0
                                                AND Course_UnitContent.Display = 1
                                                AND Course_UnitContent.Delflag = 0
                                                AND Course_UnitDetail.TrainingId = " + classDetail.TraningId + @"
                                                AND UnitType = 3  ", " dbo.Course_UnitDetail.Id", 1, out totalPage, "Course_UnitContent.*", 50));

            ViewBag.topicList = topicList;

            ViewBag.currentTopic = unitId == 0 ? (topicList.Count > 0 ? topicList[0].Content : null) : new Course_UnitContentBLL().GetModel(unitId, "").Content;
            //ViewBag.currentTopicId = unitId == 0 ? (topicList.Count > 0 ? topicList[0].Id : 0) : unitId;

            //班级成员
            var allMember = new Member_ClassRegisterBLL()
                                     .GetList(" ClassId=" + param_classId + " and Delflag=0 and status=4", "")
                                     .GroupBy(s => s.AccountId);
            totalPage2 = allMember.Count();
            ViewBag.classMember = from c in allMember.Skip((pageIndex2 - 1) * 10).Take(10)
                                  select c.Key;

            var paramUnit = unitId == 0 ? (topicList.Count > 0 ? "r.UnitContent=" + topicList[0].Id : " 1=1 ") : " r.UnitContent= " + unitId;
            var where = paramUnit + " and r.ClassId=" + param_classId + " AND r.Delflag=0 AND r.ParentReplyId=0 AND r.Display=1 and r.AccountId!=0";
            if (groupId.HasValue)//有组条件
            {
                if (groupId == 0)
                {
                    where += @" and exists (SELECT 1 FROM  Member_ClassRegister m
                    INNER JOIN dbo.Class_GroupMember cgm ON m.AccountId = cgm.AccountId
                    INNER JOIN dbo.Class_Group cg ON cgm.GroupId=cg.Id
                    INNER JOIN dbo.Class_Detail c ON cg.ClassId=c.id
                    WHERE  r.AccountId = m.AccountId
                    AND m.ClassId=r.ClassId
                    AND m.status = 4
                    AND m.Delflag = 0)";
                }
                if (groupId == -1)
                {
                    where += @" and not exists (SELECT 1 FROM  Member_ClassRegister m
                    INNER JOIN dbo.Class_GroupMember cgm ON m.AccountId = cgm.AccountId
                    INNER JOIN dbo.Class_Group cg ON cgm.GroupId=cg.Id
                    INNER JOIN dbo.Class_Detail c ON cg.ClassId=c.id
                    WHERE  r.AccountId = m.AccountId
                    AND m.ClassId=r.ClassId
                    AND m.status = 4
                    AND m.Delflag = 0)";
                }
                if (groupId > 0)
                {
                    where += @" and exists (SELECT 1 FROM  Member_ClassRegister m
                    INNER JOIN dbo.Class_GroupMember cgm ON m.AccountId = cgm.AccountId
                    INNER JOIN dbo.Class_Group cg ON cgm.GroupId=cg.Id
                    INNER JOIN dbo.Class_Detail c ON cg.ClassId=c.id
                    WHERE  r.AccountId = m.AccountId
                    AND m.ClassId=r.ClassId
                    AND m.status = 4
                    AND m.Delflag = 0
                    AND cgm.GroupId= " + groupId + ")";
                }

            }
            else//默认全部组
            {
                where += @" and exists (SELECT 1 FROM  Member_ClassRegister m
                    INNER JOIN dbo.Class_GroupMember cgm ON m.AccountId = cgm.AccountId
                    INNER JOIN dbo.Class_Group cg ON cgm.GroupId=cg.Id
                    INNER JOIN dbo.Class_Detail c ON cg.ClassId=c.id
                    WHERE  r.AccountId = m.AccountId
                    AND m.ClassId=r.ClassId
                    AND m.status = 4
                    AND m.Delflag = 0)";
            }
            //Model
            var list = DataTableToListHelper<Dianda.AP.Model.Course_UnitReplyDetail>
               .ConvertToModel(PagingQueryBll.GetPagingDataTable("Course_UnitReplyDetail r", where, "r.id", pageIndex, out totalPage, "r.*", 3));

            var allGroup = new Class_GroupBLL().GetList(" ClassId=" + param_classId + " and Delflag=0 AND Display=1", "");

            ViewBag.GroupList = allGroup;
            //成员分页
            ViewBag.pageIndex2 = pageIndex2;
            ViewBag.totalPage2 = totalPage2;

            ViewBag.classId = classId;
            ViewBag.param_classId = param_classId;
            //讨论分页
            ViewBag.pageIndex = pageIndex;
            ViewBag.totalPage = totalPage;
            ViewBag.basecount = 3;

            ViewBag.accountId = SiteCache.Instance.LoginInfo.UserId;
            ViewBag.traningId = classDetail.TraningId;

            var classModel = new Class_DetailBLL().GetModel(param_classId);
            if (classModel != null)
            {
                ViewBag.CourseName = new Traning_DetailBLL().GetModel(classModel.TraningId, "").Title;
                ViewBag.ClassName = classModel.Title;

                var traningTeacher = new Traning_TeacherBLL().GetList(" Delflag=0 AND TraningId=" + classModel.TraningId, "");
                var teacherAccount = (traningTeacher != null && traningTeacher.Count > 0) ? new PlatformManager_DetailBLL().GetModel(traningTeacher.First().PlatformManagerId.Value, "").AccountId : 0;
                ViewBag.TraningTeacher = teacherAccount;
            }

            ViewBag.ManagerId = SiteCache.Instance.ManagerId;

            return View(list);
        }
 public JsonResult getAllMemer(int ClassId)
 {
     var memberModel = new Dianda.AP.BLL.Member_ClassRegisterBLL().GetList(" Delflag=0 and ClassId=" + ClassId, "");
     var accountModel = (from c in memberModel select new { Account=c.AccountId,Status=c.Status }).ToList();
     List<Member_Account> list = new List<Member_Account>();
     var bll = new Dianda.AP.BLL.Member_AccountBLL();
     foreach (var item in accountModel)
     {
         var act = bll.GetModel(item.Account, "");
         act.RegisterStatus = item.Status;
         list.Add(act);
     }
     return Json(list, JsonRequestBehavior.AllowGet);
 }