//更新方案 新 public int Upd_ESurvey(T_OA_REQUIREMASTER survey, List <V_EmployeeSurveySubject> addLst, List <V_EmployeeSurveySubject> updLst) { try { //masterBll.BeginTransaction(); //更新方案 EmployeeSurveyViewDal esvDal = new EmployeeSurveyViewDal(); if (esvDal.UpdateRequireMaster(survey) == -1) { masterBll.RollbackTransaction(); return(-1); } foreach (V_EmployeeSurveySubject i in addLst) { //添加 题目 答案 if (subjectViewBll.AddEmployeeSurveySubjectView(i) < 1) { masterBll.RollbackTransaction(); return(-1); } } foreach (V_EmployeeSurveySubject i in updLst) { //更新题目 if (esvDal.UpdateSurveySubject(i.SubjectInfo) < 1) { masterBll.RollbackTransaction(); return(-1); } //更新答案 if (UpdataAnswerList(i.SubjectInfo, i.AnswerList.ToList()) < 1) { masterBll.RollbackTransaction(); return(-1); } } masterBll.CommitTransaction(); return(1); } catch (Exception ex) { Tracer.Debug("调查方案EmployeeSurveyViewBll-Upd_ESurvey" + System.DateTime.Now.ToString() + " " + ex.ToString()); return(-1); } }
//EmployeeSurveyViewDal esvDal = new EmployeeSurveyViewDal(); //更新方案 旧 public int UpdateEmployeeSurveyView(V_EmployeeSurvey infoView) { try { EmployeeSurveyViewDal esvDal = new EmployeeSurveyViewDal(); masterBll.BeginTransaction(); if (esvDal.UpdateRequireMaster(infoView.RequireMaster) == -1) { masterBll.RollbackTransaction(); return(-1); } //题目 添加、更新 List <V_EmployeeSurveySubject> subjectViewList = GetSubjectViewListByMasterID(infoView.RequireMaster.REQUIREMASTERID).ToList(); //////删除 IEnumerable <V_EmployeeSurveySubject> lstsub = infoView.SubjectViewList; foreach (V_EmployeeSurveySubject i in lstsub) { bool isAdd = true; foreach (V_EmployeeSurveySubject v in subjectViewList) { if (i.SubjectInfo.REQUIREDETAIL2ID == v.SubjectInfo.REQUIREDETAIL2ID) { isAdd = false; } break; } if (isAdd) { //添加 题目 答案 if (subjectViewBll.AddEmployeeSurveySubjectView(i) < 1) { masterBll.RollbackTransaction(); return(-1); } } else { //更新题目 if (esvDal.UpdateSurveySubject(i.SubjectInfo) < 1) { masterBll.RollbackTransaction(); return(-1); } //更新答案 if (UpdataAnswerList(i.SubjectInfo, i.AnswerList.ToList()) < 1) { masterBll.RollbackTransaction(); return(-1); } } } masterBll.CommitTransaction(); return(1); } catch (Exception ex) { Tracer.Debug("调查方案EmployeeSurveyViewBll-UpdateEmployeeSurveyView" + System.DateTime.Now.ToString() + " " + ex.ToString()); return(-1); } }