/// <summary> /// 获取自评分数 /// </summary> /// <param name="intentionID">评审单号</param> public FrameReviewBLL(string FrameReviewID) { if (string.IsNullOrEmpty(FrameReviewID)) { FrameReviewID = "-1";//这样取出的就是一个空的视图 } FrameReviewEntity1 = new V_FrameReviewEntity(); FrameReviewEntity1.ResetForSearch(); FrameReviewEntity1.FrameReviewID = FrameReviewID; FrameReviewEntity1.GetTable(true); FrameReviewerShowEntity = new FrameReviewerEntity(); FrameReviewerShowEntity.ResetForSearch(); FrameReviewerShowEntity.FrameReviewID = FrameReviewID; FrameReviewerShowEntity.Reviewer = FrameReviewEntity1.CreateMan; FrameReviewerShowEntity.GetTable(true); FrameReviewScoreEntity = new V_FrameReviewScoreShowEntity(); FrameReviewScoreEntity.PageSize = 0;//设置返回数据,即集合变量的大小,为0则放回全部数据 FrameReviewScoreEntity.ResetForSearch(); FrameReviewScoreEntity.FrameReviewID = FrameReviewID; //FrameReviewScoreEntity.GetTable(true); FrameReviewScoreEntity.OrderFields = "StandardType,SequenceID"; FrameReviewScoreList = FrameReviewScoreEntity.ToList <V_FrameReviewScoreShowEntity>(); }
/// <summary> /// 用于获取评审人评分数据 /// </summary> /// <param name="FrameReviewID">框架评审单号</param> /// <param name="Reviewer">评审人工号</param> public FrameReviewBLL(string FrameReviewID, string Reviewer) { string flagReviewer = null; flagReviewer = Reviewer; FrameReviewEntity1 = new V_FrameReviewEntity(); FrameReviewEntity1.ResetForSearch(); FrameReviewEntity1.FrameReviewID = FrameReviewID; FrameReviewEntity1.GetTable(true); FrameReviewerShowEntity = new FrameReviewerEntity(); FrameReviewerShowEntity.ResetForSearch(); FrameReviewerShowEntity.FrameReviewID = FrameReviewID; FrameReviewerShowEntity.Reviewer = Reviewer; FrameReviewerShowEntity.GetTable(true); FrameReviewScoreEntity = new V_FrameReviewScoreShowEntity(); FrameReviewScoreEntity.PageSize = 0;//设置返回数据,即集合变量的大小,为0则放回全部数据 FrameReviewScoreEntity.ResetForSearch(); FrameReviewScoreEntity.FrameReviewID = FrameReviewID; FrameReviewScoreEntity.OrderFields = "StandardType,SequenceID"; FrameReviewScoreList = FrameReviewScoreEntity.ToList <V_FrameReviewScoreShowEntity>(); foreach (var s in FrameReviewScoreList) { if (string.IsNullOrEmpty(s.Reviewer)) { Isexist = 0;//插入 break; } else if (s.Reviewer == flagReviewer) { Reviewer = flagReviewer; Isexist = 1;//更新 break; } else { Reviewer = s.Reviewer; Isexist = 2;//插入,评委第一次评分 } } //其实这里可以用一个foreach来遍历标准表,依次插数据到实体类中然后插入 if (Isexist != 0) { FrameReviewScoreEntity = new V_FrameReviewScoreShowEntity(); FrameReviewScoreEntity.PageSize = 0; FrameReviewScoreEntity.ResetForSearch(); if (string.IsNullOrEmpty(FrameReviewID) || string.IsNullOrEmpty(Reviewer)) { FrameReviewID = "-1"; Reviewer = "-1"; } FrameReviewScoreEntity.FrameReviewID = FrameReviewID; FrameReviewScoreEntity.Reviewer = Reviewer; FrameReviewScoreList = FrameReviewScoreEntity.ToList <V_FrameReviewScoreShowEntity>(); if (Isexist == 2 && Reviewer != flagReviewer) { if (FrameReviewEntity1.FrameReviewers.Contains(flagReviewer)) { foreach (var i in FrameReviewScoreList)//第一次评分时消除历史数据 { i.reviewerReview = null; } } else { //其他人员查看 V_FrameReviewEntity FrameReviewEntity = new V_FrameReviewEntity(); FrameReviewEntity.ResetForSearch(); FrameReviewEntity.FrameReviewID = FrameReviewID; FrameReviewEntity.GetTable(true); decimal?devDay = FrameReviewEntity.DevelopDays; decimal?passRate = FrameReviewEntity.PassingRate; SqlDataBase db = new SqlDataBase(); //妙,这里取最小值作为分数,避免了相加的麻烦,good for you DataTable dt = db.GetTable(" SELECT A.Reviewerreview FROM(SELECT StandardType,SequenceID,MIN(reviewerReview) reviewerReview FROM dbo.V_FrameReviewScore " + " WHERE ISNULL(Reviewer, '') <> '' AND FrameReviewID = '" + FrameReviewID + "' GROUP BY StandardType, SequenceID) A ORDER BY A.StandardType,A.SequenceID"); int flag = 0; foreach (var i in FrameReviewScoreList)//替换数据为综合数据 { i.reviewerReview = (int)dt.Rows[flag]["reviewerReview"]; flag++; } } } } }
/// <summary> /// 他评更新(事务) /// </summary> /// <returns></returns> public bool UpdateReview(string Reviewer) { bool result = false; int index = 0; decimal?i = 0; FrameReviewScoreEntity = new V_FrameReviewScoreShowEntity(); FrameReviewScoreEntity.PageSize = 0;//设置返回数据,即集合变量的大小,为0则放回全部数据 FrameReviewScoreEntity.ResetForSearch(); FrameReviewScoreEntity.FrameReviewID = FrameReviewEntity1.FrameReviewID; FrameReviewScoreList = FrameReviewScoreEntity.ToList <V_FrameReviewScoreShowEntity>(); foreach (var s in FrameReviewScoreList) { if (string.IsNullOrEmpty(s.Reviewer)) { Isexist = 0; break; } else if (s.Reviewer == Reviewer) { Isexist = 1; break; } else { Isexist = 2;//这里要改 } } try { List <EntityBase> listUpdate = new List <EntityBase>(); //分数明细表更新 FrameReviewSaveEntity FrameReviewScoreEntity1 = null; foreach (var key in HttpContext.Current.Request.Form.AllKeys) { if (key.StartsWith("atxt") && key.EndsWith("rowNo")) { index = int.Parse(key.Replace("atxt", "").Replace("rowNo", "")); FrameReviewScoreEntity1 = new FrameReviewSaveEntity(); FrameReviewScoreEntity1.ResetForSearch(); FrameReviewScoreEntity1.GenerateObjectFromRequest("other" + index); FrameReviewScoreEntity1.FrameReviewID = FrameReviewEntity1.FrameReviewID; FrameReviewScoreEntity1.CreateDate = DateTime.Now; FrameReviewScoreEntity1.IsSelf = 0; FrameReviewScoreEntity1.ReviewerID = Reviewer; if (FrameReviewScoreEntity1.ReviewResult != 0) { FrameReviewScoreEntity1.ReviewResult = 1; } i = i + Convert.ToInt16(FrameReviewScoreEntity1.ReviewResult); //统计出了总分数 if (Isexist == 1) { FrameReviewScoreEntity1.IsGenerateObject = true; //更新 } else { FrameReviewScoreEntity1.ID = null;//标识列不为空导致更新失败,还不报错 FrameReviewScoreEntity1.IsGenerateObject = false; } listUpdate.Add(FrameReviewScoreEntity1); } } decimal?passrate = i / listUpdate.Count; //主表更新 FrameReviewEntity1.GenerateObjectFromRequest(""); listUpdate.Add(FrameReviewEntity1); //计算通过率,更新评分人评分表 FrameReviewerShowEntity = new FrameReviewerEntity(); FrameReviewerShowEntity.ResetForSearch(); FrameReviewerShowEntity.GenerateObjectFromRequest("Review"); FrameReviewerShowEntity.FrameReviewID = FrameReviewEntity1.FrameReviewID; FrameReviewerShowEntity.PassingRate = passrate; FrameReviewerShowEntity.Reviewer = Reviewer; FrameReviewerShowEntity.ReviewDate = DateTime.Now; if (Isexist == 1) { FrameReviewerShowEntity.IsGenerateObject = true; } else { FrameReviewerShowEntity.IsGenerateObject = false; } listUpdate.Add(FrameReviewerShowEntity); result = FrameReviewEntity1.db.CommitTran(listUpdate.ToArray()); } catch (Exception e) { result = false; } return(result); }