private void SetGridBind() { MicroBSC.BSC.Biz.Biz_Bsc_Est_Dept_Grade objGrade = new MicroBSC.BSC.Biz.Biz_Bsc_Est_Dept_Grade(); DataSet rDs = objGrade.GetAllList(this.IEstTermRefID, PageUtility.GetIntByValueDropDownList(ddlDeptType)); ugrdGradeList.Clear(); ugrdGradeList.DataSource = rDs; ugrdGradeList.DataBind(); if (PageUtility.GetIntByValueDropDownList(ddlDeptType) < 1) { iBtnUpdate.Visible = false; ImgBtnAddRow.Visible = false; } else { iBtnUpdate.Visible = true; ImgBtnAddRow.Visible = true; } }
public DataSet GetEstDeptRank(int iestterm_ref_id, string iymd, int idept_type, string isum_type , int est_dept_id, string showChildDept, bool includeExtScore, int itxr_user) { Biz_Bsc_Est_Dept_Grade objGrd = new Biz_Bsc_Est_Dept_Grade(); DataSet dsGrade = objGrd.GetAllList(iestterm_ref_id, idept_type); DataSet dsRank = new DataSet(); if (includeExtScore) { dsRank = base.GetEstDeptRankList(iestterm_ref_id, iymd, idept_type, isum_type, est_dept_id, showChildDept, includeExtScore, itxr_user); } else { dsRank = base.GetEstDeptRankList(iestterm_ref_id, iymd, idept_type, isum_type, est_dept_id, showChildDept, itxr_user); } dsRank.Tables[0].Columns.Add("RANK_PERCENT", typeof(double)); dsRank.Tables[0].Columns.Add("DEPT_GRADE", typeof(string)); int intRankRow = dsRank.Tables[0].Rows.Count; int intGrdeRow = dsGrade.Tables[0].Rows.Count; if (intGrdeRow < 1) { return(dsRank); } double currRank = 0; double lastRank = 0; double minValue = 0; double maxValue = 0; double grdValue = 0; double midValue = 0; grdValue = Math.Round((double.Parse(intRankRow.ToString()) / double.Parse(intGrdeRow.ToString())), 0); grdValue = (grdValue < 1) ? 1 : grdValue; midValue = (intGrdeRow * grdValue - intRankRow); //int intMidRank = -1; //for (int i = 0; i < intGrdeRow; i++) //{ // if (dsGrade.Tables[0].Rows[i]["MID_GRADE_YN"].ToString() == "Y") // { // intMidRank = i; // } // if (intMidRank < i) // { // dsGrade.Tables[0].Rows[i]["MIN_VALUE"] = (i + 1) * grdValue; // } // else if (intMidRank == i) // { // dsGrade.Tables[0].Rows[i]["MIN_VALUE"] = ((i + 1) * grdValue) + midValue * -1; // } // else // { // dsGrade.Tables[0].Rows[i]["MIN_VALUE"] = ((i + 1) * grdValue) + midValue * -1; // } // if (intMidRank >= i) // { // intMidRank += 1; // } //} //for (int i = 0; i < intRankRow; i++) //{ // currRank = Convert.ToDouble(dsRank.Tables[0].Rows[i]["RANK_ID"].ToString()); // dsRank.Tables[0].Rows[i]["RANK_PERCENT"] = currRank ; // for (int j = 0; j < intGrdeRow; j++) // { // minValue = Convert.ToDouble(dsGrade.Tables[0].Rows[j]["MIN_VALUE"].ToString()); // if (currRank <= minValue) // { // dsRank.Tables[0].Rows[i]["DEPT_GRADE"] = dsGrade.Tables[0].Rows[j]["GRADE_NAME"].ToString(); // break; // } // } //} if (intRankRow > 0) { try { lastRank = Convert.ToDouble(dsRank.Tables[0].Rows[intRankRow - 1]["RANK_ID"].ToString()); } catch { lastRank = 0; } if (intRankRow <= intGrdeRow) { for (int i = 0; i < intRankRow; i++) { dsRank.Tables[0].Rows[i]["DEPT_GRADE"] = dsGrade.Tables[0].Rows[i]["GRADE_NAME"].ToString(); } } else { for (int i = 0; i < intRankRow; i++) { currRank = (lastRank == 0 ? 0 : Math.Round(((i + 1) / lastRank) * 100, 4)); dsRank.Tables[0].Rows[i]["RANK_PERCENT"] = currRank; double dScore = Convert.ToDouble(dsRank.Tables[0].Rows[i]["SCORE"].ToString()); for (int j = 0; j < intGrdeRow; j++) { minValue = Convert.ToDouble(dsGrade.Tables[0].Rows[j]["MIN_VALUE"].ToString()); maxValue = Convert.ToDouble(dsGrade.Tables[0].Rows[j]["MAX_VALUE"].ToString()); if (dScore >= minValue && dScore <= maxValue) { dsRank.Tables[0].Rows[i]["DEPT_GRADE"] = dsGrade.Tables[0].Rows[j]["GRADE_NAME"].ToString(); break; } } } } } return(dsRank); }