/// <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; }
public ActionResult ClassAuditDetail(string id, string doaction) { var param_id = Dianda.Common.QueryString.Decrypt(id); string param_doaction = ""; if (doaction != null) param_doaction = Dianda.Common.QueryString.Decrypt(doaction); var fkBll = new Traning_InfoFkBLL(); var traningBll = new Training_PlanBLL(); var traningDBll = new Traning_DetailBLL(); var bll = new Class_DetailBLL(); var model = bll.GetModel(param_id.ToInt()); var organ = new Organ_DetailBLL().GetModel(SiteCache.Instance.ManageOrganId); if (organ.OType == 1)//培训机构职能选择自己机构开设的课程 { ViewBag.CourseList = traningDBll.GetList(" OrganId =" + organ.Id + " and Delflag=0 and Display=1 ", ""); } else//进修学院则可以选择自己机构开设的课程,也可以选择自己机构所属的区县下的所有课程。通过Traning_Detail.ParentOrganId。如果Range=2,则表面是市级共享课程。则可以无条件选择。 { ViewBag.CourseList = traningDBll.GetList(" ((OrganId =" + organ.Id + " or ParentOrganId=" + organ.Id + ") or Range=2 ) and Delflag=0 and Display=1 ", ""); } ViewBag.OrganId = SiteCache.Instance.ManageOrganId; ViewBag.PartitionId = organ.PartitionId; ViewBag.PlanList = DataTableToListHelper<Dianda.AP.Model.Training_Plan>.ConvertToModel(traningBll.GetList(" Delflag=0 and Display=1 and IsOpen=1").Tables[0]); ViewBag.ClassesList = fkBll.GetList(" CategoryType=5 and Delflag=0 and Display=1 ", "Sort desc"); ViewBag.SubjectList = fkBll.GetList(" CategoryType=3 and Delflag=0 and Display=1 ", "Sort desc"); ViewBag.Subject = model.Subject; ViewBag.existSubjectList = new Class_TeachSubjectBLL().GetList(" Delflag=0 and ClassId=" + param_id, ""); ViewBag.StudyLevelList = fkBll.GetList(" CategoryType=4 and Delflag=0 and Display=1 ", "Sort desc"); ViewBag.StudyLevel = model.StudyLevel; ViewBag.existStudyLevel = new Class_StudySectionBLL().GetList(" Delflag=0 and ClassId=" + param_id, ""); ViewBag.TeachGradeList = fkBll.GetList(" CategoryType=7 and Delflag=0 and Display=1 ", "Sort desc"); ViewBag.TeachGrade = model.TeachGrade; ViewBag.existTeachGrade = new Class_TeachGradeBLL().GetList(" Delflag=0 and ClassId=" + param_id, ""); ViewBag.TeachRankList = fkBll.GetList(" CategoryType=8 and Delflag=0 and Display=1 ", "Sort desc"); ViewBag.TeachRank = model.TeachRank; ViewBag.existTeachRank = new Class_TeachRankBLL().GetList(" Delflag=0 and ClassId=" + param_id, ""); var course = new Traning_DetailBLL().GetModel(model.TraningId, ""); var organBll = new Organ_DetailBLL(); var list = new List<Organ_Detail>(); //if (course.Range == 1) //区级 //{ // list = organBll.GetListModel(" OType IN ( 1, 2, 3 ) and PartitionId=" + course.PartitionId + " and ParentId=" + (course.OrganId.HasValue ? course.OrganId.Value : 0)); //} //else//市级 //{ // list = organBll.GetShiOrganDetailList(); //} list = organBll.GetListModel(" id in ( " + model.OrganRange + ")"); ViewBag.schoolList = list; ViewBag.classId = param_id; ViewBag.OrangRange = model.OrganRange.Split(','); ViewBag.doaction = param_doaction; return View(model); }
//班级操作 public ActionResult ClassAction(string strAction, int Id, int? Instructor) { try { var bll = new Class_DetailBLL(); var model = bll.GetModel(Id.ToInt()); switch (strAction) { case "clear"://清除 model.Delflag = true; break; case "complete"://结业 model.Status = 6; break; case "cancel"://撤销 model.Status = 1; break; case "setInstructor"://设置辅导员 model.Instructor = Instructor.Value; break; case "start"://开班 var traingModel=new Traning_DetailBLL().GetModel(model.TraningId,""); if (traingModel.OutSideType == -1)//内部课程要有课程信息及比例 { var list = new Course_DetailBLL().GetList(" Delflag=0 and TrainingId=" + model.TraningId, ""); if (list == null || list.Count == 0) return Json(new { Code = -1, Msg = "请设置课程信息!" }, JsonRequestBehavior.AllowGet); var courseDetail = list.First(); if (courseDetail.ReadingRate + courseDetail.DisscusRate + courseDetail.HomeWorkRate + courseDetail.QuestionRate + courseDetail.TestingRate + courseDetail.CommentRate != 100) { return Json(new { Code = -1, Msg = "请设置课程考核比例!" }, JsonRequestBehavior.AllowGet); } } model.Status = 5; break; } bll.Update(model); return Json(new { Code = 0, Msg = "提交成功" }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { return Json(new { Code = -1, Msg = ex.Message }, JsonRequestBehavior.AllowGet); } }
//班级操作 public ActionResult ClassAction(string strAction, string Ids, int Val, string Remark) { try { var bll = new Class_DetailBLL(); var ids = Ids.Split(','); foreach (var id in ids) { if (!string.IsNullOrEmpty(id)) { var model = bll.GetModel(id.ToInt()); switch (strAction) { case "audit"://审核 if (model.Status == 3)//已经通过的状态时,批量操作不再有效 continue; model.Status = Val == 1 ? 3 : 4; if (Val != 1) { model.ApplyRemark = Remark; } //新建审核记录 var apply = new Dianda.AP.Model.Class_ApplyApplication(); apply.ClassId = id.ToInt(); apply.AccountId = SiteCache.Instance.LoginInfo.UserId; apply.Remark = Remark; apply.CreateDate = DateTime.Now; var applyBll = new Class_ApplyApplicationBLL(); applyBll.Add(apply); var manger = new PlatformManager_DetailBLL().GetModel(model.ManagerId, ""); if (manger != null) Code.MsgHelper.sendMsg(manger.AccountId, SiteCache.Instance.ManagerId, model.PartitionId, "班级审核", model.Title + (Val == 1 ? "班级审核通过" : "班级审核不通过")); break; } bll.Update(model); } } return Json(new { Code = 0, Msg = "提交成功" }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { return Json(new { Code = -1, Msg = ex.Message }, JsonRequestBehavior.AllowGet); } }
//添加外部作业 public JsonResult AddClassOutMission(int classId, string title, string content, int startdate , int enddate, string attlist) { try { var classObj = new Class_DetailBLL().GetModel(classId); var bll = new Class_HomeWorkMissionBLL(); var model = new Class_HomeWorkMission(); model.ClassId = classId; model.Title = title; model.Content = content; model.StartDate = startdate != -1 ? classObj.OpenClassFrom.AddDays(startdate) : Convert.ToDateTime("1800-01-01"); model.EndDate = enddate != -1 ? classObj.OpenClassFrom.AddDays(enddate) : Convert.ToDateTime("1800-01-01"); if (!string.IsNullOrEmpty(attlist)) { var json = "["; var attArry = attlist.Remove(attlist.LastIndexOf('|'), 1).Split('|'); for (int i = 0; i < attArry.Length; i++) { if (!string.IsNullOrEmpty(attArry[i])) { json += "{" + attArry[i]; if (i < attArry.Length - 1) json += "},"; else json += "}"; } } json += "]"; model.AttList = json; } model.Creater = SiteCache.Instance.LoginInfo.UserId; model.CreateDate = DateTime.Now; model.Display = true; model.Delflag = false; bll.Add(model); 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); } } }
/// <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 CoursemarketSingleEnroll(int Id) { ViewBag.Title = "课程报名"; Class_DetailBLL class_DetailBLL = new Class_DetailBLL(); Class_Detail class_Detail = new Class_Detail(); class_Detail = class_DetailBLL.GetModel(Id); return View(class_Detail); }
//编辑班级 public JsonResult EditClass(string id, string Title, string TraningId, string PlanId, string SignUpStartTime, string SignUpEndTime , string OpenClassFrom, string OpenClassTo, string ClassForm, string People, 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 = People.ToInt(); model.LimitPeopleCnt = LimitPeopleCnt.ToInt(); model.Address = Address; model.Content = Content; model.Subject = Subject == "0" ? true : false; model.StudyLevel = StudyLevel == "0" ? true : false; ; model.TeachGrade = TeachGrade == "0" ? true : false; ; model.TeachRank = TeachRank == "0" ? true : false; ; ; model.OrganRange = OrganRange; model.ManagerId = SiteCache.Instance.LoginInfo.UserId; model.Status = Status.ToInt(); model.CreateDate = DateTime.Now; bll.Update(model); 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); } }
//进度列表 public ActionResult ClassProgress(string classId, int? isPass, int pageIndex = 1) { var param_classId = Dianda.Common.QueryString.Decrypt(classId).ToInt(); int totalPage; string where = " Delflag=0 and Status=4 and ClassId= " + param_classId; if (isPass.HasValue) where += " and isnull(Result,0) =" + isPass.Value; var list = DataTableToListHelper<Dianda.AP.Model.Member_ClassRegister>.ConvertToModel(PagingQueryBll.GetPagingDataTable("Member_ClassRegister", where, "id", pageIndex, out totalPage)); ViewBag.classId = classId; ViewBag.pageIndex = pageIndex; ViewBag.totalPage = totalPage; ViewBag.basecount = 10; var classModel = new Class_DetailBLL().GetModel(param_classId); if (classModel != null) { ViewBag.CourseName = new Traning_DetailBLL().GetModel(classModel.TraningId, "").Title; ViewBag.ClassName = classModel.Title; } return View(list); }
//分组列表 public ActionResult ClassGroup(string classId, int groupId = 0, int pageIndex = 1) { var param_classId = Dianda.Common.QueryString.Decrypt(classId).ToInt(); IList<Member_ClassRegister> list = new List<Member_ClassRegister>(); int totalPage = 0; string where = " mb.ClassId = " + param_classId + " and cg.ClassId= " + param_classId + " AND cgm.Delflag=0 AND mb.Delflag=0"; if (groupId == 0)//全部组 { list = DataTableToListHelper<Dianda.AP.Model.Member_ClassRegister> .ConvertToModel(PagingQueryBll.GetPagingDataTable(@"dbo.Class_GroupMember cgm LEFT JOIN dbo.Class_Group cg ON cgm.GroupId=cg.Id LEFT JOIN dbo.Member_ClassRegister mb ON cgm.AccountId=mb.AccountId", where, "cgm.CreateDate", pageIndex, out totalPage, "mb.*,CONVERT(VARCHAR,cg.ClassId)+'|'+CONVERT(VARCHAR,cg.id) AS ClassId_GroupId", 15)); } if (groupId > 0)//单组 { where += " and cgm.GroupId=" + groupId; list = DataTableToListHelper<Dianda.AP.Model.Member_ClassRegister> .ConvertToModel(PagingQueryBll.GetPagingDataTable(@"dbo.Class_GroupMember cgm LEFT JOIN dbo.Class_Group cg ON cgm.GroupId=cg.Id LEFT JOIN dbo.Member_ClassRegister mb ON cgm.AccountId=mb.AccountId", where, "cgm.CreateDate", pageIndex, out totalPage, "mb.*,CONVERT(VARCHAR,cg.ClassId)+'|'+CONVERT(VARCHAR,cg.id) AS ClassId_GroupId", 15)); } if (groupId < 0)//无组 { where = @" NOT EXISTS ( SELECT 1 FROM dbo.Class_Group cg JOIN dbo.Class_GroupMember cgm ON cg.Id = cgm.GroupId WHERE cg.ClassId = t.ClassId AND t.AccountId=cgm.AccountId AND t.Status=4 AND t.ClassId=" + param_classId + " AND cg.Delflag=0 AND cgm.Delflag=0)" + " AND t.Status=4 AND t.ClassId=" + param_classId; list = DataTableToListHelper<Dianda.AP.Model.Member_ClassRegister> .ConvertToModel(PagingQueryBll.GetPagingDataTable(@"dbo.Member_ClassRegister t LEFT JOIN dbo.Member_Account m ON t.AccountId=m.id ", where, "t.CreateDate", pageIndex, out totalPage, "t.*,'' AS ClassId_GroupId", 15)); } var gBll = new Dianda.AP.BLL.Class_GroupBLL(); var allGroup = gBll.GetList(" ClassId=" + param_classId + " and Delflag=0 AND Display=1", ""); //无组人员 // where = @" NOT EXISTS ( SELECT 1 // FROM dbo.Class_Group cg // JOIN dbo.Class_GroupMember cgm ON cg.Id = cgm.GroupId // WHERE cg.ClassId = t.ClassId AND t.AccountId=cgm.AccountId // AND t.Status=4 AND t.ClassId=" + classId + ")" + " AND t.Status=4 AND t.ClassId=" + classId; // var noGrouper = DataTableToListHelper<Dianda.AP.Model.Member_BaseInfo> // .ConvertToModel(PagingQueryBll.GetPagingDataTable(@"dbo.Member_ClassRegister t //LEFT JOIN dbo.Member_Account m ON t.AccountId=m.id //LEFT JOIN dbo.Member_BaseInfo mb ON m.Id=mb.AccountId", where, "mb.CreateDate", pageIndex, out totalPage, "mb.*,'' AS ClassId_GroupId")); var noGrouper = DataTableToListHelper<Dianda.AP.Model.Member_ClassRegister> .ConvertToModel(new Member_ClassRegisterBLL().GetNoGroupper(param_classId)); ViewBag.noGrouper = noGrouper; ViewBag.GroupList = allGroup; ViewBag.classId = classId; ViewBag.pageIndex = pageIndex; ViewBag.totalPage = totalPage; ViewBag.basecount = 15; 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 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 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 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"); } }
/// <summary> /// 根据课程查询班级 /// </summary> /// <param name="Course"></param> /// <returns></returns> public string GetClassListBytCourse(int Course) { //主题 Class_DetailBLL class_DetailBLL = new Class_DetailBLL(); List<Class_Detail> list = class_DetailBLL.GetListModel(" TraningId=" + Course + " and Delflag='false' and Display='true'"); return (new JavaScriptSerializer()).Serialize(list); }
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); }
/// <summary> /// 教师--课程详细-班级列表 /// </summary> /// <param name="Id"></param> /// <param name="Type"></param> /// <returns></returns> public ActionResult CoursemarketTCList(int? pageIndex, int Id, int Type) { Code.SiteCache cache = Code.SiteCache.Instance; int groupId = cache.GroupId;//4,学校管理7,普通教师 ViewData["groupId"] = groupId; int i = TypeConverter.ObjectToInt(pageIndex, 1); Class_DetailBLL class_DetailBLL = new Class_DetailBLL(); IList<Class_Detail> clist = new List<Class_Detail>(); int total = 0; int partitionId = 1; string where = " display=1 and delflag='false' and TraningId='" + Id + "' and PartitionId='" + partitionId + "'"; switch (Type) { case 1: where += " and status=3"; break; case 2: where += " and status=5"; break; case 3: where += " and status=6"; break; //case 1: where += " and GETDATE()>SignUpStartTime and GETDATE()<dateadd(d,1,SignUpEndTime)"; break; //case 2: where += " and GETDATE()>OpenClassFrom and GETDATE()<dateadd(d,1,OpenClassTo)"; break; //case 3: where += " and GETDATE()>dateadd(d,1,OpenClassTo) "; break; } clist = DataTableToListHelper<Dianda.AP.Model.Class_Detail>.ConvertToModel(PagingQueryBll.GetPagingDataTable(@"Class_Detail", where, "Id", i, out total, "*", 5)); ViewBag.pageIndex = i; ViewBag.totalPage = total; ViewBag.type = Type; return View(clist); }
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); } }
//课程评价 public ActionResult ClassComment(string classId, int pageIndex = 1) { var param_classId = Dianda.Common.QueryString.Decrypt(classId).ToInt(); IList<Member_ClassRegister> list = new List<Member_ClassRegister> { }; int totalPage = 0; StringBuilder sbSql = new StringBuilder(); sbSql.AppendFormat(@"SELECT m.* , cqId = ( SELECT TOP 1 Convert(varchar, ud.Id) FROM Class_TraningCommentResult ud WHERE ud.ClassId = d.Id AND m.AccountId = ud.AccountId ORDER BY CreateDate DESC ) FROM dbo.Member_ClassRegister m LEFT JOIN dbo.Class_Detail d ON m.ClassId = d.Id WHERE m.status = 4 AND m.Delflag = 0 AND m.ClassId = {0} ", param_classId); list = DataTableToListHelper<Dianda.AP.Model.Member_ClassRegister> .ConvertToModel(PagingQueryBll.GetPagingDataTable("(" + sbSql.ToString() + ") as tmp", " 1=1 ", "CreateDate", pageIndex, out totalPage, @"*")); ViewBag.classId = classId; ViewBag.param_classId = param_classId; //分页 ViewBag.pageIndex = pageIndex; ViewBag.totalPage = totalPage; ViewBag.basecount = 10; var classModel = new Class_DetailBLL().GetModel(param_classId); if (classModel != null) { ViewBag.CourseName = new Traning_DetailBLL().GetModel(classModel.TraningId, "").Title; ViewBag.ClassName = classModel.Title; ViewBag.planId = classModel.PlanId; } return View(list); }
public JsonResult CreateClass(string Title, string TraningId, string PlanId, string SignUpStartTime, string SignUpEndTime , string OpenClassFrom, string OpenClassTo, string ClassForm, string People, string LimitPeopleCnt, string Address , string Content, string Subject, string StudyLevel, string TeachGrade, string TeachRank, string OrganRange , string OrganId, string Status, string PartitionId) { try { var model = new Dianda.AP.Model.Class_Detail(); 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 = People.ToInt(); 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; model.OrganId = OrganId.ToInt(); model.PartitionId = PartitionId.ToInt(); model.Display = true; var bll = new Dianda.AP.BLL.Class_DetailBLL(); var cid = bll.Add(model); if (!model.Subject)//不是全部则建立关联数据 { var arr = Subject.Split(','); var subject = new Class_TeachSubjectBLL(); foreach (var item in arr) { var classSubject = new Dianda.AP.Model.Class_TeachSubject(); classSubject.ClassId = cid; classSubject.CreateDate = DateTime.Now; classSubject.Delflag = false; classSubject.TeachSubject = item.ToInt(); subject.Add(classSubject); } } if (!model.StudyLevel)//不是全部则建立关联数据 { var arr = StudyLevel.Split(','); foreach (var item in arr) { var section = new Class_StudySectionBLL(); var teachSection = new Dianda.AP.Model.Class_StudySection(); teachSection.ClassId = cid; teachSection.CreateDate = DateTime.Now; teachSection.Delflag = false; teachSection.StudySection = item.ToInt(); section.Add(teachSection); } } if (!model.TeachGrade)//不是全部则建立关联数据 { var arr = TeachGrade.Split(','); var section = new Class_TeachGradeBLL(); foreach (var item in arr) { var classSection = new Dianda.AP.Model.Class_TeachGrade(); classSection.ClassId = cid; 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(); foreach (var item in arr) { var classSection = new Dianda.AP.Model.Class_TeachRank(); classSection.ClassId = cid; 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 = cid; 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); } }
//结业评价 public ActionResult ClassGraduate(string classId, int pageIndex = 1) { var param_classId = Dianda.Common.QueryString.Decrypt(classId).ToInt(); int totalPage = 0; string where = "mc.ClassId = " + param_classId + " AND mc.Delflag=0 AND mc.Status=4"; //Model var list = DataTableToListHelper<Dianda.AP.Model.Member_ClassRegister> .ConvertToModel(PagingQueryBll.GetPagingDataTable(@"dbo.Member_ClassRegister mc LEFT JOIN dbo.Member_Account ma ON mc.AccountId = ma.Id", where, "mc.CreateDate", pageIndex, out totalPage, @"mc.* ")); var classUnit = new Member_ContentAnswerResultBLL().GetListModel(" ClassId=" + param_classId).GroupBy(s => s.UnitContent); ViewBag.UnitList = from c in classUnit select c.Key; ViewBag.classId = classId; ViewBag.param_classId = param_classId; //分页 ViewBag.pageIndex = pageIndex; ViewBag.totalPage = totalPage; ViewBag.basecount = 10; var classModel = new Class_DetailBLL().GetModel(param_classId); if (classModel != null) { ViewBag.CourseName = new Traning_DetailBLL().GetModel(classModel.TraningId, "").Title; ViewBag.ClassName = classModel.Title; ViewBag.planId = classModel.PlanId; } return View(list); }
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); } } }
/// <summary> /// 学校--教师选择list /// </summary> /// <param name="pageIndex"></param> /// <param name="OrganId"></param> /// <returns></returns> public ActionResult ChooseTeachersList(int? pageIndex, int ClassId, int Type) { Class_DetailBLL class_DetailBLL = new Class_DetailBLL(); Class_Detail ClassModel = class_DetailBLL.GetModel(ClassId); int TrainingId = ClassModel.TraningId; int OrganId = Code.SiteCache.Instance.ManageOrganId; int Groupid = Code.SiteCache.Instance.GroupId; int i = TypeConverter.ObjectToInt(pageIndex, 1); Member_AccountBLL member_AccountBLL = new Member_AccountBLL(); List<Member_AccountBaseInfo> member_AccBaseInfoList = new List<Member_AccountBaseInfo>(); int total = 0; member_AccBaseInfoList = member_AccountBLL.GetMarketMemberList(12, i, Type, ClassModel, TrainingId, OrganId, Groupid, "Id", out total); ViewBag.pageIndex = i; ViewBag.totalPage = total; ViewBag.Type = Type; ViewBag.ClassId = ClassId; return View(member_AccBaseInfoList); }
/// <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 ClassTask(string classId, string unit, string status, int pageIndex = 1) { var param_classId = Dianda.Common.QueryString.Decrypt(classId).ToInt(); IList<Member_ClassRegister> list = new List<Member_ClassRegister> { }; var TrainingId = new Class_DetailBLL().GetModel(param_classId).TraningId; //作业单元 var classUnit = new Course_UnitContentBLL().GetList(" Display=1 and UnitType=4 and delflag=0 AND UnitId IN (SELECT id FROM dbo.Course_UnitDetail WHERE TrainingId=" + TrainingId + ")", "") ; var unitList = from c in classUnit select c; ViewBag.UnitList = unitList; int totalPage = 0; string param_status = "";//状态 switch (status) { case "-1"://未提交 param_status = @" and not EXISTS ( SELECT 1 FROM dbo.Course_UnitHomeWork cw JOIN dbo.Course_UnitContent cu ON cw.UnitContent = cu.Id WHERE m.AccountId = cw.AccountId AND cw.ClassId = m.ClassId AND cu.Id= {1} and cw.Delflag=0)"; break; case "0"://单元未得分 param_status = @" AND EXISTS ( SELECT 1 FROM dbo.Course_UnitHomeWork cw JOIN dbo.Course_UnitContent cu ON cw.UnitContent = cu.Id WHERE m.AccountId = cw.AccountId AND cw.ClassId = m.ClassId AND cu.Id= {1} AND isnull(cw.Score,0)=0 and cw.Delflag=0) AND not EXISTS ( SELECT 1 FROM dbo.Course_UnitHomeWork cw JOIN dbo.Course_UnitContent cu ON cw.UnitContent = cu.Id WHERE m.AccountId = cw.AccountId AND cw.ClassId = m.ClassId AND cu.Id= {1} AND isnull(cw.Score,0)!=0 and cw.Delflag=0)"; break; case "1"://单元已得分 param_status = @" AND EXISTS ( SELECT 1 FROM dbo.Course_UnitHomeWork cw JOIN dbo.Course_UnitContent cu ON cw.UnitContent = cu.Id WHERE m.AccountId = cw.AccountId AND cw.ClassId = m.ClassId AND cu.Id= {1} AND isnull(cw.Score,0)!=0 and cw.Delflag=0)"; break; default://全部 break; } var Course_UnitContentBLL = new Course_UnitContentBLL(); StringBuilder sbSql = new StringBuilder(); if (string.IsNullOrEmpty(unit)) { foreach (var item in unitList) { sbSql.AppendFormat(@"SELECT m.* , '{1}' as cqId, homeworkId = ( SELECT hw.id FROM dbo.Course_UnitHomeWork hw WHERE hw.AccountId = m.AccountId AND hw.ClassId = {0} AND hw.UnitContent = {1} and hw.Delflag=0 ) FROM dbo.Member_ClassRegister m LEFT JOIN dbo.Class_Detail d ON m.ClassId = d.Id LEFT JOIN dbo.Course_UnitDetail ud ON ud.TrainingId = d.TraningId LEFT JOIN Course_UnitContent uc ON uc.UnitId = ud.Id LEFT JOIN dbo.Member_Account ma ON m.AccountId = ma.Id WHERE m.status=4 AND m.Delflag=0 and m.ClassId = {0} AND uc.id = {1} " + param_status, param_classId, item.Id); sbSql.Append(" union "); } } else { sbSql.AppendFormat(@"SELECT m.* , '{1}' as cqId, homeworkId = ( SELECT hw.id FROM dbo.Course_UnitHomeWork hw WHERE hw.AccountId = m.AccountId AND hw.ClassId = {0} AND hw.UnitContent = {1} and hw.Delflag=0 ) FROM dbo.Member_ClassRegister m LEFT JOIN dbo.Class_Detail d ON m.ClassId = d.Id LEFT JOIN dbo.Course_UnitDetail ud ON ud.TrainingId = d.TraningId LEFT JOIN Course_UnitContent uc ON uc.UnitId = ud.Id LEFT JOIN dbo.Member_Account ma ON m.AccountId = ma.Id WHERE m.status=4 AND m.Delflag=0 and m.ClassId = {0} AND uc.id = {1}" + param_status, param_classId, unit); } if (sbSql.Length > 0) { if (sbSql.ToString().Contains("union")) { sbSql = sbSql.Remove(sbSql.ToString().LastIndexOf("union"), 5); } list = DataTableToListHelper<Dianda.AP.Model.Member_ClassRegister> .ConvertToModel(PagingQueryBll.GetPagingDataTable("(" + sbSql.ToString() + ") as tmp", " 1=1 ", "CreateDate", pageIndex, out totalPage, @"*")); } ViewBag.classId = classId; ViewBag.param_classId = param_classId; //分页 ViewBag.pageIndex = pageIndex; ViewBag.totalPage = totalPage; ViewBag.basecount = 10; var classModel = new Class_DetailBLL().GetModel(param_classId); if (classModel != null) { ViewBag.CourseName = new Traning_DetailBLL().GetModel(classModel.TraningId, "").Title; ViewBag.ClassName = classModel.Title; ViewBag.planId = classModel.PlanId; } return View(list); }
/// <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); } }
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); } }
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); }