/// <summary> /// 提案业务类 /// </summary> /// <param name="intentionID">意向书流水码</param> public ProposalWholeBLL(string billID)//构造函数 { if (string.IsNullOrEmpty(billID)) { billID = "-1"; } ProposalEntity = new V_ProposalEntity(); ProposalEntity.ResetForSearch(); ProposalEntity.ProposalID = billID; ProposalEntity.GetTable(true); //依次读取其他表的实体 if (ProposalEntity.IsGenerateObject == false) {//新建 } else { //读取初评 V_ProjectAssessmentEntity projectAssessmentEntity = new V_ProjectAssessmentEntity(); projectAssessmentEntity.ResetForSearch(); projectAssessmentEntity.ProposalID = billID; ProjectAssessmentEntityList = projectAssessmentEntity.ToList <V_ProjectAssessmentEntity>(); //读取复评 V_ReviewAccessmentEntity reviewAccessmentEntity = new V_ReviewAccessmentEntity(); reviewAccessmentEntity.ResetForSearch(); reviewAccessmentEntity.ProposalID = billID; ReviewAccessmentEntityList = reviewAccessmentEntity.ToList <V_ReviewAccessmentEntity>(); } }
/// <summary> /// 批量更新(事务) /// </summary> /// <returns></returns> public bool Update(int flag = 0) { bool result = false; if (ProposalEntity != null) { try { #region 从表单页面获取数据 // ProposalEntity.GenerateObjectFromRequest(""); #endregion List <EntityBase> listUpdate = new List <EntityBase>(); listUpdate.Add(ProposalEntity); try { #region 获取初评列单表 //循环所有的细项 if (flag == 1) { V_ProjectAssessmentEntity projectAssessmentEntity = new V_ProjectAssessmentEntity(); projectAssessmentEntity.GenerateObjectFromRequest("pae_"); if (projectAssessmentEntity.ID > 0) { projectAssessmentEntity.IsGenerateObject = true; } else { projectAssessmentEntity.IsGenerateObject = false; projectAssessmentEntity.ProposalID = ProposalEntity.ProposalID; projectAssessmentEntity.ScoreDate = DateTime.Now; //请计算出得分 } listUpdate.Add(projectAssessmentEntity); //计算最终的初评总分 V_ProjectAssessmentEntity projectAssessmentEntity1 = new V_ProjectAssessmentEntity(); projectAssessmentEntity1.ResetForSearch(); projectAssessmentEntity1.ProposalID = ProposalEntity.ProposalID; ProjectAssessmentEntityList = projectAssessmentEntity1.ToList <V_ProjectAssessmentEntity>(); int sum = 1; decimal?tmpsum = projectAssessmentEntity.TotalScore; foreach (var obj in ProjectAssessmentEntityList) { if (projectAssessmentEntity.ID == obj.ID) { continue; } tmpsum += obj.TotalScore; sum++; } ProposalEntity.FirstScore = tmpsum / sum; ProposalEntity.FirstScore = Math.Round(ProposalEntity.FirstScore.Value); } #endregion #region 获取复评单表 if (flag == 2) { V_ReviewAccessmentEntity reviewAccessmentEntity = new V_ReviewAccessmentEntity(); reviewAccessmentEntity.GenerateObjectFromRequest("rae_"); if (reviewAccessmentEntity.ID > 0) { reviewAccessmentEntity.IsGenerateObject = true; } else { reviewAccessmentEntity.IsGenerateObject = false; reviewAccessmentEntity.ProposalID = ProposalEntity.ProposalID; reviewAccessmentEntity.ReviewDate = DateTime.Now; } listUpdate.Add(reviewAccessmentEntity); //计算复评最终总分 V_ReviewAccessmentEntity reviewAccessmentEntity1 = new V_ReviewAccessmentEntity(); reviewAccessmentEntity1.ResetForSearch(); reviewAccessmentEntity1.ProposalID = ProposalEntity.ProposalID; ReviewAccessmentEntityList = reviewAccessmentEntity1.ToList <V_ReviewAccessmentEntity>(); int sum = 1; decimal?tmpsum = reviewAccessmentEntity.ReviewScore; foreach (var obj in ReviewAccessmentEntityList) { if (reviewAccessmentEntity.ID == obj.ID) { continue; } tmpsum += obj.ReviewScore; sum++; } ProposalEntity.ReviewScore = tmpsum / sum; ProposalEntity.ReviewScore = Math.Round(ProposalEntity.ReviewScore.Value); } #endregion } catch { } //开始事务更新,需要主表在最前面 result = ProposalEntity.db.CommitTran(listUpdate.ToArray()); } catch { result = false; } } return(result); }