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> 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); } } } } }